Search in sources :

Example 6 with EnvelopeType

use of net.opengis.gml.v_3_1_1.EnvelopeType in project ddf by codice.

the class WfsFilterDelegate method buildBBoxType.

private JAXBElement<BBOXType> buildBBoxType(String propertyName, String wkt) {
    BBOXType bboxType = new BBOXType();
    bboxType.setPropertyName(createPropertyNameType(propertyName).getValue());
    EnvelopeType envelopeType = gmlObjectFactory.createEnvelopeType();
    Envelope envelope = createEnvelopeFromWkt(wkt);
    List<Double> lowerCornerCoordinates = coordinateStrategy.lowerCorner(envelope);
    List<Double> upperCornerCoordinates = coordinateStrategy.upperCorner(envelope);
    DirectPositionType lowerCorner = new DirectPositionType();
    lowerCorner.setValue(lowerCornerCoordinates);
    envelopeType.setLowerCorner(lowerCorner);
    DirectPositionType upperCorner = new DirectPositionType();
    upperCorner.setValue(upperCornerCoordinates);
    envelopeType.setUpperCorner(upperCorner);
    bboxType.setEnvelope(gmlObjectFactory.createEnvelope(envelopeType));
    return filterObjectFactory.createBBOX(bboxType);
}
Also used : EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) BBOXType(net.opengis.filter.v_1_1_0.BBOXType) DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) Envelope(org.locationtech.jts.geom.Envelope)

Example 7 with EnvelopeType

use of net.opengis.gml.v_3_1_1.EnvelopeType in project ddf by codice.

the class WfsFilterDelegate method createEnvelope.

private JAXBElement<EnvelopeType> createEnvelope(Geometry geometry) {
    EnvelopeType envelopeType = gml320ObjectFactory.createEnvelopeType();
    envelopeType.setSrsName(GeospatialUtil.EPSG_4326_URN);
    Envelope envelope = geometry.getEnvelopeInternal();
    DirectPositionType lowerCorner = gml320ObjectFactory.createDirectPositionType();
    lowerCorner.getValue().add(envelope.getMinX());
    lowerCorner.getValue().add(envelope.getMinY());
    envelopeType.setLowerCorner(lowerCorner);
    DirectPositionType upperCorner = gml320ObjectFactory.createDirectPositionType();
    upperCorner.getValue().add(envelope.getMaxX());
    upperCorner.getValue().add(envelope.getMaxY());
    envelopeType.setUpperCorner(upperCorner);
    return gml320ObjectFactory.createEnvelope(envelopeType);
}
Also used : EnvelopeType(net.opengis.gml.v_3_2_1.EnvelopeType) DirectPositionType(net.opengis.gml.v_3_2_1.DirectPositionType) Envelope(org.locationtech.jts.geom.Envelope)

Example 8 with EnvelopeType

use of net.opengis.gml.v_3_1_1.EnvelopeType in project ddf by codice.

the class SlotTypeConverter method getEnvelope.

