Search in sources :

Example 56 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseCapabilities.

/**
 * Parses the capabilities, processing and removing special insertion
 * metadata
 *
 * @param abstractProcess
 *            The AbstractProcess to which capabilities and insertion
 *            metadata are added
 * @param capabilitiesArray
 *            XML capabilities
 *
 * @throws DecodingException
 *             * if an error occurs
 */
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
    for (final Capabilities cs : capabilitiesArray) {
        final SmlCapabilities capabilities = new SmlCapabilities(cs.getName());
        if (cs.isSetCapabilityList()) {
            CapabilityListType cl = cs.getCapabilityList();
            if (CollectionHelper.isNotNullOrEmpty(cl.getCapabilityArray())) {
                for (Capability c : cl.getCapabilityArray()) {
                    final SmlCapability capability = new SmlCapability(c.getName());
                    if (c.isSetAbstractDataComponent()) {
                        final Object o = decodeXmlElement(c.getAbstractDataComponent());
                        if (o instanceof SweAbstractDataComponent) {
                            capability.setAbstractDataComponent((SweAbstractDataComponent) o);
                            capabilities.addCapability(capability);
                        } else {
                            throw new DecodingException(XmlHelper.getLocalName(cs), "Error while parsing the capabilities of " + "the SensorML (the capabilities data record " + "is not of type DataRecordPropertyType)!");
                        }
                    } else if (c.isSetHref()) {
                        capability.setHref(c.getHref());
                        if (c.isSetTitle()) {
                            capability.setTitle(c.getTitle());
                        }
                    }
                }
            }
        }
        abstractProcess.addCapabilities(capabilities);
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) CapabilityListType(net.opengis.sensorml.x20.CapabilityListType) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability) Capability(net.opengis.sensorml.x20.CapabilityListType.Capability) Capabilities(net.opengis.sensorml.x20.DescribedObjectType.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SmlCapability(org.n52.shetland.ogc.sensorML.elements.SmlCapability)

Example 57 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class SosDecoderv100 method parseDescribeSensor.

/**
 * parses the XmlBean representing the describeSensor request and creates a
 * DescribeSensor request
 *
 * @param descSensorDoc
 *            XmlBean created from the incoming request stream
 * @return Returns SosDescribeSensorRequest representing the request
 */
private OwsServiceCommunicationObject parseDescribeSensor(DescribeSensorDocument descSensorDoc) {
    DescribeSensorRequest request = new DescribeSensorRequest();
    DescribeSensor descSensor = descSensorDoc.getDescribeSensor();
    request.setService(descSensor.getService());
    request.setVersion(descSensor.getVersion());
    // parse outputFormat through MediaType to ensure it's a mime type and
    // eliminate whitespace variations
    request.setProcedureDescriptionFormat(MediaType.normalizeString(descSensor.getOutputFormat()));
    request.setProcedure(descSensor.getProcedure());
    return request;
}
Also used : DescribeSensor(net.opengis.sos.x10.DescribeSensorDocument.DescribeSensor) DescribeSensorRequest(org.n52.shetland.ogc.sos.request.DescribeSensorRequest)

Example 58 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class SosDecoderv20 method checkReferencedElements.

private void checkReferencedElements(final List<OmObservation> observations, final Map<String, Time> phenomenonTimes, final Map<String, TimeInstant> resultTimes, final Map<String, AbstractFeature> features) throws DecodingException {
    for (final OmObservation observation : observations) {
        // phenomenonTime
        final Time phenomenonTime = observation.getPhenomenonTime();
        if (phenomenonTime.isReferenced()) {
            observation.getValue().setPhenomenonTime(phenomenonTimes.get(phenomenonTime.getGmlId()));
        }
        // resultTime
        final TimeInstant resultTime = observation.getResultTime();
        if (resultTime.isReferenced()) {
            if (resultTimes.containsKey(resultTime.getGmlId())) {
                observation.setResultTime(resultTimes.get(resultTime.getGmlId()));
            } else if (phenomenonTimes.containsKey(resultTime.getGmlId())) {
                final Time iTime = phenomenonTimes.get(resultTime.getGmlId());
                if (iTime instanceof TimeInstant) {
                    observation.setResultTime((TimeInstant) iTime);
                } else if (iTime instanceof TimePeriod) {
                    final TimePeriod timePeriod = (TimePeriod) iTime;
                    observation.setResultTime(new TimeInstant(timePeriod.getEnd()));
                } else {
                    throw new DecodingException("observation.resultTime", "The time value type is not supported");
                }
            }
        }
        // featureOfInterest
        final AbstractFeature featureOfInterest = observation.getObservationConstellation().getFeatureOfInterest();
        if (featureOfInterest.isReferenced()) {
            observation.getObservationConstellation().setFeatureOfInterest(features.get(featureOfInterest.getGmlId()));
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 59 with Type

use of org.n52.shetland.w3c.xlink.Type in project arctic-sea by 52North.

the class GetObservationByIdResponseDocumentDecoder method decode.

@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetObservationByIdResponse decode(GetObservationByIdResponseDocument doc) throws DecodingException {
    if (doc != null) {
        GetObservationByIdResponse response = new GetObservationByIdResponse();
        setService(response);
        setVersions(response);
        GetObservationByIdResponseType type = doc.getGetObservationByIdResponse();
        response.setExtensions(parseExtensibleResponse(type));
        response.setObservationCollection(ObservationStream.of(parseObservations(type)));
        return response;
    }
    throw new UnsupportedDecoderInputException(this, doc);
}
Also used : GetObservationByIdResponse(org.n52.shetland.ogc.sos.response.GetObservationByIdResponse) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) GetObservationByIdResponseType(net.opengis.sos.x20.GetObservationByIdResponseType) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 60 with Type

use of org.n52.shetland.w3c.xlink.Type 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)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)27 DecodingException (org.n52.svalbard.decode.exception.DecodingException)15 Actuate (org.n52.shetland.w3c.xlink.Actuate)14 Reference (org.n52.shetland.w3c.xlink.Reference)14 Show (org.n52.shetland.w3c.xlink.Show)14 Type (org.n52.shetland.w3c.xlink.Type)14 ActuateType (org.w3.x1999.xlink.ActuateType)14 ShowType (org.w3.x1999.xlink.ShowType)14 TypeType (org.w3.x1999.xlink.TypeType)14 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)13 AbstractCRSType (net.opengis.gml.x32.AbstractCRSType)10 CodeType (net.opengis.gml.x32.CodeType)10 EXExtentType (org.isotc211.x2005.gmd.EXExtentType)10 XmlException (org.apache.xmlbeans.XmlException)9 Test (org.junit.Test)9 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)9 CIResponsiblePartyPropertyType (org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType)8 CIResponsiblePartyType (org.isotc211.x2005.gmd.CIResponsiblePartyType)8 BaseUnitType (net.opengis.gml.x32.BaseUnitType)6 SupportedType (org.n52.shetland.ogc.SupportedType)6