use of org.geotools.feature.DefaultFeatureCollection in project OpenTripPlanner by opentripplanner.
the class SimpleIsochrone method makePointFeatures.
private SimpleFeatureCollection makePointFeatures() throws Exception {
Map<Vertex, Double> points = makePoints();
/* Stage the point features in memory */
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, pointSchema);
SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(pointSchema);
GeometryFactory gf = new GeometryFactory();
for (Map.Entry<Vertex, Double> entry : points.entrySet()) {
Vertex vertex = entry.getKey();
Double travelTime = entry.getValue();
fbuilder.add(gf.createPoint(vertex.getCoordinate()));
fbuilder.add(travelTime);
featureCollection.add(fbuilder.buildFeature(null));
}
return featureCollection;
}
use of org.geotools.feature.DefaultFeatureCollection in project OpenTripPlanner by opentripplanner.
the class SimpleIsochrone method makeContourFeatures.
private SimpleFeatureCollection makeContourFeatures() throws Exception {
Map<Integer, Geometry> contours = makeContours();
/* Stage the features in memory, in order from bottom to top, biggest to smallest */
DefaultFeatureCollection featureCollection = new DefaultFeatureCollection(null, contourSchema);
SimpleFeatureBuilder fbuilder = new SimpleFeatureBuilder(contourSchema);
List<Integer> thresholds = new ArrayList<Integer>(contours.keySet());
Collections.sort(thresholds);
// Collections.reverse(thresholds);
for (Integer threshold : thresholds) {
Geometry contour = contours.get(threshold);
fbuilder.add(contour);
fbuilder.add(threshold);
featureCollection.add(fbuilder.buildFeature(null));
}
return featureCollection;
}
use of org.geotools.feature.DefaultFeatureCollection in project incubator-rya by apache.
the class GeoMesaGeoIndexer method storeStatements.
@Override
public void storeStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// write this feature collection to the store
if (!featureCollection.isEmpty()) {
featureStore.addFeatures(featureCollection);
}
}
use of org.geotools.feature.DefaultFeatureCollection in project incubator-rya by apache.
the class GeoWaveGeoIndexer method storeStatements.
@Override
public void storeStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// write this feature collection to the store
if (!featureCollection.isEmpty()) {
featureStore.addFeatures(featureCollection);
}
}
use of org.geotools.feature.DefaultFeatureCollection in project incubator-rya by apache.
the class GeoWaveGeoIndexer method deleteStatements.
private void deleteStatements(final Collection<RyaStatement> ryaStatements) throws IOException {
// create a feature collection
final DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
for (final RyaStatement ryaStatement : ryaStatements) {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
// if the predicate list is empty, accept all predicates.
// Otherwise, make sure the predicate is on the "valid" list
final boolean isValidPredicate = validPredicates.isEmpty() || validPredicates.contains(statement.getPredicate());
if (isValidPredicate && (statement.getObject() instanceof Literal)) {
try {
final SimpleFeature feature = createFeature(featureType, statement);
featureCollection.add(feature);
} catch (final ParseException e) {
logger.warn("Error getting geo from statement: " + statement.toString(), e);
}
}
}
// remove this feature collection from the store
if (!featureCollection.isEmpty()) {
final Set<Identifier> featureIds = new HashSet<Identifier>();
final FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(null);
final Set<String> stringIds = DataUtilities.fidSet(featureCollection);
for (final String id : stringIds) {
featureIds.add(filterFactory.featureId(id));
}
final String filterString = stringIds.stream().collect(Collectors.joining("','", "'", "'"));
Filter filter = null;
try {
filter = ECQL.toFilter(GEO_ID_ATTRIBUTE + " IN (" + filterString + ")", filterFactory);
} catch (final CQLException e) {
logger.error("Unable to generate filter for deleting the statement.", e);
}
featureStore.removeFeatures(filter);
}
}
Aggregations