use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class WorkingTree method putInDatabase.
/**
* Adds a single feature to the staging database.
*
* @param feature the feature to add
* @param metadataId
* @return the Node for the inserted feature
*/
private Node putInDatabase(final Feature feature, final ObjectId metadataId) {
checkNotNull(feature);
checkNotNull(metadataId);
final RevFeature newFeature = RevFeatureBuilder.build(feature);
final ObjectId objectId = newFeature.getId();
final Envelope bounds = (ReferencedEnvelope) feature.getBounds();
final String nodeName = feature.getIdentifier().getID();
indexDatabase.put(newFeature);
Node newObject = Node.create(nodeName, objectId, metadataId, TYPE.FEATURE, bounds);
return newObject;
}
use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class BoundsFilteringDiffConsumer method createProjectedFilter.
private ReferencedEnvelope createProjectedFilter(ObjectId metadataId) {
final ReferencedEnvelope boundsFilter = this.boundsFilter;
RevFeatureType featureType = ftypeSource.getFeatureType(metadataId);
CoordinateReferenceSystem nativeCrs = featureType.type().getCoordinateReferenceSystem();
if (null == nativeCrs || nativeCrs instanceof DefaultEngineeringCRS) {
return boundsFilter;
}
ReferencedEnvelope transformedFilter;
try {
transformedFilter = boundsFilter.transform(nativeCrs, true);
} catch (TransformException | FactoryException e) {
throw Throwables.propagate(e);
}
return transformedFilter;
}
use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class GeoGigFeatureSourceTest method testGetBoundsQuery.
@Test
public void testGetBoundsQuery() throws Exception {
ReferencedEnvelope bounds;
Filter filter;
filter = ff.id(Collections.singleton(ff.featureId(RepositoryTestCase.idP2)));
bounds = pointsSource.getBounds(new Query(pointsName, filter));
assertEquals(boundsOf(points2), bounds);
ReferencedEnvelope queryBounds = boundsOf(points1, points2);
Polygon geometry = JTS.toGeometry(queryBounds);
filter = ff.intersects(ff.property(pointsType.getGeometryDescriptor().getLocalName()), ff.literal(geometry));
bounds = pointsSource.getBounds(new Query(pointsName, filter));
assertEquals(boundsOf(points1, points2), bounds);
ReferencedEnvelope transformedQueryBounds;
CoordinateReferenceSystem queryCrs = CRS.decode("EPSG:3857");
transformedQueryBounds = queryBounds.transform(queryCrs, true);
geometry = JTS.toGeometry(transformedQueryBounds);
geometry.setUserData(queryCrs);
filter = ff.intersects(ff.property(pointsType.getGeometryDescriptor().getLocalName()), ff.literal(geometry));
bounds = pointsSource.getBounds(new Query(pointsName, filter));
assertEquals(boundsOf(points1, points2), bounds);
filter = ECQL.toFilter("sp = 'StringProp2_3' OR ip = 2000");
bounds = linesSource.getBounds(new Query(linesName, filter));
assertEquals(boundsOf(lines3, lines2), bounds);
}
use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class GeoGigFeatureSourceTest method testGetCount.
@Test
public void testGetCount() throws Exception {
assertEquals(3, pointsSource.getCount(Query.ALL));
assertEquals(3, linesSource.getCount(Query.ALL));
Filter filter;
filter = ff.id(Collections.singleton(ff.featureId(RepositoryTestCase.idP2)));
assertEquals(1, pointsSource.getCount(new Query(pointsName, filter)));
ReferencedEnvelope queryBounds = boundsOf(points1, points2);
Polygon geometry = JTS.toGeometry(queryBounds);
filter = ff.intersects(ff.property(pointsType.getGeometryDescriptor().getLocalName()), ff.literal(geometry));
assertEquals(2, pointsSource.getCount(new Query(pointsName, filter)));
ReferencedEnvelope transformedQueryBounds;
CoordinateReferenceSystem queryCrs = CRS.decode("EPSG:3857");
transformedQueryBounds = queryBounds.transform(queryCrs, true);
geometry = JTS.toGeometry(transformedQueryBounds);
geometry.setUserData(queryCrs);
filter = ff.intersects(ff.property(pointsType.getGeometryDescriptor().getLocalName()), ff.literal(geometry));
assertEquals(2, pointsSource.getCount(new Query(pointsName, filter)));
filter = ECQL.toFilter("sp = 'StringProp2_3' OR ip = 2000");
assertEquals(2, linesSource.getCount(new Query(linesName, filter)));
}
use of org.geotools.geometry.jts.ReferencedEnvelope in project GeoGig by boundlessgeo.
the class DiffTreeTest method testBoundsFilteringReprojecting.
@Test
public void testBoundsFilteringReprojecting() throws Exception {
ObjectDatabase db = geogit.getContext().objectDatabase();
RevTree tree1 = tree(1000, db);
RevTree tree2 = tree(50, db);
RevTree root = createRoot(db, tree1, tree2);
CoordinateReferenceSystem nativeCrs = revtype.type().getCoordinateReferenceSystem();
CoordinateReferenceSystem queryCrs = CRS.decode("EPSG:4326", true);
ReferencedEnvelope nativeFilter = new ReferencedEnvelope(49.9, 51.1, 49.9, 51.1, nativeCrs);
ReferencedEnvelope queryFilter = nativeFilter.transform(queryCrs, true);
List<DiffEntry> diffs;
diffTree.setOldTree(ObjectId.NULL).setNewTree(root.getId());
diffTree.setBoundsFilter(queryFilter);
diffs = ImmutableList.copyOf(diffTree.call());
assertEquals(2, diffs.size());
}
Aggregations