Search in sources :

Example 6 with QuantityValue

use of org.n52.shetland.ogc.om.values.QuantityValue 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 7 with QuantityValue

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

the class FlotFormatter method formatSeries.

private List<Number[]> formatSeries(QuantityData timeseries) {
    List<Number[]> series = new ArrayList<>();
    for (QuantityValue currentValue : timeseries.getValues()) {
        List<Number> list = new ArrayList<>();
        list.add(currentValue.getTimestamp());
        list.add(currentValue.getValue());
        if (currentValue.isSetGeometry()) {
            Coordinate coordinate = currentValue.getGeometry().getCoordinate();
            list.add(coordinate.x);
            list.add(coordinate.y);
            if (!Double.isNaN(coordinate.z)) {
                list.add(coordinate.z);
            }
        }
        series.add(list.toArray(new Number[0]));
    }
    return series;
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) ArrayList(java.util.ArrayList)

Example 8 with QuantityValue

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

the class PDFReportGenerator method addDataTable.

private void addDataTable(TimeSeries timeseries, TimeseriesMetadataOutput metadata, TvpDataCollection<QuantityData> dataCollection) {
    TableType dataTable = timeseries.addNewTable();
    // TODO add language context
    dataTable.setLeftColHeader("Date");
    dataTable.setRightColHeader(createValueTableHeader(metadata));
    QuantityData data = dataCollection.getSeries(metadata.getId());
    for (QuantityValue valueEntry : data.getValues()) {
        Entry entry = dataTable.addNewEntry();
        // TODO update TableType schema to allow start/end time
        entry.setTime(new DateTime(valueEntry.getTimestamp()).toString());
        entry.setValue(Double.toString(valueEntry.getValue()));
    }
}
Also used : Entry(org.n52.oxf.TableType.Entry) TableType(org.n52.oxf.TableType) QuantityValue(org.n52.io.response.dataset.quantity.QuantityValue) QuantityData(org.n52.io.response.dataset.quantity.QuantityData) DateTime(org.joda.time.DateTime)

Example 9 with QuantityValue

use of org.n52.shetland.ogc.om.values.QuantityValue in project arctic-sea by 52North.

the class ProfileObservation method setValue.

@Override
public void setValue(ObservationValue<?> value) {
    if (value instanceof StreamingValue<?>) {
        super.setValue(value);
    } else if (value.getValue() instanceof RectifiedGridCoverage || value.getValue() instanceof ReferencableGridCoverage) {
        super.setValue(value);
    } else if (value.getValue() instanceof ProfileValue) {
        ProfileValue profile = (ProfileValue) value.getValue();
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.setRangeParameters(getObservationConstellation().getObservablePropertyIdentifier());
        List<Coordinate> coordinates = Lists.newArrayList();
        int srid = 0;
        for (ProfileLevel level : profile.getValue()) {
            if (level.isSetLevelEnd()) {
                rectifiedGridCoverage.addValue(new QuantityRangeValue(level.getLevelStart().getValue(), level.getLevelEnd().getValue(), level.getLevelStart().getUnit()), level.getSimpleValue());
            } else {
                rectifiedGridCoverage.addValue(level.getLevelStart(), level.getSimpleValue());
            }
            if (level.isSetLocation()) {
                Coordinate coordinate = level.getLocation().getCoordinate();
                coordinate.z = level.getLevelStart().getValue().doubleValue();
                coordinates.add(coordinate);
                if (srid == 0) {
                    srid = level.getLocation().getSRID();
                }
            }
        }
        if (CollectionHelper.isNotEmpty(coordinates)) {
            setFeatureGeometry(coordinates, srid);
        }
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    } else {
        QuantityValue heightDepth = new QuantityValue(0.0);
        if (isSetHeightDepthParameter()) {
            heightDepth = (QuantityValue) getHeightDepthParameter().getValue();
            removeParameter(getHeightDepthParameter());
        }
        RectifiedGridCoverage rectifiedGridCoverage = new RectifiedGridCoverage(getObservationID());
        rectifiedGridCoverage.setUnit(value.getValue().getUnit());
        rectifiedGridCoverage.addValue(heightDepth, value.getValue());
        super.setValue(new SingleObservationValue<>(value.getPhenomenonTime(), rectifiedGridCoverage));
    }
}
Also used : StreamingValue(org.n52.shetland.ogc.om.StreamingValue) Coordinate(org.locationtech.jts.geom.Coordinate) QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue) ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel) QuantityRangeValue(org.n52.shetland.ogc.om.values.QuantityRangeValue) RectifiedGridCoverage(org.n52.shetland.ogc.om.values.RectifiedGridCoverage) ReferencableGridCoverage(org.n52.shetland.ogc.om.values.ReferencableGridCoverage) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 10 with QuantityValue

use of org.n52.shetland.ogc.om.values.QuantityValue in project arctic-sea by 52North.

the class ProfileValueTest method createQuantity.

private QuantityValue createQuantity(String definition, double value, String unit) {
    QuantityValue quantity = new QuantityValue(value, unit);
    quantity.setValue(value).setUom(unit).setDefinition(definition);
    return quantity;
}
Also used : QuantityValue(org.n52.shetland.ogc.om.values.QuantityValue)

Aggregations

QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)21 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)8 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)6 XmlObject (org.apache.xmlbeans.XmlObject)5 Test (org.junit.Test)5 BooleanValue (org.n52.shetland.ogc.om.values.BooleanValue)5 TextValue (org.n52.shetland.ogc.om.values.TextValue)5 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)4 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)4 GeometryValue (org.n52.shetland.ogc.om.values.GeometryValue)4 BigDecimal (java.math.BigDecimal)3 List (java.util.List)3 XmlBoolean (org.apache.xmlbeans.XmlBoolean)3 XmlInteger (org.apache.xmlbeans.XmlInteger)3 XmlString (org.apache.xmlbeans.XmlString)3 Geometry (org.locationtech.jts.geom.Geometry)3 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)3 Coordinate (com.vividsolutions.jts.geom.Coordinate)2 ArrayList (java.util.ArrayList)2