Search in sources :

Example 1 with UoM

use of org.n52.shetland.ogc.UoM in project series-rest-api by 52North.

the class QuantityCsvIoHandler method writeData.

private void writeData(DatasetOutput metadata, QuantityData series, OutputStream stream) throws IOException {
    String station = null;
    ParameterOutput platform = metadata.getSeriesParameters().getPlatform();
    if (platform == null) {
        TimeseriesMetadataOutput output = (TimeseriesMetadataOutput) metadata;
        station = output.getStation().getLabel();
    } else {
        station = platform.getLabel();
    }
    String phenomenon = metadata.getSeriesParameters().getPhenomenon().getLabel();
    String uom = metadata.getUom();
    for (QuantityValue timeseriesValue : series.getValues()) {
        String[] values = new String[getHeader().length];
        values[0] = station;
        values[1] = phenomenon;
        values[2] = uom;
        Long timestart = timeseriesValue.getTimestart();
        Long timeend = timeseriesValue.getTimestamp();
        values[3] = timestart != null ? new DateTime(timestart).toString() : null;
        values[4] = new DateTime(timeend).toString();
        values[5] = numberformat.format(timeseriesValue.getValue());
        writeCsvLine(csvEncode(values), stream);
    }
}
Also used : TimeseriesMetadataOutput(org.n52.io.response.dataset.TimeseriesMetadataOutput) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) ParameterOutput(org.n52.io.response.ParameterOutput) DateTime(org.joda.time.DateTime)

Example 2 with UoM

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

the class FieldDecoderTest method timeRange.

@Test
public void timeRange() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_RANGE_TYPE).put(JSONConstants.UOM, UOM);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweTimeRange.class)));
    SweTimeRange swe = (SweTimeRange) field.getElement();
    errors.checkThat(swe.getUom(), is(UOM));
    errors.checkThat(swe.getValue(), is(nullValue()));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) Test(org.junit.Test)

Example 3 with UoM

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

the class FieldDecoderTest method time.

@Test
public void time() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_TYPE).put(JSONConstants.UOM, UOM);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweTime.class)));
    SweTime swe = (SweTime) field.getElement();
    errors.checkThat(swe.getValue(), is(nullValue()));
    errors.checkThat(swe.getUom(), is(UOM));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 4 with UoM

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

the class FieldDecoderTest method testQuantity.

@Test
public void testQuantity() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.QUANTITY_TYPE).put(JSONConstants.UOM, UOM);
    SweField field = checkCommon(json, false);
    assertThat(field.getElement(), is(instanceOf(SweQuantity.class)));
    SweQuantity swe = (SweQuantity) field.getElement();
    errors.checkThat(swe.getUom(), is(UOM));
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Example 5 with UoM

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

the class FieldDecoderTest method timeWithValue.

@Test
public void timeWithValue() throws DecodingException {
    ObjectNode json = createField().put(JSONConstants.TYPE, JSONConstants.TIME_TYPE).put(JSONConstants.UOM, UOM).put(JSONConstants.VALUE, TIME_START);
    SweField field = checkCommon(json, true);
    assertThat(field.getElement(), is(instanceOf(SweTime.class)));
    SweTime swe = (SweTime) field.getElement();
    errors.checkThat(swe.getValue(), is(timeStart));
    errors.checkThat(swe.getUom(), is(UOM));
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SweField(org.n52.shetland.ogc.swe.SweField) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 SweField (org.n52.shetland.ogc.swe.SweField)9 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)8 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)4 ParameterOutput (org.n52.io.response.ParameterOutput)3 SweQuantityRange (org.n52.shetland.ogc.swe.simpleType.SweQuantityRange)3 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)3 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)3 BigDecimal (java.math.BigDecimal)2 DefaultTVPMeasurementMetadataDocument (net.opengis.waterml.x20.DefaultTVPMeasurementMetadataDocument)2 MeasurementTimeseriesDocument (net.opengis.waterml.x20.MeasurementTimeseriesDocument)2 MeasurementTimeseriesType (net.opengis.waterml.x20.MeasurementTimeseriesType)2 TVPDefaultMetadataPropertyType (net.opengis.waterml.x20.TVPDefaultMetadataPropertyType)2 TVPMeasurementMetadataType (net.opengis.waterml.x20.TVPMeasurementMetadataType)2 Envelope (org.locationtech.jts.geom.Envelope)2 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)2 MeasurementTimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata)2 TimeseriesMetadata (org.n52.shetland.ogc.om.series.wml.TimeseriesMetadata)2 InterpolationType (org.n52.shetland.ogc.om.series.wml.WaterMLConstants.InterpolationType)2 ReferencedEnvelope (org.n52.shetland.util.ReferencedEnvelope)2