use of de.micromata.opengis.kml.v_2_2_0.LinearRing 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;
}
use of de.micromata.opengis.kml.v_2_2_0.LinearRing in project ddf by codice.
the class KmlToJtsLinearRingConverterTest method testKmlLinearRingWithNoCoordinatesReturnsNull.
@Test
public void testKmlLinearRingWithNoCoordinatesReturnsNull() {
org.locationtech.jts.geom.LinearRing jtsLinearRing = KmlToJtsLinearRingConverter.from(new LinearRing());
assertThat(jtsLinearRing, nullValue());
}
use of de.micromata.opengis.kml.v_2_2_0.LinearRing in project ddf by codice.
the class KmlToJtsLinearRingConverterTest method setupClass.
@BeforeClass
public static void setupClass() {
InputStream stream = KmlToJtsLinearRingConverterTest.class.getResourceAsStream("/kmlLinearRing.kml");
Kml kml = Kml.unmarshal(stream);
testKmlLinearRing = ((LinearRing) ((Placemark) kml.getFeature()).getGeometry());
}
use of de.micromata.opengis.kml.v_2_2_0.LinearRing 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);
}
}
use of de.micromata.opengis.kml.v_2_2_0.LinearRing in project ddf by codice.
the class KmlToJtsGeometryConverterTest method testConvertLinearRingGeometry.
@Test
public void testConvertLinearRingGeometry() {
InputStream stream = KmlToJtsGeometryConverterTest.class.getResourceAsStream("/kmlLinearRing.kml");
Kml kml = Kml.unmarshal(stream);
assertThat(kml, notNullValue());
LinearRing kmlLinearRing = ((LinearRing) ((Placemark) kml.getFeature()).getGeometry());
assertThat(kmlLinearRing, notNullValue());
org.locationtech.jts.geom.Geometry jtsGeometryLinearRing = KmlToJtsGeometryConverter.from(kmlLinearRing);
assertThat(jtsGeometryLinearRing, instanceOf(org.locationtech.jts.geom.LinearRing.class));
assertSpecificGeometry(kmlLinearRing, jtsGeometryLinearRing);
}
Aggregations