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;
}
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);
}
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);
}
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));
}
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;
}
Aggregations