Search in sources :

Example 1 with Boundary

use of de.micromata.opengis.kml.v_2_2_0.Boundary 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);
    }
}
Also used : ProfilePlacemark(se.trixon.mapollage.profile.ProfilePlacemark) Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) LineStyle(de.micromata.opengis.kml.v_2_2_0.LineStyle) ArrayList(java.util.ArrayList) PolyStyle(de.micromata.opengis.kml.v_2_2_0.PolyStyle) Boundary(de.micromata.opengis.kml.v_2_2_0.Boundary) Point2D(java.awt.geom.Point2D) LineStyle(de.micromata.opengis.kml.v_2_2_0.LineStyle) PolyStyle(de.micromata.opengis.kml.v_2_2_0.PolyStyle) Style(de.micromata.opengis.kml.v_2_2_0.Style) IconStyle(de.micromata.opengis.kml.v_2_2_0.IconStyle) BalloonStyle(de.micromata.opengis.kml.v_2_2_0.BalloonStyle) Polygon(de.micromata.opengis.kml.v_2_2_0.Polygon) LinearRing(de.micromata.opengis.kml.v_2_2_0.LinearRing)

Aggregations

BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)1 Boundary (de.micromata.opengis.kml.v_2_2_0.Boundary)1 IconStyle (de.micromata.opengis.kml.v_2_2_0.IconStyle)1 LineStyle (de.micromata.opengis.kml.v_2_2_0.LineStyle)1 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)1 Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)1 PolyStyle (de.micromata.opengis.kml.v_2_2_0.PolyStyle)1 Polygon (de.micromata.opengis.kml.v_2_2_0.Polygon)1 Style (de.micromata.opengis.kml.v_2_2_0.Style)1 Point2D (java.awt.geom.Point2D)1 ArrayList (java.util.ArrayList)1 ProfilePlacemark (se.trixon.mapollage.profile.ProfilePlacemark)1