Search in sources :

Example 6 with AbstractPhenomenon

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

the class WmlTDREncoderv20 method createMeasurementDomainRange.

private XmlObject createMeasurementDomainRange(AbstractObservationValue<?> observationValue) throws EncodingException {
    if (!observationValue.isSetObservationType() || (observationValue.isSetObservationType() && isInvalidObservationType(observationValue.getObservationType()))) {
        return null;
    }
    MeasurementTimeseriesDomainRangeDocument xbMearuementTimeseriesDomainRangeDoc = MeasurementTimeseriesDomainRangeDocument.Factory.newInstance();
    MeasurementTimeseriesCoverageType xbMeasurementTimeseriesDomainRange = xbMearuementTimeseriesDomainRangeDoc.addNewMeasurementTimeseriesDomainRange();
    xbMeasurementTimeseriesDomainRange.setId(TIMESERIES_ID_PREFIX + observationValue.getObservationID());
    // set time position list
    xbMeasurementTimeseriesDomainRange.addNewDomainSet().set(getTimePositionList(observationValue));
    // initialize unit
    // AbstractPhenomenon observableProperty =
    // observationValue.getObservableProperty();
    String unit = null;
    // create quantity list from values
    QuantityListDocument quantityListDoc = QuantityListDocument.Factory.newInstance();
    MeasureOrNilReasonListType quantityList = quantityListDoc.addNewQuantityList();
    if (observationValue instanceof MultiObservationValues) {
        TVPValue tvpValue = (TVPValue) ((MultiObservationValues<?>) observationValue).getValue();
        List<TimeValuePair> timeValuePairs = tvpValue.getValue();
        if (Strings.isNullOrEmpty(unit) && CollectionHelper.isNotEmpty(timeValuePairs) && timeValuePairs.get(0).getValue().isSetUnit()) {
            unit = timeValuePairs.get(0).getValue().getUnit();
        }
        quantityList.setListValue(getValueList(timeValuePairs));
    }
    if (Strings.isNullOrEmpty(unit)) {
        unit = OGCConstants.UNKNOWN;
    }
    quantityList.setUom(unit);
    // set unit to SosObservableProperty if not set.
    // if (observableProperty instanceof OmObservableProperty
    // && !((OmObservableProperty) observableProperty).isSetUnit()) {
    // ((OmObservableProperty) observableProperty).setUnit(unit);
    // }
    // set up range set
    xbMeasurementTimeseriesDomainRange.addNewRangeSet().set(quantityListDoc);
    // set up rangeType
    xbMeasurementTimeseriesDomainRange.addNewRangeType().set(createDataRecord(observationValue, unit));
    // set om:Result
    return xbMearuementTimeseriesDomainRangeDoc;
}
Also used : MeasurementTimeseriesDomainRangeDocument(net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument) TVPValue(org.n52.shetland.ogc.om.values.TVPValue) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument) MeasurementTimeseriesCoverageType(net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

Example 7 with AbstractPhenomenon

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

the class WmlTDREncoderv20 method createDataRecord.

/**
 * Create a SOS DataRecord object from SOS observation and encode to
 * XmlBeans object
 *
 * @param sosObservation
 *            SOS observation
 * @return XML DataRecord object
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createDataRecord(OmObservation sosObservation) throws EncodingException {
    AbstractPhenomenon observableProperty = sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observableProperty.getIdentifier());
    quantity.setDescription(observableProperty.getDescription());
    if (observableProperty instanceof OmObservableProperty && ((OmObservableProperty) observableProperty).isSetUnit()) {
        quantity.setUom(((OmObservableProperty) observableProperty).getUnit());
    }
    return createDataRecord(quantity, sosObservation.getObservationID());
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Aggregations

AbstractPhenomenon (org.n52.shetland.ogc.om.AbstractPhenomenon)5 MeasureOrNilReasonListType (net.opengis.gml.x32.MeasureOrNilReasonListType)2 QuantityListDocument (net.opengis.gml.x32.QuantityListDocument)2 MeasurementTimeseriesCoverageType (net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType)2 MeasurementTimeseriesDomainRangeDocument (net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument)2 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)2 TVPValue (org.n52.shetland.ogc.om.values.TVPValue)2 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)2 Test (org.junit.Test)1 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1