Search in sources :

Example 26 with WKTReader

use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.

the class GeometryUtilityTest method setup.

@Before
public void setup() {
    wktReader = new WKTReader();
    wktWriter = new WKTWriter();
}
Also used : WKTWriter(com.vividsolutions.jts.io.WKTWriter) WKTReader(com.vividsolutions.jts.io.WKTReader) Before(org.junit.Before)

Example 27 with WKTReader

use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.

the class LinestringGeometrySubsamplerTest method testNonLineString.

@Test
public void testNonLineString() throws ParseException {
    String wkt = "POLYGON (( 0 0, 1 1, 2 2, 0 0))";
    Geometry geometry = new WKTReader().read(wkt);
    LinestringGeometrySubsampler linestringGeometrySubsampler = new LinestringGeometrySubsampler();
    GeometryOperator.Context context = new GeometryOperator.Context();
    context.setSubsampleCount(1000);
    Geometry actual = linestringGeometrySubsampler.apply(geometry, context);
    assertThat(actual, is(geometry));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Example 28 with WKTReader

use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.

the class LinestringGeometrySubsamplerTest method testNullSubsampleCount.

@Test(expected = IllegalStateException.class)
public void testNullSubsampleCount() throws ParseException {
    String wkt = generate(1001);
    Geometry geometry = new WKTReader().read(wkt);
    LinestringGeometrySubsampler linestringGeometrySubsampler = new LinestringGeometrySubsampler();
    GeometryOperator.Context context = new GeometryOperator.Context();
    context.setSubsampleCount(null);
    linestringGeometrySubsampler.apply(geometry, context);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Example 29 with WKTReader

use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.

the class ConvertSubpolygonsToEnvelopesTest method testTwoSubpolygons.

@Test
public void testTwoSubpolygons() throws ParseException {
    String wkt = "MULTIPOLYGON (((0 0, 2 10, 10 20, 20 20, 20 0, 0 0)),((0 40, 2 50, 10 60, 20 60, 20 40, 0 40)))";
    WKTReader wktReader = new WKTReader();
    Geometry geometry = wktReader.read(wkt);
    ConvertSubpolygonsToEnvelopes convertSubpolygonsToEnvelopes = new ConvertSubpolygonsToEnvelopes();
    Geometry actual = convertSubpolygonsToEnvelopes.apply(geometry, new GeometryOperator.Context());
    Geometry expected = wktReader.read("MULTIPOLYGON (((0 0, 0 20, 20 20, 20 0, 0 0)), ((0 40, 0 60, 20 60, 20 40, 0 40)))");
    assertThat(actual, is(expected));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Example 30 with WKTReader

use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.

the class GeometryReducerTest method testTwoSubpolygons.

@Test
public void testTwoSubpolygons() throws ParseException {
    String wkt = "MULTIPOLYGON (((0 0, 2 10, 10 20, 20 20, 20 0, 0 0)),((0 40, 2 50, 10 60, 20 60, 20 40, 0 40)))";
    WKTReader wktReader = new WKTReader();
    Geometry geometry = wktReader.read(wkt);
    GeometryReducer reducer = new GeometryReducer();
    Geometry actual = reducer.apply(geometry, context);
    Geometry expected = wktReader.read(wkt);
    assertThat(actual, is(expected));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) WKTReader(com.vividsolutions.jts.io.WKTReader) Test(org.junit.Test)

Aggregations

WKTReader (com.vividsolutions.jts.io.WKTReader)71 Geometry (com.vividsolutions.jts.geom.Geometry)51 Test (org.junit.Test)28 ParseException (com.vividsolutions.jts.io.ParseException)23 WKTWriter (com.vividsolutions.jts.io.WKTWriter)9 Metacard (ddf.catalog.data.Metacard)9 Coordinate (com.vividsolutions.jts.geom.Coordinate)6 IsValidOp (com.vividsolutions.jts.operation.valid.IsValidOp)6 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)6 GeometryOperator (org.codice.alliance.libs.klv.GeometryOperator)6 Context (org.codice.alliance.video.stream.mpegts.Context)6 MapLayer (au.org.emii.portal.menu.MapLayer)5 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)4 Polygon (com.vividsolutions.jts.geom.Polygon)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Optional (java.util.Optional)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Before (org.junit.Before)3 Facet (au.org.ala.legend.Facet)2