Search in sources :

Example 1 with RelatedFeature

use of net.opengis.swes.x20.InsertSensorType.RelatedFeature in project arctic-sea by 52North.

the class SwesDecoderv20 method parseRelatedFeature.

private List<SwesFeatureRelationship> parseRelatedFeature(final RelatedFeature[] relatedFeatureArray) throws DecodingException {
    List<SwesFeatureRelationship> sosRelatedFeatures = new ArrayList<>(relatedFeatureArray.length);
    for (final RelatedFeature relatedFeature : relatedFeatureArray) {
        final SwesFeatureRelationship sosFeatureRelationship = new SwesFeatureRelationship();
        final FeaturePropertyType fpt = relatedFeature.getFeatureRelationship().getTarget();
        if (fpt.getHref() != null && !fpt.getHref().isEmpty()) {
            final String identifier = fpt.getHref();
            final AbstractSamplingFeature feature = new SamplingFeature(new CodeWithAuthority(identifier));
            if (fpt.getTitle() != null && !fpt.getTitle().isEmpty()) {
                feature.setName(Lists.newArrayList(new CodeType(fpt.getTitle())));
            }
            if (checkForRequestUrl(fpt.getHref())) {
                feature.setUrl(fpt.getHref());
            }
            feature.setFeatureType(OGCConstants.UNKNOWN);
            sosFeatureRelationship.setFeature(feature);
        } else {
            final Object decodedObject = decodeXmlElement(fpt);
            if (decodedObject instanceof AbstractSamplingFeature) {
                sosFeatureRelationship.setFeature((AbstractSamplingFeature) decodedObject);
            } else {
                throw new DecoderResponseUnsupportedException(fpt.xmlText(), decodedObject);
            }
        }
        sosFeatureRelationship.setRole(relatedFeature.getFeatureRelationship().getRole());
        sosRelatedFeatures.add(sosFeatureRelationship);
    }
    return sosRelatedFeatures;
}
Also used : DecoderResponseUnsupportedException(org.n52.svalbard.decode.exception.DecoderResponseUnsupportedException) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) RelatedFeature(net.opengis.swes.x20.InsertSensorType.RelatedFeature) ArrayList(java.util.ArrayList) CodeType(org.n52.shetland.ogc.gml.CodeType) AbstractSamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) SwesFeatureRelationship(org.n52.shetland.ogc.swes.SwesFeatureRelationship) FeaturePropertyType(net.opengis.gml.x32.FeaturePropertyType)

Example 2 with RelatedFeature

use of net.opengis.swes.x20.InsertSensorType.RelatedFeature in project arctic-sea by 52North.

the class CapabilitiesTypeDecoder method parseRelatedFeatures.

private Map<String, Set<String>> parseRelatedFeatures(ObservationOfferingType obsOff) {
    HashMap<String, Set<String>> map = new HashMap<>(obsOff.getRelatedFeatureArray().length);
    for (RelatedFeature releatedFeature : obsOff.getRelatedFeatureArray()) {
        String feature = releatedFeature.getFeatureRelationship().getTarget().getHref();
        String role = releatedFeature.getFeatureRelationship().getRole();
        Set<String> roles = map.computeIfAbsent(feature, key -> new HashSet<>(1));
        if (role != null) {
            roles.add(role);
        }
    }
    return map;
}
Also used : HashSet(java.util.HashSet) Collectors.toSet(java.util.stream.Collectors.toSet) Set(java.util.Set) HashMap(java.util.HashMap) RelatedFeature(net.opengis.swes.x20.AbstractOfferingType.RelatedFeature)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 FeaturePropertyType (net.opengis.gml.x32.FeaturePropertyType)1 RelatedFeature (net.opengis.swes.x20.AbstractOfferingType.RelatedFeature)1 RelatedFeature (net.opengis.swes.x20.InsertSensorType.RelatedFeature)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)1 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)1 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)1 SwesFeatureRelationship (org.n52.shetland.ogc.swes.SwesFeatureRelationship)1 DecoderResponseUnsupportedException (org.n52.svalbard.decode.exception.DecoderResponseUnsupportedException)1