Search in sources :

Example 26 with Kml

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

the class KmlToJtsPointConverterTest method setupClass.

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

Example 27 with Kml

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

the class KmlToMetacardTest method testKmlWithTimeSpan.

@Test
public void testKmlWithTimeSpan() {
    InputStream stream = KmlToJtsConverterTest.class.getResourceAsStream("/kmlWithTimeSpan.kml");
    Kml kml = Kml.unmarshal(stream);
    Metacard metacard = KmlToMetacard.from(new MetacardImpl(), kml);
    assertThat(metacard, notNullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 28 with Kml

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

the class KmlToMetacardTest method testConvertKmlMultiGeometryToMetacardWithBbox.

@Test
public void testConvertKmlMultiGeometryToMetacardWithBbox() {
    InputStream stream = KmlToJtsConverterTest.class.getResourceAsStream("/kmlMultiGeometry.kml");
    Kml kml = Kml.unmarshal(stream);
    assertThat(kml, notNullValue());
    Metacard metacard = KmlToMetacard.from(new MetacardImpl(), kml);
    assertThat(metacard, notNullValue());
    MultiGeometry kmlMultiGeometry = ((MultiGeometry) ((Placemark) kml.getFeature()).getGeometry());
    assertThat(kmlMultiGeometry, notNullValue());
    Geometry jtsGeometryCollectionGeometry = KmlToJtsGeometryConverter.from(kmlMultiGeometry);
    assertThat(jtsGeometryCollectionGeometry, notNullValue());
    String wktBbox = jtsGeometryCollectionGeometry.getEnvelope().toText();
    assertThat(metacard.getAttribute(Metacard.GEOGRAPHY).getValue().toString(), is(equalToIgnoringWhiteSpace(wktBbox)));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) Metacard(ddf.catalog.data.Metacard) Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 29 with Kml

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

the class KmlToMetacardTest method testConvertBadKmlReturnsNullMetacard.

@Test
public void testConvertBadKmlReturnsNullMetacard() {
    InputStream stream = KmlToJtsConverterTest.class.getResourceAsStream("/notKml.kml");
    Kml kml = Kml.unmarshal(stream);
    Metacard metacard = KmlToMetacard.from(new MetacardImpl(), kml);
    assertThat(metacard, nullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 30 with Kml

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

the class KmlToMetacardTest method testKmlWithNoGeometry.

@Test
public void testKmlWithNoGeometry() {
    InputStream stream = KmlToJtsConverterTest.class.getResourceAsStream("/kmlWithNoGeometry.kml");
    Kml kml = Kml.unmarshal(stream);
    Metacard metacard = KmlToMetacard.from(new MetacardImpl(), kml);
    assertThat(metacard, notNullValue());
}
Also used : Metacard(ddf.catalog.data.Metacard) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

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