use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.
the class OmDecoderv20 method getObservationValue.
private ObservationValue<?> getObservationValue(OMObservationType omObservation) throws DecodingException {
Time phenomenonTime = getPhenomenonTime(omObservation);
ObservationValue<?> observationValue;
if (!omObservation.getResult().getDomNode().hasChildNodes() && phenomenonTime.isSetNilReason() && phenomenonTime.getNilReason().equals(NilReason.template)) {
observationValue = new SingleObservationValue<>(new NilTemplateValue());
} else {
observationValue = getResult(omObservation);
}
observationValue.setPhenomenonTime(phenomenonTime);
return observationValue;
}
use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.
the class FesDecoderv20 method parseTemporalFilterType.
/**
* parses a single temporal filter of the requests and returns SOS temporal
* filter
*
* @param xbTemporalOpsType
* XmlObject representing the temporal filter
* @return Returns SOS representation of temporal filter
*
* @throws DecodingException
* * if parsing of the element failed
*/
private TemporalFilter parseTemporalFilterType(TemporalOpsType xbTemporalOpsType) throws DecodingException {
TemporalFilter temporalFilter = new TemporalFilter();
try {
if (xbTemporalOpsType instanceof BinaryTemporalOpType) {
BinaryTemporalOpType btot = (BinaryTemporalOpType) xbTemporalOpsType;
if (btot.getValueReference() != null && !btot.getValueReference().isEmpty()) {
temporalFilter.setValueReference(btot.getValueReference().trim());
}
NodeList nodes = btot.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)) {
Object timeObject = decodeXmlObject(Factory.parse(nodes.item(i)));
if (timeObject instanceof Time) {
TimeOperator operator;
Time time = (Time) timeObject;
String localName = XmlHelper.getLocalName(xbTemporalOpsType);
if (localName.equals(TimeOperator2.After.name())) {
operator = TimeOperator.TM_After;
} else if (localName.equals(TimeOperator2.Before.name())) {
operator = TimeOperator.TM_Before;
} else if (localName.equals(TimeOperator2.Begins.name())) {
operator = TimeOperator.TM_Begins;
} else if (localName.equals(TimeOperator2.BegunBy.name())) {
operator = TimeOperator.TM_BegunBy;
} else if (localName.equals(TimeOperator2.TContains.name())) {
operator = TimeOperator.TM_Contains;
} else if (localName.equals(TimeOperator2.During.name())) {
operator = TimeOperator.TM_During;
} else if (localName.equals(TimeOperator2.EndedBy.name())) {
operator = TimeOperator.TM_EndedBy;
} else if (localName.equals(TimeOperator2.Ends.name())) {
operator = TimeOperator.TM_Ends;
} else if (localName.equals(TimeOperator2.TEquals.name())) {
operator = TimeOperator.TM_Equals;
} else if (localName.equals(TimeOperator2.Meets.name())) {
operator = TimeOperator.TM_Meets;
} else if (localName.equals(TimeOperator2.MetBy.name())) {
operator = TimeOperator.TM_MetBy;
} else if (localName.equals(TimeOperator2.TOverlaps.name())) {
operator = TimeOperator.TM_Overlaps;
} else if (localName.equals(TimeOperator2.OverlappedBy.name())) {
operator = TimeOperator.TM_OverlappedBy;
} else {
throw unsupportedTemporalOperator();
}
temporalFilter.setOperator(operator);
temporalFilter.setTime(time);
break;
} else {
throw new DecodingException(Sos2Constants.GetObservationParams.temporalFilter, "The requested temporal filter value is not supported by this SOS!");
}
}
}
} else {
throw unsupportedTemporalOperator();
}
} catch (XmlException xmle) {
throw new DecodingException("Error while parsing temporal filter!", xmle);
}
return temporalFilter;
}
use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.
the class GetCapabilitiesResponseEncoder method encodePhenomenonTime.
private void encodePhenomenonTime(SosObservationOffering offering, int offeringCounter, ObservationOfferingType xbObsOff) throws EncodingException {
// set up phenomenon time [0..1]
if (offering.getPhenomenonTime() instanceof TimePeriod) {
TimePeriod tp = (TimePeriod) offering.getPhenomenonTime();
if (!tp.isEmpty()) {
tp.setGmlId(String.format(ID_FORMAT_STRING, Sos2Constants.EN_PHENOMENON_TIME, offeringCounter));
XmlObject xmlObject = encodeGml(tp);
xbObsOff.addNewPhenomenonTime().addNewTimePeriod().set(xmlObject);
xbObsOff.getPhenomenonTime().substitute(Sos2Constants.QN_SOS_PHENOMENON_TIME, xbObsOff.getPhenomenonTime().schemaType());
}
}
}
use of org.n52.shetland.ogc.gml.time.Time 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.gml.time.Time 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);
}
}
}
Aggregations