From 70931d99609be0a95cc0cae807df9d042fb99cd3 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Fri, 3 May 2013 09:28:20 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@74469 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../geo/retrieval/GeoIntersector.java | 55 ++++++++++++------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/geo/retrieval/GeoIntersector.java b/src/main/java/org/gcube/dataanalysis/geo/retrieval/GeoIntersector.java index cc6bcea..243b829 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/retrieval/GeoIntersector.java +++ b/src/main/java/org/gcube/dataanalysis/geo/retrieval/GeoIntersector.java @@ -58,8 +58,8 @@ public class GeoIntersector { return features; } - public List> getFeaturesInTime(String layerTitle, List> triplets) throws Exception { - List> featuresSets = new ArrayList>(); + public List getFeaturesInTimeInstant(String layerTitle, int time, List> triplets, double xL,double xR, double yL, double yR) throws Exception { + List features = new ArrayList(); // get the layer Metadata meta = featurer.checkForMetadatabyTitle(FeaturesManager.treatTitleForGN(layerTitle), layerTitle); // if the layer is good @@ -72,6 +72,8 @@ public class GeoIntersector { Identification id = meta.getIdentificationInfo().iterator().next(); String title = id.getCitation().getTitle().toString(); AnalysisLogger.getLogger().debug("found a netCDF file with title " + title + " and layer name " + layer); + features = getFeaturesFromNetCDF(featurer.getOpenDapLink(meta), layer, time, triplets, xL,xR, yL, yR); + /* for (Tuple triplet : triplets) { double x = triplet.getElements().get(0); double y = triplet.getElements().get(1); @@ -84,9 +86,11 @@ public class GeoIntersector { AnalysisLogger.getLogger().debug("Got: (" + features + ")"); featuresSets.add(features); } - + */ } else { + //TODO: adjust WFS take AnalysisLogger.getLogger().debug("found a Geo Layer with title " + layerTitle + " and layer name " + layer); + /* for (Tuple triplet : triplets) { double x = triplet.getElements().get(0); double y = triplet.getElements().get(1); @@ -95,12 +99,19 @@ public class GeoIntersector { features = getFeaturesFromWFS(featurer.getWFSLink(meta), layer, x, y); featuresSets.add(features); } + */ } } - - return featuresSets; + return features; } + private List getFeaturesFromNetCDF(String opendapURL, String layer, int time, List> triplets, double xL,double xR, double yL, double yR) { + if (opendapURL == null) + return null; + + return ThreddsDataExplorer.retrieveDataFromNetCDF(opendapURL, layer, time, triplets, xL,xR, yL, yR); + } + private LinkedHashMap getFeaturesFromNetCDF(String opendapURL, String layer, double x, double y, double z) { if (opendapURL == null) return null; @@ -140,52 +151,56 @@ public class GeoIntersector { } } - AnalysisLogger.getLogger().debug("Taking " + ysteps + " values..."); - List> time = getFeaturesInTime(layerTitle, tuples); + AnalysisLogger.getLogger().debug("Taking " + ysteps + " values per "+xsteps+"="+(ysteps*xsteps)+ "..."); + List time = getFeaturesInTimeInstant(layerTitle, 0, tuples, x1, x2, y1,y2); AnalysisLogger.getLogger().debug("Taken " + time.size() + " values"); // build back the values matrix int k = 0; int g = 0; - int ntriplets = ysteps * xsteps; + int ntriplets = time.size(); //cycle on all the triplets to recontruct the matrix for (int t = 0; t < ntriplets; t++) { //take the corresponding (time,value) pair - LinkedHashMap tvalues = time.get(t); + Double value = time.get(t); //if there is value, then set it, otherwise set NaN //the layer is undefined in that point and a value must be generated - double value = Double.NaN; - for (Double val : tvalues.values()) { - value = val; - break; - } //assign a value to the matrix slice[k][g] = value; //increase the x step according to the matrix - g++; if (g == xsteps) { g = 0; k++; } + else + g++; } AnalysisLogger.getLogger().debug("Applying nearest Neighbor to all the rows"); //apply nearest neighbor to each row AlgorithmConfiguration config = new AlgorithmConfiguration(); config.setConfigPath(configDir); + boolean rapidinit = false; for (int i=0;i