Search in sources :

Example 1 with SweAbstractUomType

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);
}
Also used : SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) SweField(org.n52.shetland.ogc.swe.SweField) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange)

Example 2 with SweAbstractUomType

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;
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) SweDataArrayValue(org.n52.shetland.ogc.om.values.SweDataArrayValue) SweAbstractUomType(org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType)

Example 3 with SweAbstractUomType

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;
}
Also used : NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) CodeType(org.n52.shetland.ogc.gml.CodeType) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) SweAbstractUomType(org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType)

Example 4 with SweAbstractUomType

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;
    }
}
Also used : SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweVector(org.n52.shetland.ogc.swe.SweVector) SweField(org.n52.shetland.ogc.swe.SweField) SweAbstractSimpleType(org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweAbstractUomType(org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

SweField (org.n52.shetland.ogc.swe.SweField)3 SweAbstractUomType (org.n52.shetland.ogc.swe.simpleType.SweAbstractUomType)3 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)2 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)1 CodeType (org.n52.shetland.ogc.gml.CodeType)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 SweDataArrayValue (org.n52.shetland.ogc.om.values.SweDataArrayValue)1 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)1 SweVector (org.n52.shetland.ogc.swe.SweVector)1 SweAbstractSimpleType (org.n52.shetland.ogc.swe.simpleType.SweAbstractSimpleType)1 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)1 SweTime (org.n52.shetland.ogc.swe.simpleType.SweTime)1 SweTimeRange (org.n52.shetland.ogc.swe.simpleType.SweTimeRange)1