Search in sources :

Example 1 with AbstractPhenomenon

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

the class AbstractOmEncoderv20 method setObservableProperty.

private void setObservableProperty(OmObservation observation, OMObservationType xb) {
    // set observedProperty (phenomenon)
    AbstractPhenomenon observableProperty = observation.getObservationConstellation().getObservableProperty();
    xb.addNewObservedProperty().setHref(observableProperty.getIdentifier());
    if (observableProperty.isSetName()) {
        xb.getObservedProperty().setTitle(observableProperty.getFirstName().getValue());
    }
    if (observableProperty.isSetName() && observableProperty.getFirstName().isSetValue()) {
        xb.getObservedProperty().setTitle(observableProperty.getFirstName().getValue());
    }
}
Also used : AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon)

Example 2 with AbstractPhenomenon

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

the class WmlTDREncoderv20 method createDataRecord.

private XmlObject createDataRecord(AbstractObservationValue<?> observationValue, String unit) throws EncodingException {
    // AbstractPhenomenon observableProperty =
    // sosObservation.getObservationConstellation().getObservableProperty();
    SweQuantity quantity = new SweQuantity();
    quantity.setDefinition(observationValue.getObservableProperty());
    quantity.setUom(unit);
    return createDataRecord(quantity, observationValue.getObservationID());
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity)

Example 3 with AbstractPhenomenon

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

the class UVFEncoder method writeLine2.

private void writeLine2(Writer fw, OmObservation o, TimePeriod centuries, String lineEnding) throws IOException {
    // 2.Zeile ABFLUSS m3/s 1900 1900
    StringBuilder sb = new StringBuilder(39);
    // Identifier
    AbstractPhenomenon observableProperty = o.getObservationConstellation().getObservableProperty();
    String observablePropertyIdentifier = observableProperty.getIdentifier();
    if (observablePropertyIdentifier != null && !observablePropertyIdentifier.isEmpty()) {
        observablePropertyIdentifier = ensureIdentifierLength(observablePropertyIdentifier, UVFConstants.MAX_IDENTIFIER_LENGTH);
    }
    sb.append(observablePropertyIdentifier);
    fillWithSpaces(sb, UVFConstants.MAX_IDENTIFIER_LENGTH);
    // Unit (optional)
    String unit = getUnit(o);
    if (unit != null && !unit.isEmpty()) {
        unit = ensureIdentifierLength(unit, UVFConstants.MAX_IDENTIFIER_LENGTH);
        sb.append(" ");
        sb.append(unit);
    }
    fillWithSpaces(sb, 30);
    // Centuries
    sb.append(centuries.getStart().getCenturyOfEra() + "00 " + centuries.getEnd().getCenturyOfEra() + "00");
    writeToFile(fw, sb.toString(), lineEnding);
}
Also used : AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon)

Example 4 with AbstractPhenomenon

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

the class MeasurementDecodingTest method testObservedProperty.

@Test
public void testObservedProperty() {
    assertThat(observation, is(notNullValue()));
    final OmObservationConstellation oc = observation.getObservationConstellation();
    assertThat(oc, is(notNullValue()));
    final AbstractPhenomenon op = oc.getObservableProperty();
    assertThat(op, is(notNullValue()));
    assertThat(op.getIdentifier(), is(equalTo(OBSERVED_PROPERTY)));
}
Also used : AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Test(org.junit.Test)

Example 5 with AbstractPhenomenon

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

the class WmlTDREncoderv20 method createMeasurementDomainRange.

/**
 * Create a XML MeasurementTimeseriesDomainRange object from SOS observation
 * for om:result
 *
 * @param sosObservation
 *            SOS observation
 * @return XML MeasurementTimeseriesDomainRange object for om:result
 * @throws EncodingException
 *             If an error occurs
 */
private XmlObject createMeasurementDomainRange(OmObservation sosObservation) throws EncodingException {
    if (!sosObservation.getObservationConstellation().isSetObservationType() || (sosObservation.getObservationConstellation().isSetObservationType() && isInvalidObservationType(sosObservation.getObservationConstellation().getObservationType()))) {
        throw new UnsupportedEncoderInputException(this, sosObservation.getObservationConstellation().isSetObservationType());
    }
    MeasurementTimeseriesDomainRangeDocument xbMearuementTimeseriesDomainRangeDoc = MeasurementTimeseriesDomainRangeDocument.Factory.newInstance();
    MeasurementTimeseriesCoverageType xbMeasurementTimeseriesDomainRange = xbMearuementTimeseriesDomainRangeDoc.addNewMeasurementTimeseriesDomainRange();
    xbMeasurementTimeseriesDomainRange.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
    // set time position list
    xbMeasurementTimeseriesDomainRange.addNewDomainSet().set(getTimePositionList(sosObservation));
    // initialize unit
    AbstractPhenomenon observableProperty = sosObservation.getObservationConstellation().getObservableProperty();
    String unit = null;
    // create quantity list from values
    QuantityListDocument quantityListDoc = QuantityListDocument.Factory.newInstance();
    MeasureOrNilReasonListType quantityList = quantityListDoc.addNewQuantityList();
    if (sosObservation.getValue() instanceof MultiObservationValues) {
        MultiObservationValues<?> observationValue = (MultiObservationValues<?>) sosObservation.getValue();
        TVPValue tvpValue = (TVPValue) 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(sosObservation));
    // set om:Result
    return xbMearuementTimeseriesDomainRangeDoc;
}
Also used : TVPValue(org.n52.shetland.ogc.om.values.TVPValue) MeasureOrNilReasonListType(net.opengis.gml.x32.MeasureOrNilReasonListType) MultiObservationValues(org.n52.shetland.ogc.om.MultiObservationValues) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) MeasurementTimeseriesDomainRangeDocument(net.opengis.watermlDr.x20.MeasurementTimeseriesDomainRangeDocument) AbstractPhenomenon(org.n52.shetland.ogc.om.AbstractPhenomenon) QuantityListDocument(net.opengis.gml.x32.QuantityListDocument) MeasurementTimeseriesCoverageType(net.opengis.watermlDr.x20.MeasurementTimeseriesCoverageType) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeValuePair(org.n52.shetland.ogc.om.TimeValuePair)

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