Search in sources :

Example 1 with CodeType

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

the class SosOffering method from.

/**
 * Creates a set of {@literal SosOffering}s from SWE simple type.
 *
 * @param type
 *            the type (may be {@literal null})
 *
 * @return the set (never {@literal null})
 */
public static SosOffering from(SweAbstractSimpleType<?> type) {
    if (type == null) {
        return null;
    }
    String identifer = type.getValue().toString();
    CodeType name = type.getName();
    SosOffering offering = new SosOffering(identifer, name);
    if (type.isSetDescription()) {
        offering.setDescription(type.getDescription());
    }
    return offering;
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType)

Example 2 with CodeType

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

the class UVFEncoder method writeMessStellenname.

private void writeMessStellenname(Writer fw, OmObservation o, String lineEnding) throws IOException {
    if (o.getObservationConstellation().getFeatureOfInterest().isSetName()) {
        final CodeType firstName = o.getObservationConstellation().getFeatureOfInterest().getFirstName();
        String name = ensureIdentifierLength(firstName.isSetValue() ? firstName.getValue() : "", UVFConstants.MAX_IDENTIFIER_LENGTH);
        writeToFile(fw, String.format("$sb Mess-Stellenname: %s", name), lineEnding);
    }
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType)

Example 3 with CodeType

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

the class SensorMLDecoderV101 method parseAbstractProcess.

private void parseAbstractProcess(final AbstractProcessType xbAbstractProcess, final AbstractProcess abstractProcess) throws DecodingException {
    if (xbAbstractProcess.getId() != null) {
        abstractProcess.setGmlId(xbAbstractProcess.getId());
    }
    if (xbAbstractProcess.getIdentificationArray() != null) {
        parseIdentifications(abstractProcess, xbAbstractProcess.getIdentificationArray());
    }
    if (xbAbstractProcess.getClassificationArray() != null) {
        abstractProcess.setClassifications(parseClassification(xbAbstractProcess.getClassificationArray()));
    }
    if (xbAbstractProcess.getCharacteristicsArray() != null) {
        abstractProcess.setCharacteristics(parseCharacteristics(xbAbstractProcess.getCharacteristicsArray()));
    }
    if (xbAbstractProcess.getCapabilitiesArray() != null) {
        parseCapabilities(abstractProcess, xbAbstractProcess.getCapabilitiesArray());
        checkCapabilitiesForRemoval(xbAbstractProcess.getCapabilitiesArray()).forEach(xbAbstractProcess::removeCapabilities);
    }
    if (xbAbstractProcess.isSetDescription()) {
        abstractProcess.addDescription(xbAbstractProcess.getDescription().getStringValue());
    }
    if (xbAbstractProcess.isSetValidTime()) {
        abstractProcess.setValidTime(parseValidTime(xbAbstractProcess.getValidTime()));
    }
    if (xbAbstractProcess.getContactArray() != null) {
        abstractProcess.setContact(parseContact(xbAbstractProcess.getContactArray()));
    }
    if (xbAbstractProcess.getDocumentationArray() != null) {
        abstractProcess.setDocumentation(parseDocumentation(xbAbstractProcess.getDocumentationArray()));
    }
    if (xbAbstractProcess.getHistoryArray() != null) {
        abstractProcess.setHistory(parseHistory(xbAbstractProcess.getHistoryArray()));
    }
    if (xbAbstractProcess.getKeywordsArray() != null) {
        abstractProcess.setKeywords(parseKeywords(xbAbstractProcess.getKeywordsArray()));
    }
    if (xbAbstractProcess.getNameArray() != null) {
        final int length = xbAbstractProcess.getNameArray().length;
        for (int i = 0; i < length; i++) {
            final Object decodedElement = decodeXmlElement(xbAbstractProcess.getNameArray(i));
            if (decodedElement instanceof CodeType) {
                abstractProcess.addName((CodeType) decodedElement);
            }
        }
    }
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType) XmlObject(org.apache.xmlbeans.XmlObject) Point(org.locationtech.jts.geom.Point)

Example 4 with CodeType

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

the class SamplingEncoderv100 method addValuesToFeature.

private void addValuesToFeature(SamplingFeatureType xbSamplingFeature, AbstractSamplingFeature sampFeat) throws EncodingException {
    xbSamplingFeature.setId(sampFeat.getGmlId());
    if (sampFeat.isSetIdentifier()) {
        sampFeat.getIdentifierCodeWithAuthority().setCodeSpace("uniquID");
        xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sampFeat.getIdentifierCodeWithAuthority()));
    }
    if (sampFeat.isSetName()) {
        for (CodeType sosName : sampFeat.getName()) {
            xbSamplingFeature.addNewName().set(encodeObjectToXml(GmlConstants.NS_GML, sosName));
        }
    }
    // TODO: CHECK
    if (sampFeat.getSampledFeatures() != null && !sampFeat.getSampledFeatures().isEmpty()) {
        for (AbstractFeature sampledFeature : sampFeat.getSampledFeatures()) {
            FeaturePropertyType sp = xbSamplingFeature.addNewSampledFeature();
            sp.setHref(sampledFeature.getIdentifier());
            if (sampFeat.isSetName() && sampFeat.getFirstName().isSetValue()) {
                sp.setTitle(sampFeat.getFirstName().getValue());
            }
        // xbSamplingFeature.addNewSampledFeature().set(createFeature(sampledFeature));
        }
    } else {
        xbSamplingFeature.addNewSampledFeature().setHref(GmlConstants.NIL_UNKNOWN);
    }
    // set metadataProperty
    setMetaDataProperty(xbSamplingFeature, sampFeat);
}
Also used : CodeType(org.n52.shetland.ogc.gml.CodeType) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) SamplingFeaturePropertyType(net.opengis.sampling.x10.SamplingFeaturePropertyType) FeaturePropertyType(net.opengis.gml.FeaturePropertyType)

