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());
}
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)));
}
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"));
}
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));
}
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));
}
Aggregations