Gianpaolo Coro 2013-04-30 10:03:08 +00:00
parent 337ab50ad6
commit c66109c505
1 changed files with 69 additions and 24 deletions

View File

@ -1,9 +1,12 @@
package org.gcube.dataanalysis.geo.retrieval;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.contentmanagement.lexicalmatcher.utils.AnalysisLogger;
import org.gcube.dataanalysis.ecoengine.configuration.AlgorithmConfiguration;
import org.gcube.dataanalysis.ecoengine.utils.Tuple;
import org.gcube.dataanalysis.geo.meta.features.FeaturesManager;
import org.gcube.dataanalysis.geo.utils.EnvDataExplorer;
import org.gcube.dataanalysis.geo.utils.ThreddsDataExplorer;
@ -22,33 +25,74 @@ public class GeoIntersector {
public LinkedHashMap<String, Double> getFeaturesInTime(String layerTitle, double x, double y) throws Exception {
return getFeaturesInTime(layerTitle, x, y, 0);
}
public LinkedHashMap<String, Double> getFeaturesInTime(String layerTitle, double x, double y, double z) throws Exception {
LinkedHashMap<String, Double> features = new LinkedHashMap<String, Double>();
// get the layer
// Metadata meta = featurer.getGNInfobyTitle(layerTitle);
Metadata meta = featurer.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerTitle),layerTitle);
// Metadata meta = featurer.getGNInfobyTitle(layerTitle);
Metadata meta = featurer.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerTitle), layerTitle);
// if the layer is good
if (meta != null) {
String layer = featurer.getLayerName(meta);
if (layer == null)
if (layer == null)
layer = layerTitle;
// check if it is a NetCDF
if (featurer.isThreddsFile(meta)) {
Identification id = meta.getIdentificationInfo().iterator().next();
String title = id.getCitation().getTitle().toString();
System.out.println("found a netCDF file with title " +title +" and layer name "+layer);
// check if it is a NetCDF
if (featurer.isThreddsFile(meta)) {
Identification id = meta.getIdentificationInfo().iterator().next();
String title = id.getCitation().getTitle().toString();
System.out.println("found a netCDF file with title " + title + " and layer name " + layer);
features = getFeaturesFromNetCDF(featurer.getOpenDapLink(meta), layer, x, y, z);
} else {
System.out.println("found a Geo Layer with title " + layerTitle + " and layer name " + layer);
features = getFeaturesFromWFS(featurer.getWFSLink(meta), layer, x, y);
}
}
return features;
}
public List<LinkedHashMap<String, Double>> getFeaturesInTime(String layerTitle, List<Tuple<Double>> triplets) throws Exception {
List<LinkedHashMap<String, Double>> featuresSets = new ArrayList<LinkedHashMap<String, Double>>();
// get the layer
Metadata meta = featurer.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerTitle), layerTitle);
// if the layer is good
if (meta != null) {
String layer = featurer.getLayerName(meta);
if (layer == null)
layer = layerTitle;
// check if it is a NetCDF
if (featurer.isThreddsFile(meta)) {
Identification id = meta.getIdentificationInfo().iterator().next();
String title = id.getCitation().getTitle().toString();
System.out.println("found a netCDF file with title " + title + " and layer name " + layer);
for (Tuple<Double> triplet : triplets) {
double x = triplet.getElements().get(0);
double y = triplet.getElements().get(1);
double z = 0;
if (triplet.getElements().size() > 2)
z = triplet.getElements().get(2);
LinkedHashMap<String, Double> features = new LinkedHashMap<String, Double>();
features = getFeaturesFromNetCDF(featurer.getOpenDapLink(meta), layer, x, y, z);
} else {
System.out.println("found a Geo Layer with title " + layerTitle+" and layer name "+layer);
featuresSets.add(features);
}
} else {
System.out.println("found a Geo Layer with title " + layerTitle + " and layer name " + layer);
for (Tuple<Double> triplet : triplets) {
double x = triplet.getElements().get(0);
double y = triplet.getElements().get(1);
LinkedHashMap<String, Double> features = new LinkedHashMap<String, Double>();
features = getFeaturesFromWFS(featurer.getWFSLink(meta), layer, x, y);
featuresSets.add(features);
}
}
return features;
}
return featuresSets;
}
private LinkedHashMap<String, Double> getFeaturesFromNetCDF(String opendapURL, String layer, double x, double y, double z) {
@ -64,14 +108,15 @@ public class GeoIntersector {
return EnvDataExplorer.getFeatures(wfsUrl, layer, x, y);
}
public static void main(String args[] ) throws Exception{
AnalysisLogger.setLogger("./cfg/"+AlgorithmConfiguration.defaultLoggerFile);
// GeoIntersector inters = new GeoIntersector("/gcube/devsec");
public static void main(String args[]) throws Exception {
AnalysisLogger.setLogger("./cfg/" + AlgorithmConfiguration.defaultLoggerFile);
// GeoIntersector inters = new GeoIntersector("/gcube/devsec");
GeoIntersector inters = new GeoIntersector(null);
// System.out.println(inters.getFeaturesInTime("temperature (04091217ruc.nc)", 0.1, 0.1));
System.out.println(inters.getFeaturesInTime("wind stress from [05-01-07 14:00] to [04-01-12 14:00] (2D) {CERSAT-GLO-CLIM_WIND_L4-OBS_FULL_TIME_SERIE_CLIMATOLOGY_METEOROLOGY_ATMOSPHERE_1366217956317.nc}", 0.1, 0.1,3000));
// System.out.println(inters.getFeaturesInTime("temperature (04091217ruc.nc)", 0.1, 0.1));
// System.out.println(inters.getFeaturesInTime("wind stress from [05-01-07 14:00] to [04-01-12 14:00] (2D) {Monthly ASCAT global wind field: Data extracted from dataset http://tds0.ifremer.fr/thredds/dodsC/CERSAT-GLO-CLIM_WIND_L4-OBS_FULL_TIME_SERIE}", 0.1, 0.1,3000));
System.out.println(inters.getFeaturesInTime("Statistical Mean in [07-01-01 01:00] (3D) {World Ocean Atlas 09: Sea Water Temperature - annual: dods://thredds.research-infrastructures.eu/thredds/dodsC/public/netcdf/temperature_annual_1deg_ENVIRONMENT_OCEANS_.nc}", -70, 0.1, 3000));
}
}