use of com.vividsolutions.jts.io.WKTReader in project ddf by codice.
the class TestGeoJsonInputTransformer method testLineStringGeo.
@Test
public void testLineStringGeo() throws IOException, CatalogTransformerException, ParseException {
InputStream inputStream = new ByteArrayInputStream(sampleLineStringJsonText().getBytes());
Metacard metacard = transformer.transform(inputStream);
verifyBasics(metacard);
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(metacard.getLocation());
Coordinate[] coords = geometry.getCoordinates();
assertThat(coords[0].x, is(30.0));
assertThat(coords[0].y, is(10.0));
assertThat(coords[1].x, is(10.0));
assertThat(coords[1].y, is(30.0));
assertThat(coords[2].x, is(40.0));
assertThat(coords[2].y, is(40.0));
}
use of com.vividsolutions.jts.io.WKTReader in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testNoConflict.
@Test
public void testNoConflict() 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, 45 35, 30 30),(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, 45 30, 40 40),(20 35, 45 10, 31 6, 10 30, 20 35))");
GeometryAttributeDiff diff2 = new GeometryAttributeDiff(Optional.of(oldGeom), Optional.of(newGeom2));
assertFalse(diff.conflicts(diff2));
Optional<?> merged = diff2.applyOn(Optional.of(newGeom));
assertTrue(merged.isPresent());
Geometry mergedGeom = (Geometry) merged.get();
assertEquals("MULTILINESTRING ((40 40, 20 45, 45 35, 30 30), (20 35, 45 10, 31 6, 10 30, 20 35))", mergedGeom.toText());
}
use of com.vividsolutions.jts.io.WKTReader in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testNoOldGeometry.
@Test
public void testNoOldGeometry() throws Exception {
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.fromNullable((Geometry) null), Optional.of(newGeom));
LCSGeometryDiffImpl deserializedDiff = new LCSGeometryDiffImpl(diff.asText());
assertEquals(diff, deserializedDiff);
assertEquals("0 point(s) deleted, 13 new point(s) added, 0 point(s) moved", diff.toString());
}
use of com.vividsolutions.jts.io.WKTReader in project GeoGig by boundlessgeo.
the class GeometryDiffTest method testConflict.
@Test
public void testConflict() 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),(20 35, 45 10, 20 35))");
GeometryAttributeDiff diff = new GeometryAttributeDiff(Optional.of(oldGeom), Optional.of(newGeom));
Geometry newGeom2 = new WKTReader().read("MULTILINESTRING ((40 40, 20 45, 41 33, 25 25),(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 GeoGig by boundlessgeo.
the class GeometryDiffTest method testNoConflictRemovingPoints.
@Test
public void testNoConflictRemovingPoints() 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, 45 30, 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, 45 30, 40 40),(20 35, 45 10, 31 6, 10 30, 20 35))");
GeometryAttributeDiff diff2 = new GeometryAttributeDiff(Optional.of(oldGeom), Optional.of(newGeom2));
assertFalse(diff.conflicts(diff2));
Optional<?> merged = diff2.applyOn(Optional.of(newGeom));
assertTrue(merged.isPresent());
Geometry mergedGeom = (Geometry) merged.get();
assertEquals("MULTILINESTRING ((40 40, 45 30, 40 40), (20 35, 45 10, 31 6, 10 30, 20 35))", mergedGeom.toText());
}
Aggregations