Search in sources :

Example 26 with SensorML

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

the class SensorMLEncoderv101 method createClassification.

/**
 * Creates the classification section of the SensorML description.
 *
 * @param classifications
 *            SOS classifications
 *
 * @return XML Classification array
 */
private Classification[] createClassification(List<SmlClassifier> classifications) {
    Classification xbClassification = Classification.Factory.newInstance(getXmlOptions());
    ClassifierList xbClassifierList = xbClassification.addNewClassifierList();
    classifications.forEach(sosSMLClassifier -> {
        Classifier xbClassifier = xbClassifierList.addNewClassifier();
        if (sosSMLClassifier.getName() != null) {
            xbClassifier.setName(sosSMLClassifier.getName());
        }
        Term xbTerm = xbClassifier.addNewTerm();
        xbTerm.setValue(sosSMLClassifier.getValue());
        if (sosSMLClassifier.isSetDefinition()) {
            xbTerm.setDefinition(sosSMLClassifier.getDefinition());
        }
        if (sosSMLClassifier.isSetCodeSpace()) {
            xbTerm.addNewCodeSpace().setHref(sosSMLClassifier.getCodeSpace());
        }
    });
    return new Classification[] { xbClassification };
}
Also used : Classification(net.opengis.sensorML.x101.ClassificationDocument.Classification) ClassifierList(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList) SmlClassifier(org.n52.shetland.ogc.sensorML.elements.SmlClassifier) Classifier(net.opengis.sensorML.x101.ClassificationDocument.Classification.ClassifierList.Classifier) Term(net.opengis.sensorML.x101.TermDocument.Term)

Example 27 with SensorML

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

the class SensorMLEncoderv101 method createInputs.

/**
 * Creates the inputs section of the SensorML description.
 *
 * @param inputs
 *            SOS SWE representation.
 *
 * @return XML Inputs element
 *
 * @throws EncodingException
 *             if an error occurs
 */
private Inputs createInputs(List<SmlIo> inputs) throws EncodingException {
    Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
    InputList xbInputList = xbInputs.addNewInputList();
    int counter = 1;
    for (SmlIo sosSMLIo : inputs) {
        if (!sosSMLIo.isSetName()) {
            sosSMLIo.setIoName("input_" + counter++);
        }
        addIoComponentPropertyType(xbInputList.addNewInput(), sosSMLIo);
    }
    return xbInputs;
}
Also used : InputList(net.opengis.sensorML.x101.InputsDocument.Inputs.InputList) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Inputs(net.opengis.sensorML.x101.InputsDocument.Inputs)

Example 28 with SensorML

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

the class SensorMLEncoderv101 method createCharacteristics.

/**
 * Creates the characteristics section of the SensorML description.
 *
 * @param smlCharacteristics
 *            SOS characteristics list
 *
 * @return XML Characteristics array
 *
 * @throws EncodingException
 *             If an error occurs
 */
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
    final List<Characteristics> characteristicsList = Lists.newArrayListWithExpectedSize(smlCharacteristics.size());
    for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
        final Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
        if (sosSMLCharacteristics.isSetName()) {
            xbCharacteristics.setName(sosSMLCharacteristics.getName());
        }
        if (sosSMLCharacteristics.isSetAbstractDataRecord()) {
            if (sosSMLCharacteristics.getDataRecord() instanceof SweSimpleDataRecord) {
                final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCharacteristics.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
                if (sosSMLCharacteristics.isSetTypeDefinition()) {
                    xbSimpleDataRecord.setDefinition(sosSMLCharacteristics.getTypeDefinition());
                }
                if (sosSMLCharacteristics.getDataRecord().isSetFields()) {
                    for (final SweField field : sosSMLCharacteristics.getDataRecord().getFields()) {
                        final AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
                        xbField.setName(field.getName().getValue());
                        addSweSimpleTypeToField(xbField, field.getElement());
                    }
                }
            } else if (sosSMLCharacteristics.getDataRecord() instanceof SweDataRecord) {
                throw unsupportedCharacteristicsType(SweAggregateType.DataRecord);
            } else {
                throw unsupportedCharacteristicsType(sosSMLCharacteristics.getDataRecord().getClass().getName());
            }
        } else if (sosSMLCharacteristics.isSetHref()) {
            if (sosSMLCharacteristics.isSetName()) {
                xbCharacteristics.setName(sosSMLCharacteristics.getName());
            }
            xbCharacteristics.setHref(sosSMLCharacteristics.getHref());
            if (sosSMLCharacteristics.isSetTitle()) {
                xbCharacteristics.setTitle(sosSMLCharacteristics.getTitle());
            }
        }
        characteristicsList.add(xbCharacteristics);
    }
    return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
Also used : SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) Characteristics(net.opengis.sensorML.x101.CharacteristicsDocument.Characteristics) SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Example 29 with SensorML

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

the class SensorMLEncoderv20 method createInputs.

// /**
// * Creates the location section of the SensorML description.
// *
// * @param dot
// *            the described object
// * @param location
// *            SOS location representation.
// *
// * @throws EncodingException
// *             if an error occurs
// */
// private void createLocation(DescribedObjectType dot, SmlLocation location) throws EncodingException {
// dot.addNewLocation().addNewAbstractGeometry().set(encodeObjectToXmlGml32(location.getPoint()));
// }
/**
 * Creates the inputs section of the SensorML description.
 *
 * @param inputs
 *            SOS SWE representation.
 *
 * @return XML Inputs element
 *
 * @throws EncodingException
 *             if an error occurs
 */
private Inputs createInputs(final List<SmlIo> inputs) throws EncodingException {
    final Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
    final InputListType xbInputList = xbInputs.addNewInputList();
    int counter = 1;
    for (final SmlIo sosSMLIo : inputs) {
        if (!sosSMLIo.isSetName()) {
            sosSMLIo.setIoName("input_" + counter++);
        } else {
            sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
        }
        addInput(xbInputList.addNewInput(), sosSMLIo);
    }
    return xbInputs;
}
Also used : InputListType(net.opengis.sensorml.x20.InputListType) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo) Inputs(net.opengis.sensorml.x20.AbstractProcessType.Inputs)

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