use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.
the class SimplifyGeometryFunctionTest method setup.
@Before
public void setup() {
simplifyGeometryFunction = new SimplifyGeometryFunction();
wktReader = new WKTReader();
}
use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.
the class LocationKlvProcessor method setLocationFromAttribute.
private void setLocationFromAttribute(Metacard metacard, Attribute attribute, GeometryOperator.Context geometryOperatorContext) {
WKTReader wktReader = new WKTReader();
WKTWriter wktWriter = new WKTWriter();
GeometryUtility.createUnionOfGeometryAttribute(wktReader, wktWriter, attribute, postUnionGeometryOperator, preUnionGeometryOperator, geometryOperatorContext).ifPresent(location -> setAttribute(metacard, location));
}
use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.
the class WKTUtil method getWKTBoundingRectangle.
public static Geometry getWKTBoundingRectangle(String wktString) throws ParseException {
Geometry boundingGeo = null;
WKTReader wktReader = new WKTReader(GEOMETRY_FACTORY);
Geometry geo = wktReader.read(wktString);
if (geo instanceof Point) {
Point pt = (Point) geo;
Coordinate[] coordinates = new Coordinate[5];
Coordinate ptCoord = pt.getCoordinate();
Coordinate lowerLeftCoord = ptCoord;
Coordinate upperLeftCoord = ptCoord;
Coordinate upperRightCoord = ptCoord;
Coordinate lowerRightCoord = ptCoord;
coordinates[0] = lowerLeftCoord;
coordinates[1] = upperLeftCoord;
coordinates[2] = upperRightCoord;
coordinates[3] = lowerRightCoord;
coordinates[4] = lowerLeftCoord;
LinearRing shell = GEOMETRY_FACTORY.createLinearRing(coordinates);
boundingGeo = new Polygon(shell, null, GEOMETRY_FACTORY);
} else {
boundingGeo = geo.getEnvelope();
}
return boundingGeo;
}
use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.
the class FrameCenterUpdateField method doUpdateField.
@Override
protected void doUpdateField(Metacard parent, List<Metacard> children, Context context) {
WKTReader wktReader = new WKTReader();
List<String> childLocations = extractChildFrameCenters(children);
List<Geometry> geometries = new LinkedList<>();
if (intermediateGeometry != null) {
geometries.add(intermediateGeometry);
}
geometries.addAll(childLocations.stream().map(s -> GeometryUtility.wktToGeometry(s, wktReader)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList()));
List<Coordinate> coordinates = geometries.stream().flatMap(geometry -> Stream.of(geometry.getCoordinates())).collect(Collectors.toList());
intermediateGeometry = geometryFactory.createLineString(coordinates.toArray(new Coordinate[coordinates.size()]));
}
use of com.vividsolutions.jts.io.WKTReader in project alliance by codice.
the class LocationMetacardUpdater method locationUnion.
private Optional<String> locationUnion(Metacard metacard1, Metacard metacard2, GeometryOperator.Context geometryOperatorContext) {
WKTReader wktReader = new WKTReader();
WKTWriter wktWriter = new WKTWriter();
Optional<Geometry> parentGeometry = GeometryUtility.wktToGeometry(metacard1.getLocation(), wktReader);
Optional<Geometry> childGeometry = GeometryUtility.wktToGeometry(metacard2.getLocation(), wktReader);
return Stream.of(parentGeometry, childGeometry).filter(Optional::isPresent).map(Optional::get).map(geometry -> preUnionGeometryOperator.apply(geometry, geometryOperatorContext)).reduce(Geometry::union).map(geometry -> postUnionGeometryOperator.apply(geometry, geometryOperatorContext)).map(wktWriter::write);
}
Aggregations