当前位置: 首页>>代码示例>>Java>>正文


Java FeatureType类代码示例

本文整理汇总了Java中org.opengis.feature.type.FeatureType的典型用法代码示例。如果您正苦于以下问题:Java FeatureType类的具体用法?Java FeatureType怎么用?Java FeatureType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FeatureType类属于org.opengis.feature.type包,在下文中一共展示了FeatureType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateFromSchema

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Transforms a FeatureTypeInfo into gml, with no headers.
 *
 * @param schema the schema to transform.
 *
 * @return DOCUMENT ME!
 *
 *  @task REVISIT: when this class changes to writing directly to out this
 *       can just take a writer and write directly to it.
 */
private String generateFromSchema(FeatureType schema)
    throws IOException {
    try {
        StringWriter writer = new StringWriter();
        FeatureTypeTransformer t = new FeatureTypeTransformer();
        t.setIndentation(4);
        t.setOmitXMLDeclaration(true);
        t.transform(schema, writer);

        return writer.getBuffer().toString();
    } catch (TransformerException te) {
        LOGGER.log( Level.WARNING, "Error generating schema from feature type", te );
        throw (IOException) new IOException("problem transforming type").initCause(te);
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:26,代码来源:XmlSchemaEncoder_ISO.java

示例2: buildSchemaContent

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
private void buildSchemaContent(FeatureTypeInfo featureTypeMeta, XSDSchema schema,
         XSDFactory factory, String baseUrl)
         throws IOException {
     if (!findTypeInSchema(featureTypeMeta, schema, factory)) {
         // build the type manually
         FeatureType featureType = featureTypeMeta.getFeatureType();
         if(featureTypeMeta.isCircularArcPresent() && this.getClass().equals(GML3.class)) {
             featureType = new CurveTypeWrapper(featureType);
         }
XSDComplexTypeDefinition xsdComplexType = buildComplexSchemaContent(featureType, schema, factory);

         XSDElementDeclaration element = factory.createXSDElementDeclaration();
         element.setName(featureTypeMeta.getName());
         element.setTargetNamespace(featureTypeMeta.getNamespace().getURI());
         synchronized(Schemas.class) {
             // this call changes the global schemas too, need to be synchronized
             element.setSubstitutionGroupAffiliation(getFeatureElement());
         }
         element.setTypeDefinition(xsdComplexType);

         schema.getContents().add(element);

         schema.updateElement();
     }
 }
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:26,代码来源:ISOFeatureTypeSchemaBuilder.java

示例3: getSampleFeatureForRule

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Returns a sample feature for the given rule, with the following criteria: - if a sample is
 * given in input is returned in output - if a sample is not given in input, scan the rule
 * symbolizers to find the one with the max dimensionality, and return a sample for that
 * dimensionality.
 * 
 * @param featureType featureType used to create a sample, if none is given as input
 * @param sample feature sample to be returned as is in output, if defined
 * @param rule rule containing symbolizers to scan for max dimensionality
 *
 */
private Feature getSampleFeatureForRule(FeatureType featureType, Feature sample,
        final Rule rule) {
    Symbolizer[] symbolizers = rule.getSymbolizers();
    // if we don't have a sample as input, we need to create a sampleFeature
    // looking at the requested symbolizers (we chose the one with the max
    // dimensionality and create a congruent sample)
    if (sample == null) {
        int dimensionality = 1;
        for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
            final Symbolizer symbolizer = symbolizers[sIdx];
            if (LineSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
                dimensionality = 2;
            }
            if (PolygonSymbolizer.class.isAssignableFrom(symbolizer.getClass())) {
                dimensionality = 3;
            }
        }
        return createSampleFeature(featureType, dimensionality);
    } else {
        return sample;
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:34,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例4: createSampleFeature

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Creates a sample Feature instance in the hope that it can be used in the rendering of the
 * legend graphic.
 * 
 * @param schema the schema for which to create a sample Feature instance
 * 
 *
 * 
 * @throws ServiceException
 */
private Feature createSampleFeature(FeatureType schema) throws ServiceException {
    Feature sampleFeature;
    try {
        if (schema instanceof SimpleFeatureType) {
            if (hasMixedGeometry((SimpleFeatureType) schema)) {
                // we can't create a sample for a generic Geometry type
                sampleFeature = null;
            } else {
                sampleFeature = SimpleFeatureBuilder.template((SimpleFeatureType) schema, null);
            }
        } else {
            sampleFeature = DataUtilities.templateFeature(schema);
        }
    } catch (IllegalAttributeException e) {
        throw new ServiceException(e);
    }
    return sampleFeature;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:29,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例5: createStyle

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
private static Style[] createStyle(File shapeFile, FeatureType schema) {
    final Style[] styles = SLDUtils.loadSLD(shapeFile);
    if (styles != null && styles.length > 0) {
        return styles;
    }
    Class<?> type = schema.getGeometryDescriptor().getType().getBinding();
    if (type.isAssignableFrom(Polygon.class)
            || type.isAssignableFrom(MultiPolygon.class)) {
        return new Style[]{createPolygonStyle()};
    } else if (type.isAssignableFrom(LineString.class)
            || type.isAssignableFrom(MultiLineString.class)) {
        return new Style[]{createLineStyle()};
    } else {
        return new Style[]{createPointStyle()};
    }
}
 
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:17,代码来源:ShapefileLoader.java

示例6: grabFeaturesInBoundingBox

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * What features on in this bounding Box?
 * 
 * You can make a bounding box query as shown below:
 * 
 * @param x1
 * @param y1
 * @param x2
 * @param y2
 * @return
 * @throws Exception
 */
// grabFeaturesInBoundingBox start
SimpleFeatureCollection grabFeaturesInBoundingBox(double x1, double y1, double x2, double y2)
        throws Exception {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    FeatureType schema = featureSource.getSchema();
    
    // usually "THE_GEOM" for shapefiles
    String geometryPropertyName = schema.getGeometryDescriptor().getLocalName();
    CoordinateReferenceSystem targetCRS = schema.getGeometryDescriptor()
            .getCoordinateReferenceSystem();
    
    ReferencedEnvelope bbox = new ReferencedEnvelope(x1, y1, x2, y2, targetCRS);
    
    Filter filter = ff.bbox(ff.property(geometryPropertyName), bbox);
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:29,代码来源:FilterExamples.java

示例7: rawSchemaExample

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
private void rawSchemaExample() throws Exception {
    Name typeName = null;
    URL schemaLocation = null;
    CoordinateReferenceSystem crs = null;
    // rawSchemaExample start
    
    // assume we are working from WFS 1.1 / GML3 / etc...    
    final QName featureName = new QName(typeName.getNamespaceURI(), typeName.getLocalPart());

    String namespaceURI = featureName.getNamespaceURI();
    String uri = schemaLocation.toExternalForm();
    
    Configuration wfsConfiguration = new org.geotools.gml3.ApplicationSchemaConfiguration(
            namespaceURI, uri);

    FeatureType parsed = GTXML.parseFeatureType(wfsConfiguration, featureName, crs);
    // safely cast down to SimpleFeatureType
    SimpleFeatureType schema = DataUtilities.simple(parsed);
    // rawSchemaExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:21,代码来源:GMLExamples.java

示例8: testComplexFeature

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
@Test
public void testComplexFeature() throws IOException {
	DataAccess<FeatureType, Feature> dataAccess = DataAccessFinder.getDataStore(SampleDataAccessFactory.PARAMS);
	FeatureSource<FeatureType, Feature> featureSource = dataAccess.getFeatureSource(SampleDataAccessData.MAPPEDFEATURE_TYPE_NAME);
	FeatureCollection<FeatureType, Feature> featureCollection = featureSource.getFeatures();
	int count = 0;
	FeatureIterator<Feature> iterator = featureCollection.features();
	try {
		while (iterator.hasNext()) {
			Feature feature = iterator.next();
			// System.out.println(feature);
			m_sha1Sync.sha1One(feature);
			count++;
		}
	} finally {
		iterator.close();
	}
}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:19,代码来源:FeatureCollectionSha1SyncTest.java

示例9: validateSortBy

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
void validateSortBy(List<SortBy> sortBys, FeatureTypeInfo meta, final GetFeatureRequest3D request)
        throws IOException {
    FeatureType featureType = meta.getFeatureType();
    for (SortBy sortBy : sortBys) {
        PropertyName name = sortBy.getPropertyName();
        if (name.evaluate(featureType) == null) {
            throw new WFSException(request, "Illegal property name: " + name.getPropertyName()
                    + " for feature type " + meta.prefixedName(), "InvalidParameterValue");
        }
    }
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:12,代码来源:GetFeature3D.java

示例10: initWfsConfiguration

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
public static void initWfsConfiguration(
    Configuration config, GeoServer gs, ISOFeatureTypeSchemaBuilder schemaBuilder) {
    
    MutablePicoContainer context = config.getContext();
    
    //seed the cache with entries from the catalog
    FeatureTypeCache featureTypeCache = new FeatureTypeCache();

    Collection featureTypes = gs.getCatalog().getFeatureTypes();
    for (Iterator f = featureTypes.iterator(); f.hasNext();) {
        FeatureTypeInfo meta = (FeatureTypeInfo) f.next();
        if ( !meta.enabled() ) {
            continue;
        }

        
        FeatureType featureType =  null;
        try {
            featureType = meta.getFeatureType();
        } 
        catch(Exception e) {
            throw new RuntimeException(e);
        }

        featureTypeCache.put(featureType);
    }
    
    //add the wfs handler factory to handle feature elements
    context.registerComponentInstance(featureTypeCache);
    context.registerComponentInstance(new ISOWFSHandlerFactory(gs.getCatalog(), schemaBuilder));
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:32,代码来源:WFSXmlUtils_ISO.java

示例11: getDeclaredCrs

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Returns the declared CRS given a feature type and the request WFS version
 * 
 * @param nativeCRS
 * @param wfsVersion
 *
 */
public static CoordinateReferenceSystem getDeclaredCrs(FeatureType schema, String wfsVersion) {
    if (schema == null)
        return null;

    CoordinateReferenceSystem crs = (schema.getGeometryDescriptor() != null) ? schema
            .getGeometryDescriptor().getCoordinateReferenceSystem() : null;

    return getDeclaredCrs(crs, wfsVersion);
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:17,代码来源:WFSReprojectionUtil_ISO.java

示例12: calcSymbolScale

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Calculates a global rescaling factor for all the symbols to be drawn in the given rules. This
 * is to be sure all symbols are drawn inside the given w x h box.
 * 
 * @param width horizontal constraint
 * @param height vertical constraint
 * @param featureType FeatureType to be used for size extraction in expressions (used to create
 *        a sample if feature is null)
 * @param feature Feature to be used for size extraction in expressions (if null a sample
 *        Feature will be created from featureType)
 * @param rules set of rules to scan for symbols
 * @param minimumSymbolSize lower constraint for the symbols size
 *
 */
private double calcSymbolScale(int width, int height, FeatureType featureType, Feature feature,
        final Rule[] rules, double minimumSymbolsSize) {
    // check for max and min size in rendered symbols
    double minSize = Double.MAX_VALUE;
    double maxSize = 0.0;

    final int ruleCount = rules.length;

    for (int i = 0; i < ruleCount; i++) {
        Feature sample = getSampleFeatureForRule(featureType, feature, rules[i]);
        final Symbolizer[] symbolizers = rules[i].getSymbolizers();
        for (int sIdx = 0; sIdx < symbolizers.length; sIdx++) {
            final Symbolizer symbolizer = symbolizers[sIdx];
            if (symbolizer instanceof PointSymbolizer) {
                double size = getGraphicSize(sample,
                        ((PointSymbolizer) symbolizer).getGraphic(), Math.min(width, height));
                if (size < minSize) {
                    minSize = size;
                }
                if (size > maxSize) {
                    maxSize = size;
                }
            }
        }
    }
    if (minSize != maxSize) {
        return (maxSize - minSize + 1) / (Math.min(width, height) - minimumSymbolsSize);
    } else {
        return maxSize / (Math.min(width, height) - minimumSymbolsSize);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:46,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例13: cloneWithDimensionality

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Clones the given schema, changing the geometry attribute to match the given dimensionality.
 * 
 * @param schema schema to clone
 * @param dimensionality dimensionality for the geometry 1= points, 2= lines, 3= polygons
 *
 */
private FeatureType cloneWithDimensionality(FeatureType schema, int dimensionality) {
    SimpleFeatureType simpleFt = (SimpleFeatureType) schema;
    SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
    builder.setName(schema.getName());
    builder.setCRS(schema.getCoordinateReferenceSystem());
    for (AttributeDescriptor desc : simpleFt.getAttributeDescriptors()) {
        if (isMixedGeometry(desc)) {
            GeometryDescriptor geomDescriptor = (GeometryDescriptor) desc;
            GeometryType geomType = geomDescriptor.getType();

            Class<?> geometryClass = getGeometryForDimensionality(dimensionality);

            GeometryType gt = new GeometryTypeImpl(geomType.getName(), geometryClass,
                    geomType.getCoordinateReferenceSystem(), geomType.isIdentified(),
                    geomType.isAbstract(), geomType.getRestrictions(), geomType.getSuper(),
                    geomType.getDescription());

            builder.add(new GeometryDescriptorImpl(gt, geomDescriptor.getName(),
                    geomDescriptor.getMinOccurs(), geomDescriptor.getMaxOccurs(),
                    geomDescriptor.isNillable(), geomDescriptor.getDefaultValue()));
        } else {
            builder.add(desc);
        }
    }
    schema = builder.buildFeatureType();
    return schema;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:35,代码来源:SLDEditorBufferedImageLegendGraphicBuilder.java

示例14: featureStore

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
/**
 * Creates a new Feature Store for writing features
 * @param originalSource the original feature source, used for bounds and geometry descriptor information
 * @param path the location where the store will be saved
 * @param attributeTypes a map of attribute information (name, type) to create the schema
 * @return an empty store for writing features
 * @throws IOException if the file cannot be created
 */
public static AbstractDataStore featureStore(
  FeatureSource originalSource,
  String path,
  Map<String,Class<?>> attributeTypes
) throws IOException {
  // Create store
  DataStoreFactorySpi storeFactory = new ShapefileDataStoreFactory();
  File file = new java.io.File(path);
  HashMap<String, Serializable> createFlags = new HashMap<String, Serializable>();
  createFlags.put("url", file.toURI().toURL());
  ShapefileDataStore saveStore = (ShapefileDataStore)storeFactory.createNewDataStore(createFlags);
  // Set flags and descriptors
  saveStore.setStringCharset(Charset.forName("UTF-8"));
  FeatureType oldSchema = originalSource.getSchema();
  final List<AttributeDescriptor> descriptorList = new java.util.ArrayList<AttributeDescriptor>();
  descriptorList.add(oldSchema.getGeometryDescriptor());
  // Set attributes
  for (Map.Entry<String, Class<?>> entry: attributeTypes.entrySet()) {
    AttributeTypeBuilder keyTB = new AttributeTypeBuilder();
    keyTB.setName(entry.getKey());
    keyTB.setBinding(entry.getValue());
    keyTB.setNillable(true);
    AttributeDescriptor desc = keyTB.buildDescriptor(entry.getKey());
    descriptorList.add(desc);
  }
  // Finalize schema
  SimpleFeatureTypeImpl newSchema = new SimpleFeatureTypeImpl(
    new NameImpl(file.getName()),
    descriptorList,
    oldSchema.getGeometryDescriptor(),
    oldSchema.isAbstract(),
    oldSchema.getRestrictions(),
    oldSchema.getSuper(),
    null);
  saveStore.createSchema(newSchema);
  return saveStore;
}
 
开发者ID:foursquare,项目名称:shapefile-geo,代码行数:46,代码来源:ShapefileUtils.java

示例15: canHandle

import org.opengis.feature.type.FeatureType; //导入依赖的package包/类
@Override
public boolean canHandle(FeatureTypeInfo info,
        DataAccess<? extends FeatureType, ? extends Feature> dataAccess) {
    if (dataAccess instanceof ElasticDataStore) {
        return true;
    } else {
        return false;
    }
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:10,代码来源:ElasticFeatureTypeCallback.java


注:本文中的org.opengis.feature.type.FeatureType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。