use of com.vividsolutions.jts.geom.Geometry in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testDoubleReverseEquality.
@Test
public void testDoubleReverseEquality() throws Exception {
Geometry oldGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
Geometry newGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 35, 45 30, 40 40),(20 35, 45 20, 30 15, 10 10, 10 30, 20 35),(10 10, 20 20, 35 30))");
LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom), Optional.of(newGeom));
LCSGeometryDiffImpl diff2 = diff.reversed().reversed();
assertEquals(diff, diff2);
}
use of com.vividsolutions.jts.geom.Geometry in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testModifiedMultiLineString.
@Test
public void testModifiedMultiLineString() throws Exception {
Geometry oldGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
Geometry newGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 35, 45 30, 40 40),(20 35, 45 20, 30 15, 10 10, 10 30, 20 35),(10 10, 20 20, 35 30))");
LCSGeometryDiffImpl diff = new LCSGeometryDiffImpl(Optional.of(oldGeom), Optional.of(newGeom));
LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
assertEquals(diff, deserializedDiff);
assertEquals("0 point(s) deleted, 4 new point(s) added, 3 point(s) moved", diff.toString());
Optional<Geometry> resultingGeom = diff.applyOn(Optional.of(oldGeom));
assertEquals(newGeom, resultingGeom.get());
}
use of com.vividsolutions.jts.geom.Geometry in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testConflictEditedSamePoint.
@Test
public void testConflictEditedSamePoint() throws Exception {
Geometry oldGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 45 30, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
Geometry newGeom = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 48 32, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
GeometryAttributeDiff diff = new GeometryAttributeDiff(Optional.of(oldGeom), Optional.of(newGeom));
Geometry newGeom2 = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 41 33, 40 40),(20 35, 45 10, 30 5, 10 30, 20 35))");
GeometryAttributeDiff diff2 = new GeometryAttributeDiff(Optional.of(oldGeom), Optional.of(newGeom2));
assertTrue(diff.conflicts(diff2));
}
use of com.vividsolutions.jts.geom.Geometry 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;
}
use of com.vividsolutions.jts.geom.Geometry in project ignite by apache.
the class GridH2SpatialIndex method getEnvelope.
/**
* @param row Row.
* @param rowId Row id.
* @return Envelope.
*/
private SpatialKey getEnvelope(SearchRow row, long rowId) {
Value v = row.getValue(columnIds[0]);
Geometry g = ((ValueGeometry) v.convertTo(Value.GEOMETRY)).getGeometry();
Envelope env = g.getEnvelopeInternal();
return new SpatialKey(rowId, (float) env.getMinX(), (float) env.getMaxX(), (float) env.getMinY(), (float) env.getMaxY());
}
Aggregations