use of de.micromata.opengis.kml.v_2_2_0.Coordinate in project ddf by codice.
the class KmlModelToJtsPointConverterTest method assertKmlModelToJtsPoint.
static void assertKmlModelToJtsPoint(Model kmlModel, Point jtsPoint) {
assertThat(jtsPoint, notNullValue());
Location location = kmlModel.getLocation();
KmlToJtsCoordinateConverterTest.assertJtsCoordinatesFromKmlCoordinates(Collections.singletonList(new Coordinate(location.getLongitude(), location.getLatitude(), location.getAltitude())), jtsPoint.getCoordinates());
}
use of de.micromata.opengis.kml.v_2_2_0.Coordinate in project ddf by codice.
the class KmlToJtsCoordinateConverterTest method testCoordinateConversion.
@Test
public void testCoordinateConversion() {
org.locationtech.jts.geom.Coordinate jtsCoordinate;
for (Coordinate kmlCoordinate : testKmlCoordinates) {
jtsCoordinate = KmlToJtsCoordinateConverter.from(kmlCoordinate);
assertJtsCoordinateFromKmlCoordinate(kmlCoordinate, jtsCoordinate);
}
}
use of de.micromata.opengis.kml.v_2_2_0.Coordinate in project ddf by codice.
the class KMLTransformerImpl method createKmlGeo.
private Geometry createKmlGeo(com.vividsolutions.jts.geom.Geometry geo) throws CatalogTransformerException {
Geometry kmlGeo = null;
if (Point.class.getSimpleName().equals(geo.getGeometryType())) {
Point jtsPoint = (Point) geo;
kmlGeo = KmlFactory.createPoint().addToCoordinates(jtsPoint.getX(), jtsPoint.getY());
} else if (LineString.class.getSimpleName().equals(geo.getGeometryType())) {
LineString jtsLS = (LineString) geo;
de.micromata.opengis.kml.v_2_2_0.LineString kmlLS = KmlFactory.createLineString();
List<Coordinate> kmlCoords = kmlLS.createAndSetCoordinates();
for (com.vividsolutions.jts.geom.Coordinate coord : jtsLS.getCoordinates()) {
kmlCoords.add(new Coordinate(coord.x, coord.y));
}
kmlGeo = kmlLS;
} else if (Polygon.class.getSimpleName().equals(geo.getGeometryType())) {
Polygon jtsPoly = (Polygon) geo;
de.micromata.opengis.kml.v_2_2_0.Polygon kmlPoly = KmlFactory.createPolygon();
List<Coordinate> kmlCoords = kmlPoly.createAndSetOuterBoundaryIs().createAndSetLinearRing().createAndSetCoordinates();
for (com.vividsolutions.jts.geom.Coordinate coord : jtsPoly.getCoordinates()) {
kmlCoords.add(new Coordinate(coord.x, coord.y));
}
kmlGeo = kmlPoly;
} else if (geo instanceof GeometryCollection) {
List<Geometry> geos = new ArrayList<Geometry>();
for (int xx = 0; xx < geo.getNumGeometries(); xx++) {
geos.add(createKmlGeo(geo.getGeometryN(xx)));
}
kmlGeo = KmlFactory.createMultiGeometry().withGeometry(geos);
} else {
throw new CatalogTransformerException("Unknown / Unsupported Geometry Type '" + geo.getGeometryType() + "'. Unale to preform KML Transform.");
}
return kmlGeo;
}
use of de.micromata.opengis.kml.v_2_2_0.Coordinate 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.Coordinate in project java-mapollage by trixon.
the class Operation method addPolygons.
private void addPolygons(Folder polygonParent, List<Feature> features) {
for (Feature feature : features) {
if (feature instanceof Folder) {
Folder folder = (Folder) feature;
if (folder != mPathFolder && folder != mPathGapFolder && folder != mPolygonFolder) {
System.out.println("ENTER FOLDER=" + folder.getName());
System.out.println("PARENT FOLDER=" + polygonParent.getName());
Folder polygonFolder = polygonParent.createAndAddFolder().withName(folder.getName()).withOpen(true);
mFolderPolygonInputs.put(polygonFolder, new ArrayList<>());
addPolygons(polygonFolder, folder.getFeature());
System.out.println("POLYGON FOLDER=" + polygonFolder.getName() + " CONTAINS");
if (mFolderPolygonInputs.get(polygonFolder) != null) {
addPolygon(folder.getName(), mFolderPolygonInputs.get(polygonFolder), polygonParent);
}
System.out.println("EXIT FOLDER=" + folder.getName());
System.out.println("");
}
}
if (feature instanceof Placemark) {
Placemark placemark = (Placemark) feature;
System.out.println("PLACEMARK=" + placemark.getName() + "(PARENT=)" + polygonParent.getName());
Point point = (Point) placemark.getGeometry();
point.getCoordinates().forEach((coordinate) -> {
mFolderPolygonInputs.get(polygonParent).add(coordinate);
});
}
}
}
Aggregations