Search in sources :

Example 1 with SweCoordinate

use of org.n52.shetland.ogc.swe.SweCoordinate 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 2 with SweCoordinate

use of org.n52.shetland.ogc.swe.SweCoordinate in project arctic-sea by 52North.

the class SweCommonEncoderv101 method encode.

@Override
public XmlObject encode(Object element, EncodingContext context) throws EncodingException {
    XmlObject encodedObject = null;
    if (element instanceof SweAbstractSimpleType) {
        encodedObject = createSimpleType((SweAbstractSimpleType<?>) element, context);
    // }
    // if (element instanceof SweBoolean) {
    // encodedObject = createBoolean((SweBoolean) element);
    // } else if (element instanceof SweCategory) {
    // encodedObject = createCategory((SweCategory) element);
    // } else if (element instanceof SweCount) {
    // encodedObject = createCount((SweCount) element);
    // } else if (element instanceof SweObservableProperty) {
    // encodedObject = createObservableProperty((SweObservableProperty)
    // element);
    // } else if (element instanceof SweQuantity) {
    // encodedObject = createQuantity((SweQuantity) element);
    // } else if (element instanceof SweQuantityRange) {
    // encodedObject = createQuantityRange((SweQuantityRange) element);
    // } else if (element instanceof SweText) {
    // encodedObject = createText((SweText) element);
    // } else if (element instanceof SweTime) {
    // encodedObject = createTime((SweTime) element);
    // } else if (element instanceof SweTimeRange) {
    // encodedObject = createTimeRange((SweTimeRange) element);
    } else if (element instanceof SweCoordinate) {
        encodedObject = createCoordinate((SweCoordinate<?>) element);
    } else if (element instanceof SweDataArray) {
        encodedObject = createDataArray((SweDataArray) element);
    } else if (element instanceof SweDataRecord) {
        DataRecordType drt = createDataRecord((SweDataRecord) element);
        if (context.has(XmlBeansEncodingFlags.DOCUMENT)) {
            DataRecordDocument drd = DataRecordDocument.Factory.newInstance(getXmlOptions());
            drd.setDataRecord(drt);
            encodedObject = drd;
        } else {
            encodedObject = drt;
        }
    } else if (element instanceof SweEnvelope) {
        encodedObject = createEnvelope((SweEnvelope) element);
    } else if (element instanceof SweSimpleDataRecord) {
        encodedObject = createSimpleDataRecord((SweSimpleDataRecord) element);
    } else if (element instanceof TimePeriod) {
        encodedObject = createTimeGeometricPrimitivePropertyType((TimePeriod) element);
    } else {
        throw new UnsupportedEncoderInputException(this, element);
    }
    XmlHelper.validateDocument(encodedObject, EncodingException::new);
    return encodedObject;
}
Also used : DataRecordType(net.opengis.swe.x101.DataRecordType) SimpleDataRecordType(net.opengis.swe.x101.SimpleDataRecordType) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) XmlObject(org.apache.xmlbeans.XmlObject) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordDocument(net.opengis.swe.x101.DataRecordDocument) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 3 with SweCoordinate

use of org.n52.shetland.ogc.swe.SweCoordinate 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 SweCoordinate

use of org.n52.shetland.ogc.swe.SweCoordinate in project arctic-sea by 52North.

the class SweEnvelopeTest method should_create_valid_sosSweEnvelope_from_sosEnvelope.

@Test
public void should_create_valid_sosSweEnvelope_from_sosEnvelope() {
    final int srid = 52;
    final double x1 = 1;
    final double y1 = 2;
    final double y2 = 3;
    final double x2 = 4;
    final BigDecimal bx1 = new BigDecimal(x1);
    final BigDecimal by1 = new BigDecimal(y1);
    final BigDecimal by2 = new BigDecimal(y2);
    final BigDecimal bx2 = new BigDecimal(x2);
    final String uom = "deg";
    final ReferencedEnvelope sosEnvelope = new ReferencedEnvelope(new Envelope(x1, x2, y1, y2), srid);
    final SweEnvelope sweEnvelope = new SweEnvelope(sosEnvelope, uom, false);
    // srid
    assertThat(sweEnvelope.getReferenceFrame(), is(Integer.toString(srid)));
    // x1
    final List<? extends SweCoordinate<?>> lcCoordinates = sweEnvelope.getLowerCorner().getCoordinates();
    assertThat(((BigDecimal) lcCoordinates.get(0).getValue().getValue()), is(bx1));
    // y1
    assertThat(((BigDecimal) lcCoordinates.get(1).getValue().getValue()), is(by1));
    // x2
    final List<? extends SweCoordinate<?>> ucCoordinates = sweEnvelope.getUpperCorner().getCoordinates();
    assertThat(((BigDecimal) ucCoordinates.get(0).getValue().getValue()), is(bx2));
    // y2
    assertThat(((BigDecimal) ucCoordinates.get(1).getValue().getValue()), is(by2));
    // uom
    assertThat(((SweQuantity) lcCoordinates.get(0).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) lcCoordinates.get(1).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) ucCoordinates.get(0).getValue()).getUom(), is(uom));
    assertThat(((SweQuantity) ucCoordinates.get(1).getValue()).getUom(), is(uom));
    // northing
    assertThat(lcCoordinates.get(0).getName(), is(SweCoordinateNames.EASTING));
    assertThat(ucCoordinates.get(0).getName(), is(SweCoordinateNames.EASTING));
    // easting
    assertThat(lcCoordinates.get(1).getName(), is(SweCoordinateNames.NORTHING));
    assertThat(ucCoordinates.get(1).getName(), is(SweCoordinateNames.NORTHING));
}
Also used : ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) Envelope(org.locationtech.jts.geom.Envelope) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 5 with SweCoordinate

use of org.n52.shetland.ogc.swe.SweCoordinate in project arctic-sea by 52North.

the class SweEnvelope method createSweVector.

private static SweVector createSweVector(double x, double y, String uom) {
    SweQuantity xCoord = new SweQuantity().setAxisID(SweConstants.X_AXIS).setValue(x).setUom(uom);
    SweQuantity yCoord = new SweQuantity().setAxisID(SweConstants.Y_AXIS).setValue(y).setUom(uom);
    return new SweVector(new SweCoordinate<>(SweCoordinateNames.EASTING, xCoord), new SweCoordinate<>(SweCoordinateNames.NORTHING, yCoord));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity)

Aggregations

SweCoordinate (org.n52.shetland.ogc.swe.SweCoordinate)3 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)2 BigDecimal (java.math.BigDecimal)1 Position (net.opengis.sensorML.x101.PositionDocument.Position)1 DataRecordDocument (net.opengis.swe.x101.DataRecordDocument)1 DataRecordType (net.opengis.swe.x101.DataRecordType)1 PositionType (net.opengis.swe.x101.PositionType)1 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)1 VectorType (net.opengis.swe.x101.VectorType)1 Coordinate (net.opengis.swe.x101.VectorType.Coordinate)1 Coordinate (net.opengis.swe.x20.VectorType.Coordinate)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 Envelope (org.locationtech.jts.geom.Envelope)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 SmlPosition (org.n52.shetland.ogc.sensorML.elements.SmlPosition)1 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)1 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)1