Search in sources :

Example 1 with PhenomenonProperty

use of org.geotoolkit.swe.xml.PhenomenonProperty in project geotoolkit by Geomatys.

the class XmlObservationReader method getPhenomenonNames.

private Collection<String> getPhenomenonNames() throws DataStoreException {
    final Set<String> phenomenons = new HashSet<>();
    for (Object xmlObject : xmlObjects) {
        if (xmlObject instanceof ObservationCollection) {
            final ObservationCollection collection = (ObservationCollection) xmlObject;
            for (Observation obs : collection.getMember()) {
                final AbstractObservation o = (AbstractObservation) obs;
                final PhenomenonProperty phenProp = o.getPropertyObservedProperty();
                phenomenons.addAll(OMUtils.getPhenomenonsFields(phenProp));
            }
        } else if (xmlObject instanceof AbstractObservation) {
            final AbstractObservation obs = (AbstractObservation) xmlObject;
            final PhenomenonProperty phenProp = obs.getPropertyObservedProperty();
            phenomenons.addAll(OMUtils.getPhenomenonsFields(phenProp));
        }
    }
    return phenomenons;
}
Also used : Observation(org.opengis.observation.Observation) PhenomenonProperty(org.geotoolkit.swe.xml.PhenomenonProperty) ObservationCollection(org.opengis.observation.ObservationCollection) HashSet(java.util.HashSet)

Example 2 with PhenomenonProperty

use of org.geotoolkit.swe.xml.PhenomenonProperty in project geotoolkit by Geomatys.

the class AbstractObservationStore method getProcedures.

/**
 * {@inheritDoc }
 */
@Override
public List<ExtractionResult.ProcedureTree> getProcedures() throws DataStoreException {
    final List<ExtractionResult.ProcedureTree> result = new ArrayList<>();
    final List<Observation> observations = getAllObservations(new ArrayList<>());
    for (Observation obs : observations) {
        final AbstractObservation o = (AbstractObservation) obs;
        final Process proc = o.getProcedure();
        final ExtractionResult.ProcedureTree procedure = new ExtractionResult.ProcedureTree(proc.getHref(), proc.getName(), proc.getDescription(), "Component", "timeseries");
        if (!result.contains(procedure)) {
            result.add(procedure);
        }
        final PhenomenonProperty phenProp = o.getPropertyObservedProperty();
        final List<String> fields = OMUtils.getPhenomenonsFields(phenProp);
        for (String field : fields) {
            if (!procedure.fields.contains(field)) {
                procedure.fields.add(field);
            }
        }
        procedure.spatialBound.appendLocation(obs.getSamplingTime(), obs.getFeatureOfInterest());
        procedure.spatialBound.getHistoricalLocations().putAll(getSensorLocations(proc.getHref(), "2.0.0"));
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) Process(org.geotoolkit.observation.xml.Process) Observation(org.opengis.observation.Observation) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) PhenomenonProperty(org.geotoolkit.swe.xml.PhenomenonProperty) ExtractionResult(org.geotoolkit.observation.model.ExtractionResult)

Example 3 with PhenomenonProperty

use of org.geotoolkit.swe.xml.PhenomenonProperty in project geotoolkit by Geomatys.

the class XmlObservationReader method getPhenomenons.

