Search in sources :

Example 6 with Observation

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

Example 7 with Observation

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

Example 8 with Observation

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

the class AbstractObservationStore method getTemporalBounds.

/**
 * {@inheritDoc }
 */
@Override
public TemporalGeometricPrimitive getTemporalBounds() throws DataStoreException {
    final ExtractionResult result = new ExtractionResult();
    result.spatialBound.initBoundary();
    final List<Observation> observations = getAllObservations(new ArrayList<>());
    for (Observation obs : observations) {
        result.spatialBound.addTime(obs.getSamplingTime());
    }
    return result.spatialBound.getTimeObject("2.0.0");
}
Also used : Observation(org.opengis.observation.Observation) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) ExtractionResult(org.geotoolkit.observation.model.ExtractionResult)

Example 9 with Observation

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

the class OMUtils method getCollectionBound.

/**
 * Return an envelope containing all the Observation member of the collection.
 *
 * @param version
 * @param observations
 * @param srsName
 * @return
 */
public static Envelope getCollectionBound(final String version, final List<Observation> observations, final String srsName) {
    double minx = Double.MAX_VALUE;
    double miny = Double.MAX_VALUE;
    double maxx = -Double.MAX_VALUE;
    double maxy = -Double.MAX_VALUE;
    for (Observation observation : observations) {
        final AbstractFeature feature = (AbstractFeature) observation.getFeatureOfInterest();
        if (feature != null) {
            if (feature.getBoundedBy() != null) {
                final BoundingShape bound = feature.getBoundedBy();
                if (bound.getEnvelope() != null) {
                    if (bound.getEnvelope().getLowerCorner() != null && bound.getEnvelope().getLowerCorner().getCoordinate() != null && bound.getEnvelope().getLowerCorner().getCoordinate().length == 2) {
                        final double[] lower = bound.getEnvelope().getLowerCorner().getCoordinate();
                        if (lower[0] < minx) {
                            minx = lower[0];
                        }
                        if (lower[1] < miny) {
                            miny = lower[1];
                        }
                    }
                    if (bound.getEnvelope().getUpperCorner() != null && bound.getEnvelope().getUpperCorner().getCoordinate() != null && bound.getEnvelope().getUpperCorner().getCoordinate().length == 2) {
                        final double[] upper = bound.getEnvelope().getUpperCorner().getCoordinate();
                        if (upper[0] > maxx) {
                            maxx = upper[0];
                        }
                        if (upper[1] > maxy) {
                            maxy = upper[1];
                        }
                    }
                }
            }
        }
    }
    if (minx == Double.MAX_VALUE) {
        minx = -180.0;
    }
    if (miny == Double.MAX_VALUE) {
        miny = -90.0;
    }
    if (maxx == (-Double.MAX_VALUE)) {
        maxx = 180.0;
    }
    if (maxy == (-Double.MAX_VALUE)) {
        maxy = 90.0;
    }
    final Envelope env = SOSXmlFactory.buildEnvelope(version, null, minx, miny, maxx, maxy, srsName);
    env.setSrsDimension(2);
    env.setAxisLabels(Arrays.asList("Y X"));
    return env;
}
Also used : BoundingShape(org.geotoolkit.gml.xml.BoundingShape) Observation(org.opengis.observation.Observation) AbstractObservation(org.geotoolkit.observation.xml.AbstractObservation) AbstractFeature(org.geotoolkit.gml.xml.AbstractFeature) Envelope(org.geotoolkit.gml.xml.Envelope)

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