Search in sources :

Example 6 with SosObservationOffering

use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method encodeOffering.

private JsonNode encodeOffering(SosObservationOffering soo) throws EncodingException {
    if (soo == null) {
        return nodeFactory().nullNode();
    }
    ObjectNode jsoo = nodeFactory().objectNode();
    SosOffering offering = soo.getOffering();
    jsoo.put(JSONConstants.IDENTIFIER, offering.getIdentifier());
    if (offering.isSetName()) {
        jsoo.put(JSONConstants.NAME, offering.getFirstName().getValue());
    }
    if (soo.isSetProcedures()) {
        jsoo.set(JSONConstants.PROCEDURE, soo.getProcedures().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetObservableProperties()) {
        jsoo.set(JSONConstants.OBSERVABLE_PROPERTY, soo.getObservableProperties().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetRelatedFeature()) {
        ArrayNode jrf = jsoo.putArray(JSONConstants.RELATED_FEATURE);
        soo.getRelatedFeatures().forEach((feature, roles) -> {
            jrf.addObject().put(JSONConstants.FEATURE_OF_INTEREST, feature).set(JSONConstants.ROLE, roles.stream().map(nodeFactory()::textNode).collect(toJsonArray()));
        });
    }
    if (soo.isSetObservedArea() && soo.getObservedArea().isSetEnvelope() && soo.getObservedArea().isSetSrid()) {
        Envelope e = soo.getObservedArea().getEnvelope();
        ObjectNode oa = jsoo.putObject(JSONConstants.OBSERVED_AREA);
        oa.putArray(JSONConstants.LOWER_LEFT).add(e.getMinX()).add(e.getMinY());
        oa.putArray(JSONConstants.UPPER_RIGHT).add(e.getMaxX()).add(e.getMaxY());
        oa.putObject(JSONConstants.CRS).put(JSONConstants.TYPE, JSONConstants.LINK).putObject(JSONConstants.PROPERTIES).put(JSONConstants.HREF, GeoJSONEncoder.SRID_LINK_PREFIX + soo.getObservedArea().getSrid());
    }
    if (soo.isSetPhenomenonTime()) {
        jsoo.set(JSONConstants.PHENOMENON_TIME, encodeObjectToJson(soo.getPhenomenonTime()));
    }
    if (soo.isSetResultTime()) {
        jsoo.set(JSONConstants.RESULT_TIME, encodeObjectToJson(soo.getResultTime()));
    }
    if (soo.isSetResponseFormats()) {
        jsoo.set(JSONConstants.RESPONSE_FORMAT, soo.getResponseFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetObservationTypes()) {
        jsoo.set(JSONConstants.OBSERVATION_TYPE, soo.getObservationTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetFeatureOfInterestTypes()) {
        jsoo.set(JSONConstants.FEATURE_OF_INTEREST_TYPE, soo.getFeatureOfInterestTypes().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    if (soo.isSetProcedureDescriptionFormats()) {
        jsoo.set(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, soo.getProcedureDescriptionFormats().stream().map(nodeFactory()::textNode).collect(toJsonArray()));
    }
    // TODO soo.getResponseModes();
    return jsoo;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SosOffering(org.n52.shetland.ogc.sos.SosOffering) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Envelope(org.locationtech.jts.geom.Envelope)

Example 7 with SosObservationOffering

use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method encodeResultTime.

private void encodeResultTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
    // set resultTime [0..1]
    if (offering.getResultTime() instanceof TimePeriod) {
        TimePeriod tp = (TimePeriod) offering.getResultTime();
        tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_RESULT_TIME, offeringCounter));
        if (!tp.isEmpty()) {
            XmlObject xmlObject = encodeGml(tp);
            xbObsOff.addNewResultTime().addNewTimePeriod().set(xmlObject);
            xbObsOff.getResultTime().substitute(Sos2Constants.QN_SOS_RESULT_TIME, xbObsOff.getResultTime().schemaType());
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject)

Example 8 with SosObservationOffering

use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method setContents.

/**
 * Sets the content section to the Capabilities document.
 *
 * @param xbContents
 *            SOS 2.0 contents section
 * @param offerings
 *            SOS offerings for contents
 * @param version
 *            SOS response version
 *
 * @throws EncodingException
 *             * if an error occurs.
 */
protected void setContents(Contents xbContents, Collection<SosObservationOffering> offerings, String version) throws EncodingException {
    final ContentsType xbContType = xbContents.addNewContents();
    // for gml:id generation
    int offeringCounter = 0;
    for (final SosObservationOffering offering : offerings) {
        if (offering.isValidObservationOffering()) {
            ++offeringCounter;
            encodeObservationOffering(offering, offeringCounter, xbContType);
        }
    }
    // FIXME: change swes:AbstractOffering to sos:ObservationOffering and
    // the namespace prefix ns to sos due to
    // XMLBeans problems with substitution
    // (http://www.mail-archive.com/dev%40xmlbeans.apache.org/msg00962.html).
    renameContentsElementNames(xbContents);
}
Also used : SosObservationOffering(org.n52.shetland.ogc.sos.SosObservationOffering) ContentsType(net.opengis.sos.x20.ContentsType)

Example 9 with SosObservationOffering

use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method encodePhenomenonTime.

private void encodePhenomenonTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
    // set up phenomenon time [0..1]
    if (offering.getPhenomenonTime() instanceof TimePeriod) {
        TimePeriod tp = (TimePeriod) offering.getPhenomenonTime();
        if (!tp.isEmpty()) {
            tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_PHENOMENON_TIME, offeringCounter));
            XmlObject xmlObject = encodeGml(tp);
            xbObsOff.addNewPhenomenonTime().addNewTimePeriod().set(xmlObject);
            xbObsOff.getPhenomenonTime().substitute(Sos2Constants.QN_SOS_PHENOMENON_TIME, xbObsOff.getPhenomenonTime().schemaType());
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject)

Example 10 with SosObservationOffering

use of org.n52.shetland.ogc.sos.SosObservationOffering in project arctic-sea by 52North.

the class GetCapabilitiesResponseEncoder method encodeObservationOffering.

private void encodeObservationOffering(SosObservationOffering offering, int offeringCounter, ContentsType xbContType) throws EncodingException {
    final ObservationOfferingType xbObsOff = ObservationOfferingType.Factory.newInstance(getXmlOptions());
    SosOffering sosOffering = offering.getOffering();
    xbObsOff.setIdentifier(sosOffering.getIdentifier());
    if (sosOffering.isSetName()) {
        for (CodeType name : sosOffering.getName()) {
            xbObsOff.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML_32, name));
        }
    }
    if (sosOffering.isSetDescription()) {
        xbObsOff.setDescription(sosOffering.getDescription());
    }
    encodeOfferingExtension(offering, xbObsOff);
    offering.getProcedures().forEach(xbObsOff::setProcedure);
    encodeObservableProperties(offering, xbObsOff);
    encodeRelatedFeatures(offering, xbObsOff);
    encodeObservedArea(offering, xbObsOff);
    encodePhenomenonTime(offering, offeringCounter, xbObsOff);
    encodeResultTime(offering, offeringCounter, xbObsOff);
    encodeResponseFormat(offering, xbObsOff);
    encodeObservationType(offering, xbObsOff);
    encodeFeatureOfInterestTypes(offering, xbObsOff);
    encodeProcedureDescriptionFormats(offering, xbObsOff);
    xbContType.addNewOffering().setAbstractOffering(xbObsOff);
/*
         * Offering addNewOffering = xbContType.addNewOffering();
         * addNewOffering.addNewAbstractOffering().set(xbObsOff); XmlHelper
         * .substituteElement(addNewOffering.getAbstractOffering(), xbObsOff);
         */
}
Also used : ObservationOfferingType(net.opengis.sos.x20.ObservationOfferingType) CodeType(org.n52.shetland.ogc.gml.CodeType) SosOffering(org.n52.shetland.ogc.sos.SosOffering)

Aggregations

SosObservationOffering (org.n52.shetland.ogc.sos.SosObservationOffering)6 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 ObservationOfferingType (net.opengis.sos.x20.ObservationOfferingType)2 XmlObject (org.apache.xmlbeans.XmlObject)2 FilterCapabilities (org.n52.shetland.ogc.filter.FilterCapabilities)2 CodeType (org.n52.shetland.ogc.gml.CodeType)2 OwsCapabilities (org.n52.shetland.ogc.ows.OwsCapabilities)2 SosCapabilities (org.n52.shetland.ogc.sos.SosCapabilities)2 SosOffering (org.n52.shetland.ogc.sos.SosOffering)2 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ObservationOfferingList (net.opengis.sos.x10.ContentsDocument.Contents.ObservationOfferingList)1 ObservationOfferingType (net.opengis.sos.x10.ObservationOfferingType)1 ContentsType (net.opengis.sos.x20.ContentsType)1 ObservationOfferingPropertyType (net.opengis.sos.x20.ObservationOfferingPropertyType)1 XmlException (org.apache.xmlbeans.XmlException)1 Envelope (org.locationtech.jts.geom.Envelope)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1