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());
}
}
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());
}
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);
}
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)));
}
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;
}
Aggregations