當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleFeatureType類代碼示例

本文整理匯總了Java中org.opengis.feature.simple.SimpleFeatureType的典型用法代碼示例。如果您正苦於以下問題:Java SimpleFeatureType類的具體用法?Java SimpleFeatureType怎麽用?Java SimpleFeatureType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleFeatureType類屬於org.opengis.feature.simple包,在下文中一共展示了SimpleFeatureType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: read

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
public void read(URL file) throws IOException {
    Map<String, Object> map = new HashMap<>();
    map.put("url", file);


    DataStore dataStore = DataStoreFinder.getDataStore(map);
    String typeName = dataStore.getTypeNames()[0];

    FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);

    FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();

    FeatureIterator<SimpleFeature> features = collection.features();
    int count = 0;
    LOGGER.info("reading world time zones ...");
    while (features.hasNext()) {
        count++;
        SimpleFeature feature = features.next();
        ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(feature.getBounds());
        quadtree.insert(referencedEnvelope,feature);
    }
    LOGGER.info(count + " features read");

}
 
開發者ID:graphhopper,項目名稱:timezone,代碼行數:25,代碼來源:TZShapeReader.java

示例2: saveAll

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Method to store analysed image params in a table on the DDBB for posterior data mining
 *
 * @param layer
 * @param projection
 * @param imageCis
 */
public void saveAll(GeometryImage layer, String projection, Object[] imageCis,GeoImageReader gir) {
    try {
    	//Data store to get access to ddbb
        DataStore datastore = (DataStore) DataStoreFinder.getDataStore(config);
        //Access to the corresponding Imagery table on ddbb
        FeatureStore featurestore = (FeatureStore) datastore.getFeatureSource(imageCis[0].toString());
        SimpleFeatureType featuretype = (SimpleFeatureType) featurestore.getSchema();
        FeatureCollection features = createTabFeatures(featuretype,imageCis);
        featurestore.addFeatures(features);
        writeToDB(datastore, features);
        datastore.dispose();
        // store extracted VDS points
        save(null,projection,((SarImageReader)gir).getGeoTransform());
    } catch (Exception ex) {
    	logger.error(ex.getMessage(),ex);
    }
}
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:25,代碼來源:PostgisIO.java

示例3: exportFeaturesToShapeFile

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
public static void exportFeaturesToShapeFile(File fileOutput,FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection){
  	 DataStore data =null;
  	 try {

  		 if (!fileOutput.exists()){
  			 fileOutput.createNewFile();
  			 fileOutput.setWritable(true);
  		 }
   	 FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
   	 data = factory.createDataStore( fileOutput.toURI().toURL() );

   	 data.createSchema(featureCollection.getSchema());
   	 exportToShapefile(data,featureCollection);
} catch (Exception e) {
	logger.error("Export to shapefile failed",e );
}finally{
	if(data!=null)
		data.dispose();
}
   }
 
開發者ID:ec-europa,項目名稱:sumo,代碼行數:21,代碼來源:SimpleShapefile.java

示例4: createFeatureType

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
public SimpleFeatureType createFeatureType(Geometry newGeometry, String uuid, CoordinateReferenceSystem coordinateReferenceSystem) {
    String namespace = "http://www.52north.org/" + uuid;

    SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
    if (coordinateReferenceSystem == null) {
        coordinateReferenceSystem = getDefaultCRS();
    }
    typeBuilder.setCRS(coordinateReferenceSystem);
    typeBuilder.setNamespaceURI(namespace);
    Name nameType = new NameImpl(namespace, "Feature-" + uuid);
    typeBuilder.setName(nameType);

    typeBuilder.add("GEOMETRY", newGeometry.getClass());

    SimpleFeatureType featureType;

    featureType = typeBuilder.buildFeatureType();
    return featureType;
}
 
開發者ID:52North,項目名稱:javaps-geotools-backend,代碼行數:20,代碼來源:GTHelper.java

