use of org.geotoolkit.swe.xml.v101.DataArrayPropertyType in project arctic-sea by 52North.
the class SweCommonDecoderV20 method decode.
@Override
public Object decode(Object element) throws DecodingException {
if (element instanceof DataArrayPropertyType) {
final DataArrayPropertyType dataArrayPropertyType = (DataArrayPropertyType) element;
return parseAbstractDataComponent(dataArrayPropertyType.getDataArray1());
} else if (element instanceof DataRecordPropertyType) {
final DataRecordPropertyType dataRecordPropertyType = (DataRecordPropertyType) element;
return parseAbstractDataComponent(dataRecordPropertyType.getDataRecord());
} else if (element instanceof AbstractDataComponentDocument) {
return parseAbstractDataComponentDocument((AbstractDataComponentDocument) element);
} else if (element instanceof AbstractDataComponentType) {
return parseAbstractDataComponent((AbstractDataComponentType) element);
} else if (element instanceof Coordinate[]) {
return parseCoordinates((Coordinate[]) element);
} else if (element instanceof AnyScalarPropertyType[]) {
return parseAnyScalarPropertyTypeArray((AnyScalarPropertyType[]) element);
} else if (element instanceof TextEncodingDocument) {
final TextEncodingDocument textEncodingDoc = (TextEncodingDocument) element;
final SweTextEncoding sosTextEncoding = parseTextEncoding(textEncodingDoc.getTextEncoding());
sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
return sosTextEncoding;
} else if (element instanceof TextEncodingType) {
TextEncodingDocument textEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
TextEncodingType textEncoding = (TextEncodingType) element;
textEncodingDoc.setTextEncoding(textEncoding);
SweTextEncoding sosTextEncoding = parseTextEncoding(textEncoding);
sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
return sosTextEncoding;
} else if (element instanceof AbstractEncodingType) {
SweAbstractEncoding absEncoding = parseEncoding((AbstractEncodingType) element);
TextEncodingDocument absEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
absEncoding.setXml(absEncodingDoc.xmlText(getXmlOptions()));
return absEncoding;
} else if (element instanceof TextPropertyType) {
return parseAbstractDataComponent(((TextPropertyType) element).getText());
} else if (element instanceof CountPropertyType) {
return parseAbstractDataComponent(((CountPropertyType) element).getCount());
} else if (element instanceof BooleanPropertyType) {
return parseAbstractDataComponent(((BooleanPropertyType) element).getBoolean());
} else if (element instanceof CategoryPropertyType) {
return parseAbstractDataComponent(((CategoryPropertyType) element).getCategory());
} else if (element instanceof QuantityPropertyType) {
return parseAbstractDataComponent(((QuantityPropertyType) element).getQuantity());
} else if (element instanceof DataStreamPropertyType) {
return parseDataStream(((DataStreamPropertyType) element).getDataStream());
} else if (element instanceof DataStreamType) {
return parseDataStream((DataStreamType) element);
} else if (element instanceof DataStreamDocument) {
return parseDataStream(((DataStreamDocument) element).getDataStream());
} else if (element instanceof XmlObject) {
throw new UnsupportedDecoderXmlInputException(this, (XmlObject) element);
} else {
throw new UnsupportedDecoderInputException(this, element);
}
}
use of org.geotoolkit.swe.xml.v101.DataArrayPropertyType in project arctic-sea by 52North.
the class SweCommonEncoderv20 method asPropertyType.
private XmlObject asPropertyType(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
if (type instanceof BooleanType) {
BooleanPropertyType propertyType = BooleanPropertyType.Factory.newInstance();
propertyType.setBoolean((BooleanType) type);
return propertyType;
} else if (type instanceof CountType) {
CountPropertyType propertyType = CountPropertyType.Factory.newInstance();
propertyType.setCount((CountType) type);
return propertyType;
} else if (type instanceof CountRangeType) {
CountRangePropertyType propertyType = CountRangePropertyType.Factory.newInstance();
propertyType.setCountRange((CountRangeType) type);
return propertyType;
} else if (type instanceof QuantityType) {
QuantityPropertyType propertyType = QuantityPropertyType.Factory.newInstance();
propertyType.setQuantity((QuantityType) type);
return propertyType;
} else if (type instanceof QuantityRangeType) {
QuantityRangePropertyType propertyType = QuantityRangePropertyType.Factory.newInstance();
propertyType.setQuantityRange((QuantityRangeType) type);
return propertyType;
} else if (type instanceof TimeType) {
TimePropertyType propertyType = TimePropertyType.Factory.newInstance();
propertyType.setTime((TimeType) type);
return propertyType;
} else if (type instanceof TimeRangeType) {
TimeRangePropertyType propertyType = TimeRangePropertyType.Factory.newInstance();
propertyType.setTimeRange((TimeRangeType) type);
return propertyType;
} else if (type instanceof CategoryType) {
CategoryPropertyType propertyType = CategoryPropertyType.Factory.newInstance();
propertyType.setCategory((CategoryType) type);
return propertyType;
} else if (type instanceof CategoryRangeType) {
CategoryRangePropertyType propertyType = CategoryRangePropertyType.Factory.newInstance();
propertyType.setCategoryRange((CategoryRangeType) type);
return propertyType;
} else if (type instanceof MatrixType) {
MatrixPropertyType propertyType = MatrixPropertyType.Factory.newInstance();
propertyType.setMatrix((MatrixType) type);
return propertyType;
} else if (type instanceof DataArrayType) {
DataArrayPropertyType propertyType = DataArrayPropertyType.Factory.newInstance();
propertyType.setDataArray1((DataArrayType) type);
return propertyType;
} else if (type instanceof DataChoiceType) {
DataChoicePropertyType propertyType = DataChoicePropertyType.Factory.newInstance();
propertyType.setDataChoice((DataChoiceType) type);
return propertyType;
} else if (type instanceof DataRecordType) {
DataRecordPropertyType propertyType = DataRecordPropertyType.Factory.newInstance();
propertyType.setDataRecord((DataRecordType) type);
return propertyType;
} else if (type instanceof TextType) {
TextPropertyType propertyType = TextPropertyType.Factory.newInstance();
propertyType.setText((TextType) type);
return propertyType;
} else if (type instanceof VectorType) {
VectorPropertyType propertyType = VectorPropertyType.Factory.newInstance();
propertyType.setVector((VectorType) type);
return propertyType;
} else {
throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
}
}
use of org.geotoolkit.swe.xml.v101.DataArrayPropertyType in project arctic-sea by 52North.
the class GetObservationResponseEncoderTest method testMetadataEncoding.
@Test
public void testMetadataEncoding() throws EncodingException, XmlException {
XmlObject encode = encoder.encode(createResponse());
assertThat(encode, instanceOf(GetObservationResponseDocument.class));
GetObservationResponseDocument gord = (GetObservationResponseDocument) encode;
assertThat(gord.getGetObservationResponse() != null, is(true));
assertThat(gord.getGetObservationResponse().getExtensionArray() != null, is(true));
assertThat(gord.getGetObservationResponse().getExtensionArray().length, is(1));
XmlObject parse = XmlObject.Factory.parse(gord.getGetObservationResponse().getExtensionArray(0).xmlText());
assertThat(parse, instanceOf(DataArrayPropertyType.class));
DataArrayPropertyType dad = (DataArrayPropertyType) parse;
assertThat(dad.getDataArray1(), instanceOf(DataArrayType.class));
DataArrayType dat = dad.getDataArray1();
assertThat(dat.getElementType().isSetAbstractDataComponent(), is(true));
assertThat(dat.getElementType().getAbstractDataComponent(), instanceOf(DataRecordType.class));
}
use of org.geotoolkit.swe.xml.v101.DataArrayPropertyType in project arctic-sea by 52North.
the class AbstractMetadataTest method checkMetadataResponse.
protected void checkMetadataResponse(XmlObject[] extensionArray) throws XmlException {
assertThat(extensionArray != null, is(true));
assertThat(extensionArray.length, is(1));
XmlObject parse = XmlObject.Factory.parse(extensionArray[0].xmlText());
assertThat(parse, instanceOf(DataArrayPropertyType.class));
DataArrayPropertyType dad = (DataArrayPropertyType) parse;
assertThat(dad.getDataArray1(), instanceOf(DataArrayType.class));
DataArrayType dat = dad.getDataArray1();
assertThat(dat.getElementType().isSetAbstractDataComponent(), is(true));
assertThat(dat.getElementType().getAbstractDataComponent(), instanceOf(DataRecordType.class));
}
use of org.geotoolkit.swe.xml.v101.DataArrayPropertyType in project geotoolkit by Geomatys.
the class ObservationXMLBindingTest method marshallingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void marshallingTest() throws Exception {
DirectPositionType pos = new DirectPositionType("urn:ogc:crs:espg:4326", 2, Arrays.asList(3.2, 6.5));
PointType location = new PointType("point-ID", pos);
SamplingPointType sp = new SamplingPointType("samplingID-007", "urn:sampling:test:007", "a sampling Test", new FeaturePropertyType(""), location);
PhenomenonType observedProperty = new PhenomenonType("phenomenon-007", "urn:OGC:phenomenon-007");
TimePeriodType samplingTime = new TimePeriodType("t1", "2007-01-01", "2008-09-09");
TextBlockType encoding = new TextBlockType("encoding-001", ",", "@@", ".");
List<AnyScalarPropertyType> fields = new ArrayList<>();
AnyScalarPropertyType field = new AnyScalarPropertyType("text-field-001", new Text("urn:something", "some value"));
fields.add(field);
SimpleDataRecordType record = new SimpleDataRecordType(fields);
DataArrayType array = new DataArrayType("array-001", 1, "array-001", record, encoding, "somevalue", null);
DataArrayPropertyType arrayProp = new DataArrayPropertyType(array);
ObservationType obs = new ObservationType("urn:Observation-007", "observation definition", sp, observedProperty, "urn:sensor:007", arrayProp, samplingTime);
StringWriter sw = new StringWriter();
marshaller.marshal(obs, sw);
String result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
String expResult = "<om:Observation xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:om=\"http://www.opengis.net/om/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\"" + " xmlns:swe=\"http://www.opengis.net/swe/1.0.1\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + '\n' + " <gml:name>urn:Observation-007</gml:name>" + '\n' + " <om:samplingTime>" + '\n' + " <gml:TimePeriod gml:id=\"t1\">" + '\n' + " <gml:beginPosition>2007-01-01</gml:beginPosition>" + '\n' + " <gml:endPosition>2008-09-09</gml:endPosition>" + '\n' + " </gml:TimePeriod>" + '\n' + " </om:samplingTime>" + '\n' + " <om:procedure xlink:href=\"urn:sensor:007\"/>" + '\n' + " <om:observedProperty>" + '\n' + " <swe:Phenomenon gml:id=\"phenomenon-007\">" + '\n' + " <gml:name>urn:OGC:phenomenon-007</gml:name>" + '\n' + " </swe:Phenomenon>" + '\n' + " </om:observedProperty>" + '\n' + " <om:featureOfInterest>" + '\n' + " <sampling:SamplingPoint gml:id=\"samplingID-007\">" + '\n' + " <gml:description>a sampling Test</gml:description>" + '\n' + " <gml:name>urn:sampling:test:007</gml:name>" + '\n' + " <gml:boundedBy>" + '\n' + " <gml:Null>not_bounded</gml:Null>" + '\n' + " </gml:boundedBy>" + '\n' + " <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + " <sampling:position>" + '\n' + " <gml:Point gml:id=\"point-ID\">" + '\n' + " <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </sampling:position>" + '\n' + " </sampling:SamplingPoint>" + '\n' + " </om:featureOfInterest>" + '\n' + " <om:result xsi:type=\"swe:DataArrayPropertyType\" >" + '\n' + " <swe:DataArray gml:id=\"array-001\">" + '\n' + " <swe:elementCount>" + '\n' + " <swe:Count>" + '\n' + " <swe:value>1</swe:value>" + '\n' + " </swe:Count>" + '\n' + " </swe:elementCount>" + '\n' + " <swe:elementType name=\"array-001\">" + '\n' + " <swe:SimpleDataRecord>" + '\n' + " <swe:field name=\"text-field-001\">" + '\n' + " <swe:Text definition=\"urn:something\">" + '\n' + " <swe:value>some value</swe:value>" + '\n' + " </swe:Text>" + '\n' + " </swe:field>" + '\n' + " </swe:SimpleDataRecord>" + '\n' + " </swe:elementType>" + '\n' + " <swe:encoding>" + '\n' + " <swe:TextBlock blockSeparator=\"@@\" decimalSeparator=\".\" tokenSeparator=\",\" id=\"encoding-001\"/>" + '\n' + " </swe:encoding>" + '\n' + " <swe:values>somevalue</swe:values>" + '\n' + " </swe:DataArray>" + '\n' + " </om:result>" + '\n' + "</om:Observation>\n";
assertXmlEquals(expResult, result, "xmlns:*");
UnitOfMeasureEntry uom = new UnitOfMeasureEntry("m", "meters", "distance", "meters");
MeasureType meas = new MeasureType(uom, 7);
MeasurementType measmt = new MeasurementType("urn:Observation-007", "observation definition", sp, observedProperty, "urn:sensor:007", meas, samplingTime);
sw = new StringWriter();
marshaller.marshal(measmt, sw);
result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
expResult = "<om:Measurement xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:om=\"http://www.opengis.net/om/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\"" + " xmlns:swe=\"http://www.opengis.net/swe/1.0.1\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + '\n' + " <gml:name>urn:Observation-007</gml:name>" + '\n' + " <om:samplingTime>" + '\n' + " <gml:TimePeriod gml:id=\"t1\">" + '\n' + " <gml:beginPosition>2007-01-01</gml:beginPosition>" + '\n' + " <gml:endPosition>2008-09-09</gml:endPosition>" + '\n' + " </gml:TimePeriod>" + '\n' + " </om:samplingTime>" + '\n' + " <om:procedure xlink:href=\"urn:sensor:007\"/>" + '\n' + " <om:observedProperty>" + '\n' + " <swe:Phenomenon gml:id=\"phenomenon-007\">" + '\n' + " <gml:name>urn:OGC:phenomenon-007</gml:name>" + '\n' + " </swe:Phenomenon>" + '\n' + " </om:observedProperty>" + '\n' + " <om:featureOfInterest>" + '\n' + " <sampling:SamplingPoint gml:id=\"samplingID-007\">" + '\n' + " <gml:description>a sampling Test</gml:description>" + '\n' + " <gml:name>urn:sampling:test:007</gml:name>" + '\n' + " <gml:boundedBy>" + '\n' + " <gml:Null>not_bounded</gml:Null>" + '\n' + " </gml:boundedBy>" + '\n' + " <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + " <sampling:position>" + '\n' + " <gml:Point gml:id=\"point-ID\">" + '\n' + " <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </sampling:position>" + '\n' + " </sampling:SamplingPoint>" + '\n' + " </om:featureOfInterest>" + '\n' + " <om:result xsi:type=\"om:MeasureType\" uom=\"meters\">7.0</om:result>" + '\n' + "</om:Measurement>\n";
assertXmlEquals(expResult, result, "xmlns:*");
ObservationCollectionType collection = new ObservationCollectionType();
collection.add(measmt);
sw = new StringWriter();
marshaller.marshal(collection, sw);
result = sw.toString();
// System.out.println(result);
collection = new ObservationCollectionType();
collection.add(obs.getTemporaryTemplate("temporaryName", samplingTime));
sw = new StringWriter();
marshaller.marshal(collection, sw);
result = sw.toString();
}
Aggregations