Search in sources :

Example 16 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark 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 17 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark 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 18 with Placemark

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

the class KmlMarshallerTest method unmarshallNullStream.

@Test(expected = NoSuchElementException.class)
public void unmarshallNullStream() {
    final Kml kml = kmlMarshaller.unmarshal(null).get();
    final Feature feature = kml.getFeature();
    assertThat(feature.getName(), is("Simple placemark"));
}
Also used : Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Feature(de.micromata.opengis.kml.v_2_2_0.Feature) Test(org.junit.Test)

Example 19 with Placemark

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

the class TestKMLTransformerImpl method testPerformDefaultTransformationMultiPointLocation.

@Test
public void testPerformDefaultTransformationMultiPointLocation() throws CatalogTransformerException {
    MetacardImpl metacard = createMockMetacard();
    metacard.setLocation(MULTIPOINT_WKT);
    Placemark placemark = kmlTransformer.performDefaultTransformation(metacard, null);
    assertThat(placemark.getId(), is("Placemark-" + ID));
    assertThat(placemark.getName(), is(TITLE));
    assertThat(placemark.getTimePrimitive(), instanceOf(TimeSpan.class));
    TimeSpan timeSpan = (TimeSpan) placemark.getTimePrimitive();
    assertThat(timeSpan.getBegin(), is(dateFormat.format(metacard.getEffectiveDate())));
    assertThat(placemark.getGeometry(), instanceOf(MultiGeometry.class));
    MultiGeometry multiGeo = (MultiGeometry) placemark.getGeometry();
    assertThat(multiGeo.getGeometry().size(), is(2));
    assertThat(multiGeo.getGeometry().get(0), instanceOf(Point.class));
    assertThat(multiGeo.getGeometry().get(1), instanceOf(MultiGeometry.class));
    MultiGeometry multiPoint = (MultiGeometry) multiGeo.getGeometry().get(1);
    assertThat(multiPoint.getGeometry().size(), is(3));
    assertThat(multiPoint.getGeometry().get(0), instanceOf(Point.class));
    assertThat(multiPoint.getGeometry().get(1), instanceOf(Point.class));
    assertThat(multiPoint.getGeometry().get(2), instanceOf(Point.class));
}
Also used : TimeSpan(de.micromata.opengis.kml.v_2_2_0.TimeSpan) Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) Point(de.micromata.opengis.kml.v_2_2_0.Point) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 20 with Placemark

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

the class TestKMLTransformerImpl method testPerformDefaultTransformationLineStringLocation.

@Test
public void testPerformDefaultTransformationLineStringLocation() throws CatalogTransformerException {
    MetacardImpl metacard = createMockMetacard();
    metacard.setLocation(LINESTRING_WKT);
    Placemark placemark = kmlTransformer.performDefaultTransformation(metacard, null);
    assertThat(placemark.getId(), is("Placemark-" + ID));
    assertThat(placemark.getName(), is(TITLE));
    assertThat(placemark.getTimePrimitive(), instanceOf(TimeSpan.class));
    TimeSpan timeSpan = (TimeSpan) placemark.getTimePrimitive();
    assertThat(timeSpan.getBegin(), is(dateFormat.format(metacard.getEffectiveDate())));
    assertThat(placemark.getGeometry(), instanceOf(MultiGeometry.class));
    MultiGeometry multiGeo = (MultiGeometry) placemark.getGeometry();
    assertThat(multiGeo.getGeometry().size(), is(2));
    assertThat(multiGeo.getGeometry().get(0), instanceOf(Point.class));
    assertThat(multiGeo.getGeometry().get(1), instanceOf(LineString.class));
}
Also used : TimeSpan(de.micromata.opengis.kml.v_2_2_0.TimeSpan) Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) LineString(de.micromata.opengis.kml.v_2_2_0.LineString) MultiGeometry(de.micromata.opengis.kml.v_2_2_0.MultiGeometry) Point(de.micromata.opengis.kml.v_2_2_0.Point) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Aggregations

Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)35 Test (org.junit.Test)29 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)23 InputStream (java.io.InputStream)20 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Point (de.micromata.opengis.kml.v_2_2_0.Point)19 TimeSpan (de.micromata.opengis.kml.v_2_2_0.TimeSpan)16 MultiGeometry (de.micromata.opengis.kml.v_2_2_0.MultiGeometry)15 LineString (de.micromata.opengis.kml.v_2_2_0.LineString)12 Polygon (de.micromata.opengis.kml.v_2_2_0.Polygon)10 BeforeClass (org.junit.BeforeClass)8 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)5 Document (de.micromata.opengis.kml.v_2_2_0.Document)4 Feature (de.micromata.opengis.kml.v_2_2_0.Feature)4 Style (de.micromata.opengis.kml.v_2_2_0.Style)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 ProfilePlacemark (se.trixon.mapollage.profile.ProfilePlacemark)4 BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)3 IconStyle (de.micromata.opengis.kml.v_2_2_0.IconStyle)3