Search in sources :

Example 16 with Kml

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

the class MetacardToKmlTest method addJtsGeoPointsToKmlGeo.

@Test
public void addJtsGeoPointsToKmlGeo() {
    final LineString kmlLineString = new LineString();
    kmlLineString.setCoordinates(singletonList(new Coordinate(80.0, 170.0)));
    doReturn(new org.locationtech.jts.geom.Coordinate()).when(jtsLineString).getCoordinate();
    final Geometry newKmlGeometry = MetacardToKml.addJtsGeoPointsToKmlGeo(jtsLineString, kmlLineString);
    assertTrue(newKmlGeometry instanceof MultiGeometry);
    final MultiGeometry multiGeometry = (MultiGeometry) newKmlGeometry;
    assertThat("New KML Geometry should be MultiGeometry containing 2 Geometries", multiGeometry.getGeometry(), hasSize(2));
}
Also used : Geometry(de.micromata.opengis.kml.v_2_2_0.Geometry) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) LineString(de.micromata.opengis.kml.v_2_2_0.LineString) Coordinate(de.micromata.opengis.kml.v_2_2_0.Coordinate) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) Test(org.junit.Test)

Example 17 with Kml

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

the class KmlFolderToJtsGeometryConverterTest method setupClass.

@BeforeClass
public static void setupClass() {
    InputStream stream = KmlFolderToJtsGeometryConverterTest.class.getResourceAsStream("/kmlFolder.kml");
    Kml kml = Kml.unmarshal(stream);
    testKmlFolder = ((Folder) kml.getFeature());
}
Also used : InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Folder(de.micromata.opengis.kml.v_2_2_0.Folder) BeforeClass(org.junit.BeforeClass)

Example 18 with Kml

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

the class KmlToJtsMultiGeometryConverterTest method setupClass.

@BeforeClass
public static void setupClass() {
    InputStream stream = KmlToJtsMultiGeometryConverterTest.class.getResourceAsStream("/kmlMultiGeometry.kml");
    Kml kml = Kml.unmarshal(stream);
    testKmlMultiGeometry = ((MultiGeometry) ((Placemark) kml.getFeature()).getGeometry());
}
Also used : InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) BeforeClass(org.junit.BeforeClass)

Example 19 with Kml

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

the class KmlToJtsPolygonConverterTest method setupClass.

@BeforeClass
public static void setupClass() {
    InputStream stream = KmlToJtsPolygonConverterTest.class.getResourceAsStream("/kmlPolygon.kml");
    Kml kml = Kml.unmarshal(stream);
    testKmlPolygon = ((Polygon) ((Placemark) kml.getFeature()).getGeometry());
}
Also used : InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Polygon(de.micromata.opengis.kml.v_2_2_0.Polygon) BeforeClass(org.junit.BeforeClass)

Example 20 with Kml

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

the class KmlToJtsPolygonConverterTest method getTestKmlPolygonWithHoles.

private Polygon getTestKmlPolygonWithHoles() {
    InputStream stream = KmlToJtsPolygonConverterTest.class.getResourceAsStream("/kmlPolygonWithHoles.kml");
    Kml kml = Kml.unmarshal(stream);
    assertThat(kml, notNullValue());
    Polygon polygon = ((Polygon) ((Placemark) kml.getFeature()).getGeometry());
    assertThat(polygon, notNullValue());
    LinearRing linearRing = polygon.getOuterBoundaryIs().getLinearRing();
    assertThat(linearRing, notNullValue());
    List<LinearRing> holes = polygon.getInnerBoundaryIs().stream().map(Boundary::getLinearRing).collect(Collectors.toList());
    assertThat(holes, not(empty()));
    return polygon;
}
Also used : Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Polygon(de.micromata.opengis.kml.v_2_2_0.Polygon) LinearRing(de.micromata.opengis.kml.v_2_2_0.LinearRing)

Aggregations

Kml (de.micromata.opengis.kml.v_2_2_0.Kml)53 InputStream (java.io.InputStream)34 Test (org.junit.Test)31 Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)15 BeforeClass (org.junit.BeforeClass)13 NetworkLink (de.micromata.opengis.kml.v_2_2_0.NetworkLink)10 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)9 Geometry (org.locationtech.jts.geom.Geometry)8 Document (de.micromata.opengis.kml.v_2_2_0.Document)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)6 Metacard (ddf.catalog.data.Metacard)4 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)4 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)4 MultiGeometry (de.micromata.opengis.kml.v_2_2_0.MultiGeometry)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 UriBuilder (javax.ws.rs.core.UriBuilder)4 Handlebars (com.github.jknack.handlebars.Handlebars)3 Template (com.github.jknack.handlebars.Template)3 Feature (de.micromata.opengis.kml.v_2_2_0.Feature)3