Search in sources :

Example 1 with AnyScalarPropertyType

use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldText.

@Test
public void should_encode_simpleDatarecord_with_fieldText() throws EncodingException {
    final String field1Name = "field-1";
    final String field1Value = "field-1-value";
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field1Name, new SweText().setValue(field1Value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.isSetText(), is(TRUE));
    assertThat(field1.getName(), is(field1Name));
    assertThat(field1.getText().getValue(), is(field1Value));
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Example 2 with AnyScalarPropertyType

use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDataRecord_with_field_with_null_element.

@Test
public void should_encode_simpleDataRecord_with_field_with_null_element() throws EncodingException {
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField("field-name", null)));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    final AnyScalarPropertyType field = xbSimpleDataRecord.getFieldArray(0);
    assertThat(field.getName(), is("field-name"));
    assertThat(field.getQuantity() == null, is(true));
}
Also used : SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Example 3 with AnyScalarPropertyType

use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_simpleDatarecord_with_fieldCount.

@Test
public void should_encode_simpleDatarecord_with_fieldCount() throws EncodingException {
    final String name = "field-1";
    final int value = 42;
    final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(name, new SweCount().setValue(value))));
    assertThat(encode, instanceOf(SimpleDataRecordType.class));
    final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
    final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(0);
    assertThat(xbSimpleDataRecord.getFieldArray().length, is(1));
    assertThat(field1.getName(), is(name));
    assertThat(field1.isSetCount(), is(TRUE));
    assertThat(field1.getCount().getValue().intValue(), is(value));
}
Also used : SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweField(org.n52.shetland.ogc.swe.SweField) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) Test(org.junit.jupiter.api.Test)

Example 4 with AnyScalarPropertyType

use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType 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);
    }
}
Also used : TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) DataStreamDocument(net.opengis.swe.x20.DataStreamDocument) AnyScalarPropertyType(net.opengis.swe.x20.AnyScalarPropertyType) DataRecordPropertyType(net.opengis.swe.x20.DataRecordPropertyType) DataArrayPropertyType(net.opengis.swe.x20.DataArrayPropertyType) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) TextEncodingType(net.opengis.swe.x20.TextEncodingType) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Coordinate(net.opengis.swe.x20.VectorType.Coordinate) CountPropertyType(net.opengis.swe.x20.CountPropertyType) DataStreamType(net.opengis.swe.x20.DataStreamType) SweAbstractEncoding(org.n52.shetland.ogc.swe.encoding.SweAbstractEncoding) DataStreamPropertyType(net.opengis.swe.x20.DataStreamPropertyType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) QuantityPropertyType(net.opengis.swe.x20.QuantityPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) TextPropertyType(net.opengis.swe.x20.TextPropertyType) AbstractDataComponentDocument(net.opengis.swe.x20.AbstractDataComponentDocument) AbstractEncodingType(net.opengis.swe.x20.AbstractEncodingType) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) CategoryPropertyType(net.opengis.swe.x20.CategoryPropertyType)

Example 5 with AnyScalarPropertyType

use of org.geotoolkit.swe.xml.v101.AnyScalarPropertyType in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createSimpleDataRecord.

private SimpleDataRecordType createSimpleDataRecord(SweSimpleDataRecord simpleDataRecord) throws EncodingException {
    SimpleDataRecordType xbSimpleDataRecord = SimpleDataRecordType.Factory.newInstance(getXmlOptions());
    if (simpleDataRecord.isSetDefinition()) {
        xbSimpleDataRecord.setDefinition(simpleDataRecord.getDefinition());
    }
    if (simpleDataRecord.isSetDescription()) {
        StringOrRefType xbSoR = StringOrRefType.Factory.newInstance();
        xbSoR.setStringValue(simpleDataRecord.getDefinition());
        xbSimpleDataRecord.setDescription(xbSoR);
    }
    if (simpleDataRecord.isSetFields()) {
        AnyScalarPropertyType[] xbFields = new AnyScalarPropertyType[simpleDataRecord.getFields().size()];
        int xbFieldIndex = 0;
        for (SweField sweField : simpleDataRecord.getFields()) {
            AnyScalarPropertyType xbField = createFieldForSimpleDataRecord(sweField);
            xbFields[xbFieldIndex] = xbField;
            xbFieldIndex++;
        }
        xbSimpleDataRecord.setFieldArray(xbFields);
    }
    return xbSimpleDataRecord;
}
Also used : StringOrRefType(net.opengis.gml.StringOrRefType) AnyScalarPropertyType(net.opengis.swe.x101.AnyScalarPropertyType) SweField(org.n52.shetland.ogc.swe.SweField) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType)

Aggregations

AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)13 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)11 XmlObject (org.apache.xmlbeans.XmlObject)11 SweField (org.n52.shetland.ogc.swe.SweField)11 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)10 Test (org.junit.jupiter.api.Test)9 ArrayList (java.util.ArrayList)4 PhenomenonType (org.geotoolkit.swe.xml.v101.PhenomenonType)3 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)3 StringWriter (java.io.StringWriter)2 DirectPositionType (org.geotoolkit.gml.xml.v311.DirectPositionType)2 FeaturePropertyType (org.geotoolkit.gml.xml.v311.FeaturePropertyType)2 PointType (org.geotoolkit.gml.xml.v311.PointType)2 TimePeriodType (org.geotoolkit.gml.xml.v311.TimePeriodType)2 UnitOfMeasureEntry (org.geotoolkit.gml.xml.v311.UnitOfMeasureEntry)2 MeasureType (org.geotoolkit.observation.xml.v100.MeasureType)2 MeasurementType (org.geotoolkit.observation.xml.v100.MeasurementType)2 ObservationCollectionType (org.geotoolkit.observation.xml.v100.ObservationCollectionType)2 ObservationType (org.geotoolkit.observation.xml.v100.ObservationType)2 SamplingPointType (org.geotoolkit.sampling.xml.v100.SamplingPointType)2