use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class KmlLatLonBoxToJtsGeometryConverter method createLinearRing.
private static LinearRing createLinearRing(GeometryFactory geometryFactory, LatLonBox latLonBox) {
double minX = latLonBox.getWest();
double maxX = latLonBox.getEast();
if (minX > maxX) {
minX = maxX;
maxX = latLonBox.getWest();
}
double minY = latLonBox.getSouth();
double maxY = latLonBox.getNorth();
if (minY > maxY) {
minY = maxY;
maxY = latLonBox.getSouth();
}
// WKT wants the bounding box to start upper right and go clockwise
return geometryFactory.createLinearRing(new Coordinate[] { new Coordinate(maxX, maxY), new Coordinate(maxX, minY), new Coordinate(minX, minY), new Coordinate(minX, maxY), new Coordinate(maxX, maxY) });
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class KmlToJtsLinearRingConverter method from.
public static org.locationtech.jts.geom.LinearRing from(LinearRing kmlLinearRing) {
if (!isValidKmlLinearRing(kmlLinearRing)) {
return null;
}
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
Coordinate[] jtsCoordinates = KmlToJtsCoordinateConverter.from(kmlLinearRing.getCoordinates());
return geometryFactory.createLinearRing(jtsCoordinates);
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class CswQueryFactoryTest method createPolygon.
private JAXBElement<AbstractGeometryType> createPolygon() {
PolygonType localPolygon = new PolygonType();
LinearRingType ring = new LinearRingType();
for (Coordinate coordinate : polygon.getCoordinates()) {
CoordType coord = new CoordType();
coord.setX(BigDecimal.valueOf(coordinate.x));
coord.setY(BigDecimal.valueOf(coordinate.y));
if (!Double.isNaN(coordinate.z)) {
coord.setZ(BigDecimal.valueOf(coordinate.z));
}
ring.getCoord().add(coord);
}
AbstractRingPropertyType abstractRing = new AbstractRingPropertyType();
abstractRing.setRing(gmlObjectFactory.createLinearRing(ring));
localPolygon.setExterior(gmlObjectFactory.createExterior(abstractRing));
JAXBElement<AbstractGeometryType> agt = new JAXBElement<>(new QName("http://www.opengis.net/gml", "Polygon"), AbstractGeometryType.class, null, localPolygon);
return agt;
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitDWithin.
@Test
public void testVisitDWithin() {
GeometryFactory geoFactory = new GeometryFactory();
double val = 10;
Expression pt1 = factory.literal(geoFactory.createPoint(new Coordinate(4, 5)));
Expression pt2 = factory.literal(geoFactory.createPoint(new Coordinate(6, 7)));
DWithin filter = factory.dwithin(pt1, pt2, val, "meters");
DWithin duplicate = (DWithin) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(pt1));
assertThat(duplicate.getExpression2(), is(pt2));
assertThat(duplicate.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
assertThat(duplicate.getDistance(), is(val));
}
use of org.locationtech.jts.geom.Coordinate in project ddf by codice.
the class Wfs20JTStoGML321Converter method convertToLineStringType.
public static LineStringType convertToLineStringType(LineString line, String srsName) {
LineStringType lineStringType = GML320_OBJECT_FACTORY.createLineStringType();
CoordinatesType coordinatesType = GML320_OBJECT_FACTORY.createCoordinatesType();
StringBuilder stringBuffer = new StringBuilder();
for (int i = 0; i < line.getCoordinateSequence().size(); i++) {
Coordinate coordinate = line.getCoordinateSequence().getCoordinate(i);
if (i != 0) {
stringBuffer.append(" ");
}
stringBuffer.append(coordinate.x).append(",").append(coordinate.y);
if (!Double.isNaN(coordinate.z)) {
stringBuffer.append(",").append(coordinate.z);
}
}
coordinatesType.setValue(stringBuffer.toString());
lineStringType.setCoordinates(coordinatesType);
lineStringType.setSrsName(srsName);
return lineStringType;
}
Aggregations