Search in sources :

Example 26 with TimeInstant

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);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 27 with TimeInstant

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;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) TEqualsDocument(net.opengis.fes.x20.TEqualsDocument) BinaryTemporalOpType(net.opengis.fes.x20.BinaryTemporalOpType) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 28 with TimeInstant

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);
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Time(org.n52.shetland.ogc.gml.time.Time) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 29 with TimeInstant

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);
    }
}
Also used : OmObservation(org.n52.shetland.ogc.om.OmObservation) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority)

Example 30 with TimeInstant

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;
}
Also used : PhysicalSystem(org.n52.shetland.ogc.sensorML.v20.PhysicalSystem) OmObservation(org.n52.shetland.ogc.om.OmObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) Date(java.util.Date) SingleObservationValue(org.n52.shetland.ogc.om.SingleObservationValue) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) InsertObservationRequest(org.n52.shetland.ogc.sos.request.InsertObservationRequest) CodeType(org.n52.shetland.ogc.gml.CodeType) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Aggregations

TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)38 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)16 Time (org.n52.shetland.ogc.gml.time.Time)13 DateTime (org.joda.time.DateTime)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)12 Test (org.junit.Test)9 XmlObject (org.apache.xmlbeans.XmlObject)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)5 EncodingException (org.n52.svalbard.encode.exception.EncodingException)5 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)4 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)4 XmlString (org.apache.xmlbeans.XmlString)3 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 URI (java.net.URI)2 Date (java.util.Date)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 EReportingChange (org.n52.shetland.aqd.EReportingChange)2 GeographicalName (org.n52.shetland.inspire.GeographicalName)2