示例5: createCorrectFeatureCollection

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
private SimpleFeatureCollection createCorrectFeatureCollection(FeatureCollection<?, ?> fc) {

        List<SimpleFeature> simpleFeatureList = new ArrayList<SimpleFeature>();
        SimpleFeatureType featureType = null;
        FeatureIterator<?> iterator = fc.features();
        String uuid = UUID.randomUUID().toString();
        int i = 0;
        while (iterator.hasNext()) {
            SimpleFeature feature = (SimpleFeature) iterator.next();

            //if (i == 0) {
                featureType = gtHelper.createFeatureType(feature.getProperties(), (Geometry) feature.getDefaultGeometry(), uuid, feature.getFeatureType().getCoordinateReferenceSystem());
                QName qname = gtHelper.createGML3SchemaForFeatureType(featureType);
                SchemaRepository.registerSchemaLocation(qname.getNamespaceURI(), qname.getLocalPart());
            //}
            SimpleFeature resultFeature = gtHelper.createFeature("ID" + i, (Geometry) feature.getDefaultGeometry(), featureType, feature.getProperties());

            simpleFeatureList.add(resultFeature);
            i++;
        }
        iterator.close();

        ListFeatureCollection resultFeatureCollection = new ListFeatureCollection(featureType, simpleFeatureList);
        return resultFeatureCollection;

    }
 
開發者ID:52North,項目名稱:javaps-geotools-backend,代碼行數:27,代碼來源:GML3BasicGenerator.java

示例6: analyze

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
@Override
public void analyze(IVgiAction action, Date timePeriod) {
	VgiAnalysisUser user = findUser(action.getOperations().get(0).getUid(), action.getOperations().get(0).getUser());
	
	if (!user.actionPerFeatureType.containsKey(timePeriod)) {
		user.actionPerFeatureType.put(timePeriod, new ConcurrentHashMap<SimpleFeatureType, Integer>());
	}
	Map<SimpleFeatureType, Integer> actionsPerFeatureType = user.actionPerFeatureType.get(timePeriod);
	
	if (!featureTypes.contains(action.getFeatureType())) featureTypes.add(action.getFeatureType());
	
	Integer value = actionsPerFeatureType.get(action.getFeatureType());
	if (value != null) {
		value = value + 1;
	} else {
		value = new Integer(1);
	}
	actionsPerFeatureType.put(action.getFeatureType(), value);
}
 
開發者ID:SGroe,項目名稱:vgi-analytics-framework,代碼行數:20,代碼來源:VgiAnalysisActionPerFeatureType.java

