use of de.micromata.opengis.kml.v_2_2_0.Geometry in project ddf by codice.
the class KMLTransformerImpl method getKmlGeoFromWkt.
private Geometry getKmlGeoFromWkt(final String wkt) throws CatalogTransformerException {
if (StringUtils.isBlank(wkt)) {
throw new CatalogTransformerException("WKT was null or empty. Unable to preform KML Transform on Metacard.");
}
com.vividsolutions.jts.geom.Geometry geo = readGeoFromWkt(wkt);
Geometry kmlGeo = createKmlGeo(geo);
if (!Point.class.getSimpleName().equals(geo.getGeometryType())) {
kmlGeo = addPointToKmlGeo(kmlGeo, geo.getCoordinate());
}
return kmlGeo;
}
use of de.micromata.opengis.kml.v_2_2_0.Geometry 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;
}
Aggregations