Search in sources :

Example 11 with Polygon

use of de.micromata.opengis.kml.v_2_2_0.Polygon in project ddf by codice.

the class KmlToJtsPolygonConverterTest method testEmptyKmlPolygonReturnsNull.

@Test
public void testEmptyKmlPolygonReturnsNull() {
    org.locationtech.jts.geom.Polygon jtsPolygon = KmlToJtsPolygonConverter.from(new Polygon());
    assertThat(jtsPolygon, nullValue());
}
Also used : Polygon(de.micromata.opengis.kml.v_2_2_0.Polygon) Test(org.junit.Test)

Example 12 with Polygon

use of de.micromata.opengis.kml.v_2_2_0.Polygon in project ddf by codice.

the class MetacardToKmlTest method getKmlGeoFromJtsGeoMultiPolygonWithHoles.

@Test
public void getKmlGeoFromJtsGeoMultiPolygonWithHoles() throws CatalogTransformerException {
    final org.locationtech.jts.geom.Geometry jtsGeoFromWkt = MetacardToKml.getJtsGeoFromWkt("MULTIPOLYGON (((-153.0063 57.1158, -154.0051 56.7347, -154.5164 56.9927, -154.671 57.4612, -153.2287 57.969, -152.5648 57.9014, -152.1411 57.5911, -153.0063 57.1158), (-155.5421 19.0835, -155.6882 18.9162, -155.9366 19.0594, -156.0735 19.7029, -155.8501 19.9773, -155.8611 20.2672, -155.2245 19.993, -154.8074 19.5087, -155.5421 19.0835), (-156.0793 20.644, -156.4144 20.5724, -156.7106 20.9268, -156.2571 20.9175, -155.9957 20.764, -156.0793 20.644)))");
    assertThat(jtsGeoFromWkt.getGeometryType(), is("MultiPolygon"));
    final Geometry kmlGeo = MetacardToKml.getKmlGeoFromJtsGeo(jtsGeoFromWkt);
    assertTrue(kmlGeo instanceof MultiGeometry);
    final MultiGeometry kmlMultiGeo = (MultiGeometry) kmlGeo;
    assertThat(kmlMultiGeo.getGeometry(), hasSize(1));
    assertTrue(kmlMultiGeo.getGeometry().get(0) instanceof Polygon);
    final Polygon kmlGeoPolygon = (Polygon) kmlMultiGeo.getGeometry().get(0);
    assertTrue(kmlGeoPolygon.getOuterBoundaryIs() != null);
    assertThat(kmlGeoPolygon.getOuterBoundaryIs().getLinearRing().getCoordinates(), hasSize(8));
    assertThat(kmlGeoPolygon.getOuterBoundaryIs().getLinearRing().getCoordinates().get(0).toString(), is("-153.0063,57.1158"));
    assertThat(kmlGeoPolygon.getInnerBoundaryIs(), hasSize(2));
}
Also used : Geometry(de.micromata.opengis.kml.v_2_2_0.Geometry) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) Polygon(de.micromata.opengis.kml.v_2_2_0.Polygon) Test(org.junit.Test)

Aggregations

Polygon (de.micromata.opengis.kml.v_2_2_0.Polygon)8 Test (org.junit.Test)5 Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)4 Coordinate (de.micromata.opengis.kml.v_2_2_0.Coordinate)3 Geometry (de.micromata.opengis.kml.v_2_2_0.Geometry)3 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)2 MultiGeometry (de.micromata.opengis.kml.v_2_2_0.MultiGeometry)2 ProfilePlacemark (se.trixon.mapollage.profile.ProfilePlacemark)2 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)1 LineString (com.vividsolutions.jts.geom.LineString)1 Point (com.vividsolutions.jts.geom.Point)1 Polygon (com.vividsolutions.jts.geom.Polygon)1 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)1 BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)1 Boundary (de.micromata.opengis.kml.v_2_2_0.Boundary)1 Feature (de.micromata.opengis.kml.v_2_2_0.Feature)1 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)1