Search in sources :

Example 31 with TimePeriod

use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.

the class InspireEncoderTest method getFullInspireExtendedCapabilities.

private FullInspireExtendedCapabilities getFullInspireExtendedCapabilities() {
    InspireResourceLocator resourceLocator = new InspireResourceLocator("http://full.test.org/sos");
    resourceLocator.addMediaType(MediaTypes.APPLICATION_SOAP_XML);
    // -------------------
    InspireTemporalReference temporalReference = new InspireTemporalReference();
    temporalReference.setDateOfCreation(new InspireDateOfCreation(new DateTime()));
    temporalReference.setDateOfLastRevision(new InspireDateOfLastRevision(new DateTime()));
    temporalReference.addDateOfPublication(new InspireDateOfPublication(new DateTime()));
    temporalReference.addTemporalExtent(new TimeInstant(new DateTime()));
    temporalReference.addTemporalExtent(new TimePeriod(new DateTime(), new DateTime().plus(3456)));
    // -------------------
    InspireConformityCitation inspireConformityCitation = new InspireConformityCitation("Test", new InspireDateOfCreation(new DateTime()));
    InspireConformity conformity = new InspireConformity(inspireConformityCitation, InspireDegreeOfConformity.notEvaluated);
    // -------------------
    InspireMetadataPointOfContact inspireMetadataPointOfContact = new InspireMetadataPointOfContact("test", "test@test.te");
    // -------------------
    InspireOriginatingControlledVocabulary inspireOriginatingControlledVocabulary = new InspireOriginatingControlledVocabulary("Test", new InspireDateOfCreation(new DateTime()));
    InspireMandatoryKeyword inspireMandatoryKeyword = new InspireMandatoryKeyword(InspireMandatoryKeywordValue.humanServiceEditor, inspireOriginatingControlledVocabulary);
    // --------------------
    InspireSupportedLanguages inspireSupportedLanguages = new InspireSupportedLanguages(InspireLanguageISO6392B.ENG);
    // --------------------
    InspireLanguageISO6392B responseLanguage = InspireLanguageISO6392B.ENG;
    // --------------------
    InspireUniqueResourceIdentifier iuri = new InspireUniqueResourceIdentifier("test");
    iuri.setNamespace("http://test.org");
    // --------------------
    FullInspireExtendedCapabilities inspireExtendedCapabilities = new FullInspireExtendedCapabilities(resourceLocator, inspireSupportedLanguages, responseLanguage, iuri, new InspireSupportedCRS("4326"));
    inspireExtendedCapabilities.setResourceType(InspireServiceSpatialDataResourceType.service);
    inspireExtendedCapabilities.addKeyword(new InspireKeyword("test"));
    inspireExtendedCapabilities.addMandatoryKeyword(inspireMandatoryKeyword);
    // -------------------
    inspireExtendedCapabilities.setMetadataDate(new TimeInstant(new DateTime()));
    // -------------------
    inspireExtendedCapabilities.addMetadataPointOfContact(inspireMetadataPointOfContact);
    inspireExtendedCapabilities.addConformity(conformity);
    inspireExtendedCapabilities.addTemporalReference(temporalReference);
    return inspireExtendedCapabilities;
}
Also used : InspireOriginatingControlledVocabulary(org.n52.shetland.inspire.InspireOriginatingControlledVocabulary) InspireMetadataPointOfContact(org.n52.shetland.inspire.InspireMetadataPointOfContact) InspireUniqueResourceIdentifier(org.n52.shetland.inspire.InspireUniqueResourceIdentifier) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) InspireTemporalReference(org.n52.shetland.inspire.InspireTemporalReference) InspireLanguageISO6392B(org.n52.shetland.inspire.InspireLanguageISO6392B) InspireConformityCitation(org.n52.shetland.inspire.InspireConformityCitation) InspireKeyword(org.n52.shetland.inspire.InspireKeyword) InspireConformity(org.n52.shetland.inspire.InspireConformity) DateTime(org.joda.time.DateTime) InspireSupportedCRS(org.n52.shetland.inspire.InspireSupportedCRS) InspireDateOfLastRevision(org.n52.shetland.inspire.InspireDateOfLastRevision) InspireMandatoryKeyword(org.n52.shetland.inspire.InspireMandatoryKeyword) InspireResourceLocator(org.n52.shetland.inspire.InspireResourceLocator) InspireDateOfPublication(org.n52.shetland.inspire.InspireDateOfPublication) InspireDateOfCreation(org.n52.shetland.inspire.InspireDateOfCreation) InspireSupportedLanguages(org.n52.shetland.inspire.InspireSupportedLanguages) FullInspireExtendedCapabilities(org.n52.shetland.inspire.dls.FullInspireExtendedCapabilities) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 32 with TimePeriod

use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.

the class AbstractOmV20XmlStreamWriter method writeResultTime.

/**
 * Write om:resultTime to stream
 *
 * @throws XMLStreamException
 *             If an error occurs when writing to stream
 * @throws EncodingException
 *             If an error occurs when creating elements to be written
 */
