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;
}
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;
}
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;
}
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"));
}
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;
}
Aggregations