use of org.n52.shetland.ogc.gml.time.TimeInstant 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.gml.time.TimeInstant in project arctic-sea by 52North.
the class FesEncoderv20 method encodeTemporalFilterEquals.
private XmlObject encodeTemporalFilterEquals(TemporalFilter temporalFilter) throws EncodingException {
final TEqualsDocument equalsDoc = TEqualsDocument.Factory.newInstance(getXmlOptions());
final BinaryTemporalOpType equals = equalsDoc.addNewTEquals();
if (temporalFilter.getTime() instanceof TimeInstant) {
equals.set(encodeObjectToXml(GmlConstants.NS_GML_32, temporalFilter.getTime(), EncodingContext.of(XmlBeansEncodingFlags.DOCUMENT)));
} else {
throw new EncodingException("The temporal filter value is not a TimeInstant!");
}
checkAndAddValueReference(equals, temporalFilter);
return equalsDoc;
}
use of org.n52.shetland.ogc.gml.time.TimeInstant 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.gml.time.TimeInstant in project arctic-sea by 52North.
the class AbstractAqdResponseEncoder 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.gml.time.TimeInstant in project arctic-sea by 52North.
the class InsertObservationRequestEncoderTest method createInsertObservationRequest.
private InsertObservationRequest createInsertObservationRequest() throws InvalidSridException, ParseException {
SamplingFeature samplingFeature = new SamplingFeature(new CodeWithAuthority("test-feature-uri"));
samplingFeature.setName(new CodeType("test-feature-name"));
samplingFeature.setSampledFeatures(Arrays.asList(new SamplingFeature(new CodeWithAuthority("test-parent-feature-uri"))));
samplingFeature.setGeometry(JTSHelper.createGeometryFromWKT("POINT(52.0 42.0)", 4326));
PhysicalSystem procedure = new PhysicalSystem();
procedure.setIdentifier("test-procedure");
OmObservationConstellation observationConstellation = new OmObservationConstellation();
observationConstellation.setGmlId("o1");
observationConstellation.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
observationConstellation.setObservableProperty(new OmObservableProperty("test-property"));
observationConstellation.setFeatureOfInterest(samplingFeature);
observationConstellation.setProcedure(procedure);
TimeInstant time = new TimeInstant(new Date(0));
QuantityValue quantity = new QuantityValue(23.0, "test-uom");
ObservationValue<?> value = new SingleObservationValue<>(time, quantity);
OmObservation omObservation = new OmObservation();
omObservation.setObservationConstellation(observationConstellation);
omObservation.setResultTime(time);
omObservation.setValue(value);
InsertObservationRequest request = new InsertObservationRequest("SOS", "2.0.0");
request.setOfferings(Arrays.asList(OFFERING_ID));
request.addObservation(omObservation);
return request;
}
Aggregations