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;
}
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;
}
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");
}
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;
}
Aggregations