private Optional<EnvelopeType> getEnvelope(Map<String, Object> envelopeMap) {
    Optional<EnvelopeType> optionalEnvelope = Optional.empty();
    if (MapUtils.isEmpty(envelopeMap)) {
        return optionalEnvelope;
    }
    optionalEnvelope = Optional.of(GML_FACTORY.createEnvelopeType());
    String valueToPopulate = MapUtils.getString(envelopeMap, SRS_NAME);
    if (StringUtils.isNotBlank(valueToPopulate)) {
        optionalEnvelope.get().setSrsName(valueToPopulate);
    }
    String upperCorner = MapUtils.getString(envelopeMap, UPPER_CORNER);
    String lowerCorner = MapUtils.getString(envelopeMap, LOWER_CORNER);
    if (StringUtils.isNotBlank(upperCorner)) {
        List<Double> values = Arrays.stream(StringUtils.split(upperCorner)).map(e -> new Double(e)).collect(Collectors.toList());
        DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
        directPosition.setValue(values);
        optionalEnvelope.get().setUpperCorner(directPosition);
    }
    if (StringUtils.isNotBlank(lowerCorner)) {
        List<Double> values = Arrays.stream(StringUtils.split(lowerCorner)).map(e -> new Double(e)).collect(Collectors.toList());
        DirectPositionType directPosition = GML_FACTORY.createDirectPositionType();
        directPosition.setValue(values);
        optionalEnvelope.get().setLowerCorner(directPosition);
    }
    return optionalEnvelope;
}
Also used : DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) MapToSchemaElement(org.codice.ddf.registry.schemabindings.helper.MapToSchemaElement) WebMapHelper(org.codice.ddf.registry.schemabindings.helper.WebMapHelper) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) POINT_KEY(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.POINT_KEY) LOWER_CORNER(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.LOWER_CORNER) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) GML_FACTORY(org.codice.ddf.registry.schemabindings.EbrimConstants.GML_FACTORY) NAME(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.NAME) RIM_FACTORY(org.codice.ddf.registry.schemabindings.EbrimConstants.RIM_FACTORY) ENVELOPE_KEY(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.ENVELOPE_KEY) POSITION(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.POSITION) SRS_DIMENSION(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.SRS_DIMENSION) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) RegistryConstants(org.codice.ddf.registry.common.RegistryConstants) BigInteger(java.math.BigInteger) WRS_FACTORY(org.codice.ddf.registry.schemabindings.EbrimConstants.WRS_FACTORY) SRS_NAME(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.SRS_NAME) UPPER_CORNER(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.UPPER_CORNER) ValueListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType) MapUtils(org.apache.commons.collections.MapUtils) Collectors(java.util.stream.Collectors) List(java.util.List) SLOT_TYPE(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.SLOT_TYPE) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) VALUE(org.codice.ddf.registry.schemabindings.converter.web.SlotWebConverter.VALUE) PointType(net.opengis.gml.v_3_1_1.PointType) Optional(java.util.Optional) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) DirectPositionType(net.opengis.gml.v_3_1_1.DirectPositionType)

Example 9 with EnvelopeType

use of net.opengis.gml.v_3_1_1.EnvelopeType 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 10 with EnvelopeType

use of net.opengis.gml.v_3_1_1.EnvelopeType in project ddf by codice.

the class SlotWebConverter method getSlotBoundsMap.

private Map<String, Object> getSlotBoundsMap(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 EnvelopeType) {
                Map<String, Object> boundsMap = getBoundsMapFromEnvelopeType((EnvelopeType) jaxbElement.getValue());
                if (MapUtils.isNotEmpty(boundsMap)) {
                    Map<String, Object> valueMap = new HashMap<>();
                    valueMap.put(ENVELOPE_KEY, boundsMap);
                    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) EnvelopeType(net.opengis.gml.v_3_1_1.EnvelopeType) HashMap(java.util.HashMap) ValueListType(net.opengis.cat.wrs.v_1_0_2.ValueListType) AnyValueType(net.opengis.cat.wrs.v_1_0_2.AnyValueType) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

EnvelopeType (net.opengis.gml.v_3_1_1.EnvelopeType)11 DirectPositionType (net.opengis.gml.v_3_1_1.DirectPositionType)8 BBOXType (net.opengis.filter.v_1_1_0.BBOXType)6 AnyValueType (net.opengis.cat.wrs.v_1_0_2.AnyValueType)4 FilterType (net.opengis.filter.v_1_1_0.FilterType)4 PointType (net.opengis.gml.v_3_1_1.PointType)4 Test (org.junit.Test)4 Map (java.util.Map)3 EnvelopeType (net.opengis.swe.x101.EnvelopeType)3 SlotType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)3 Envelope (org.locationtech.jts.geom.Envelope)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 ValueListType (net.opengis.cat.wrs.v_1_0_2.ValueListType)2 ValueListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ValueListType)2 MapUtils (org.apache.commons.collections.MapUtils)2 StringUtils (org.apache.commons.lang.StringUtils)2 XmlObject (org.apache.xmlbeans.XmlObject)2