Search in sources :

Example 46 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class GmlDecoderv311 method parseTimePosition.

private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
    TimeInstant ti = new TimeInstant();
    String timeString = xbTimePosition.getStringValue();
    if (timeString != null && !timeString.isEmpty()) {
        try {
            // TODO better differnetiate between ISO8601 and an
            // indeterminate value
            DateTime dateTime = DateTimeHelper.parseIsoString2DateTime(timeString);
            ti.setValue(dateTime);
            ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
        } catch (DateTimeParseException ex) {
            ti.setIndeterminateValue(new IndeterminateValue(timeString));
        }
    }
    if (xbTimePosition.getIndeterminatePosition() != null) {
        ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
    }
    return ti;
}
Also used : DateTimeParseException(org.n52.shetland.util.DateTimeParseException) IndeterminateValue(org.n52.shetland.ogc.gml.time.IndeterminateValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) DateTime(org.joda.time.DateTime)

Example 47 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class AbstractCoverageEncoder method encodeValueList.

/**
 * Encode value list of {@link RangeSetType} from {@link DiscreteCoverage}
 *
 * @param rst
 *            The {@link RangeSetType} to encode value list for
 * @param discreteCoverage
 *            The {@link DiscreteCoverage} with the value list
 * @throws EncodingException
 *             If an error occurs
 */
protected void encodeValueList(RangeSetType rst, DiscreteCoverage<?> discreteCoverage) throws EncodingException {
    List<?> list = getList(discreteCoverage);
    Value<?> value = discreteCoverage.getRangeSet().iterator().next();
    if (value instanceof BooleanValue) {
        BooleanListDocument bld = BooleanListDocument.Factory.newInstance(getXmlOptions());
        bld.setBooleanList(list);
        rst.set(bld);
    } else if (value instanceof CategoryValue || value instanceof TextValue) {
        DataBlockType dbt = rst.addNewDataBlock();
        dbt.addNewRangeParameters().setHref(discreteCoverage.getRangeParameters());
        CoordinatesType ct = dbt.addNewTupleList();
        ct.setCs(",");
        ct.setStringValue(Joiner.on(",").join(list));
    } else if (value instanceof CountValue) {
        CountListDocument cld = CountListDocument.Factory.newInstance(getXmlOptions());
        cld.setCountList(list);
        rst.set(cld);
    } else if (value instanceof QuantityValue) {
        QuantityListDocument qld = QuantityListDocument.Factory.newInstance(getXmlOptions());
        MeasureOrNilReasonListType monrlt = qld.addNewQuantityList();
        if (discreteCoverage.isSetUnit()) {
            monrlt.setUom(discreteCoverage.getUnit());
        } else if (value.isSetUnit()) {
            monrlt.setUom(value.getUnit());
        }
        monrlt.setListValue(list);
        rst.set(qld);
    }
}
Also used : CountListDocument(net.opengis.gml.x32.CountListDocument) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) BooleanListDocument(net.opengis.gml.x32.BooleanListDocument) CoordinatesType(net.opengis.gml.x32.CoordinatesType) CountValue(org.n52.shetland.ogc.om.values.CountValue) TextValue(org.n52.shetland.ogc.om.values.TextValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) BooleanValue(org.n52.shetland.ogc.om.values.BooleanValue) DataBlockType(net.opengis.gml.x32.DataBlockType) CategoryValue(org.n52.shetland.ogc.om.values.CategoryValue) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument)

Example 48 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class OgcDecoderv100 method parseTemporalOperatorType.

/**
 * parses a single temporal filter of the requests and returns SOS temporal filter
 *
 * @param xbBinaryTemporalOp XmlObject representing the temporal filter
 *
 * @return Returns SOS representation of temporal filter
 *
 * @throws DecodingException if parsing of the element failed
 */
