From 4e6addb87f4e1023fb207771c95a4aea49b7cae7 Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Tue, 10 Feb 2015 18:50:16 +0000 Subject: [PATCH] adjusted order by and limitations git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@111875 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../dataanalysis/geo/algorithms/CSquaresCreator.java | 10 +++++----- .../geo/algorithms/FAOOceanAreaCreator.java | 2 +- .../geo/algorithms/FAOOceanAreaCreatorQuadrant.java | 2 +- .../geo/test/TestCSquareCodesCreator.java | 11 ++++++++--- .../geo/test/TestFAOAreaCodesQuadrantCreator.java | 2 +- .../dataanalysis/geo/utils/CSquareCodesConverter.java | 4 +++- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gcube/dataanalysis/geo/algorithms/CSquaresCreator.java b/src/main/java/org/gcube/dataanalysis/geo/algorithms/CSquaresCreator.java index 14396f6..48f8a40 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/algorithms/CSquaresCreator.java +++ b/src/main/java/org/gcube/dataanalysis/geo/algorithms/CSquaresCreator.java @@ -103,7 +103,7 @@ public class CSquaresCreator extends StandardLocalExternalAlgorithm { String x = IOHelper.getInputParameter(config, xDim); String y = IOHelper.getInputParameter(config, yDim); - String select = "select *," + x + "," + y + " from " + table + " order by " + x + " limit " + limit + " offset " + offset; + String select = "select *," + x + " as loforcs01," + y + " as laforcs01 from " + table + " limit " + limit + " offset " + offset; return select; } @@ -161,14 +161,14 @@ public class CSquaresCreator extends StandardLocalExternalAlgorithm { while (true) { String select = selectInformationForTransformation(config, table, limit, initIdx); - AnalysisLogger.getLogger().debug("CodeCreator: from " + initIdx + " to " + (initIdx + limit)); + AnalysisLogger.getLogger().debug("CodeCreator: from " + initIdx + " to " + (initIdx + limit) + " limit "+limit); List rows = DatabaseFactory.executeSQLQuery(select, connection); - + if (rows == null || rows.size() == 0) { AnalysisLogger.getLogger().debug("CodeCreator: no more rows"); break; } - AnalysisLogger.getLogger().debug("CodeCreator: transforming"); + AnalysisLogger.getLogger().debug("CodeCreator: transforming "); // take x and y List stringrows = new ArrayList(); for (Object row : rows) { @@ -187,7 +187,7 @@ public class CSquaresCreator extends StandardLocalExternalAlgorithm { AnalysisLogger.getLogger().debug("CSquareCreator: inserting chunks into the table"); // write the vector into the table DatabaseUtils.insertChunksIntoTable(outTable, colnames.toString(), stringrows, limit, connection, true); - initIdx += limit; + initIdx = initIdx+limit; status = Math.min(90, 20 + (70 * initIdx / maxRows)); AnalysisLogger.getLogger().debug("CSquareCreator: status " + status); } diff --git a/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreator.java b/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreator.java index b0bdeaf..0017d83 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreator.java +++ b/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreator.java @@ -46,7 +46,7 @@ public class FAOOceanAreaCreator extends CSquaresCreator { String x = IOHelper.getInputParameter(config, xDim); String y = IOHelper.getInputParameter(config, yDim); - String select = "select *," + x + "," + y + " from " + table + " order by " + x + " limit " + limit + " offset " + offset; + String select = "select *," + x + " as loforcs01," + y + " as laforcs01 from " + table + " limit " + limit + " offset " + offset; return select; } diff --git a/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreatorQuadrant.java b/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreatorQuadrant.java index d9665c0..6fd811c 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreatorQuadrant.java +++ b/src/main/java/org/gcube/dataanalysis/geo/algorithms/FAOOceanAreaCreatorQuadrant.java @@ -52,7 +52,7 @@ public class FAOOceanAreaCreatorQuadrant extends FAOOceanAreaCreator { String y = IOHelper.getInputParameter(config, yDim); String quadrant = IOHelper.getInputParameter(config, quadrantDim); - String select = "select *," + x + "," + y +","+quadrant+ " from " + table + " order by " + x + " limit " + limit + " offset " + offset; + String select = "select *," + x + " as loforcs01," + y +" as laforcs01,"+quadrant+ " from " + table + " limit " + limit + " offset " + offset; return select; } @Override diff --git a/src/main/java/org/gcube/dataanalysis/geo/test/TestCSquareCodesCreator.java b/src/main/java/org/gcube/dataanalysis/geo/test/TestCSquareCodesCreator.java index a08941f..e2c34dd 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/test/TestCSquareCodesCreator.java +++ b/src/main/java/org/gcube/dataanalysis/geo/test/TestCSquareCodesCreator.java @@ -22,10 +22,15 @@ public class TestCSquareCodesCreator { config.setParam("DatabaseURL", "jdbc:postgresql://statistical-manager.d.d4science.research-infrastructures.eu/testdb"); config.setParam("DatabaseDriver", "org.postgresql.Driver"); - config.setParam("Longitude_Column", "centerlong"); - config.setParam("Latitude_Column", "centerlat"); +// config.setParam("Longitude_Column", "centerlong"); +// config.setParam("Latitude_Column", "centerlat"); // config.setParam("InputTable", "interp_2024_linear_01355325354899"); - config.setParam("InputTable", "interp_2036_linear_11384851795640"); +// config.setParam("InputTable", "interp_2036_linear_11384851795640"); + + config.setParam("Longitude_Column", "center_long"); + config.setParam("Latitude_Column", "center_lat"); + config.setParam("InputTable", "generic_ide4573b63_b955_4bbc_b83f_579ff3f0858f"); + config.setParam("OutputTableName", "csqout"); config.setParam("CSquare_Resolution", "0.5"); diff --git a/src/main/java/org/gcube/dataanalysis/geo/test/TestFAOAreaCodesQuadrantCreator.java b/src/main/java/org/gcube/dataanalysis/geo/test/TestFAOAreaCodesQuadrantCreator.java index 39185dd..a29168e 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/test/TestFAOAreaCodesQuadrantCreator.java +++ b/src/main/java/org/gcube/dataanalysis/geo/test/TestFAOAreaCodesQuadrantCreator.java @@ -18,7 +18,7 @@ public class TestFAOAreaCodesQuadrantCreator { config.setParam("DatabaseURL", "jdbc:postgresql://statistical-manager.d.d4science.research-infrastructures.eu/testdb"); config.setParam("DatabaseDriver", "org.postgresql.Driver"); - config.setParam("Quadrant_column", "quadrant"); + config.setParam("Quadrant_Column", "quadrant"); config.setParam("Longitude_Column", "long"); config.setParam("Latitude_Column", "lat"); config.setParam("InputTable", "generic_id6ef3e4fa_6a06_4df1_9445_553f2e918102"); diff --git a/src/main/java/org/gcube/dataanalysis/geo/utils/CSquareCodesConverter.java b/src/main/java/org/gcube/dataanalysis/geo/utils/CSquareCodesConverter.java index 06fcdf0..f56726c 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/utils/CSquareCodesConverter.java +++ b/src/main/java/org/gcube/dataanalysis/geo/utils/CSquareCodesConverter.java @@ -32,7 +32,9 @@ public class CSquareCodesConverter { // System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(-49.99999999999994,35.75000000000006, 1)); // System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(35.75000000000006,-49.99999999999994, 0.5)); // System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(35.75,-50, 0.5)); - System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(35.7500,-49.9999, 0.5)); +// System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(0.75,31.25, 0.5)); + //System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(31.25, 0.75,0.1)); + System.out.println(it.cnr.aquamaps.CSquare.centroidToCode(0.75,31.25, 0.1)); } }