Search in sources :

Example 1 with SweAbstractDataComponentCreator

use of org.n52.sos.ds.hibernate.util.observation.SweAbstractDataComponentCreator in project SOS by 52North.

the class ResultHandlingHelper method createObservedPropertyField.

private List<SweField> createObservedPropertyField(DataEntity<?> observation) throws OwsExceptionReport {
    List<SweField> fields = new LinkedList<>();
    PhenomenonEntity phenomenon = observation.getDataset().getPhenomenon();
    if (observation.getDataset().getDatasetType().equals(DatasetType.profile) || observation.getDataset().getObservationType().equals(ObservationType.profile)) {
        ProfileValue profile = (ProfileValue) new ObservationValueCreator(decoderRepository).visit(observation);
        ProfileLevel level = profile.getValue().get(0);
        fields.add(createVerticalParameter(level));
        if (level.getValue().get(0) instanceof SweAbstractDataComponent) {
            if (level.getValue().size() > 1) {
                SweDataRecord record = new SweDataRecord();
                for (Value<?> v : level.getValue()) {
                    SweAbstractDataComponent dc = (SweAbstractDataComponent) v;
                    record.addField(new SweField(NcName.makeValid(dc.getDefinition()), dc));
                }
                fields.add(new SweField(getNcNameName(phenomenon), record));
                return fields;
            } else {
                SweAbstractDataComponent swe = (SweAbstractDataComponent) level.getValue().get(0).setValue(null);
                swe.setDefinition(phenomenon.getIdentifier());
                fields.add(new SweField(getNcNameName(phenomenon), swe));
                return fields;
            }
        }
    } else {
        SweAbstractDataComponent value = new SweAbstractDataComponentCreator(decoderRepository, true).visit(observation);
        fields.add(new SweField(getNcNameName(phenomenon), (SweAbstractDataComponent) value));
        return fields;
    }
    throw new NoApplicableCodeException();
}
Also used : SweField(org.n52.shetland.ogc.swe.SweField) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) ProfileLevel(org.n52.shetland.ogc.om.values.ProfileLevel) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ObservationValueCreator(org.n52.sos.ds.hibernate.util.observation.ObservationValueCreator) SweAbstractDataComponentCreator(org.n52.sos.ds.hibernate.util.observation.SweAbstractDataComponentCreator) PhenomenonEntity(org.n52.series.db.beans.PhenomenonEntity) LinkedList(java.util.LinkedList) ProfileValue(org.n52.shetland.ogc.om.values.ProfileValue)

Example 2 with SweAbstractDataComponentCreator

use of org.n52.sos.ds.hibernate.util.observation.SweAbstractDataComponentCreator in project SOS by 52North.

the class ObservationValueCreator method visit.

@Override
public ComplexValue visit(ComplexDataEntity o) throws OwsExceptionReport {
    SweAbstractDataComponentCreator visitor = new SweAbstractDataComponentCreator(getDecoderRepository());
    SweDataRecord record = visitor.visit(o);
    return new ComplexValue(record);
}
Also used : ComplexValue(org.n52.shetland.ogc.om.values.ComplexValue) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord)

Aggregations

SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)2 LinkedList (java.util.LinkedList)1 PhenomenonEntity (org.n52.series.db.beans.PhenomenonEntity)1 ComplexValue (org.n52.shetland.ogc.om.values.ComplexValue)1 ProfileLevel (org.n52.shetland.ogc.om.values.ProfileLevel)1 ProfileValue (org.n52.shetland.ogc.om.values.ProfileValue)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)1 SweField (org.n52.shetland.ogc.swe.SweField)1 ObservationValueCreator (org.n52.sos.ds.hibernate.util.observation.ObservationValueCreator)1 SweAbstractDataComponentCreator (org.n52.sos.ds.hibernate.util.observation.SweAbstractDataComponentCreator)1