Search in sources :

Example 1 with SensorML

use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseLocation.

/**
 * Parses the location
 *
 * @param location XML location
 *
 * @return SOS location
 *
 * @throws DecodingException if an error occurs
 */
private org.n52.shetland.ogc.sensorML.elements.SmlLocation parseLocation(final SmlLocation2 location) throws DecodingException {
    if (!location.isSetPoint()) {
        throw new DecodingException(XmlHelper.getLocalName(location), "Error while parsing the sml:location of the SensorML " + "(point is not set, only point is supported)!");
    }
    org.n52.shetland.ogc.sensorML.elements.SmlLocation sosSmlLocation = null;
    final Object point = decodeXmlElement(location.getPoint());
    if (point instanceof Point) {
        sosSmlLocation = new org.n52.shetland.ogc.sensorML.elements.SmlLocation((Point) point);
    }
    return sosSmlLocation;
}
Also used : DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) Point(org.locationtech.jts.geom.Point)

Example 2 with SensorML

use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseCapabilities.

/**
 * Parses the capabilities, processing and removing special insertion metadata
 *
 * @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
 * @param capabilitiesArray XML capabilities
 *
 * @throws DecodingException if an error occurs
 */
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
    for (final Capabilities xbcaps : capabilitiesArray) {
        final SmlCapabilities caps = new SmlCapabilities();
        if (xbcaps.isSetName()) {
            caps.setName(xbcaps.getName());
        }
        if (xbcaps.isSetAbstractDataRecord()) {
            final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
            if (o instanceof DataRecord) {
                final DataRecord record = (DataRecord) o;
                caps.setDataRecord(record).setName(xbcaps.getName());
            } else {
                throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
            }
        } else if (xbcaps.isSetHref()) {
            caps.setHref(xbcaps.getHref());
            if (xbcaps.isSetTitle()) {
                caps.setTitle(xbcaps.getTitle());
            }
        }
        if (caps.isSetName()) {
            abstractProcess.addCapabilities(caps);
        }
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataRecord(org.n52.shetland.ogc.swe.DataRecord)

Example 3 with SensorML

use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createIdentification.

/**
 * Creates the valueentification section of the SensorML description.
 *
 * @param identifications
 *            SOS valueentifications
 *
 * @return XML Identification array
 */
protected Identification[] createIdentification(List<SmlIdentifier> identifications) {
    Identification xbIdentification = Identification.Factory.newInstance(getXmlOptions());
    IdentifierList xbIdentifierList = xbIdentification.addNewIdentifierList();
    identifications.forEach(sosSMLIdentifier -> {
        Identifier xbIdentifier = xbIdentifierList.addNewIdentifier();
        if (sosSMLIdentifier.getName() != null) {
            xbIdentifier.setName(sosSMLIdentifier.getName());
        }
        Term xbTerm = xbIdentifier.addNewTerm();
        xbTerm.setDefinition(sosSMLIdentifier.getDefinition());
        xbTerm.setValue(sosSMLIdentifier.getValue());
    });
    return new Identification[] { xbIdentification };
}
Also used : Identifier(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier) SmlIdentifier(org.n52.shetland.ogc.sensorML.elements.SmlIdentifier) Identification(net.opengis.sensorML.x101.IdentificationDocument.Identification) Term(net.opengis.sensorML.x101.TermDocument.Term) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)

Example 4 with SensorML

use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createSensorMLDescription.

protected SensorMLDocument createSensorMLDescription(final SensorML smlSensorDesc) throws EncodingException {
    final SensorMLDocument sensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
    final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = sensorMLDoc.addNewSensorML();
    xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
    if (smlSensorDesc.isSetMembers()) {
        for (final AbstractProcess sml : smlSensorDesc.getMembers()) {
            if (sml instanceof System) {
                final SystemType xbSystem = (SystemType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_SYSTEM), SystemType.type);
                final System smlSystem = (System) sml;
                addAbstractProcessValues(xbSystem, smlSystem);
                addSystemValues(xbSystem, smlSystem);
            } else if (sml instanceof ProcessModel) {
                final ProcessModelType xbProcessModel = (ProcessModelType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_PROCESS_MODEL), ProcessModelType.type);
                final ProcessModel smlProcessModel = (ProcessModel) sml;
                addAbstractProcessValues(xbProcessModel, smlProcessModel);
                addProcessModelValues(xbProcessModel, smlProcessModel);
            } else if (sml instanceof org.n52.shetland.ogc.sensorML.Component) {
                final ComponentType xbCompontent = (ComponentType) xbSensorML.addNewMember().addNewProcess().substitute(new QName(SensorMLConstants.NS_SML, SensorMLConstants.EN_COMPONENT), ComponentType.type);
                final org.n52.shetland.ogc.sensorML.Component smlComponent = (org.n52.shetland.ogc.sensorML.Component) sml;
                addAbstractProcessValues(xbCompontent, smlComponent);
                addComponentValues(xbCompontent, smlComponent);
            }
        }
    }
    return sensorMLDoc;
}
Also used : ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) QName(javax.xml.namespace.QName) SystemType(net.opengis.sensorML.x101.SystemType) System(org.n52.shetland.ogc.sensorML.System) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType)

Example 5 with SensorML

use of org.n52.shetland.ogc.sensorML.SensorML in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createOutputs.

/**
 * Creates the outputs section of the SensorML description.
 *
 * @param sosOutputs
 *            SOS SWE representation.
 *
 * @return XML Outputs element
 *
 * @throws EncodingException
 *             if the encoding fails
 */
private Outputs createOutputs(final List<SmlIo> sosOutputs) throws EncodingException {
    Outputs outputs = Outputs.Factory.newInstance(getXmlOptions());
    OutputList outputList = outputs.addNewOutputList();
    Set<String> definitions = Sets.newHashSet();
    int counter = 1;
    Set<String> outputNames = Sets.newHashSet();
    for (SmlIo sosSMLIo : sosOutputs) {
        if (sosSMLIo.isSetValue() && !definitions.contains(sosSMLIo.getIoValue().getDefinition())) {
            if (!sosSMLIo.isSetName() || outputNames.contains(sosSMLIo.getIoName())) {
                sosSMLIo.setIoName(getValidOutputName(counter++, outputNames));
            }
            outputNames.add(sosSMLIo.getIoName());
            addIoComponentPropertyType(outputList.addNewOutput(), sosSMLIo);
            definitions.add(sosSMLIo.getIoValue().getDefinition());
        }
    }
    return outputs;
}
Also used : Outputs(net.opengis.sensorML.x101.OutputsDocument.Outputs) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) OutputList(net.opengis.sensorML.x101.OutputsDocument.Outputs.OutputList)

Aggregations

SensorML (org.n52.shetland.ogc.sensorML.SensorML)13 XmlObject (org.apache.xmlbeans.XmlObject)12 SystemType (net.opengis.sensorML.x101.SystemType)10 Test (org.junit.Test)9 System (org.n52.shetland.ogc.sensorML.System)9 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)7 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)5 DecodingException (org.n52.svalbard.decode.exception.DecodingException)5 SmlIo (org.n52.shetland.ogc.sensorML.elements.SmlIo)4 ResponsibleParty (net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty)3 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)3 ArrayList (java.util.ArrayList)2 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)2 ComponentType (net.opengis.sensorML.x101.ComponentType)2 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)2 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)2 Member (net.opengis.sensorML.x101.ContactListDocument.ContactList.Member)2 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)2 Identifier (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList.Identifier)2 Person (net.opengis.sensorML.x101.PersonDocument.Person)2