use of com.vividsolutions.jts.io.WKTReader 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.io.WKTReader 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.io.WKTReader in project incubator-rya by apache.
the class GeoMongoDBStorageStrategy method serialize.
@Override
public DBObject serialize(final RyaStatement ryaStatement) {
// write the statement data to the fields
try {
final Statement statement = RyaToRdfConversions.convertStatement(ryaStatement);
final Geometry geo = (new WKTReader()).read(GeoParseUtils.getWellKnownText(statement));
if (geo == null) {
LOG.error("Failed to parse geo statement: " + statement.toString());
return null;
}
final BasicDBObject base = (BasicDBObject) super.serialize(ryaStatement);
if (geo.getNumPoints() > 1) {
base.append(GEO, getCorrespondingPoints(geo));
} else {
base.append(GEO, getDBPoint(geo));
}
return base;
} catch (final ParseException e) {
LOG.error("Could not create geometry for statement " + ryaStatement, e);
return null;
}
}
use of com.vividsolutions.jts.io.WKTReader in project incubator-rya by apache.
the class GeoTemporalMongoDBStorageStrategy method getGeoObjs.
private DBObject[] getGeoObjs(final Collection<IndexingExpr> geoFilters) {
final List<DBObject> objs = new ArrayList<>();
geoFilters.forEach(filter -> {
final GeoPolicy policy = GeoPolicy.fromURI(filter.getFunction());
final WKTReader reader = new WKTReader();
final String geoStr = ((Value) filter.getArguments()[0]).stringValue();
try {
// This method is what is used in the GeoIndexer.
final Geometry geo = reader.read(geoStr);
objs.add(getGeoObject(geo, policy));
} catch (final GeoTemporalIndexException | UnsupportedOperationException | ParseException e) {
LOG.error("Unable to parse '" + geoStr + "'.", e);
}
});
return objs.toArray(new DBObject[] {});
}
use of com.vividsolutions.jts.io.WKTReader in project hibernate-orm by hibernate.
the class HANAExpectationsFactory method getTestPolygon.
@Override
public Polygon getTestPolygon() {
WKTReader reader = new WKTReader();
try {
Polygon polygon = (Polygon) reader.read("POLYGON((0 0, 50 0, 90 90, 100 0, 0 0))");
polygon.setSRID(getTestSrid());
return polygon;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
Aggregations