Search in sources :

Example 6 with PointType

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

the class SlotTypeConverter method getPoint.

private Optional<PointType> getPoint(Map<String, Object> pointMap) {
    Optional<PointType> optionalPoint = Optional.empty();
    if (MapUtils.isEmpty(pointMap)) {
        return optionalPoint;
    }
    BigInteger dimension = getBigIntFromMap(SRS_DIMENSION, pointMap);
    if (dimension != null) {
        if (!optionalPoint.isPresent()) {
            optionalPoint = Optional.of(GML_FACTORY.createPointType());
        }
        optionalPoint.get().setSrsDimension(dimension);
    }
    String valueToPopulate = MapUtils.getString(pointMap, SRS_NAME);
    if (StringUtils.isNotBlank(valueToPopulate)) {
        if (!optionalPoint.isPresent()) {
            optionalPoint = Optional.of(GML_FACTORY.createPointType());
        }
        optionalPoint.get().setSrsName(valueToPopulate);
    }
    valueToPopulate = MapUtils.getString(pointMap, POSITION);
    if (StringUtils.isNotBlank(valueToPopulate)) {
        String[] values = StringUtils.split(valueToPopulate);
        DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
        for (String value : values) {
            directPosition.getValue().add(Double.valueOf(value));
        }
        if (!optionalPoint.isPresent()) {
            optionalPoint = Optional.of(GML_FACTORY.createPointType());
        }
        optionalPoint.get().setPos(directPosition);
    }
    return optionalPoint;
}
Also used : DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) PointType(net.opengis.gml.v_3_1_1.PointType) BigInteger(java.math.BigInteger)

Example 7 with PointType

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

the class WfsFilterDelegate method createPoint.