Example 5 with CodeType

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

the class InsertResultTemplateRequestEncoderTest method setup.

@Before
public void setup() throws InvalidSridException, ParseException {
    SensorML procedure = new SensorML();
    procedure.setIdentifier(procedureIdentifier);
    SamplingFeature featureOfInterest = new SamplingFeature(new CodeWithAuthority(featureIdentifier));
    featureOfInterest.setIdentifier(featureIdentifier);
    featureOfInterest.setName(new CodeType(featureName));
    featureOfInterest.setFeatureType(SfConstants.SAMPLING_FEAT_TYPE_SF_SAMPLING_POINT);
    featureOfInterest.setGeometry(JTSHelper.createGeometryFromWKT("POINT(30 10)", 4326));
    observationTemplate = new OmObservationConstellation();
    observationTemplate.addOffering(offering);
    observationTemplate.setObservationType(OmConstants.OBS_TYPE_MEASUREMENT);
    observationTemplate.setProcedure(procedure);
    observationTemplate.setObservableProperty(new OmObservableProperty(observedProperty));
    observationTemplate.setFeatureOfInterest(featureOfInterest);
    SweTextEncoding textEncoding = new SweTextEncoding();
    textEncoding.setBlockSeparator(blockSeparator);
    textEncoding.setTokenSeparator(tokenSeparator);
    SweDataRecord resultStructure = new SweDataRecord();
    SweTime sweTime = new SweTime();
    sweTime.setDefinition(field1Definition);
    sweTime.setUom(field1Uom);
    resultStructure.addField(new SweField(field1Name, sweTime));
    request = new InsertResultTemplateRequest(SosConstants.SOS, Sos2Constants.SERVICEVERSION, Sos2Constants.Operations.InsertResultTemplate.name());
    request.setResultEncoding(new SosResultEncoding(textEncoding));
    request.setResultStructure(new SosResultStructure(resultStructure));
    request.setIdentifier(templateIdentifier);
    request.setObservationTemplate(observationTemplate);
    Supplier<XmlOptions> xmlOptions = () -> new XmlOptions();
    encoder = new InsertResultTemplateRequestEncoder();
    encoder.setXmlOptions(xmlOptions);
    OmEncoderv20 omEncoder = new OmEncoderv20();
    omEncoder.setXmlOptions(xmlOptions);
    SamplingEncoderv20 samsEncoder = new SamplingEncoderv20();
    samsEncoder.setXmlOptions(xmlOptions);
    GmlEncoderv321 gml32Encoder = new GmlEncoderv321();
    gml32Encoder.setXmlOptions(xmlOptions);
    SweCommonEncoderv20 sweEncoderv20 = new SweCommonEncoderv20();
    sweEncoderv20.setXmlOptions(xmlOptions);
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, omEncoder, samsEncoder, gml32Encoder, sweEncoderv20));
    encoderRepository.init();
    encoderRepository.getEncoders().stream().forEach(e -> ((AbstractDelegatingEncoder<?, ?>) e).setEncoderRepository(encoderRepository));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) XmlOptions(org.apache.xmlbeans.XmlOptions) SamplingFeature(org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SosResultEncoding(org.n52.shetland.ogc.sos.SosResultEncoding) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) CodeType(org.n52.shetland.ogc.gml.CodeType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OmObservableProperty(org.n52.shetland.ogc.om.OmObservableProperty) SosResultStructure(org.n52.shetland.ogc.sos.SosResultStructure) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest) Before(org.junit.Before)

Aggregations

CodeType (org.n52.shetland.ogc.gml.CodeType)23 XmlObject (org.apache.xmlbeans.XmlObject)9 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)7 SamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.SamplingFeature)7 Test (org.junit.Test)5 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)5 XmlException (org.apache.xmlbeans.XmlException)4 OmObservationConstellation (org.n52.shetland.ogc.om.OmObservationConstellation)4 URI (java.net.URI)3 ArrayList (java.util.ArrayList)3 GeographicalName (org.n52.shetland.inspire.GeographicalName)3 Spelling (org.n52.shetland.inspire.Spelling)3 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 AbstractSamplingFeature (org.n52.shetland.ogc.om.features.samplingFeatures.AbstractSamplingFeature)3 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2