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