Search in sources :

Example 66 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseSweDataArrayType.

private SweDataArray parseSweDataArrayType(DataArrayType xbDataArray) throws DecodingException {
    if (!xbDataArray.getElementType().isSetAbstractDataRecord()) {
        throw new DecodingException("The swe:DataArray contains a not yet supported elementType element. " + "Currently only 'swe:DataRecord' is supported as elementType element.");
    }
    final SweDataArray dataArray = new SweDataArray();
    if (xbDataArray.getElementCount() != null) {
        dataArray.setElementCount(parseElementCount(xbDataArray.getElementCount()));
    }
    // parse data record to elementType
    DataComponentPropertyType elementType = xbDataArray.getElementType();
    if (elementType != null) {
        dataArray.setElementType(parseDataComponentProperty(elementType));
    }
    if (xbDataArray.isSetEncoding()) {
        dataArray.setEncoding(parseEncoding(xbDataArray.getEncoding()));
    }
    // parse values
    // if (xbDataArray.isSetValues()) {
    // // TODO implement full support
    // // dataArray.setValues(parseValues(dataArray.getElementCount(),
    // // dataArray.getElementType(),
    // // dataArray.getEncoding(), xbDataArray.getValues()));
    // }
    DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    xbDataArrayDoc.setDataArray1(xbDataArray);
    dataArray.setXml(xbDataArrayDoc.xmlText());
    return dataArray;
}
Also used : NotYetSupportedDecodingException(org.n52.svalbard.decode.exception.NotYetSupportedDecodingException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 67 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseDataStream.

private SweDataStream parseDataStream(DataStreamType dataStream) throws DecodingException {
    SweDataStream sweDataStream = new SweDataStream();
    if (dataStream.isSetElementCount() && dataStream.getElementCount().getCount() != null) {
        sweDataStream.setElementCount(parseCount(dataStream.getElementCount().getCount()));
    }
    // parse data record to elementType
    ElementType xbElementType = dataStream.getElementType();
    if (xbElementType != null && xbElementType.getAbstractDataComponent() != null) {
        sweDataStream.setElementType(parseAbstractDataComponent(xbElementType.getAbstractDataComponent()));
    }
    if (dataStream.getEncoding() != null && dataStream.getEncoding().getAbstractEncoding() != null) {
        sweDataStream.setEncoding(parseEncoding(dataStream.getEncoding().getAbstractEncoding()));
    }
    // parse values
    if (dataStream.getValues() != null) {
        sweDataStream.setValues(parseValues(sweDataStream.getElementCount(), sweDataStream.getElementType(), sweDataStream.getEncoding(), dataStream.getValues()));
    }
    // set XML
    DataStreamDocument dataStreamDoc = DataStreamDocument.Factory.newInstance(getXmlOptions());
    dataStreamDoc.setDataStream(dataStream);
    sweDataStream.setXml(dataStreamDoc.xmlText(getXmlOptions()));
    return sweDataStream;
}
Also used : DataStreamDocument(net.opengis.swe.x20.DataStreamDocument) ElementType(net.opengis.swe.x20.DataStreamType.ElementType) SweDataStream(org.n52.shetland.ogc.swe.SweDataStream)

Example 68 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseDataArray.

private SweDataArray parseDataArray(DataArrayType xbDataArray) throws DecodingException {
    SweDataArray sosSweDataArray = new SweDataArray();
    CountPropertyType elementCount = xbDataArray.getElementCount();
    if (elementCount != null) {
        sosSweDataArray.setElementCount(parseElementCount(elementCount));
    }
    // parse data record to elementType
    DataArrayType.ElementType xbElementType = xbDataArray.getElementType();
    if (xbElementType != null && xbElementType.getAbstractDataComponent() != null) {
        sosSweDataArray.setElementType(parseAbstractDataComponent(xbElementType.getAbstractDataComponent()));
    }
    if (xbDataArray.isSetEncoding()) {
        sosSweDataArray.setEncoding(parseEncoding(xbDataArray.getEncoding().getAbstractEncoding()));
    }
    // parse values
    if (xbDataArray.isSetValues()) {
        sosSweDataArray.setValues(parseValues(sosSweDataArray.getElementCount(), sosSweDataArray.getElementType(), sosSweDataArray.getEncoding(), xbDataArray.getValues()));
    }
    // set XML
    DataArrayDocument dataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    dataArrayDoc.setDataArray1(xbDataArray);
    sosSweDataArray.setXml(dataArrayDoc.xmlText(getXmlOptions()));
    return sosSweDataArray;
}
Also used : CountPropertyType(net.opengis.swe.x20.CountPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument)

Example 69 with Data

use of org.n52.io.response.dataset.Data in project arctic-sea by 52North.

the class ODataFesParserTest method testSamplingGeometryGeoIntersectsPolygon.

@Test
public void testSamplingGeometryGeoIntersectsPolygon() throws Exception {
    Filter<?> filter = parser.decode(String.format("geo.intersects(samplingGeometry,'SRID=%s;%s')", polygon.getSRID(), wktGeometry));
    assertThat(filter, is(instanceOf(SpatialFilter.class)));
    SpatialFilter sf = (SpatialFilter) filter;
    errors.checkThat(sf.getSrid(), is(4326));
    errors.checkThat(sf.getGeometry().isEnvelope(), is(false));
    errors.checkThat(sf.getGeometry().isGeometry(), is(true));
    errors.checkThat(sf.getGeometry().getGeometry().get(), is(instanceOf(Polygon.class)));
    errors.checkThat(sf.getValueReference(), is("http://www.opengis.net/req/omxml/2.0/data/samplingGeometry"));
}
Also used : SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) Test(org.junit.Test)

Example 70 with Data

use of org.n52.io.response.dataset.Data 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

IoParameters (org.n52.io.request.IoParameters)25 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 Data (org.n52.io.response.dataset.Data)13 IOException (java.io.IOException)12 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)11 HashMap (java.util.HashMap)6 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)6 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)6 InputStream (java.io.InputStream)5 XmlObject (org.apache.xmlbeans.XmlObject)5 IoParseException (org.n52.io.IoParseException)5 File (java.io.File)4 Test (org.junit.Test)4 InternalServerException (org.n52.web.exception.InternalServerException)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 BigDecimal (java.math.BigDecimal)3 ElasticsearchAwareTest (org.n52.iceland.statistics.basetests.ElasticsearchAwareTest)3 ResultTimeClassifiedData (org.n52.io.format.ResultTimeClassifiedData)3 RawDataService (org.n52.series.spi.srv.RawDataService)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3