use of org.opengis.referencing.crs.CoordinateReferenceSystem 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.opengis.referencing.crs.CoordinateReferenceSystem 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.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class Show method printRaw.
private void printRaw(GeogigCLI cli) throws IOException {
ConsoleReader console = cli.getConsole();
GeoGIG geogig = cli.getGeogig();
for (String ref : refs) {
Optional<RevObject> obj = geogig.command(RevObjectParse.class).setRefSpec(ref).call();
if (!obj.isPresent()) {
ref = getFullRef(ref);
obj = geogig.command(RevObjectParse.class).setRefSpec(ref).call();
}
checkParameter(obj.isPresent(), "refspec did not resolve to any object.");
RevObject revObject = obj.get();
if (revObject instanceof RevFeature) {
Optional<RevFeatureType> opt = geogig.command(ResolveFeatureType.class).setRefSpec(ref).call();
if (opt.isPresent()) {
RevFeatureType ft = opt.get();
ImmutableList<PropertyDescriptor> attribs = ft.sortedDescriptors();
RevFeature feature = (RevFeature) revObject;
Ansi ansi = super.newAnsi(console.getTerminal());
ansi.a(ref).newline();
ansi.a(feature.getId().toString()).newline();
ImmutableList<Optional<Object>> values = feature.getValues();
int i = 0;
for (Optional<Object> value : values) {
PropertyDescriptor attrib = attribs.get(i);
ansi.a(attrib.getName()).newline();
PropertyType attrType = attrib.getType();
String typeName = FieldType.forBinding(attrType.getBinding()).name();
if (attrType instanceof GeometryType) {
GeometryType gt = (GeometryType) attrType;
CoordinateReferenceSystem crs = gt.getCoordinateReferenceSystem();
String crsText = CrsTextSerializer.serialize(crs);
ansi.a(typeName).a(" ").a(crsText).newline();
} else {
ansi.a(typeName).newline();
}
ansi.a(value.or("[NULL]").toString()).newline();
i++;
}
console.println(ansi.toString());
} else {
CharSequence s = geogig.command(CatObject.class).setObject(Suppliers.ofInstance(revObject)).call();
console.println(s);
}
} else {
CharSequence s = geogig.command(CatObject.class).setObject(Suppliers.ofInstance(revObject)).call();
console.println(s);
}
}
}
use of org.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class OSMHistoryImportTest method test.
@Test
public void test() throws Exception {
cli.execute("config", "user.name", "Gabriel Roldan");
cli.execute("config", "user.email", "groldan@boundlessgeo.com");
cli.execute("osm", "import-history", fakeOsmApiUrl, "--to", "10");
GeoGIG geogig = cli.getGeogig();
List<DiffEntry> changes = ImmutableList.copyOf(geogig.command(DiffOp.class).setOldVersion("HEAD~2").setNewVersion("HEAD~1").call());
assertEquals(1, changes.size());
DiffEntry entry = changes.get(0);
assertEquals(ChangeType.MODIFIED, entry.changeType());
assertEquals("node/20", entry.getOldObject().path());
assertEquals("node/20", entry.getNewObject().path());
Optional<RevFeature> oldRevFeature = geogig.command(RevObjectParse.class).setObjectId(entry.getOldObject().objectId()).call(RevFeature.class);
Optional<RevFeature> newRevFeature = geogig.command(RevObjectParse.class).setObjectId(entry.getNewObject().objectId()).call(RevFeature.class);
assertTrue(oldRevFeature.isPresent());
assertTrue(newRevFeature.isPresent());
Optional<RevFeatureType> type = geogig.command(RevObjectParse.class).setObjectId(entry.getOldObject().getMetadataId()).call(RevFeatureType.class);
assertTrue(type.isPresent());
FeatureType featureType = type.get().type();
CoordinateReferenceSystem expected = CRS.decode("EPSG:4326", true);
CoordinateReferenceSystem actual = featureType.getCoordinateReferenceSystem();
assertTrue(actual.toString(), CRS.equalsIgnoreMetadata(expected, actual));
}
use of org.opengis.referencing.crs.CoordinateReferenceSystem in project GeoGig by boundlessgeo.
the class ExtractBounds method visit.
@Override
public List<ReferencedEnvelope> visit(Literal literal, @Nullable Object data) {
Object value = literal.getValue();
if (value instanceof Geometry) {
Geometry geom = (Geometry) value;
Envelope literalEnvelope = geom.getEnvelopeInternal();
CoordinateReferenceSystem crs = nativeCrs;
if (geom.getUserData() instanceof CoordinateReferenceSystem) {
crs = (CoordinateReferenceSystem) geom.getUserData();
}
ReferencedEnvelope bbox = new ReferencedEnvelope(literalEnvelope, crs);
bounds.add(bbox);
}
return bounds;
}
Aggregations