Search in sources :

Example 36 with TimeInstant

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

the class GmlDecoderv311 method parseTimeInstant.

private Object parseTimeInstant(TimeInstantType xbTimeIntant) throws DecodingException {
    TimeInstant ti = parseTimePosition(xbTimeIntant.getTimePosition());
    ti.setGmlId(xbTimeIntant.getId());
    return ti;
}
Also used : TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 37 with TimeInstant

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

the class GmlDecoderv321 method parseTimePosition.

private TimeInstant parseTimePosition(TimePositionType xbTimePosition) throws DecodingException {
    TimeInstant ti = new TimeInstant();
    String timeString = xbTimePosition.getStringValue();
    if (timeString != null && !timeString.isEmpty()) {
        try {
            // TODO better differentiate between ISO8601 and indeterminate
            // value
            ti.setValue(DateTimeHelper.parseIsoString2DateTime(timeString));
            ti.setRequestedTimeLength(DateTimeHelper.getTimeLengthBeforeTimeZone(timeString));
        } catch (DateTimeParseException ex) {
            ti.setIndeterminateValue(new IndeterminateValue(timeString));
        }
    }
    if (xbTimePosition.isSetIndeterminatePosition()) {
        ti.setIndeterminateValue(new IndeterminateValue(xbTimePosition.getIndeterminatePosition().toString()));
    }
    return ti;
}
Also used : DateTimeParseException(org.n52.shetland.util.DateTimeParseException) IndeterminateValue(org.n52.shetland.ogc.gml.time.IndeterminateValue) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 38 with TimeInstant

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

the class GmlDecoderv321 method parseTimeInstant.

/**
 * parses TimeInstant
 *
 * @param xbTimeIntant XmlBean representation of TimeInstant
 *
 * @return Returns a TimeInstant created from the TimeInstantType
 *
 * @throws DecodingException if the time string is invalid
 */
private Object parseTimeInstant(TimeInstantType xbTimeIntant) throws DecodingException {
    TimeInstant ti = parseTimePosition(xbTimeIntant.getTimePosition());
    ti.setGmlId(xbTimeIntant.getId());
    return ti;
}
Also used : TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant)

Example 39 with TimeInstant

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

the class TrajectoryObservationTypeEncoderTest method createObservation.

private OmObservation createObservation() throws DecodingException, XmlException, IOException {
    DateTime now = new DateTime(DateTimeZone.UTC);
    TimeInstant resultTime = new TimeInstant(now);
    TrajectoryObservation observation = new TrajectoryObservation();
    observation.setObservationID("123");
    OmObservationConstellation observationConstellation = new OmObservationConstellation();
    observationConstellation.setFeatureOfInterest(new SamplingFeature(new CodeWithAuthority("feature", CODE_SPACE)));
    OmObservableProperty observableProperty = new OmObservableProperty(OBSERVABLE_PROPERTY);
    observationConstellation.setObservableProperty(observableProperty);
    observationConstellation.addOffering(OFFERING);
    Process procedure = createProcessFromFile();
    observationConstellation.setProcedure(procedure);
    observation.setObservationConstellation(observationConstellation);
    observation.setResultTime(resultTime);
    return observation;
}
Also used : TrajectoryObservation(org.n52.shetland.inspire.omso.TrajectoryObservation) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) Process(org.n52.shetland.inspire.ompr.Process) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) DateTime(org.joda.time.DateTime) TimeInstant(org.n52.shetland.ogc.gml.time.TimeInstant) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty)

Example 40 with TimeInstant

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

the class SensorMLEncoderv20 method addDescribedObjectValues.

