Search in sources :

Example 1 with ObservationCollection

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

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

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

use of org.opengis.observation.ObservationCollection 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 5 with ObservationCollection

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

the class XmlObservationReader method getProcedureNames.

private Collection<String> getProcedureNames(String sensorType) throws DataStoreException {
    // no filter yet
    final Set<String> names = new HashSet<>();
    for (Object xmlObject : xmlObjects) {
        if (xmlObject instanceof ObservationCollection) {
            final ObservationCollection collection = (ObservationCollection) xmlObject;
            for (Observation obs : collection.getMember()) {
                final org.geotoolkit.observation.xml.Process process = (Process) obs.getProcedure();
                names.add(process.getHref());
            }
        } else if (xmlObject instanceof Observation) {
            final Observation obs = (Observation) xmlObject;
            final Process process = (Process) obs.getProcedure();
            names.add(process.getHref());
        }
    }
    return names;
}
Also used : org.geotoolkit.observation.xml(org.geotoolkit.observation.xml) Process(org.geotoolkit.observation.xml.Process) Observation(org.opengis.observation.Observation) Process(org.geotoolkit.observation.xml.Process) ObservationCollection(org.opengis.observation.ObservationCollection) HashSet(java.util.HashSet)

Aggregations

Observation (org.opengis.observation.Observation)5 ObservationCollection (org.opengis.observation.ObservationCollection)5 HashSet (java.util.HashSet)4 FeatureProperty (org.geotoolkit.gml.xml.FeatureProperty)2 org.geotoolkit.observation.xml (org.geotoolkit.observation.xml)2 PhenomenonProperty (org.geotoolkit.swe.xml.PhenomenonProperty)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Process (org.geotoolkit.observation.xml.Process)1 Phenomenon (org.opengis.observation.Phenomenon)1 SamplingFeature (org.opengis.observation.sampling.SamplingFeature)1