Search in sources :

Example 71 with Coordinate

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) });
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate)

Example 72 with Coordinate

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);
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate)

Example 73 with Coordinate

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;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) AbstractGeometryType(net.opengis.gml.v_3_1_1.AbstractGeometryType) LinearRingType(net.opengis.gml.v_3_1_1.LinearRingType) AbstractRingPropertyType(net.opengis.gml.v_3_1_1.AbstractRingPropertyType) QName(javax.xml.namespace.QName) PolygonType(net.opengis.gml.v_3_1_1.PolygonType) JAXBElement(javax.xml.bind.JAXBElement) CoordType(net.opengis.gml.v_3_1_1.CoordType)

Example 74 with Coordinate

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));
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) DWithin(org.opengis.filter.spatial.DWithin) Expression(org.opengis.filter.expression.Expression) Coordinate(org.locationtech.jts.geom.Coordinate) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 75 with Coordinate

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;
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) Point(org.locationtech.jts.geom.Point) MultiPoint(org.locationtech.jts.geom.MultiPoint) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Aggregations

Coordinate (org.locationtech.jts.geom.Coordinate)348 Test (org.junit.Test)145 Geometry (org.locationtech.jts.geom.Geometry)69 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)65 LineString (org.locationtech.jts.geom.LineString)57 Point (org.locationtech.jts.geom.Point)57 Polygon (org.locationtech.jts.geom.Polygon)47 LinearRing (org.locationtech.jts.geom.LinearRing)45 AbstractArcTest (eu.esdihumboldt.util.geometry.interpolation.AbstractArcTest)37 ArcByCenterPoint (eu.esdihumboldt.util.geometry.interpolation.model.ArcByCenterPoint)32 ArrayList (java.util.ArrayList)32 MultiPolygon (org.locationtech.jts.geom.MultiPolygon)27 Test (org.junit.jupiter.api.Test)26 Arc (eu.esdihumboldt.util.geometry.interpolation.model.Arc)20 MultiPoint (org.locationtech.jts.geom.MultiPoint)20 ArcByPointsImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByPointsImpl)17 ArcByCenterPointImpl (eu.esdihumboldt.util.geometry.interpolation.model.impl.ArcByCenterPointImpl)16 GeometryWrapper (org.apache.jena.geosparql.implementation.GeometryWrapper)15 ArcByPoints (eu.esdihumboldt.util.geometry.interpolation.model.ArcByPoints)14 HashMap (java.util.HashMap)13