From 4afdf7cebbb1a065bf2d711b73001670a4f1c1e2 Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 21 Sep 2023 13:35:48 +0200 Subject: [PATCH 1/2] Fix issue 840 (workflow stops when only the zone is only sea --- .../geoindicators/RsuIndicators.groovy | 12 +++ osm/classpath.index | Bin 0 -> 780 bytes .../geoclimate/osm/WorflowOSMTest.groovy | 98 +++++++++++++++++- .../osm/WorkflowAbstractTest.groovy | 23 ++-- .../geoclimate/osm/ZONE_ONLY_SEA.geojson | 1 + 5 files changed, 125 insertions(+), 9 deletions(-) create mode 100644 osm/classpath.index create mode 100644 osm/src/test/resources/org/orbisgis/geoclimate/osm/ZONE_ONLY_SEA.geojson diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index 6e066120f1..13a1fb755e 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -1469,6 +1469,18 @@ String smallestCommunGeometry(JdbcDataSource datasource, String zone, String id_ MAX(BUILDING) AS BUILDING, MAX(RAIL) AS RAIL, ${id_zone} FROM $allInfoTableName GROUP BY ${ID_COLUMN_NAME}, ${id_zone}; DROP TABLE IF EXISTS ${tablesToMerge.keySet().join(' , ')}, ${allInfoTableName}, ${tmpTablesToDrop.join(",")}""".toString() } + else{ + datasource """DROP TABLE IF EXISTS $outputTableName; + CREATE TABLE $outputTableName(AREA DOUBLE, + LOW_VEGETATION INTEGER, + HIGH_VEGETATION INTEGER, + WATER INTEGER, + IMPERVIOUS INTEGER, + ROAD INTEGER, + BUILDING INTEGER, + RAIL INTEGER, + ${id_zone} INTEGER)""" + } } else { error """Cannot compute the smallest geometries""" diff --git a/osm/classpath.index b/osm/classpath.index new file mode 100644 index 0000000000000000000000000000000000000000..21477a06729a01abbc7d410f89a349e270261545 GIT binary patch literal 780 zcmb1OU}9ikPzByt1Rgd$TGM9~7a#xs`MSD7pKD>W_F2}s-v0wLFN9rh%8#h%eF67G zp9fZ}X8KA9zMK7>N$n)x`UzXoE;V_sIP>3cithrLy-qiO)yaIdQg`xK@h{#!(RVNF z6?@KtKbgDV?Y=)@^|~Equ9Z4}g~}a_pQP@%AHE^oD7N6jy5=0YjVEO7L|^^l)sz0v zD3`YL`J^VcprB#Fo-RZoWTMV@vpEx+BCn@#a(s776u0K{R|B1M;RD; zQy3V|#{u=#hTSbX!@$6_9mwDQ;mx_P(pR1WU0YpR#wNezP3%6m)!!4pGBDJXTk`RQ zHBSVYezH>IS7IX2{Xy&(85p)#m07GwSgTdVnOexeAXx#n|MHRSxgV1*GcafdORZEn z913(@&xxHt-BC%^&A+1yk|)|R@|}8fd5vL>?B03&i|W7mK7D$1{?GL*%y;$~oSn@I z3^Smu6YKBD&B&kI-YEZQ-WK+I@elvrUHbLw{%v#e!-T#pWnfr)oq^#G&{wg`KYYE> z%D`}7O;771*CT6RpJiZZdV7F%hB`1T{{3{_Ii>Y4$Xzd|berCd-EHz#)#%wbm2 0) + if (!onlySea){ + assertTrue(datasource.getSpatialTable(buildingIndicators).srid > 0) + } if (saveResults) { logger.debug("Saving building indicators") datasource.getSpatialTable(buildingIndicators).save(directory + File.separator + "${buildingIndicators}.geojson", true) @@ -102,7 +107,9 @@ class WorkflowAbstractTest { def countRelationBlocks = datasource.firstRow("select count(*) as count from ${relationBlocks}".toString()) def countBlocksIndicators = datasource.firstRow("select count(*) as count from ${blockIndicators}".toString()) assertEquals(countRelationBlocks.count, countBlocksIndicators.count) - assertTrue(datasource.getSpatialTable(blockIndicators).srid > 0) + if (!onlySea){ + assertTrue(datasource.getSpatialTable(blockIndicators).srid > 0) + } } Map parameters = Geoindicators.WorkflowGeoIndicators.getParameters(["indicatorUse": indicatorUse, "svfSimplified": svfSimplified]) @@ -112,7 +119,7 @@ class WorkflowAbstractTest { vegetationTableName, roadTableName, hydrographicTableName, - null, railTableName, + imperviousTableName, railTableName, parameters, prefixName) assert rsuIndicators diff --git a/osm/src/test/resources/org/orbisgis/geoclimate/osm/ZONE_ONLY_SEA.geojson b/osm/src/test/resources/org/orbisgis/geoclimate/osm/ZONE_ONLY_SEA.geojson new file mode 100644 index 0000000000..b0bd8ab765 --- /dev/null +++ b/osm/src/test/resources/org/orbisgis/geoclimate/osm/ZONE_ONLY_SEA.geojson @@ -0,0 +1 @@ +{"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::32633"}},"features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[668159.840844761,3652725.8675869787],[667779.2423065485,3674902.6933475523],[686424.2826395712,3675241.3737045107],[686847.2227853552,3653063.5042925826],[668159.840844761,3652725.8675869787]]]},"properties":{"ID_ZONE":"[33, 16.8, 33.2, 17]"}}]} \ No newline at end of file From d7c620d44a205638f431d94416013dc3ff9bcaec Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 21 Sep 2023 14:21:21 +0200 Subject: [PATCH 2/2] add double precision in fix --- .../org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy index 13a1fb755e..da1c592f7a 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/RsuIndicators.groovy @@ -1471,7 +1471,7 @@ String smallestCommunGeometry(JdbcDataSource datasource, String zone, String id_ } else{ datasource """DROP TABLE IF EXISTS $outputTableName; - CREATE TABLE $outputTableName(AREA DOUBLE, + CREATE TABLE $outputTableName(AREA DOUBLE PRECISION, LOW_VEGETATION INTEGER, HIGH_VEGETATION INTEGER, WATER INTEGER,