Search in sources :

Example 26 with PointType

use of org.geotoolkit.kml.xml.v220.PointType in project ddf by codice.

the class WfsFilterDelegate method createPoint.

private JAXBElement<AbstractGeometryType> createPoint(String wkt) {
    Coordinate[] coordinates = getCoordinatesFromWkt(wkt);
    if (coordinates != null && coordinates.length > 0) {
        CoordinatesType coordinatesType = new CoordinatesType();
        String coordinateString = coordinateStrategy.toString(coordinates[0]);
        coordinatesType.setValue(coordinateString);
        PointType point = new PointType();
        point.setCoordinates(coordinatesType);
        return gmlObjectFactory.createGeometry(point);
    } else {
        throw new IllegalArgumentException("Unable to parse Point coordinates from WKT String");
    }
}
Also used : Coordinate(org.locationtech.jts.geom.Coordinate) PointType(net.opengis.gml.v_3_1_1.PointType) LineString(org.locationtech.jts.geom.LineString) CoordinatesType(net.opengis.gml.v_3_1_1.CoordinatesType)

Example 27 with PointType

use of org.geotoolkit.kml.xml.v220.PointType in project ddf by codice.

the class WfsFilterDelegateTest method testPointLatLonOrder.

@Test
public void testPointLatLonOrder() {
    final WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.DWITHIN.getValue(), new LatLonCoordinateStrategy());
    final FilterType filter = delegate.dwithin(Metacard.ANY_GEO, POINT, DISTANCE);
    assertThat(filter.getSpatialOps().getValue(), is(instanceOf(DistanceBufferType.class)));
    final DistanceBufferType distanceBufferType = (DistanceBufferType) filter.getSpatialOps().getValue();
    assertThat(distanceBufferType.getGeometry().getValue(), is(instanceOf(PointType.class)));
    final PointType pointType = (PointType) distanceBufferType.getGeometry().getValue();
    assertThat(pointType.getCoordinates().getValue(), is("-10.0,30.0"));
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) PointType(net.opengis.gml.v_3_1_1.PointType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) Test(org.junit.Test)

Example 28 with PointType

use of org.geotoolkit.kml.xml.v220.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 29 with PointType

use of org.geotoolkit.kml.xml.v220.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)

Example 30 with PointType

use of org.geotoolkit.kml.xml.v220.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)

Aggregations

PointType (org.geotoolkit.gml.xml.v311.PointType)15 ArrayList (java.util.ArrayList)14 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)14 Test (org.junit.Test)13 StringWriter (java.io.StringWriter)9 JAXBElement (javax.xml.bind.JAXBElement)9 PointType (net.opengis.gml.v_3_1_1.PointType)9 PointType (org.geotoolkit.gml.xml.v321.PointType)8 Geometry (org.locationtech.jts.geom.Geometry)8 Coordinate (org.locationtech.jts.geom.Coordinate)7 Point (org.locationtech.jts.geom.Point)6 StringReader (java.io.StringReader)5 List (java.util.List)5 DistanceBufferType (net.opengis.filter.v_1_1_0.DistanceBufferType)4 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)4 SamplingPointType (org.geotoolkit.sampling.xml.v100.SamplingPointType)4 LineString (org.locationtech.jts.geom.LineString)4 LineString (com.vividsolutions.jts.geom.LineString)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 QName (javax.xml.namespace.QName)3