protected void writeResultTime() throws XMLStreamException, EncodingException {
    OmObservation observation = getElement();
    TimeInstant resultTime = observation.getResultTime();
    Time phenomenonTime = observation.getPhenomenonTime();
    // get result time from SOS result time
    if (observation.getResultTime() != null) {
        if (resultTime.equals(phenomenonTime)) {
            empty(OmConstants.QN_OM_20_RESULT_TIME);
            addXlinkHrefAttr("#".concat(phenomenonTime.getGmlId()));
        } else {
            addResultTime(resultTime);
        }
    } else if (phenomenonTime instanceof TimeInstant) {
        // if result time is not set, get result time from phenomenon time
        empty(OmConstants.QN_OM_20_RESULT_TIME);
        addXlinkHrefAttr("#".concat(phenomenonTime.getGmlId()));
    } else if (phenomenonTime instanceof TimePeriod) {
        TimeInstant rsTime = new TimeInstant(((TimePeriod) observation.getPhenomenonTime()).getEnd());
        addResultTime(rsTime);
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 33 with TimePeriod

use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.

the class SosDecoderv20 method checkReferencedElements.

private void checkReferencedElements(final List<OmObservation> observations, final Map<String, Time> phenomenonTimes, final Map<String, TimeInstant> resultTimes, final Map<String, AbstractFeature> features) throws DecodingException {
    for (final OmObservation observation : observations) {
        // phenomenonTime
        final Time phenomenonTime = observation.getPhenomenonTime();
        if (phenomenonTime.isReferenced()) {
            observation.getValue().setPhenomenonTime(phenomenonTimes.get(phenomenonTime.getGmlId()));
        }
        // resultTime
        final TimeInstant resultTime = observation.getResultTime();
        if (resultTime.isReferenced()) {
            if (resultTimes.containsKey(resultTime.getGmlId())) {
                observation.setResultTime(resultTimes.get(resultTime.getGmlId()));
            } else if (phenomenonTimes.containsKey(resultTime.getGmlId())) {
                final Time iTime = phenomenonTimes.get(resultTime.getGmlId());
                if (iTime instanceof TimeInstant) {
                    observation.setResultTime((TimeInstant) iTime);
                } else if (iTime instanceof TimePeriod) {
                    final TimePeriod timePeriod = (TimePeriod) iTime;
                    observation.setResultTime(new TimeInstant(timePeriod.getEnd()));
                } else {
                    throw new DecodingException("observation.resultTime", "The time value type is not supported");
                }
            }
        }
        // featureOfInterest
        final AbstractFeature featureOfInterest = observation.getObservationConstellation().getFeatureOfInterest();
        if (featureOfInterest.isReferenced()) {
            observation.getObservationConstellation().setFeatureOfInterest(features.get(featureOfInterest.getGmlId()));
        }
    }
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) OmObservation(org.n52.shetland.ogc.om.OmObservation) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) Time(org.n52.shetland.ogc.gml.time.Time) DecodingException(org.n52.svalbard.decode.exception.DecodingException) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 34 with TimePeriod

use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(net.opengis.sosgda.x20.GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (net.opengis.sosgda.x20.DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType offering = decodeXmlElement(damt.getOffering());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            DataAvailability dataAvailability = new DataAvailability(procedure, observedProperty, featureOfInterest, offering, phenomenonTime);
            FormatDescriptor formatDescriptor = createFormatDescriptor(damt.getFormatDescriptor());
            if (formatDescriptor != null) {
                dataAvailability.setFormatDescriptor(formatDescriptor);
            }
            availabilities.add(dataAvailability);
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ProcedureDescriptionFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ProcedureDescriptionFormatDescriptor) ObservationFormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.ObservationFormatDescriptor) FormatDescriptor(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.FormatDescriptor) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType)

Example 35 with TimePeriod

use of org.n52.shetland.ogc.gml.time.TimePeriod in project arctic-sea by 52North.

the class GetDataAvailabilityResponseDecoder method parseDataAvalabilities.

private Collection<DataAvailability> parseDataAvalabilities(GetDataAvailabilityResponseType response) throws DecodingException {
    List<DataAvailability> availabilities = Lists.newArrayList();
    if (CollectionHelper.isNotNullOrEmpty(response.getDataAvailabilityMemberArray())) {
        Map<String, TimePeriod> periods = Maps.newHashMap();
        for (DataAvailabilityMemberType damt : response.getDataAvailabilityMemberArray()) {
            ReferenceType procedure = decodeXmlElement(damt.getProcedure());
            ReferenceType featureOfInterest = decodeXmlElement(damt.getFeatureOfInterest());
            ReferenceType observedProperty = decodeXmlElement(damt.getObservedProperty());
            TimePeriod phenomenonTime = getPhenomenonTime(damt.getPhenomenonTime().getAbstractTimeObject(), damt.getPhenomenonTime().getHref(), periods);
            availabilities.add(new DataAvailability(procedure, observedProperty, featureOfInterest, null, phenomenonTime));
        }
    }
    return availabilities;
}
Also used : TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) DataAvailability(org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability) ReferenceType(org.n52.shetland.ogc.gml.ReferenceType) DataAvailabilityMemberType(net.opengis.sosgda.x10.DataAvailabilityMemberType)

Aggregations

TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)33 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)16 DateTime (org.joda.time.DateTime)13 Time (org.n52.shetland.ogc.gml.time.Time)12 OmObservation (org.n52.shetland.ogc.om.OmObservation)10 EncodingException (org.n52.svalbard.encode.exception.EncodingException)8 XmlObject (org.apache.xmlbeans.XmlObject)7 Test (org.junit.Test)4 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)3 ReferenceType (org.n52.shetland.ogc.gml.ReferenceType)3 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 DataAvailability (org.n52.shetland.ogc.sos.gda.GetDataAvailabilityResponse.DataAvailability)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 SweField (org.n52.shetland.ogc.swe.SweField)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)2 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)2