use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AqdEncoder method processObservation.
protected void processObservation(OmObservation observation, TimePeriod timePeriod, TimeInstant resultTime, FeatureCollection featureCollection, AbstractEReportingHeader eReportingHeader, int counter) {
if (observation.isSetPhenomenonTime()) {
// generate gml:id
observation.setGmlId(getObservationId(counter));
// add xlink:href to eReportingHeader.content
eReportingHeader.addContent((AbstractFeature) new OmObservation().setIdentifier(new CodeWithAuthority(getObservationXlink(observation.getGmlId()))));
timePeriod.extendToContain(observation.getPhenomenonTime());
observation.setResultTime(resultTime);
featureCollection.addMember(observation);
}
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method setPhenomenonTime.
private void setPhenomenonTime(OmObservation observation, OMObservationType xb) throws EncodingException {
// set validTime
Time phenomenonTime = observation.getPhenomenonTime();
if (phenomenonTime.getGmlId() == null) {
phenomenonTime.setGmlId(OmConstants.PHENOMENON_TIME_NAME + "_" + observation.getObservationID());
}
addPhenomenonTime(xb.addNewPhenomenonTime(), phenomenonTime);
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method setObservationName.
private void setObservationName(OmObservation observation, OMObservationType xb) throws EncodingException {
// set observation identifier if available
if (observation.isSetIdentifier()) {
for (CodeType name : observation.getName()) {
XmlObject xbId = encodeGML(name);
xb.addNewName().set(xbId);
}
}
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class AbstractOmEncoderv20 method addResultTime.
/**
* Method to add the result time to the XML observation object
*
* @param xbObs
* XML observation object
* @param sosObservation
* SOS observation object
* @throws EncodingException
* If an error occurs.
*/
private void addResultTime(OMObservationType xbObs, OmObservation sosObservation) throws EncodingException {
TimeInstant resultTime = sosObservation.getResultTime();
Time phenomenonTime = sosObservation.getPhenomenonTime();
// get result time from SOS result time representation
if (sosObservation.getResultTime() != null) {
if (resultTime.equals(phenomenonTime)) {
xbObs.addNewResultTime().setHref("#" + phenomenonTime.getGmlId());
} else {
addResultTime(xbObs, resultTime);
}
} else {
// representation
if (phenomenonTime instanceof TimeInstant) {
xbObs.addNewResultTime().setHref("#" + phenomenonTime.getGmlId());
} else if (phenomenonTime instanceof TimePeriod) {
TimeInstant rsTime = new TimeInstant(((TimePeriod) sosObservation.getPhenomenonTime()).getEnd());
addResultTime(xbObs, rsTime);
}
}
}
use of org.n52.shetland.ogc.om.OmObservation in project arctic-sea by 52North.
the class ObservationEncoder method encodeTVPValue.
private JsonNode encodeTVPValue(OmObservation o) throws EncodingException {
TVPValue tvpValue = (TVPValue) o.getValue().getValue();
ObjectNode result = nodeFactory().objectNode();
List<TimeValuePair> values = tvpValue.getValue();
if (values != null && !values.isEmpty()) {
String obsProp = o.getObservationConstellation().getObservableProperty().getIdentifier();
SweTime timeDef = new SweTime();
timeDef.setDefinition(OmConstants.PHENOMENON_TIME);
timeDef.setUom(OmConstants.PHEN_UOM_ISO8601);
SweField timeField = new SweField(OmConstants.PHENOMENON_TIME_NAME, timeDef);
SweField valueField = getFieldForValue(obsProp, values.get(0).getValue());
result.putArray(JSONConstants.FIELDS).add(encodeObjectToJson(timeField)).add(encodeObjectToJson(valueField));
ArrayNode jvalues = result.putArray(JSONConstants.VALUES);
for (TimeValuePair tvp : values) {
if (tvp != null && tvp.getValue() != null && tvp.getValue().isSetValue()) {
jvalues.addArray().add(encodeObjectToJson(tvp.getTime())).add(getTokenForValue(tvp.getValue()));
}
}
}
return result;
}
Aggregations