@Override
public Collection<Phenomenon> getPhenomenons(final Map<String, Object> hints) throws DataStoreException {
    final Set<Phenomenon> phenomenons = new HashSet<>();
    String version = (String) hints.get(SOS_VERSION);
    Object identifierVal = hints.get(IDENTIFIER);
    List<String> identifiers = new ArrayList<>();
    if (identifierVal instanceof Collection) {
        identifiers.addAll((Collection<? extends String>) identifierVal);
    } else if (identifierVal instanceof String) {
        identifiers.add((String) identifierVal);
    }
    for (Object xmlObject : xmlObjects) {
        if (xmlObject instanceof ObservationCollection) {
            final ObservationCollection collection = (ObservationCollection) xmlObject;
            for (Observation obs : collection.getMember()) {
                final AbstractObservation o = (AbstractObservation) obs;
                final PhenomenonProperty phenProp = o.getPropertyObservedProperty();
                final Phenomenon ph = OMUtils.getPhenomenon(phenProp);
                if (ph instanceof org.geotoolkit.swe.xml.Phenomenon) {
                    org.geotoolkit.swe.xml.Phenomenon phe = (org.geotoolkit.swe.xml.Phenomenon) ph;
                    if (identifiers.isEmpty() || identifiers.contains(phe.getName().getCode())) {
                        phenomenons.add(ph);
                    }
                }
            }
        } else if (xmlObject instanceof AbstractObservation) {
            final AbstractObservation obs = (AbstractObservation) xmlObject;
            final PhenomenonProperty phenProp = obs.getPropertyObservedProperty();
            final Phenomenon ph = OMUtils.getPhenomenon(phenProp);
            if (ph instanceof org.geotoolkit.swe.xml.Phenomenon) {
                org.geotoolkit.swe.xml.Phenomenon phe = (org.geotoolkit.swe.xml.Phenomenon) ph;
                if (identifiers.isEmpty() || identifiers.contains(phe.getName().getCode())) {
                    phenomenons.add(ph);
                }
            }
        }
    }
    return phenomenons;
}
Also used : ArrayList(java.util.ArrayList) org.geotoolkit.observation.xml(org.geotoolkit.observation.xml) Observation(org.opengis.observation.Observation) PhenomenonProperty(org.geotoolkit.swe.xml.PhenomenonProperty) Phenomenon(org.opengis.observation.Phenomenon) Collection(java.util.Collection) ObservationCollection(org.opengis.observation.ObservationCollection) ObservationCollection(org.opengis.observation.ObservationCollection) HashSet(java.util.HashSet)

Example 4 with PhenomenonProperty

use of org.geotoolkit.swe.xml.PhenomenonProperty in project geotoolkit by Geomatys.

the class AbstractObservationStore method getResults.

/**
 * {@inheritDoc }
 */
@Override
public ExtractionResult getResults(final String affectedSensorId, final List<String> sensorIDs, Set<Phenomenon> phenomenons, final Set<org.opengis.observation.sampling.SamplingFeature> samplingFeatures) throws DataStoreException {
    if (affectedSensorId != null) {
        LOGGER.warning("This ObservationStore does not allow to override sensor ID");
    }
    final ExtractionResult result = new ExtractionResult();
    result.spatialBound.initBoundary();
    final List<Observation> observations = getAllObservations(sensorIDs);
    for (Observation obs : observations) {
        final AbstractObservation o = (AbstractObservation) obs;
        final Process proc = o.getProcedure();
        final ExtractionResult.ProcedureTree procedure = new ExtractionResult.ProcedureTree(proc.getHref(), proc.getName(), proc.getDescription(), "Component", "timeseries");
        if (sensorIDs == null || sensorIDs.contains(procedure.id)) {
            if (!result.procedures.contains(procedure)) {
                result.procedures.add(procedure);
            }
            final PhenomenonProperty phenProp = o.getPropertyObservedProperty();
            final List<String> fields = OMUtils.getPhenomenonsFields(phenProp);
            for (String field : fields) {
                if (!result.fields.contains(field)) {
                    result.fields.add(field);
                }
            }
            final Phenomenon phen = OMUtils.getPhenomenon(phenProp);
            if (!result.phenomenons.contains(phen)) {
                result.phenomenons.add(phen);
            }
            result.spatialBound.appendLocation(o.getSamplingTime(), o.getFeatureOfInterest());
            procedure.spatialBound.appendLocation(o.getSamplingTime(), o.getFeatureOfInterest());
            procedure.spatialBound.getHistoricalLocations().putAll(getSensorLocations(o.getProcedure().getHref(), "2.0.0"));
            result.observations.add(o);
        }
    }
    return result;
}
Also used : Observation(org.opengis.observation.Observation) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) PhenomenonProperty(org.geotoolkit.swe.xml.PhenomenonProperty) Phenomenon(org.opengis.observation.Phenomenon) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) Process(org.geotoolkit.observation.xml.Process) ExtractionResult(org.geotoolkit.observation.model.ExtractionResult)

Aggregations

PhenomenonProperty (org.geotoolkit.swe.xml.PhenomenonProperty)4 Observation (org.opengis.observation.Observation)4 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ExtractionResult (org.geotoolkit.observation.model.ExtractionResult)2 AbstractObservation (org.geotoolkit.observation.xml.AbstractObservation)2 Process (org.geotoolkit.observation.xml.Process)2 ObservationCollection (org.opengis.observation.ObservationCollection)2 Phenomenon (org.opengis.observation.Phenomenon)2 Collection (java.util.Collection)1 org.geotoolkit.observation.xml (org.geotoolkit.observation.xml)1