use of com.vividsolutions.jts.io.WKTWriter in project spatial-portal by AtlasOfLivingAustralia.
the class UserDataQuery method newWkt.
/**
* Restrict to an area.
* <p/>
* If an area already exists the additional area is applied.
*
* @param wkt
* @return new BiocacheQuery with the additional wkt area applied.
*/
@Override
public UserDataQuery newWkt(String wkt, boolean forMapping) {
if (wkt == null || wkt.equals(CommonData.WORLD_WKT) || wkt.equals(this.wkt)) {
return this;
}
UserDataQuery sq = null;
try {
String newWkt = wkt;
if (this.wkt != null) {
Geometry newGeom = new WKTReader().read(wkt);
Geometry thisGeom = new WKTReader().read(this.wkt);
Geometry intersectionGeom = thisGeom.intersection(newGeom);
newWkt = (new WKTWriter()).write(intersectionGeom).replace(" (", "(").replace(", ", ",").replace(") ", ")");
}
sq = new UserDataQuery(udHeaderId, newWkt, facets);
} catch (Exception e) {
LOGGER.error("failed to filter user uploaded points with WKT: " + udHeaderId + ", " + wkt);
}
return sq;
}
use of com.vividsolutions.jts.io.WKTWriter 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.WKTWriter in project alliance by codice.
the class LineStringMetacardUpdater method setAttribute.
private void setAttribute(Metacard parent, Geometry lineString) {
WKTWriter wktWriter = new WKTWriter();
parent.setAttribute(createAttribute(wktWriter.write(lineString)));
}
use of com.vividsolutions.jts.io.WKTWriter 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);
}
use of com.vividsolutions.jts.io.WKTWriter in project alliance by codice.
the class LocationUpdateField method setLocation.
private void setLocation(Metacard parentMetacard, Geometry geometry) {
WKTWriter wktWriter = new WKTWriter();
parentMetacard.setAttribute(new AttributeImpl(Core.LOCATION, wktWriter.write(geometry)));
}
Aggregations