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