use of org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType in project arctic-sea by 52North.
the class SweHelper method getPhenomenonTimeField.
private SweField getPhenomenonTimeField(Time sosTime) {
SweAbstractUomType<?> time;
if (sosTime instanceof TimePeriod) {
time = new SweTimeRange();
} else {
time = new SweTime();
}
time.setDefinition(OmConstants.PHENOMENON_TIME);
time.setUom(OmConstants.PHEN_UOM_ISO8601);
return new SweField(OmConstants.PHENOMENON_TIME_NAME, time);
}
use of org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType in project SOS by 52North.
the class ObservationUnfolder method parseSweDataArray.
private Value<?> parseSweDataArray(SweDataArray dataArray, List<String> block, IncDecInteger tokenIndex, ParameterHolder parameterHolder, String observedProperty) throws CodedException {
List<List<String>> values = new LinkedList<>();
values.add(block.subList(4, block.size()));
dataArray.setValues(values);
SweDataArrayValue sweDataArrayValue = new SweDataArrayValue(dataArray);
SweField field = ((SweDataRecord) dataArray.getElementType()).getFieldByIdentifier(observedProperty);
if (field != null && field.getElement() instanceof SweAbstractUomType) {
sweDataArrayValue.setUnit(((SweAbstractUomType) field.getElement()).getUomObject());
}
return sweDataArrayValue;
}
use of org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType in project SOS by 52North.
the class SweAbstractDataComponentCreator method setCommonValues.
protected <T extends SweAbstractDataComponent> T setCommonValues(T component, DataEntity<?> valuedObservation) throws CodedException {
if (valuedObservation != null) {
PhenomenonEntity op = valuedObservation.getDataset().getPhenomenon();
component.setIdentifier(op.getIdentifier());
component.setDefinition(op.getIdentifier());
component.setDescription(op.getDescription());
if (op.isSetNameCodespace()) {
String codespace = op.getNameCodespace().getName();
try {
component.setName(new CodeType(op.getName(), new URI(codespace)));
} catch (URISyntaxException e) {
throw new NoApplicableCodeException().causedBy(e).withMessage("Error while creating URI from '{}'", codespace);
}
} else {
component.setName(op.getName());
}
if (valuedObservation.getDataset().hasUnit() && component instanceof SweAbstractUomType) {
SweAbstractUomType<?> uomType = (SweAbstractUomType<?>) component;
uomType.setUom(valuedObservation.getDataset().getUnit().getUnit());
}
}
return component;
}
use of org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType in project SOS by 52North.
the class InsertResultHandler method getIndexFor.
/*
* TODO: Check if this mehtod is still required!?!
*/
@VisibleForTesting
protected void getIndexFor(SweDataRecord record, int j, Map<Integer, String> observedProperties, Map<Integer, String> units, Map<Integer, String> featureOfInterest, Map<Integer, String> procedure, HashSet<Integer> reserved, SweAbstractEncoding encoding) throws CodedException {
int idx = j;
for (final SweField swefield : record.getFields()) {
if (!reserved.contains(idx)) {
final Integer index = Integer.valueOf(idx);
if (swefield.getElement() instanceof SweAbstractSimpleType<?>) {
final SweAbstractSimpleType<?> sweAbstractSimpleType = (SweAbstractSimpleType<?>) swefield.getElement();
if (swefield.getElement() instanceof SweText && swefield.getElement().getDefinition().contains(ResultHandlingHelper.OM_FEATURE_OF_INTEREST)) {
featureOfInterest.put(index, swefield.getElement().getDefinition());
} else if (swefield.getElement() instanceof SweText && swefield.getElement().getDefinition().contains(ResultHandlingHelper.OM_PROCEDURE)) {
procedure.put(index, swefield.getElement().getDefinition());
} else {
observedProperties.put(index, swefield.getElement().getDefinition());
if (sweAbstractSimpleType instanceof SweAbstractUomType<?>) {
units.put(index, ((SweAbstractUomType<?>) sweAbstractSimpleType).getUom());
}
}
} else if (swefield.getElement() instanceof SweDataRecord) {
getIndexFor((SweDataRecord) swefield.getElement(), idx, observedProperties, units, featureOfInterest, procedure, reserved, encoding);
} else if (swefield.getElement() instanceof SweDataArray && ((SweDataArray) swefield.getElement()).getElementType() instanceof SweDataRecord) {
SweDataArray array = (SweDataArray) swefield.getElement();
if (!array.isSetEncoding()) {
array.setEncoding(encoding);
}
getIndexFor((SweDataRecord) array.getElementType(), j, observedProperties, units, featureOfInterest, procedure, reserved, encoding);
} else if (swefield.getElement() instanceof SweVector) {
helper.checkVectorForSamplingGeometry(swefield);
} else {
throw new NoApplicableCodeException().withMessage("The swe:Field element of type %s is not yet supported!", swefield.getElement().getClass().getName());
}
}
++idx;
}
}
Aggregations