private Object parseTemporalOperatorType(BinaryTemporalOpType xbBinaryTemporalOp) throws DecodingException {
    TemporalFilter temporalFilter = new TemporalFilter();
    // FIXME local workaround against SOSHelper check value reference
    String valueRef = "phenomenonTime";
    try {
        NodeList nodes = xbBinaryTemporalOp.getDomNode().getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            if (nodes.item(i).getNamespaceURI() != null && !nodes.item(i).getLocalName().equals(FilterConstants.EN_VALUE_REFERENCE)) {
                // GML decoder will return TimeInstant or TimePriod
                Object timeObject = decodeXmlElement(XmlObject.Factory.parse(nodes.item(i)));
                if (timeObject instanceof PropertyNameType) {
                    PropertyNameType propType = (PropertyNameType) timeObject;
                // TODO here apply logic for ogc property
                // om:samplingTime etc
                // valueRef = propType.getDomNode().getNodeValue();
                }
                if (timeObject instanceof Time) {
                    TimeOperator operator;
                    Time time = (Time) timeObject;
                    String localName = XmlHelper.getLocalName(xbBinaryTemporalOp);
                    // change to SOS 1.0. TMDuring kind of
                    if (localName.equals(TimeOperator.TM_During.name()) && time instanceof TimePeriod) {
                        operator = TimeOperator.TM_During;
                    } else if (localName.equals(TimeOperator.TM_Equals.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_Equals;
                    } else if (localName.equals(TimeOperator.TM_After.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_After;
                    } else if (localName.equals(TimeOperator.TM_Before.name()) && time instanceof TimeInstant) {
                        operator = TimeOperator.TM_Before;
                    } else {
                        throw unsupportedTemporalFilterOperand();
                    }
                    temporalFilter.setOperator(operator);
                    temporalFilter.setTime(time);
                    // actually it should be eg om:samplingTime
                    temporalFilter.setValueReference(valueRef);
                    break;
                }
            }
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing temporal filter!", xmle);
    }
    return temporalFilter;
}
Also used : TimeOperator(org.n52.shetland.ogc.filter.FilterConstants.TimeOperator) TemporalFilter(org.n52.shetland.ogc.filter.TemporalFilter) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlException(org.apache.xmlbeans.XmlException) NodeList(org.w3c.dom.NodeList) XmlObject(org.apache.xmlbeans.XmlObject) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) PropertyNameType(net.opengis.ogc.PropertyNameType)

Example 49 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class Iso19139GmdEncoder method encodeEXVerticalExtent.

private XmlObject encodeEXVerticalExtent(EXVerticalExtent exVerticalExtent, EncodingContext context) throws EncodingException {
    EXVerticalExtentType exvet = EXVerticalExtentType.Factory.newInstance();
    if (exVerticalExtent.isSetId()) {
        exvet.setId(exVerticalExtent.getId());
    }
    if (exVerticalExtent.isSetUuid()) {
        exvet.setUuid(exVerticalExtent.getUuid());
    }
    // min value
    Nillable<Double> minNillable = exVerticalExtent.getMinimumValue();
    RealPropertyType rptMinValue = exvet.addNewMinimumValue();
    if (minNillable.isPresent()) {
        rptMinValue.setReal(minNillable.get());
    } else {
        rptMinValue.setNil();
        if (minNillable.hasReason()) {
            rptMinValue.setNilReason(minNillable.getNilReason().get());
        } else {
            rptMinValue.setNilReason(Nillable.missing().get());
        }
    }
    // max value
    Nillable<Double> maxNillable = exVerticalExtent.getMaximumValue();
    RealPropertyType rptMinMaxValue = exvet.addNewMaximumValue();
    if (maxNillable.isPresent()) {
        rptMinMaxValue.setReal(maxNillable.get());
    } else {
        rptMinMaxValue.setNil();
        if (maxNillable.hasReason()) {
            rptMinMaxValue.setNilReason(maxNillable.getNilReason().get());
        } else {
            rptMinMaxValue.setNilReason(Nillable.missing().get());
        }
    }
    // verticalCRS
    SCCRSPropertyType sccrspt = exvet.addNewVerticalCRS();
    Referenceable<ScCRS> verticalCRS = exVerticalExtent.getVerticalCRS();
    if (verticalCRS.isReference()) {
        Reference reference = verticalCRS.getReference();
        reference.getActuate().map(Actuate::toString).map(ActuateType.Enum::forString).ifPresent(sccrspt::setActuate);
        reference.getArcrole().ifPresent(sccrspt::setArcrole);
        reference.getHref().map(URI::toString).ifPresent(sccrspt::setHref);
        reference.getRole().ifPresent(sccrspt::setRole);
        reference.getShow().map(Show::toString).map(ShowType.Enum::forString).ifPresent(sccrspt::setShow);
        reference.getTitle().ifPresent(sccrspt::setTitle);
        reference.getType().map(Type::toString).map(TypeType.Enum::forString).ifPresent(sccrspt::setType);
    } else {
        if (verticalCRS.isInstance()) {
            Nillable<ScCRS> nillable = verticalCRS.getInstance();
            if (nillable.isPresent()) {
                XmlObject xml = encodeObjectToXml(GmlConstants.NS_GML_32, nillable.get().getAbstractCrs());
                if (xml != null && xml instanceof AbstractCRSType) {
                    final XmlObject substituteElement = XmlHelper.substituteElement(sccrspt.addNewAbstractCRS(), xml);
                    substituteElement.set(xml);
                } else {
                    sccrspt.setNil();
                    sccrspt.setNilReason(Nillable.missing().get());
                }
            } else {
                sccrspt.setNil();
                if (nillable.hasReason()) {
                    sccrspt.setNilReason(nillable.getNilReason().get());
                } else {
                    sccrspt.setNilReason(Nillable.missing().get());
                }
            }
        }
    }
    if (context.has(XmlBeansEncodingFlags.PROPERTY_TYPE)) {
        EXVerticalExtentPropertyType exvept = EXVerticalExtentPropertyType.Factory.newInstance(getXmlOptions());
        exvept.setEXVerticalExtent(exvet);
        return exvept;
    } else if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
        EXVerticalExtentDocument exved = EXVerticalExtentDocument.Factory.newInstance(getXmlOptions());
        exved.setEXVerticalExtent(exvet);
        return exved;
    }
    return exvet;
}
Also used : ActuateType(org.w3.x1999.xlink.ActuateType) Reference(org.n52.shetland.w3c.xlink.Reference) ScCRS(org.n52.shetland.iso.gmd.ScCRS) EXVerticalExtentPropertyType(org.isotc211.x2005.gmd.EXVerticalExtentPropertyType) EXVerticalExtentType(org.isotc211.x2005.gmd.EXVerticalExtentType) Actuate(org.n52.shetland.w3c.xlink.Actuate) CIAddressType(org.isotc211.x2005.gmd.CIAddressType) CIContactPropertyType(org.isotc211.x2005.gmd.CIContactPropertyType) DQDomainConsistencyPropertyType(org.isotc211.x2005.gmd.DQDomainConsistencyPropertyType) CodeType(net.opengis.gml.x32.CodeType) MDMetadataPropertyType(org.isotc211.x2005.gmd.MDMetadataPropertyType) MDMetadataType(org.isotc211.x2005.gmd.MDMetadataType) LocalisedCharacterStringPropertyType(org.isotc211.x2005.gmd.LocalisedCharacterStringPropertyType) CharacterStringPropertyType(org.isotc211.x2005.gco.CharacterStringPropertyType) EXExtentPropertyType(org.isotc211.x2005.gmd.EXExtentPropertyType) CICitationType(org.isotc211.x2005.gmd.CICitationType) MDDataIdentificationType(org.isotc211.x2005.gmd.MDDataIdentificationType) DQDomainConsistencyType(org.isotc211.x2005.gmd.DQDomainConsistencyType) EXVerticalExtentType(org.isotc211.x2005.gmd.EXVerticalExtentType) GmdDateType(org.n52.shetland.iso.gmd.GmdDateType) CodeListValueType(org.isotc211.x2005.gco.CodeListValueType) AbstractCRSType(net.opengis.gml.x32.AbstractCRSType) DQResultPropertyType(org.isotc211.x2005.gmd.DQResultPropertyType) CIDateType(org.isotc211.x2005.gmd.CIDateType) CIContactType(org.isotc211.x2005.gmd.CIContactType) ShowType(org.w3.x1999.xlink.ShowType) MDIdentificationPropertyType(org.isotc211.x2005.gmd.MDIdentificationPropertyType) EXExtentType(org.isotc211.x2005.gmd.EXExtentType) CIOnlineResourcePropertyType(org.isotc211.x2005.gmd.CIOnlineResourcePropertyType) BaseUnitType(net.opengis.gml.x32.BaseUnitType) CITelephonePropertyType(org.isotc211.x2005.gmd.CITelephonePropertyType) ActuateType(org.w3.x1999.xlink.ActuateType) CIAddressPropertyType(org.isotc211.x2005.gmd.CIAddressPropertyType) UnitOfMeasurePropertyType(org.isotc211.x2005.gco.UnitOfMeasurePropertyType) EXVerticalExtentPropertyType(org.isotc211.x2005.gmd.EXVerticalExtentPropertyType) CIOnlineResourceType(org.isotc211.x2005.gmd.CIOnlineResourceType) DQQuantitativeResultType(org.isotc211.x2005.gmd.DQQuantitativeResultType) CIResponsiblePartyType(org.isotc211.x2005.gmd.CIResponsiblePartyType) SupportedType(org.n52.shetland.ogc.SupportedType) LocalisedCharacterStringType(org.isotc211.x2005.gmd.LocalisedCharacterStringType) CICitationPropertyType(org.isotc211.x2005.gmd.CICitationPropertyType) CITelephoneType(org.isotc211.x2005.gmd.CITelephoneType) DQConformanceResultType(org.isotc211.x2005.gmd.DQConformanceResultType) TypeType(org.w3.x1999.xlink.TypeType) Type(org.n52.shetland.w3c.xlink.Type) CIRoleCodePropertyType(org.isotc211.x2005.gmd.CIRoleCodePropertyType) MDDataIdentificationPropertyType(org.isotc211.x2005.gmd.MDDataIdentificationPropertyType) RealPropertyType(org.isotc211.x2005.gco.RealPropertyType) AbstractMDIdentificationType(org.isotc211.x2005.gmd.AbstractMDIdentificationType) PTFreeTextType(org.isotc211.x2005.gmd.PTFreeTextType) SCCRSPropertyType(org.isotc211.x2005.gsr.SCCRSPropertyType) CIResponsiblePartyPropertyType(org.isotc211.x2005.gmd.CIResponsiblePartyPropertyType) RealPropertyType(org.isotc211.x2005.gco.RealPropertyType) SCCRSPropertyType(org.isotc211.x2005.gsr.SCCRSPropertyType) AbstractCRSType(net.opengis.gml.x32.AbstractCRSType) Show(org.n52.shetland.w3c.xlink.Show) XmlObject(org.apache.xmlbeans.XmlObject) EXVerticalExtentDocument(org.isotc211.x2005.gmd.EXVerticalExtentDocument) TypeType(org.w3.x1999.xlink.TypeType) ShowType(org.w3.x1999.xlink.ShowType)

