Search in sources :

Example 1 with Coordinate

use of net.opengis.swe.x101.VectorType.Coordinate 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 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) 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) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) CategoryPropertyType(net.opengis.swe.x20.CategoryPropertyType)

Example 2 with Coordinate

use of net.opengis.swe.x101.VectorType.Coordinate in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createCoordinate.

/**
 * Adds values to SWE coordinates
 *
 * @param coordinate
 *            SOS internal representation
 *
 * @return the coordinate
 */
private Coordinate createCoordinate(SweCoordinate<?> coordinate) {
    Coordinate xbCoordinate = Coordinate.Factory.newInstance(getXmlOptions());
    xbCoordinate.setName(coordinate.getName());
    xbCoordinate.setQuantity(createQuantity((SweQuantity) coordinate.getValue()));
    return xbCoordinate;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Coordinate(net.opengis.swe.x101.VectorType.Coordinate)

Example 3 with Coordinate

use of net.opengis.swe.x101.VectorType.Coordinate in project arctic-sea by 52North.

the class SweCommonEncoderv20 method createCoordinate.

private Coordinate createCoordinate(SweCoordinate<?> coordinate) throws EncodingException {
    Coordinate xbCoordinate = Coordinate.Factory.newInstance(getXmlOptions());
    xbCoordinate.setName(coordinate.getName());
    xbCoordinate.setQuantity((QuantityType) createAbstractDataComponent(coordinate.getValue(), EncodingContext.empty()));
    return xbCoordinate;
}
Also used : Coordinate(net.opengis.swe.x20.VectorType.Coordinate) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate)

Example 4 with Coordinate

use of net.opengis.swe.x101.VectorType.Coordinate in project arctic-sea by 52North.

the class SweCommonEncoderv101Test method should_encode_ReferencedEnvelope.

@Test
public void should_encode_ReferencedEnvelope() throws EncodingException {
    final int srid = 4326;
    final double y1 = 7.0;
    final double x1 = 51.0;
    final double y2 = 8.0;
    final double x2 = 52.0;
    final String uom = "test-uom";
    final String definition = "test-definition";
    final SweEnvelope sweEnvelope = new SweEnvelope(new ReferencedEnvelope(new Envelope(x1, x2, y1, y2), srid), uom, true);
    final String xAxisId = "x";
    final String yAxisId = "y";
    final String northing = "northing";
    final String easting = "easting";
    sweEnvelope.setDefinition(definition);
    final XmlObject encode = sweCommonEncoderv101.encode(sweEnvelope);
    assertThat(encode, instanceOf(EnvelopeType.class));
    final EnvelopeType xbEnvelope = (EnvelopeType) encode;
    assertThat(xbEnvelope.isSetDefinition(), is(true));
    assertThat(xbEnvelope.getDefinition(), is(definition));
    final Coordinate lcX = xbEnvelope.getLowerCorner().getVector().getCoordinateArray(0);
    assertThat(lcX.getName(), is(easting));
    assertThat(lcX.getQuantity().getAxisID(), is(xAxisId));
    assertThat(lcX.getQuantity().getUom().getCode(), is(uom));
    assertThat(lcX.getQuantity().getValue(), is(y1));
    final Coordinate lcY = xbEnvelope.getLowerCorner().getVector().getCoordinateArray(1);
    assertThat(lcY.getName(), is(northing));
    assertThat(lcY.getQuantity().getAxisID(), is(yAxisId));
    assertThat(lcY.getQuantity().getUom().getCode(), is(uom));
    assertThat(lcY.getQuantity().getValue(), is(x1));
    final Coordinate ucX = xbEnvelope.getUpperCorner().getVector().getCoordinateArray(0);
    assertThat(ucX.getName(), is(easting));
    assertThat(ucX.getQuantity().getAxisID(), is(xAxisId));
    assertThat(ucX.getQuantity().getUom().getCode(), is(uom));
    assertThat(ucX.getQuantity().getValue(), is(y2));
    final Coordinate ucY = xbEnvelope.getUpperCorner().getVector().getCoordinateArray(1);
    assertThat(ucY.getName(), is(northing));
    assertThat(ucY.getQuantity().getAxisID(), is(yAxisId));
    assertThat(ucY.getQuantity().getUom().getCode(), is(uom));
    assertThat(ucY.getQuantity().getValue(), is(x2));
    assertThat(xbEnvelope.isSetReferenceFrame(), is(true));
    assertThat(xbEnvelope.getReferenceFrame(), is("" + srid));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) EnvelopeType(net.opengis.swe.x101.EnvelopeType) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Coordinate(net.opengis.swe.x101.VectorType.Coordinate) XmlObject(org.apache.xmlbeans.XmlObject) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) Envelope(org.locationtech.jts.geom.Envelope) Test(org.junit.Test)

Example 5 with Coordinate

use of net.opengis.swe.x101.VectorType.Coordinate in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createPosition.

/**
 * Creates the position section of the SensorML description.
 *
 * @param position
 *            SOS position
 *
 * @return XML Position element
 *
 * @throws EncodingException
 *             if an error occurs
 */
private Position createPosition(final SmlPosition position) throws EncodingException {
    Position xbPosition = Position.Factory.newInstance(getXmlOptions());
    if (position.isSetName()) {
        xbPosition.setName(position.getName().getValue());
    } else {
        xbPosition.setName("position");
    }
    PositionType xbSwePosition = xbPosition.addNewPosition();
    xbSwePosition.setFixed(position.isFixed());
    xbSwePosition.setReferenceFrame(position.getReferenceFrame());
    final VectorType xbVector = xbSwePosition.addNewLocation().addNewVector();
    for (SweCoordinate<?> coordinate : position.getPosition()) {
        if (coordinate.getValue().getValue() != null && (!coordinate.getValue().isSetValue() || !coordinate.getValue().getValue().equals(Double.NaN))) {
            // FIXME: SWE Common NS
            xbVector.addNewCoordinate().set(encodeObjectToXml(SweConstants.NS_SWE_101, coordinate));
        }
    }
    return xbPosition;
}
Also used : PositionType(net.opengis.swe.x101.PositionType) SmlPosition(org.n52.shetland.ogc.sensorML.elements.SmlPosition) Position(net.opengis.sensorML.x101.PositionDocument.Position) VectorType(net.opengis.swe.x101.VectorType)

Aggregations

SweCoordinate (org.n52.shetland.ogc.swe.SweCoordinate)3 Coordinate (net.opengis.swe.x101.VectorType.Coordinate)2 Coordinate (net.opengis.swe.x20.VectorType.Coordinate)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Position (net.opengis.sensorML.x101.PositionDocument.Position)1 EnvelopeType (net.opengis.swe.x101.EnvelopeType)1 PositionType (net.opengis.swe.x101.PositionType)1 VectorType (net.opengis.swe.x101.VectorType)1 AbstractDataComponentDocument (net.opengis.swe.x20.AbstractDataComponentDocument)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AnyScalarPropertyType (net.opengis.swe.x20.AnyScalarPropertyType)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)1 CountPropertyType (net.opengis.swe.x20.CountPropertyType)1 DataArrayPropertyType (net.opengis.swe.x20.DataArrayPropertyType)1 DataRecordPropertyType (net.opengis.swe.x20.DataRecordPropertyType)1 DataStreamDocument (net.opengis.swe.x20.DataStreamDocument)1 DataStreamPropertyType (net.opengis.swe.x20.DataStreamPropertyType)1 DataStreamType (net.opengis.swe.x20.DataStreamType)1 QuantityPropertyType (net.opengis.swe.x20.QuantityPropertyType)1