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