Search in sources :

Example 21 with Value

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

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

the class HasExtension method addSweTextExtension.

default void addSweTextExtension(String name, String value) {
    SweText sweText = new SweText();
    sweText.setValue(value);
    sweText.setIdentifier(name);
    addSwesExtension(name, sweText);
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText)

Example 23 with Value

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

the class HasExtension method addSweBooleanExtension.

default void addSweBooleanExtension(String name, boolean value) {
    SweBoolean sweBoolean = new SweBoolean();
    sweBoolean.setValue(value);
    sweBoolean.setIdentifier(name);
    addSwesExtension(name, sweBoolean);
}
Also used : SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean)

Example 24 with Value

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

the class TimeTest method inteterminate.

@Test
public void inteterminate() {
    TimePosition timePosition = new TimePosition(IndeterminateValue.NOW);
    assertThat("time position is not set", timePosition.isSetTime(), is(false));
    assertThat("indeterminate value is set", timePosition.isSetIndeterminateValue(), is(true));
    assertThat("indeterminate value is 'now'", timePosition.getIndeterminateValue(), is(IndeterminateValue.NOW));
    assertThat("format is not set", timePosition.isSetTimeFormat(), is(false));
}
Also used : TimePosition(org.n52.shetland.ogc.gml.time.TimePosition) Test(org.junit.Test)

Example 25 with Value

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

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5