private JAXBElement<PointType> createPoint(String wkt) {
    Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
    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 gmlObjectFactory.createPoint(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) PointType(ogc.schema.opengis.gml.v_2_1_2.PointType) MultiPointType(ogc.schema.opengis.gml.v_2_1_2.MultiPointType) CoordinatesType(ogc.schema.opengis.gml.v_2_1_2.CoordinatesType)

Example 8 with PointType

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

the class GmlEncoderv321 method createPosition.

private XmlObject createPosition(Geometry geom, EncodingContext ctx) throws EncodingException {
    String foiId = ctx.<String>get(XmlBeansEncodingFlags.GMLID).orElse(null);
    if (geom instanceof Point) {
        PointType xbPoint = PointType.Factory.newInstance(getXmlOptions());
        xbPoint.setId(getGmlID(geom, foiId));
        createPointFromJtsGeometry((Point) geom, xbPoint);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            PointDocument xbPointDoc = PointDocument.Factory.newInstance(getXmlOptions());
            xbPointDoc.setPoint(xbPoint);
            return xbPointDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbPoint);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POINT_32, PointType.type);
            return geometryPropertyType;
        }
        return xbPoint;
    } else if (geom instanceof LineString) {
        LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
        xbLineString.setId(getGmlID(geom, foiId));
        createLineStringFromJtsGeometry((LineString) geom, xbLineString);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            LineStringDocument xbLineStringDoc = LineStringDocument.Factory.newInstance(getXmlOptions());
            xbLineStringDoc.setLineString(xbLineString);
            return xbLineStringDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbLineString);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_LINESTRING_32, LineStringType.type);
            return geometryPropertyType;
        }
        return xbLineString;
    } else if (geom instanceof MultiLineString) {
        MultiCurveType xbMultiCurve = MultiCurveType.Factory.newInstance(getXmlOptions());
        xbMultiCurve.setId(getGmlID(geom, foiId));
        xbMultiCurve.setSrsName(getSrsName(geom));
        for (int i = 0; i < geom.getNumGeometries(); ++i) {
            Geometry lineString = geom.getGeometryN(i);
            LineStringType xbLineString = LineStringType.Factory.newInstance(getXmlOptions());
            xbLineString.setId(getGmlID(geom, foiId));
            xbLineString.addNewPosList().setStringValue(JTSHelper.getCoordinatesString(lineString));
            CurvePropertyType xbCurveMember = xbMultiCurve.addNewCurveMember();
            xbCurveMember.addNewAbstractCurve().set(xbLineString);
            XmlHelper.substituteElement(xbCurveMember.getAbstractCurve(), xbLineString);
        }
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            MultiCurveDocument xbMultiCurveDoc = MultiCurveDocument.Factory.newInstance(getXmlOptions());
            xbMultiCurveDoc.setMultiCurve(xbMultiCurve);
            return xbMultiCurveDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType xbGeometryProperty = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            xbGeometryProperty.addNewAbstractGeometry().set(xbMultiCurve);
            XmlHelper.substituteElement(xbGeometryProperty.getAbstractGeometry(), xbMultiCurve);
            return xbGeometryProperty;
        } else {
            return xbMultiCurve;
        }
    } else if (geom instanceof Polygon) {
        PolygonType xbPolygon = PolygonType.Factory.newInstance(getXmlOptions());
        xbPolygon.setId(getGmlID(geom, foiId));
        createPolygonFromJtsGeometry((Polygon) geom, xbPolygon);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            PolygonDocument xbPolygonDoc = PolygonDocument.Factory.newInstance(getXmlOptions());
            xbPolygonDoc.setPolygon(xbPolygon);
            return xbPolygonDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbPolygon);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_POLYGON_32, PolygonType.type);
            return geometryPropertyType;
        }
        return xbPolygon;
    } else if (geom instanceof MultiPoint) {
        MultiPointType xbMultiPoint = MultiPointType.Factory.newInstance(getXmlOptions());
        String id = getGmlID(geom, foiId);
        xbMultiPoint.setId(id);
        createMultiPointFromJtsGeometry((MultiPoint) geom, xbMultiPoint, id);
        if (ctx.has(XmlBeansEncodingFlags.DOCUMENT)) {
            MultiPointDocument xbMultiPointDoc = MultiPointDocument.Factory.newInstance(getXmlOptions());
            xbMultiPointDoc.setMultiPoint(xbMultiPoint);
            return xbMultiPointDoc;
        } else if (ctx.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
            GeometryPropertyType geometryPropertyType = GeometryPropertyType.Factory.newInstance(getXmlOptions());
            geometryPropertyType.setAbstractGeometry(xbMultiPoint);
            geometryPropertyType.getAbstractGeometry().substitute(GmlConstants.QN_MULTI_POINT_32, PolygonType.type);
            return geometryPropertyType;
        }
        return xbMultiPoint;
    } else {
        throw new UnsupportedEncoderInputException(this, geom);
    }
}
Also used : MultiPoint(org.locationtech.jts.geom.MultiPoint) MultiLineString(org.locationtech.jts.geom.MultiLineString) PolygonDocument(net.opengis.gml.x32.PolygonDocument) MultiPointDocument(net.opengis.gml.x32.MultiPointDocument) PointDocument(net.opengis.gml.x32.PointDocument) MultiCurveType(net.opengis.gml.x32.MultiCurveType) MultiCurveDocument(net.opengis.gml.x32.MultiCurveDocument) PolygonType(net.opengis.gml.x32.PolygonType) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.locationtech.jts.geom.Point) LineStringType(net.opengis.gml.x32.LineStringType) MultiPointType(net.opengis.gml.x32.MultiPointType) MultiPointDocument(net.opengis.gml.x32.MultiPointDocument) MultiPoint(org.locationtech.jts.geom.MultiPoint) Point(org.locationtech.jts.geom.Point) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) EnvelopeOrGeometry(org.n52.shetland.util.EnvelopeOrGeometry) Geometry(org.locationtech.jts.geom.Geometry) AbstractGeometry(org.n52.shetland.ogc.gml.AbstractGeometry) MultiLineString(org.locationtech.jts.geom.MultiLineString) LineString(org.locationtech.jts.geom.LineString) LineStringDocument(net.opengis.gml.x32.LineStringDocument) MultiPointType(net.opengis.gml.x32.MultiPointType) PointType(net.opengis.gml.x32.PointType) CurvePropertyType(net.opengis.gml.x32.CurvePropertyType) Polygon(org.locationtech.jts.geom.Polygon) GeometryPropertyType(net.opengis.gml.x32.GeometryPropertyType)

