Search in sources :

Example 1 with Observation

use of org.opengis.observation.Observation 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 Observation

use of org.opengis.observation.Observation in project geotoolkit by Geomatys.

the class XmlObservationReader method getFeatureOfInterest.

@Override
public SamplingFeature getFeatureOfInterest(final String samplingFeatureName, final String version) throws DataStoreException {
    for (Object xmlObject : xmlObjects) {
        if (xmlObject instanceof ObservationCollection) {
            final ObservationCollection collection = (ObservationCollection) xmlObject;
            for (Observation obs : collection.getMember()) {
                final AbstractObservation o = (AbstractObservation) obs;
                final FeatureProperty foiProp = o.getPropertyFeatureOfInterest();
                if (foiProp != null && foiProp.getAbstractFeature() != null && foiProp.getAbstractFeature().getId() != null && foiProp.getAbstractFeature().getId().equals(samplingFeatureName)) {
                    return (SamplingFeature) foiProp.getAbstractFeature();
                }
            }
        } else if (xmlObject instanceof AbstractObservation) {
            final AbstractObservation obs = (AbstractObservation) xmlObject;
            final FeatureProperty foiProp = obs.getPropertyFeatureOfInterest();
            if (foiProp != null && foiProp.getAbstractFeature() != null && foiProp.getAbstractFeature().getId() != null && foiProp.getAbstractFeature().getId().equals(samplingFeatureName)) {
                return (SamplingFeature) foiProp.getAbstractFeature();
            }
        }
    }
    return null;
}
Also used : Observation(org.opengis.observation.Observation) SamplingFeature(org.opengis.observation.sampling.SamplingFeature) FeatureProperty(org.geotoolkit.gml.xml.FeatureProperty) ObservationCollection(org.opengis.observation.ObservationCollection)

Example 3 with Observation

use of org.opengis.observation.Observation 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 4 with Observation

use of org.opengis.observation.Observation in project geotoolkit by Geomatys.

the class XmlObservationReader method getFeatureOfInterestNames.

private Collection<String> getFeatureOfInterestNames() throws DataStoreException {
    final Set<String> featureOfInterest = 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 FeatureProperty foiProp = o.getPropertyFeatureOfInterest();
                featureOfInterest.add(OMUtils.getFOIId(foiProp));
            }
        } else if (xmlObject instanceof AbstractObservation) {
            final AbstractObservation obs = (AbstractObservation) xmlObject;
            final FeatureProperty foiProp = obs.getPropertyFeatureOfInterest();
            featureOfInterest.add(OMUtils.getFOIId(foiProp));
        }
    }
    return featureOfInterest;
}
Also used : Observation(org.opengis.observation.Observation) FeatureProperty(org.geotoolkit.gml.xml.FeatureProperty) ObservationCollection(org.opengis.observation.ObservationCollection) HashSet(java.util.HashSet)

Example 5 with Observation

use of org.opengis.observation.Observation 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)

Aggregations

Observation (org.opengis.observation.Observation)9 ObservationCollection (org.opengis.observation.ObservationCollection)5 HashSet (java.util.HashSet)4 AbstractObservation (org.geotoolkit.observation.xml.AbstractObservation)4 PhenomenonProperty (org.geotoolkit.swe.xml.PhenomenonProperty)4 ExtractionResult (org.geotoolkit.observation.model.ExtractionResult)3 Process (org.geotoolkit.observation.xml.Process)3 ArrayList (java.util.ArrayList)2 FeatureProperty (org.geotoolkit.gml.xml.FeatureProperty)2 org.geotoolkit.observation.xml (org.geotoolkit.observation.xml)2 Phenomenon (org.opengis.observation.Phenomenon)2 Collection (java.util.Collection)1 AbstractFeature (org.geotoolkit.gml.xml.AbstractFeature)1 BoundingShape (org.geotoolkit.gml.xml.BoundingShape)1 Envelope (org.geotoolkit.gml.xml.Envelope)1 SamplingFeature (org.opengis.observation.sampling.SamplingFeature)1