use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method timeRangeWithValue.
@Test
public void timeRangeWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_RANGE_TYPE).put(JSONConstants.UOM, UOM);
json.putArray(JSONConstants.VALUE).add(TIME_START).add(TIME_END);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweTimeRange.class)));
SweTimeRange swe = (SweTimeRange) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
errors.checkThat(swe.getValue(), is(notNullValue()));
errors.checkThat(swe.getValue().getRangeStart(), is(timeStart));
errors.checkThat(swe.getValue().getRangeEnd(), is(timeEnd));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class FieldDecoderTest method testQuantityRangeWithValue.
@Test
public void testQuantityRangeWithValue() throws DecodingException {
ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_RANGE_TYPE).put(JSONConstants.UOM, UOM);
json.putArray(JSONConstants.VALUE).add(QUANTITY_VALUE_START).add(QUANTITY_VALUE_END);
SweField field = checkCommon(json, true);
assertThat(field.getElement(), is(instanceOf(SweQuantityRange.class)));
SweQuantityRange swe = (SweQuantityRange) field.getElement();
errors.checkThat(swe.getUom(), is(UOM));
errors.checkThat(swe.getValue(), is(notNullValue()));
errors.checkThat(swe.getValue().getRangeStart().doubleValue(), is(QUANTITY_VALUE_START));
errors.checkThat(swe.getValue().getRangeEnd().doubleValue(), is(QUANTITY_VALUE_END));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class InsertResultTemplateRequestDecoderTest method resultStructure.
@Test
public void resultStructure() throws IOException, DecodingException {
InsertResultTemplateRequest req = load();
assertThat(req.getResultStructure(), is(notNullValue()));
assertThat(req.getResultStructure().isDecoded(), is(true));
assertThat(req.getResultStructure().isEncoded(), is(false));
assertThat(req.getResultStructure().get().get(), is(instanceOf(SweDataRecord.class)));
SweDataRecord structure = (SweDataRecord) req.getResultStructure().get().get();
assertThat(structure.getFields(), is(notNullValue()));
assertThat(structure.getFields(), hasSize(3));
SweField field1 = structure.getFields().get(0);
assertThat(field1, is(notNullValue()));
errors.checkThat(field1.getName().getValue(), is("phenomenonTime"));
assertThat(field1.getElement(), is(instanceOf(SweTimeRange.class)));
SweTimeRange phenomenonTime = (SweTimeRange) field1.getElement();
errors.checkThat(phenomenonTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/PhenomenonTime"));
errors.checkThat(phenomenonTime.getUom(), is("http://www.opengis.net/def/uom/ISO-8601/0/Gregorian"));
SweField field2 = structure.getFields().get(1);
assertThat(field2, is(notNullValue()));
errors.checkThat(field2.getName().getValue(), is("resultTime"));
assertThat(field2.getElement(), is(instanceOf(SweTime.class)));
SweTime resultTime = (SweTime) field2.getElement();
errors.checkThat(resultTime.getDefinition(), is("http://www.opengis.net/def/property/OGC/0/ResultTime"));
errors.checkThat(resultTime.getUom(), is("testunit1"));
SweField field3 = structure.getFields().get(2);
assertThat(field3, is(notNullValue()));
errors.checkThat(field3.getName().getValue(), is("observable_property_6"));
assertThat(field3.getElement(), is(instanceOf(SweQuantity.class)));
SweQuantity quantity = (SweQuantity) field3.getElement();
errors.checkThat(quantity.getDefinition(), is("http://www.52north.org/test/observableProperty/6"));
errors.checkThat(quantity.getUom(), is("test_unit_6"));
}
use of org.n52.shetland.ogc.UoM in project arctic-sea by 52North.
the class WmlTVPEncoderv20 method createMeasurementTimeseries.
/**
* Create a XML MeasurementTimeseries object from SOS observation for
* om:result
*
* @param sosObservation
* SOS observation
*
* @return XML MeasurementTimeseries object
*
* @throws CodedException
* if the encoding fails
*/
private XmlObject createMeasurementTimeseries(OmObservation sosObservation) throws OwsExceptionReport {
MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
MeasurementTimeseriesType measurementTimeseries = measurementTimeseriesDoc.addNewMeasurementTimeseries();
measurementTimeseries.setId(TIMESERIES_ID_PREFIX + sosObservation.getObservationID());
// Default value
TimeseriesMetadata timeseriesMetadata = new MeasurementTimeseriesMetadata().setCumulative(false);
if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getValue().getValue().getClass().isAssignableFrom(TVPValue.class) && sosObservation.getObservationConstellation().isSetMetadata() && sosObservation.getObservationConstellation().getMetadata().isSetTimeseriesMetadata()) {
timeseriesMetadata = sosObservation.getObservationConstellation().getMetadata().getTimeseriesmetadata();
}
addTimeseriesMetadata(measurementTimeseries, sosObservation.getPhenomenonTime().getGmlId(), timeseriesMetadata);
TVPDefaultMetadataPropertyType xbMetaComponent = measurementTimeseries.addNewDefaultPointMetadata();
DefaultTVPMeasurementMetadataDocument xbDefMeasureMetaComponent = DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
TVPMeasurementMetadataType defaultTVPMeasurementMetadata = xbDefMeasureMetaComponent.addNewDefaultTVPMeasurementMetadata();
// Default value
InterpolationType interpolationType = InterpolationType.Continuous;
if (sosObservation.isSetValue() && sosObservation.getValue().isSetValue() && sosObservation.getObservationConstellation().isSetDefaultPointMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().isSetDefaultTVPMeasurementMetadata() && sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().isSetInterpolationType()) {
interpolationType = sosObservation.getObservationConstellation().getDefaultPointMetadata().getDefaultTVPMeasurementMetadata().getInterpolationtype();
}
defaultTVPMeasurementMetadata.addNewInterpolationType().setHref(interpolationType.getIdentifier());
xbDefMeasureMetaComponent.getDefaultTVPMeasurementMetadata().getInterpolationType().setTitle(interpolationType.getTitle());
String unit = addValues(measurementTimeseries, sosObservation.getValue());
// set uom
if (unit != null && !unit.isEmpty()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(unit);
} else {
OmObservableProperty observableProperty = (OmObservableProperty) sosObservation.getObservationConstellation().getObservableProperty();
if (observableProperty.isSetUnit()) {
defaultTVPMeasurementMetadata.addNewUom().setCode(observableProperty.getUnit());
}
}
xbMetaComponent.set(xbDefMeasureMetaComponent);
return measurementTimeseriesDoc;
}
use of org.n52.shetland.ogc.UoM 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));
}
Aggregations