Search in sources :

Example 6 with LineString

use of com.vividsolutions.jts.geom.LineString in project ddf by codice.

the class WfsFilterDelegate method createGeometryOperand.

private JAXBElement<?> createGeometryOperand(String wkt) {
    String convertedWkt = convertWktToLatLonOrdering(wkt);
    Geometry wktGeometry = null;
    try {
        wktGeometry = getGeometryFromWkt(convertedWkt);
    } catch (ParseException e) {
        throw new UnsupportedOperationException("Unable to parse WKT Geometry [" + convertedWkt + "]", e);
    }
    if (wktGeometry instanceof Polygon) {
        GeometryOperand polygonOperand = new GeometryOperand();
        polygonOperand.setName(Wfs20Constants.POLYGON);
        if (isGeometryOperandSupported(polygonOperand)) {
            return createPolygon(wktGeometry);
        }
        GeometryOperand envelopeOperand = new GeometryOperand();
        envelopeOperand.setName(Wfs20Constants.ENVELOPE);
        if (isGeometryOperandSupported(envelopeOperand)) {
            return createEnvelope(wktGeometry);
        }
    } else if (wktGeometry instanceof Point) {
        GeometryOperand pointOperand = new GeometryOperand();
        pointOperand.setName(Wfs20Constants.POINT);
        if (isGeometryOperandSupported(pointOperand)) {
            return createPoint(wktGeometry);
        }
    } else if (wktGeometry instanceof LineString) {
        GeometryOperand lineStringOperand = new GeometryOperand();
        lineStringOperand.setName(Wfs20Constants.LINESTRING);
        if (isGeometryOperandSupported(lineStringOperand)) {
            return createLineString(wktGeometry);
        }
    }
    throw new UnsupportedOperationException("Geometry Operand from WKT [" + convertedWkt + "] is not supported.");
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryOperand(net.opengis.filter.v_2_0_0.GeometryOperandsType.GeometryOperand) LineString(com.vividsolutions.jts.geom.LineString) LineString(com.vividsolutions.jts.geom.LineString) ParseException(com.vividsolutions.jts.io.ParseException) Point(com.vividsolutions.jts.geom.Point) Polygon(com.vividsolutions.jts.geom.Polygon)

Example 7 with LineString

use of com.vividsolutions.jts.geom.LineString in project ddf by codice.

the class Wfs20JTStoGML321Converter method convertToPolygonType.

public static PolygonType convertToPolygonType(Polygon polygon, String srsName) {
    PolygonType polygonType = GML320_OBJECT_FACTORY.createPolygonType();
    //exterior
    LineString lineString = polygon.getExteriorRing();
    LinearRing linearRing = lineString.getFactory().createLinearRing(lineString.getCoordinateSequence());
    RingType ringType = convertToRingType(linearRing, srsName);
    JAXBElement<RingType> ringTypeJAXBElement = GML320_OBJECT_FACTORY.createRing(ringType);
    AbstractRingPropertyType abstractRingPropertyType = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
    abstractRingPropertyType.setAbstractRing(ringTypeJAXBElement);
    polygonType.setExterior(abstractRingPropertyType);
    //interiors
    for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
        LineString interiorRingN = polygon.getInteriorRingN(i);
        LinearRing linearRing1 = interiorRingN.getFactory().createLinearRing(interiorRingN.getCoordinateSequence());
        RingType ringType1 = convertToRingType(linearRing1, srsName);
        JAXBElement<RingType> ringTypeJAXBElement1 = GML320_OBJECT_FACTORY.createRing(ringType1);
        AbstractRingPropertyType abstractRingPropertyType1 = GML320_OBJECT_FACTORY.createAbstractRingPropertyType();
        abstractRingPropertyType1.setAbstractRing(ringTypeJAXBElement1);
        polygonType.getInterior().add(abstractRingPropertyType1);
    }
    polygonType.setSrsName(srsName);
    return polygonType;
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) AbstractRingPropertyType(net.opengis.gml.v_3_2_1.AbstractRingPropertyType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType) LinearRing(com.vividsolutions.jts.geom.LinearRing) RingType(net.opengis.gml.v_3_2_1.RingType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 8 with LineString

use of com.vividsolutions.jts.geom.LineString in project ddf by codice.

the class Wfs20JTStoGML321Converter method createGeometryPropertyType.

private static GeometryPropertyType createGeometryPropertyType(Geometry geometry, String srsName) {
    final GeometryPropertyType geometryPropertyType = GML320_OBJECT_FACTORY.createGeometryPropertyType();
    if (geometry instanceof Point) {
        PointType pointType = convertToPointType((Point) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertPointTypeToJAXB(pointType));
    } else if (geometry instanceof LineString) {
        LineStringType lineStringType = convertToLineStringType((LineString) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertLineStringTypeToJAXB(lineStringType));
    } else if (geometry instanceof Polygon) {
        PolygonType polygonType = convertToPolygonType((Polygon) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertPolygonTypeToJAXB(polygonType));
    } else if (geometry instanceof MultiPoint) {
        MultiPointType multiPointType = convertToMultiPointType((MultiPoint) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiPointTypeToJAXB(multiPointType));
    } else if (geometry instanceof MultiLineString) {
        MultiCurveType multiCurveType = convertToMultiLineStringType((MultiLineString) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiCurveTypeToJAXB(multiCurveType));
    } else if (geometry instanceof MultiPolygon) {
        MultiSurfaceType multiSurfaceType = convertToMultiSurfaceType((MultiPolygon) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiSurfaceTypeToJAXB(multiSurfaceType));
    } else if (geometry instanceof GeometryCollection) {
        MultiGeometryType multiGeometryType = convertToMultiGeometryType((GeometryCollection) geometry, srsName);
        geometryPropertyType.setAbstractGeometry(convertMultiGeometryTypeToJAXB(multiGeometryType));
    } else {
        throw new IllegalArgumentException();
    }
    return geometryPropertyType;
}
Also used : MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiCurveType(net.opengis.gml.v_3_2_1.MultiCurveType) MultiGeometryType(net.opengis.gml.v_3_2_1.MultiGeometryType) PolygonType(net.opengis.gml.v_3_2_1.PolygonType) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) LineStringType(net.opengis.gml.v_3_2_1.LineStringType) MultiPointType(net.opengis.gml.v_3_2_1.MultiPointType) GeometryCollection(com.vividsolutions.jts.geom.GeometryCollection) MultiSurfaceType(net.opengis.gml.v_3_2_1.MultiSurfaceType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) PointType(net.opengis.gml.v_3_2_1.PointType) MultiPointType(net.opengis.gml.v_3_2_1.MultiPointType) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) GeometryPropertyType(net.opengis.gml.v_3_2_1.GeometryPropertyType)

