本文整理汇总了Java中org.geotools.data.simple.SimpleFeatureCollection.size方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureCollection.size方法的具体用法?Java SimpleFeatureCollection.size怎么用?Java SimpleFeatureCollection.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.simple.SimpleFeatureCollection
的用法示例。
在下文中一共展示了SimpleFeatureCollection.size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: joinFeaures
import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
*
* @param shapes
* @param shapes2
* @throws Exception
*/
private static SimpleFeatureCollection joinFeaures(SimpleFeatureSource shapes, SimpleFeatureSource shapes2) throws Exception {
SimpleFeatureCollection join =null;
SimpleFeatureType schema = shapes.getSchema();
String typeName = schema.getTypeName();
String geomName = schema.getGeometryDescriptor().getLocalName();
SimpleFeatureType schema2 = shapes2.getSchema();
String typeName2 = schema2.getTypeName();
String geomName2 = schema2.getGeometryDescriptor().getLocalName();
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
Query outerGeometry = new Query(typeName, Filter.INCLUDE, new String[] { geomName });
SimpleFeatureCollection outerFeatures = shapes.getFeatures(outerGeometry);
SimpleFeatureIterator iterator = outerFeatures.features();
int max = 0;
try {
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
try {
Geometry geometry = (Geometry) feature.getDefaultGeometry();
if (!geometry.isValid()) {
// skip bad data
continue;
}
Filter innerFilter = ff.intersects(ff.property(geomName2), ff.literal(geometry));
Query innerQuery = new Query(typeName2, innerFilter, Query.NO_NAMES);
join = shapes2.getFeatures(innerQuery);
int size = join.size();
max = Math.max(max, size);
} catch (Exception skipBadData) {
}
}
} finally {
iterator.close();
}
return join;
}
示例2: process
import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
* Process a single coordinate.
*
* @param x
* Longitude in degrees.
* @param y
* Latitude in degrees.
* @return Timezone Id.
*/
public String process(double x, double y) throws IOException {
Point point = geometryFactory.createPoint(new Coordinate(x, y));
Filter pointInPolygon = filterFactory.contains(filterFactory.property("the_geom"), filterFactory.literal(point));
SimpleFeatureCollection features = featureSource.getFeatures(pointInPolygon);
SimpleFeature result;
// search in coastal waters
// no longer necessary with new shapes from evansiroky
if (searchCoastalWaters && features.isEmpty()) {
// find polygon within distance 0.1 deg
Filter dWithin = filterFactory.dwithin(filterFactory.property("the_geom"), filterFactory.literal(point),
0.1, "");
features = featureSource.getFeatures(dWithin);
if (features.size() > 1) {
// if more than one polygon was found, then choose the nearest one
result = selectMinDistance(features, point);
} else {
result = selectFirst(features);
}
} else {
result = selectFirst(features);
}
return result == null ? "" : (String) result.getAttribute(tzidAttr);
}
示例3: readShapes
import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
public void readShapes(final IScope scope) {
final IList<IShape> list = getBuffer();
int size = 0;
final SimpleFeatureCollection fc = getFeatureCollection(scope);
if (fc == null)
return;
final Envelope3D env = Envelope3D.of(fc.getBounds());
size = fc.size();
int index = 0;
computeProjection(scope, env);
try (SimpleFeatureIterator reader = fc.features()) {
while (reader.hasNext()) {
index++;
if (index % 20 == 0)
scope.getGui().getStatus(scope).setSubStatusCompletion(index / size);
final SimpleFeature feature = reader.next();
Geometry g = (Geometry) feature.getDefaultGeometry();
if (g != null && !g.isEmpty() /* Fix for Issue 725 && 677 */ ) {
g = gis.transform(g);
if (!with3D) {
g.apply(ZERO_Z);
g.geometryChanged();
}
list.add(new GamaGisGeometry(g, feature));
} else if (g == null) {
// See Issue 725
GAMA.reportError(scope,
GamaRuntimeException
.warning("GamaGeoJsonFile.fillBuffer; geometry could not be added as it is "
+ "nil: " + feature.getIdentifier(), scope),
false);
}
}
}
if (size > list.size()) {
GAMA.reportError(scope, GamaRuntimeException.warning("Problem with file " + getFile(scope) + ": only "
+ list.size() + " of the " + size + " geometries could be added", scope), false);
}
}
示例4: featureCollectionQuery
import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
private long featureCollectionQuery(
final BasicAccumuloOperations featureCollectionOperations,
final AccumuloDataStore featureCollectionDataStore,
final FeatureCollectionDataAdapter featureCollectionAdapter,
final Geometry geom )
throws IOException {
final long queryStart = new Date().getTime();
CloseableIterator<DefaultFeatureCollection> itr = null;
if (iterMode == IterMode.DETACHED) {
final AccumuloConstraintsQuery q = new AccumuloConstraintsQuery(
Arrays.asList(new ByteArrayId[] {
featureCollectionAdapter.getAdapterId()
}),
index,
new SpatialQuery(
geom).getIndexConstraints(index.getIndexStrategy()),
null);
q.setQueryFiltersEnabled(false);
itr = (CloseableIterator<DefaultFeatureCollection>) q.query(
featureCollectionOperations,
new MemoryAdapterStore(
new DataAdapter[] {
featureCollectionAdapter
}),
null);
}
else {
itr = featureCollectionDataStore.query(
featureCollectionAdapter,
index,
new SpatialQuery(
geom));
}
int i = 0;
int j = 0;
while (itr.hasNext()) {
final SimpleFeatureCollection featColl = itr.next();
j++;
i += featColl.size();
}
itr.close();
final long queryStop = new Date().getTime();
log.info("*** Query Runtime: " + (queryStop - queryStart) + " ms");
log.info("*** Features: " + i);
log.info("*** Collections: " + j);
return (queryStop - queryStart);
}
示例5: Geography
import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
* Create the Geography object.
* @param filePath the path to a shapefile object.
* @throws IOException if can't open the shapefile path or any IO error occur.
*/
public Geography(String filePath) throws IOException {
final File file = new File(filePath);
final Map<String, Serializable> map = new HashMap<>(1);
map.put(DATASTORE_TYPE, file.toURI().toURL());
SimpleFeatureIterator iterator = null;
DataStore dataStore = null;
try {
dataStore = DataStoreFinder.getDataStore(map);
final SimpleFeatureSource featureSource = dataStore.getFeatureSource(
dataStore.getTypeNames()[0]
);
final SimpleFeatureType schema = featureSource.getSchema();
final String geometryAttributeName = schema.getGeometryDescriptor().getLocalName();
final SimpleFeatureCollection features = featureSource.getFeatures();
final ArrayList<Map.Entry<String, MultiPolygon>> polygons = new ArrayList<>(features.size());
iterator = features.features();
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
MultiPolygon polygon = (MultiPolygon) feature.getAttribute(geometryAttributeName);
String name = (String) feature.getAttribute(STATE_NAME);
polygons.add(new AbstractMap.SimpleImmutableEntry<>(name, polygon));
}
this.polygons = Collections.unmodifiableList(polygons);
} finally {
if (iterator != null) {
iterator.close();
}
if (dataStore != null) {
dataStore.dispose();
}
}
}