private void addDescribedObjectValues(DescribedObjectType dot, DescribedObject describedObject) throws EncodingException {
    if (!describedObject.isSetGmlID()) {
        describedObject.setGmlId("do_" + JavaHelper.generateID(describedObject.toString()));
    }
    if (dot.getId() == null || dot.getId().isEmpty()) {
        dot.setId(describedObject.getGmlId());
    }
    // update/set gml:identifier
    if (describedObject.isSetIdentifier()) {
        describedObject.getIdentifierCodeWithAuthority().setCodeSpace(OGCConstants.UNIQUE_ID);
        XmlObject encodeObjectToXml = encodeObjectToXmlGml32(describedObject.getIdentifierCodeWithAuthority());
        if (encodeObjectToXml != null) {
            if (dot.isSetIdentifier()) {
                dot.getIdentifier().set(encodeObjectToXml);
            } else {
                dot.addNewIdentifier().set(encodeObjectToXml);
            }
        }
    }
    // set capabilities
    if (describedObject.isSetCapabilities()) {
        final Capabilities[] existing = dot.getCapabilitiesArray();
        final Set<String> names = Sets.newHashSetWithExpectedSize(existing.length);
        for (final Capabilities element : existing) {
            if (element.getName() != null) {
                names.add(element.getName());
            }
        }
        for (final SmlCapabilities sosCapability : describedObject.getCapabilities()) {
            // Update Discovery Profile
            if (!SensorMLConstants.ELEMENT_NAME_OBSERVED_BBOX.equals(sosCapability.getName())) {
                final Capabilities c = createCapability(sosCapability);
                // replace existing capability with the same name
                if (c != null) {
                    if (names.contains(c.getName())) {
                        removeCapability(dot, c);
                    }
                    dot.addNewCapabilities().set(c);
                }
            }
        }
    }
    // set description
    if (describedObject.isSetDescription() && !dot.isSetDescription()) {
        dot.addNewDescription().setStringValue(describedObject.getDescription());
    }
    // set names
    if (describedObject.isSetName() && CollectionHelper.isNullOrEmpty(dot.getNameArray())) {
        // TODO check if override existing names
        addNamesToAbstractProcess(dot, describedObject.getNames());
    }
    // set keywords
    if (describedObject.isSetKeywords()) {
        if (CollectionHelper.isNullOrEmpty(dot.getKeywordsArray())) {
            final List<String> keywords = describedObject.getKeywords();
            // final int length = dot.getKeywordsArray().length;
            // for (int i = 0; i < length; ++i) {
            // dot.removeKeywords(i);
            // }
            dot.addNewKeywords().addNewKeywordList().setKeywordArray(keywords.toArray(new String[keywords.size()]));
        // TODO else
        }
    }
    // set identification
    if (describedObject.isSetIdentifications()) {
        // TODO check for merging identifications if exists
        dot.setIdentificationArray(createIdentification(describedObject.getIdentifications()));
    }
    // set classification
    if (describedObject.isSetClassifications()) {
        dot.setClassificationArray(createClassification(describedObject.getClassifications()));
    }
    // set validTime
    if (describedObject.isSetValidTime() && CollectionHelper.isNullOrEmpty(dot.getValidTimeArray())) {
        for (Time time : describedObject.getValidTime()) {
            final XmlObject xbtime = encodeObjectToXmlGml32(time);
            if (time instanceof TimeInstant) {
                dot.addNewValidTime().addNewTimeInstant().set(xbtime);
            } else if (time instanceof TimePeriod) {
                dot.addNewValidTime().addNewTimePeriod().set(xbtime);
            }
        }
    // } else {
    // TODO remove or
    // remove existing validTime element
    // final XmlCursor newCursor = dot.getValidTime().newCursor();
    // newCursor.removeXml();
    // newCursor.dispose();
    }
    // set characteristics
    if (describedObject.isSetCharacteristics()) {
        dot.setCharacteristicsArray(createCharacteristics(describedObject.getCharacteristics()));
    }
    // CollectionHelper.isNotNullOrEmpty(dot.getContactsArray())) {
    if (describedObject.isSetContact()) {
        if (CollectionHelper.isNullOrEmpty(dot.getContactsArray())) {
            ContactListType cl = ContactListType.Factory.newInstance();
            for (SmlContact contact : describedObject.getContact()) {
                if (contact instanceof SmlResponsibleParty) {
                    if (contact.isSetHref()) {
                        XmlObject xml = encodeObjectToXml(GmdConstants.NS_GMD, (SmlResponsibleParty) contact, EncodingContext.of(XmlBeansEncodingFlags.PROPERTY_TYPE));
                        cl.addNewContact().set(xml);
                    } else {
                        XmlObject encodeObjectToXml = encodeObjectToXml(GmdConstants.NS_GMD, contact);
                        if (encodeObjectToXml != null) {
                            cl.addNewContact().addNewCIResponsibleParty().set(encodeObjectToXml);
                        }
                    }
                }
            }
            if (CollectionHelper.isNotNullOrEmpty(cl.getContactArray())) {
                dot.addNewContacts().setContactList(cl);
            }
        }
    }
    // set documentation
    if (describedObject.isSetDocumentation()) {
        if (CollectionHelper.isNullOrEmpty(dot.getDocumentationArray())) {
            dot.setDocumentationArray(createDocumentationArray(describedObject.getDocumentation()));
        }
    }
// set history
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) Time(org.n52.shetland.ogc.gml.time.Time) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorml.x20.DescribedObjectType.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) ContactListType(net.opengis.sensorml.x20.ContactListType) 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