本文整理汇总了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");
}
示例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);
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}