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