Search in sources :

Example 1 with Time

use of org.n52.shetland.ogc.gml.time.Time 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 2 with Time

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

the class ChartRendererTest method shouldHaveUTCTimezoneIncludedInDomainAxisLabel.

@Test
public void shouldHaveUTCTimezoneIncludedInDomainAxisLabel() {
    IoStyleContext context = IoStyleContext.createEmpty();
    context.getChartStyleDefinitions().setTimespan(VALID_ISO8601_ABSOLUTE_START);
    MyChartRenderer chartRenderer = new MyChartRenderer(context);
    String label = chartRenderer.getXYPlot().getDomainAxis().getLabel();
    ISODateTimeFormat.dateTimeParser().withOffsetParsed().parseDateTime(VALID_ISO8601_ABSOLUTE_START.split("/")[1]);
    assertThat(label, is("Time (UTC)"));
}
Also used : IoStyleContext(org.n52.io.IoStyleContext) Test(org.junit.Test)

Example 3 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class ProfileValue method getGeometry.

public Geometry getGeometry() {
    if (isSetGeometry()) {
        TreeMap<Time, Coordinate> map = new TreeMap<>();
        int srid = -1;
        for (ProfileLevel level : getValue()) {
            if (level.isSetPhenomenonTime() && level.isSetLocation()) {
                if (srid < 0) {
                    srid = level.getLocation().getSRID();
                }
                map.put(level.getPhenomenonTime(), level.getLocation().getCoordinate());
            }
        }
        if (!map.isEmpty()) {
            if (new HashSet<>(map.values()).size() == 1) {
                return getValue().iterator().next().getLocation();
            } else {
                return new GeometryFactory(new PrecisionModel(), srid).createLineString(map.values().toArray(new Coordinate[1]));
            }
        }
    }
    return null;
}
Also used : GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) Time(org.n52.shetland.ogc.gml.time.Time) PrecisionModel(org.locationtech.jts.geom.PrecisionModel) TreeMap(java.util.TreeMap) HashSet(java.util.HashSet)

Example 4 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class SweDataArrayValue method getPhenomenonTime.

@Override
public Time getPhenomenonTime() {
    final TimePeriod timePeriod = new TimePeriod();
    Set<Integer> dateTokenIndizes = Sets.newHashSet();
    if (getValue() != null && getValue().getElementType() != null && getValue().getEncoding() != null) {
        // get index of time token from elementtype
        if (getValue().getElementType() instanceof SweDataRecord) {
            final SweDataRecord elementType = (SweDataRecord) getValue().getElementType();
            final List<SweField> fields = elementType.getFields();
            for (int i = 0; i < fields.size(); i++) {
                final SweField sweField = fields.get(i);
                if (sweField.getElement() instanceof SweTime || sweField.getElement() instanceof SweTimeRange) {
                    if (checkFieldNameAndElementDefinition(sweField)) {
                        dateTokenIndizes.add(i);
                    }
                }
            }
        }
        if (CollectionHelper.isNotEmpty(dateTokenIndizes)) {
            for (final List<String> block : getValue().getValues()) {
                // datetimehelper to DateTime from joda time
                for (Integer index : dateTokenIndizes) {
                    String token = null;
                    try {
                        token = block.get(index);
                        final Time time = DateTimeHelper.parseIsoString2DateTime2Time(token);
                        timePeriod.extendToContain(time);
                    } catch (final DateTimeParseException dte) {
                        LOGGER.error(String.format("Could not parse ISO8601 string \"%s\"", token), dte);
                        // try next block;
                        continue;
                    }
                }
            }
        } else {
            final String errorMsg = "PhenomenonTime field could not be found in ElementType";
            LOGGER.error(errorMsg);
        }
    } else {
        final String errorMsg = String.format("Value of type \"%s\" not set correct.", SweDataArrayValue.class.getName());
        LOGGER.error(errorMsg);
    }
    return timePeriod;
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) Time(org.n52.shetland.ogc.gml.time.Time) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) DateTimeParseException(java.time.format.DateTimeParseException) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) SweField(org.n52.shetland.ogc.swe.SweField)

Example 5 with Time

use of org.n52.shetland.ogc.gml.time.Time in project arctic-sea by 52North.

the class TimeTest method missingFormat.

@Test
public void missingFormat() {
    TimePosition timePosition = new TimePosition(DateTime.now(), null);
    TimePosition timePositionWithDefaultFormat = new TimePosition(DateTime.now());
    assertThat("provided nullable time format will return default time format", timePosition.getTimeFormat(), is(equalTo(timePositionWithDefaultFormat.getTimeFormat())));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Aggregations

Time (org.n52.shetland.ogc.gml.time.Time)24 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)18 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)17 DateTime (org.joda.time.DateTime)12 Test (org.junit.Test)11 XmlObject (org.apache.xmlbeans.XmlObject)9 OmObservation (org.n52.shetland.ogc.om.OmObservation)8 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 EncodingException (org.n52.svalbard.encode.exception.EncodingException)7 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)6 TimePosition (org.n52.shetland.ogc.gml.time.TimePosition)5 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)4 XmlException (org.apache.xmlbeans.XmlException)3 XmlString (org.apache.xmlbeans.XmlString)3 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)3 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)3 MultiObservationValues (org.n52.shetland.ogc.om.MultiObservationValues)3 OmObservableProperty (org.n52.shetland.ogc.om.OmObservableProperty)3 SingleObservationValue (org.n52.shetland.ogc.om.SingleObservationValue)3 TimeValuePair (org.n52.shetland.ogc.om.TimeValuePair)3