Example 9 with LineString

use of com.vividsolutions.jts.geom.LineString in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToLineStringType.

@Test
public void testGMLToLineStringType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
    assertThat(lineString == null, is(Boolean.FALSE));
    String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString);
    LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING);
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(lineStringType.getJAXBElementName().getLocalPart()), is(Boolean.TRUE));
    String coords = lineStringType.getCoordinates().getValue().replaceAll("\n", "").trim();
    assertThat(coords.isEmpty(), is(Boolean.FALSE));
    assertThat(LINESTRING_COORDS.equals(coords), is(Boolean.TRUE));
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) MultiLineStringType(ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType) LineStringType(ogc.schema.opengis.gml.v_2_1_2.LineStringType) Test(org.junit.Test)

Example 10 with LineString

use of com.vividsolutions.jts.geom.LineString in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGeometryToLineStringGML.

@Test
public void testGeometryToLineStringGML() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    LineString lineString = (LineString) getGeometryFromWkt(LINESTRING);
    assertThat(lineString == null, is(Boolean.FALSE));
    String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString).replaceAll("\n", "").trim();
    assertThat(StringUtils.isEmpty(lineStringGML), is(Boolean.FALSE));
    Diff diff = XMLUnit.compareXML(lineStringGML, LINESTRING_GML);
    assertTrue(XMLUNIT_SIMILAR, diff.similar());
    assertTrue(XMLUNIT_IDENTICAL, diff.identical());
}
Also used : LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Diff(org.custommonkey.xmlunit.Diff) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Test(org.junit.Test)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)26 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)15 Point (com.vividsolutions.jts.geom.Point)12 Coordinate (com.vividsolutions.jts.geom.Coordinate)9 Geometry (com.vividsolutions.jts.geom.Geometry)7 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)7 Polygon (com.vividsolutions.jts.geom.Polygon)7 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)3 LineStringType (ogc.schema.opengis.gml.v_2_1_2.LineStringType)3 MultiLineStringType (ogc.schema.opengis.gml.v_2_1_2.MultiLineStringType)3 CoordinatesBuilder (org.elasticsearch.common.geo.builders.CoordinatesBuilder)3 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)3 ElasticsearchGeoAssertions.assertMultiLineString (org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiLineString)3 ElasticsearchGeoAssertions.assertMultiPolygon (org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertMultiPolygon)3 ElasticsearchGeoAssertions.assertPolygon (org.elasticsearch.test.hamcrest.ElasticsearchGeoAssertions.assertPolygon)3 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)2 ParseException (com.vividsolutions.jts.io.ParseException)2 MultiCurveType (net.opengis.gml.v_3_2_1.MultiCurveType)2