Example 9 with PointType

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

the class SlotWebConverter method getSlotGeoMap.

private Map<String, Object> getSlotGeoMap(SlotType1 slot) {
    Map<String, Object> map = new HashMap<>();
    if (!slot.isSetValueList()) {
        return map;
    }
    ValueListType valueList = (ValueListType) slot.getValueList().getValue();
    for (AnyValueType anyValue : valueList.getAnyValue()) {
        anyValue.getContent().stream().filter(content -> content instanceof JAXBElement).forEach(content -> {
            JAXBElement jaxbElement = (JAXBElement) content;
            if (jaxbElement.getValue() instanceof PointType) {
                Map<String, Object> pointMap = getPointMapFromPointType((PointType) jaxbElement.getValue());
                if (MapUtils.isNotEmpty(pointMap)) {
                    Map<String, Object> valueMap = new HashMap<>();
                    valueMap.put(POINT_KEY, pointMap);
                    map.put(VALUE, valueMap);
                }
            }
        });
    }
    return map;
}
Also used : DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) StringUtils(org.apache.commons.lang.StringUtils) WebMapHelper(org.codice.ddf.registry.schemabindings.helper.WebMapHelper) MapUtils(org.apache.commons.collections.MapUtils) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) ArrayList(java.util.ArrayList) List(java.util.List) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Map(java.util.Map) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) SlotTypeHelper(org.codice.ddf.registry.schemabindings.helper.SlotTypeHelper) RegistryConstants(org.codice.ddf.registry.common.RegistryConstants) HashMap(java.util.HashMap) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement)

Example 10 with PointType

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

the class SlotTypeConverter method getWrsValueList.

private Optional<net.opengis.cat.wrs.v_1_0_2.ValueListType> getWrsValueList(Map<String, Object> map) {
    Optional<net.opengis.cat.wrs.v_1_0_2.ValueListType> optionalValueList = Optional.empty();
    if (MapUtils.isEmpty(map) || !map.containsKey(VALUE)) {
        return optionalValueList;
    }
    Map<String, Object> valueMap = (Map<String, Object>) map.get(VALUE);
    if (valueMap.containsKey(POINT_KEY)) {
        Optional<PointType> optionalPoint = getPoint((Map<String, Object>) valueMap.get(POINT_KEY));
        if (optionalPoint.isPresent()) {
            AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
            anyValue.getContent().add(GML_FACTORY.createPoint(optionalPoint.get()));
            net.opengis.cat.wrs.v_1_0_2.ValueListType valueList = WRS_FACTORY.createValueListType();
            valueList.getAnyValue().add(anyValue);
            if (!optionalValueList.isPresent()) {
                optionalValueList = Optional.of(WRS_FACTORY.createValueListType());
            }
            optionalValueList.get().getAnyValue().add(anyValue);
        }
    } else if (valueMap.containsKey(ENVELOPE_KEY)) {
        Optional<EnvelopeType> optionalEnvelope = getEnvelope((Map<String, Object>) valueMap.get(ENVELOPE_KEY));
        if (optionalEnvelope.isPresent()) {
            AnyValueType anyValue = WRS_FACTORY.createAnyValueType();
            anyValue.getContent().add(GML_FACTORY.createEnvelope(optionalEnvelope.get()));
            net.opengis.cat.wrs.v_1_0_2.ValueListType valueList = WRS_FACTORY.createValueListType();
            valueList.getAnyValue().add(anyValue);
            if (!optionalValueList.isPresent()) {
                optionalValueList = Optional.of(WRS_FACTORY.createValueListType());
            }
            optionalValueList.get().getAnyValue().add(anyValue);
        }
    }
    return optionalValueList;
}
Also used : Optional(java.util.Optional) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType) PointType(net.opengis.gml.v_3_1_1.PointType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) Map(java.util.Map)

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 MultiPointType (net.opengis.gml.x32.MultiPointType)2 PointType (net.opengis.gml.x32.PointType)2 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1