From 4910092ee26b85d72081367ab9cc0aaca3472629 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Wed, 26 Feb 2014 15:55:38 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@92339 82a268e6-3cf1-43bd-a215-b396298e98cf --- ...sformations.java => VectorOperations.java} | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) rename src/main/java/org/gcube/dataanalysis/geo/utils/{VectorTransformations.java => VectorOperations.java} (61%) diff --git a/src/main/java/org/gcube/dataanalysis/geo/utils/VectorTransformations.java b/src/main/java/org/gcube/dataanalysis/geo/utils/VectorOperations.java similarity index 61% rename from src/main/java/org/gcube/dataanalysis/geo/utils/VectorTransformations.java rename to src/main/java/org/gcube/dataanalysis/geo/utils/VectorOperations.java index 5e29e9b..ffec983 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/utils/VectorTransformations.java +++ b/src/main/java/org/gcube/dataanalysis/geo/utils/VectorOperations.java @@ -10,7 +10,7 @@ import ucar.ma2.ArrayByte; import ucar.ma2.ArrayDouble; import ucar.ma2.IndexIterator; -public class VectorTransformations { +public class VectorOperations { public static ArrayDouble.D2 arrayByte2DArrayDouble(ArrayByte bytes) { int[] shapeD = bytes.getShape(); @@ -62,6 +62,9 @@ public class VectorTransformations { valuesForGrid.add(Double.NaN); } +// AnalysisLogger.getLogger().debug("Grid contains: "+grid3d.size()+" values"); +// AnalysisLogger.getLogger().debug("Dataset contains: "+coordinates5d.size()+" values"); + for (Tuple coord5d : coordinates5d) { double rx = coord5d.getElements().get(0); double ry = coord5d.getElements().get(1); @@ -92,4 +95,35 @@ public class VectorTransformations { return Math.sqrt(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2)) + ((t1 - t2) * (t1 - t2))); } + + public static List> generateCoordinateTripletsInBoundingBox(double x1, double x2, double y1, double y2, double z, double xResolution, double yResolution) { + + int ysteps = (int) ((y2 - y1) / yResolution); + int xsteps = (int) ((x2 - x1) / xResolution); + List> tuples = new ArrayList>(); + AnalysisLogger.getLogger().debug("Building the points grid according to YRes:" + yResolution + " and XRes:" + xResolution); + // build the tuples according to the desired resolution + for (int i = 0; i < ysteps + 1; i++) { + double y = (i * yResolution) + y1; + if (i == ysteps) + y = y2; + for (int j = 0; j < xsteps + 1; j++) { + double x = (j * xResolution) + x1; + if (j == xsteps) + x = x2; + tuples.add(new Tuple(x, y, z)); + } + } + return tuples; + } + + public void applyNearestNeighbor() { + + /* + * 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