Search in sources :

Example 11 with PointType

use of net.opengis.gml.x32.PointType in project ddf by codice.

the class WfsFilterDelegate method createPoint.

private JAXBElement<PointType> createPoint(Geometry geometry) {
    Coordinate[] coordinates = geometry.getCoordinates();
    if (coordinates != null && coordinates.length > 0) {
        StringBuilder coordString = new StringBuilder();
        coordString.append(coordinates[0].x).append(",").append(coordinates[0].y);
        CoordinatesType coordinatesType = new CoordinatesType();
        coordinatesType.setValue(coordString.toString());
        PointType point = new PointType();
        point.setSrsName(srsName);
        point.setCoordinates(coordinatesType);
        return gml320ObjectFactory.createPoint(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) PointType(net.opengis.gml.v_3_2_1.PointType) CoordinatesType(net.opengis.gml.v_3_2_1.CoordinatesType)

Example 12 with PointType

use of net.opengis.gml.x32.PointType in project ddf by codice.

the class TestWfs10JTStoGML200Converter method testGMLToGeometryCollectionType.

@Test
public void testGMLToGeometryCollectionType() throws JAXBException, SAXException, IOException, ParseException, NullPointerException {
    String geometryCollectionGML = Wfs10JTStoGML200Converter.convertGeometryToGML(getGeometryFromWkt(GEOMETRYCOLLECTION));
    GeometryCollectionType geometryCollectionType = (GeometryCollectionType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(geometryCollectionGML, Wfs10Constants.GEOMETRY_COLLECTION);
    assertFalse(geometryCollectionType == null);
    List<JAXBElement<? extends GeometryAssociationType>> geometryMembers = geometryCollectionType.getGeometryMember();
    assertThat(CollectionUtils.isEmpty(geometryMembers), is(Boolean.FALSE));
    assertThat(geometryMembers.size() == 2, is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType = geometryMembers.get(0).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement = geometryAssociationType.getGeometry();
    assertThat(Wfs10Constants.POINT.getLocalPart().equals(jaxbElement.getName().getLocalPart()), is(Boolean.TRUE));
    PointType pointType = (PointType) jaxbElement.getValue();
    assertThat(pointType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_POINT_COORD.equals(pointType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
    GeometryAssociationType geometryAssociationType2 = geometryMembers.get(1).getValue();
    JAXBElement<? extends AbstractGeometryType> jaxbElement2 = geometryAssociationType2.getGeometry();
    assertThat(Wfs10Constants.LINESTRING.getLocalPart().equals(jaxbElement2.getName().getLocalPart()), is(Boolean.TRUE));
    LineStringType lineStringType = (LineStringType) jaxbElement2.getValue();
    assertThat(lineStringType == null, is(Boolean.FALSE));
    assertThat(GEOMETRYCOLLECTION_LINESTRING_COORD.equals(lineStringType.getCoordinates().getValue().trim()), is(Boolean.TRUE));
}
Also used : GeometryAssociationType(ogc.schema.opengis.gml.v_2_1_2.GeometryAssociationType) GeometryCollectionType(ogc.schema.opengis.gml.v_2_1_2.GeometryCollectionType) PointType(ogc.schema.opengis.gml.v_2_1_2.PointType) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) JAXBElement(javax.xml.bind.JAXBElement) 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 13 with PointType

use of net.opengis.gml.x32.PointType in project arctic-sea by 52North.

the class AbstractCVDiscretePointCoverageTypeEncoder method encodeGeometry.

/**
 * Encode {@link Point} to {@link PointPropertyType}
 *
 * @param point
 *            The {@link Point} to encode
 * @param gmlId
 *            The gml id for the point
 * @return The encoded {@link Point}
 * @throws UnsupportedEncoderInputException
 *             If an element can not be encoded
 * @throws EncodingException
 *             If an error occurs
 */
private PointPropertyType encodeGeometry(Point point, String gmlId) throws EncodingException {
    PointPropertyType ppt = PointPropertyType.Factory.newInstance(getXmlOptions());
    ppt.setPoint((PointType) encodeGML(point, EncodingContext.of(XmlBeansEncodingFlags.GMLID, gmlId)));
    return ppt;
}
Also used : PointPropertyType(net.opengis.gml.x32.PointPropertyType)

Example 14 with PointType

use of net.opengis.gml.x32.PointType in project arctic-sea by 52North.

the class GmlDecoderv321 method parsePointType.

private Geometry parsePointType(PointType xbPointType) throws DecodingException {
    String geomWKT = null;
    int srid = -1;
    if (xbPointType.getSrsName() != null) {
        srid = CRSHelper.parseSrsName(xbPointType.getSrsName());
    }
    if (xbPointType.getPos() != null) {
        DirectPositionType xbPos = xbPointType.getPos();
        if (srid == -1 && xbPos.getSrsName() != null) {
            srid = CRSHelper.parseSrsName(xbPos.getSrsName());
        }
        String directPosition = getString4Pos(xbPos);
        geomWKT = "POINT(" + directPosition + ")";
    } else if (xbPointType.getCoordinates() != null) {
        CoordinatesType xbCoords = xbPointType.getCoordinates();
        String directPosition = getString4Coordinates(xbCoords);
        geomWKT = "POINT" + directPosition;
    } else {
        throw new DecodingException("For geometry type 'gml:Point' only element " + "'gml:pos' and 'gml:coordinates' are allowed " + "in the feature of interest parameter!");
    }
    srid = setDefaultForUnsetSrid(srid);
    try {
        return JTSHelper.createGeometryFromWKT(geomWKT, srid);
    } catch (ParseException ex) {
        throw new DecodingException(ex);
    }
}
Also used : DirectPositionType(net.opengis.gml.x32.DirectPositionType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DateTimeParseException(org.n52.shetland.util.DateTimeParseException) ParseException(org.locationtech.jts.io.ParseException) CoordinatesType(net.opengis.gml.x32.CoordinatesType)

Example 15 with PointType

use of net.opengis.gml.x32.PointType in project arctic-sea by 52North.

the class GmlEncoderv321 method createPointFromJtsGeometry.

/**
 * Creates a XML Point from a SOS Point.
 *
 * @param jtsPoint
 *            SOS Point
 * @param xbPoint
 *            XML Point
 */
private void createPointFromJtsGeometry(Point jtsPoint, PointType xbPoint) {
    DirectPositionType xbPos = xbPoint.addNewPos();
    xbPos.setSrsName(getSrsName(jtsPoint));
    xbPos.setStringValue(JTSHelper.getCoordinatesString(jtsPoint));
}
Also used : DirectPositionType(net.opengis.gml.x32.DirectPositionType)

Aggregations

LineString (com.vividsolutions.jts.geom.LineString)4 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)4 PointType (net.opengis.gml.v_3_1_1.PointType)4 MultiPointType (ogc.schema.opengis.gml.v_2_1_2.MultiPointType)4 PointType (ogc.schema.opengis.gml.v_2_1_2.PointType)4 JAXBElement (javax.xml.bind.JAXBElement)3 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)3 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)3 PointType (net.opengis.gml.v_3_2_1.PointType)3 Test (org.junit.Test)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ValueListType (net.opengis.cat.wrs.v_1_0_2.ValueListType)2 EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)2 MultiPointType (net.opengis.gml.v_3_2_1.MultiPointType)2 DirectPositionType (net.opengis.gml.x32.DirectPositionType)2 MultiPointType (net.opengis.gml.x32.MultiPointType)2 PointType (net.opengis.gml.x32.PointType)2 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)1