Example 50 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class AqdEncoder method encodeGetObservationResponse.

private XmlObject encodeGetObservationResponse(GetObservationResponse response, EncodingContext ctx) throws EncodingException {
    try {
        FeatureCollection featureCollection = getFeatureCollection(response);
        // TODO get FLOW from response
        EReportingHeader eReportingHeader = getEReportingHeader(getReportObligationType(response));
        featureCollection.addMember(eReportingHeader);
        TimePeriod timePeriod = new TimePeriod();
        TimeInstant resultTime = new TimeInstant(new DateTime(DateTimeZone.UTC));
        int counter = 1;
        ObservationStream observationCollection = response.getObservationCollection();
        while (observationCollection.hasNext()) {
            OmObservation observation = observationCollection.next();
            if (observation.getValue() instanceof ObservationStream) {
                ObservationStream value = (ObservationStream) observation.getValue();
                if (value instanceof StreamingValue) {
                    value = value.merge();
                }
                while (value.hasNext()) {
                    processObservation(value.next(), timePeriod, resultTime, featureCollection, eReportingHeader, counter++);
                }
            } else {
                processObservation(observation, timePeriod, resultTime, featureCollection, eReportingHeader, counter++);
            }
        }
        if (!timePeriod.isEmpty()) {
            eReportingHeader.setReportingPeriod(Referenceable.of((Time) timePeriod));
        }
        return encodeObjectToXml(GmlConstants.NS_GML_32, featureCollection, ctx.with(XmlEncoderFlags.ENCODE_NAMESPACE, OmConstants.NS_OM_2).with(XmlBeansEncodingFlags.DOCUMENT));
    } catch (OwsExceptionReport ex) {
        throw new EncodingException(ex);
    }
}
Also used : FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) ObservationStream(org.n52.shetland.ogc.om.ObservationStream) StreamingValue(org.n52.shetland.ogc.om.StreamingValue) EncodingException(org.n52.svalbard.encode.exception.EncodingException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AbstractEReportingHeader(org.n52.shetland.aqd.AbstractEReportingHeader) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) DateTime(org.joda.time.DateTime)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5