use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.
the class TestKMLTransformerImpl method testPerformDefaultTransformationGeometryCollectionLocation.
@Test
public void testPerformDefaultTransformationGeometryCollectionLocation() throws CatalogTransformerException {
MetacardImpl metacard = createMockMetacard();
metacard.setLocation(GEOMETRYCOLLECTION_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 multiGeo2 = (MultiGeometry) multiGeo.getGeometry().get(1);
assertThat(multiGeo2.getGeometry().size(), is(3));
assertThat(multiGeo2.getGeometry().get(0), instanceOf(Point.class));
assertThat(multiGeo2.getGeometry().get(1), instanceOf(LineString.class));
assertThat(multiGeo2.getGeometry().get(2), instanceOf(Polygon.class));
}
use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.
the class TestKMLTransformerImpl method testPerformDefaultTransformationPointLocation.
@Test
public void testPerformDefaultTransformationPointLocation() throws CatalogTransformerException {
MetacardImpl metacard = createMockMetacard();
metacard.setLocation(POINT_WKT);
Placemark placemark = kmlTransformer.performDefaultTransformation(metacard, null);
assertThat(placemark.getId(), is("Placemark-" + ID));
assertThat(placemark.getName(), is(TITLE));
assertThat(placemark.getStyleSelector().isEmpty(), is(true));
assertThat(placemark.getStyleUrl(), nullValue());
assertThat(placemark.getTimePrimitive(), instanceOf(TimeSpan.class));
TimeSpan timeSpan = (TimeSpan) placemark.getTimePrimitive();
assertThat(timeSpan.getBegin(), is(dateFormat.format(metacard.getEffectiveDate())));
assertThat(placemark.getGeometry(), instanceOf(Point.class));
}
use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.
the class TestKMLTransformerImpl method testPerformDefaultTransformationMultiLineStringLocation.
@Test
public void testPerformDefaultTransformationMultiLineStringLocation() throws CatalogTransformerException {
MetacardImpl metacard = createMockMetacard();
metacard.setLocation(MULTILINESTRING_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 multiLineString = (MultiGeometry) multiGeo.getGeometry().get(1);
assertThat(multiLineString.getGeometry().size(), is(2));
assertThat(multiLineString.getGeometry().get(0), instanceOf(LineString.class));
assertThat(multiLineString.getGeometry().get(1), instanceOf(LineString.class));
}
use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.
the class KMLTransformerImpl method encloseDoc.
/**
* Encapsulate the kml content (placemarks, etc.) with a style in a KML Document element If
* either content or style are null, they will be in the resulting Document
*
* @param kml
* @param style
* @param documentId
* which should be the metacard id
* @return KML DocumentType element with style and content
*/
public static Document encloseDoc(Placemark placemark, Style style, String documentId, String docName) throws IllegalArgumentException {
Document document = KmlFactory.createDocument();
document.setId(documentId);
document.setOpen(true);
document.setName(docName);
if (style != null) {
document.getStyleSelector().add(style);
}
if (placemark != null) {
document.getFeature().add(placemark);
}
return document;
}
use of de.micromata.opengis.kml.v_2_2_0.Placemark in project java-mapollage by trixon.
the class Operation method addPolygon.
private void addPolygon(String name, ArrayList<Coordinate> coordinates, Folder polygonFolder) {
List<Point2D.Double> inputs = new ArrayList<>();
coordinates.forEach((coordinate) -> {
inputs.add(new Point2D.Double(coordinate.getLongitude(), coordinate.getLatitude()));
});
try {
List<Point2D.Double> convexHull = GrahamScan.getConvexHullDouble(inputs);
Placemark placemark = polygonFolder.createAndAddPlacemark().withName(name);
Style style = placemark.createAndAddStyle();
LineStyle lineStyle = style.createAndSetLineStyle().withColor("00000000").withWidth(0.0);
PolyStyle polyStyle = style.createAndSetPolyStyle().withColor("ccffffff").withColorMode(ColorMode.RANDOM);
Polygon polygon = placemark.createAndSetPolygon();
Boundary boundary = polygon.createAndSetOuterBoundaryIs();
LinearRing linearRing = boundary.createAndSetLinearRing();
convexHull.forEach((node) -> {
linearRing.addToCoordinates(node.x, node.y);
});
} catch (IllegalArgumentException e) {
System.err.println(e);
}
}
Aggregations