示例7: loadShapeFile

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
public void loadShapeFile(String shapefileName) {
    try {
        File shapefile = new File(shapefileName);
        Map<String, Object> shapefileParams = Maps.newHashMap();
        shapefileParams.put("url", shapefile.toURI().toURL());
        DataStore dataStore = DataStoreFinder.getDataStore(shapefileParams);
        if (dataStore == null)
            throw new RuntimeException("couldn't load the damn data store: " + shapefile);
        String typeName = dataStore.getTypeNames()[0];
        FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
        Filter filter = Filter.INCLUDE;
        FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);

        try (FeatureIterator<SimpleFeature> features = collection.features()) {
            while (features.hasNext()) {
                SimpleFeature feature = features.next();
                GeoInfo geoInfo = GeoInfo.fromSimpleFeature(feature);
                qt.insert(GeoUtils.getBoundingRectangleAsEnvelope(geoInfo.multiPolygon),
                        geoInfo);
            }
        }
        System.err.printf("loaded shapefile %s\n", shapefile);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
開發者ID:confluentinc,項目名稱:strata-tutorials,代碼行數:27,代碼來源:ReverseGeocoder.java

示例8: getFeatures

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Gets the features.
 *
 * @return the features
 */
public FeatureSource<SimpleFeatureType, SimpleFeature> getFeatures() {
    FeatureSource<SimpleFeatureType, SimpleFeature> features = null;

    try
    {
        if((schema != null) && (dataStore != null))
        {
            features = dataStore.getFeatureSource(schema.getName());
        }
    }catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }

    return features;
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:21,代碼來源:DataSourceInfo.java

示例9: getFeatureStore

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Gets the feature store.
 *
 * @return the feature store
 */
public FeatureStore<SimpleFeatureType, SimpleFeature> getFeatureStore() {
    FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = null;

    if(dataStore != null)
    {
        try
        {
            FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore.getFeatureSource(typeName);

            featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return featureStore;
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:22,代碼來源:DataSourceInfo.java

示例10: createSampleFeature

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的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

示例11: getFeatureStore

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Gets the feature store.
 *
 * @return the feature store
 */
public FeatureStore<SimpleFeatureType, SimpleFeature> getFeatureStore() {
    FeatureStore<SimpleFeatureType, SimpleFeature> featureStore = null;

    if (dataStore != null) {
        try {
            FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = dataStore
                    .getFeatureSource(typeName);

            featureStore = (FeatureStore<SimpleFeatureType, SimpleFeature>) featureSource;
        } catch (IOException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return featureStore;
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:21,代碼來源:DataSourceInfo.java

示例12: analyze

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
@Override
public void analyze(IVgiAction action, Date timePeriod) {
	Map<SimpleFeatureType, Double> actionsPerGeometryType = featureByGeometryType.get(action.getOperations().get(0).getVgiGeometryType());
	
	SimpleFeatureType featureType = action.getFeatureType();
	
	if (!featureTypes.contains(featureType)) featureTypes.add(featureType);
	
	Double value = actionsPerGeometryType.get(featureType);
	if (value != null) {
		value = value + 1.0;
	} else {
		value = new Double(1.0);
	}
	actionsPerGeometryType.put(featureType, value);
}
 
開發者ID:SGroe,項目名稱:vgi-analytics-framework,代碼行數:17,代碼來源:VgiAnalysisGeometryType.java

示例13: getExampleFeatureSource

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Gets the example feature source.
 *
 * @return the example feature source
 */
/*
 * (non-Javadoc)
 * 
 * @see com.sldeditor.datasource.impl.DataSourceInterface#getExampleFeatureSource()
 */
@Override
public FeatureSource<SimpleFeatureType, SimpleFeature> getExampleFeatureSource() {
    if (exampleDataSourceInfo != null) {
        FeatureSource<SimpleFeatureType, SimpleFeature> features = exampleDataSourceInfo
                .getFeatures();

        return features;
    }
    return null;
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:21,代碼來源:DataSourceImpl.java

示例14: setInlineFeatures

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
/**
 * Sets the inline features.
 *
 * @param userLayer the user layer
 */
public void setInlineFeatures(UserLayer userLayer) {
    if (userLayer != null) {
        String crsCode = "";
        SimpleFeatureType inlineFeatureType = userLayer.getInlineFeatureType();
        if (inlineFeatureType != null) {
            crsCode = CoordManager.getInstance()
                    .getCRSCode(inlineFeatureType.getCoordinateReferenceSystem());
        }

        setPopulating(true);
        crsComboBox.setSelectValueKey(crsCode);
        setPopulating(false);
        model.populate(userLayer);
    }
}
 
開發者ID:robward-scisys,項目名稱:sldeditor,代碼行數:21,代碼來源:InlineFeaturePanel.java

示例15: createSimpleFeatureType

import org.opengis.feature.simple.SimpleFeatureType; //導入依賴的package包/類
static SimpleFeatureType createSimpleFeatureType(String simpleFeatureTypeName)
        throws SchemaException {

    // list the attributes that constitute the feature type
    List<String> attributes = Lists.newArrayList(
            "Who:String:index=full",
            "What:java.lang.Long",     // some types require full qualification (see DataUtilities docs)
            "When:Date",               // a date-time field is optional, but can be indexed
            "*Where:Point:srid=4326",  // the "*" denotes the default geometry (used for indexing)
            "Why:String"               // you may have as many other attributes as you like...
    );

    // create the bare simple-feature type
    String simpleFeatureTypeSchema = Joiner.on(",").join(attributes);
    SimpleFeatureType simpleFeatureType =
            SimpleFeatureTypes.createType(simpleFeatureTypeName, simpleFeatureTypeSchema);

    return simpleFeatureType;
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:20,代碼來源:AvroExample.java


注:本文中的org.opengis.feature.simple.SimpleFeatureType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。