Search in sources :

Example 1 with CharacteristicListPropertyType

use of net.opengis.sensorml.x20.CharacteristicListPropertyType in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseCharacteristics.

/**
 * Parses the characteristics
 *
 * @param clpts
 *            XML characteristics
 * @return SOS characteristics
 *
 * @throws DecodingException
 *             * if an error occurs
 */
private List<SmlCharacteristics> parseCharacteristics(final CharacteristicListPropertyType[] clpts) throws DecodingException {
    final List<SmlCharacteristics> sosCharacteristicsList = new ArrayList<>(clpts.length);
    for (final CharacteristicListPropertyType clpt : clpts) {
        final SmlCharacteristics sosCharacteristics = new SmlCharacteristics();
        if (clpt.isSetCharacteristicList()) {
            CharacteristicListType clt = clpt.getCharacteristicList();
            if (CollectionHelper.isNotNullOrEmpty(clt.getCharacteristicArray())) {
                for (Characteristic c : clt.getCharacteristicArray()) {
                    final SmlCharacteristic characteristic = new SmlCharacteristic(c.getName());
                    if (c.isSetAbstractDataComponent()) {
                        final Object o = decodeXmlElement(c.getAbstractDataComponent());
                        if (o instanceof SweAbstractDataComponent) {
                            characteristic.setAbstractDataComponent((SweAbstractDataComponent) o);
                        } else {
                            throw new DecodingException(XmlHelper.getLocalName(clpt), "Error while parsing the characteristics of the SensorML " + "(the characteristics' data record is not of " + "type DataRecordPropertyType)!");
                        }
                    } else if (c.isSetHref()) {
                        characteristic.setHref(c.getHref());
                        if (c.isSetTitle()) {
                            characteristic.setTitle(c.getTitle());
                        }
                    }
                    sosCharacteristics.addCharacteristic(characteristic);
                }
            }
        }
        sosCharacteristicsList.add(sosCharacteristics);
    }
    return sosCharacteristicsList;
}
Also used : SmlCharacteristics(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics) CharacteristicListPropertyType(net.opengis.sensorml.x20.CharacteristicListPropertyType) SmlCharacteristic(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic) SmlCharacteristic(org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic) Characteristic(net.opengis.sensorml.x20.CharacteristicListType.Characteristic) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ArrayList(java.util.ArrayList) CharacteristicListType(net.opengis.sensorml.x20.CharacteristicListType) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Aggregations

ArrayList (java.util.ArrayList)1 CharacteristicListPropertyType (net.opengis.sensorml.x20.CharacteristicListPropertyType)1 CharacteristicListType (net.opengis.sensorml.x20.CharacteristicListType)1 Characteristic (net.opengis.sensorml.x20.CharacteristicListType.Characteristic)1 XmlObject (org.apache.xmlbeans.XmlObject)1 SmlCharacteristic (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristic)1 SmlCharacteristics (org.n52.shetland.ogc.sensorML.elements.SmlCharacteristics)1 DescribedObject (org.n52.shetland.ogc.sensorML.v20.DescribedObject)1 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1