diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e49f6a3688..a41082d26e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1 +1,3 @@ ## Changelog for v1.0.1 + +- Upgrade dependencies H2, H2GIS, JTS and Groovy diff --git a/geoindicators/pom.xml b/geoindicators/pom.xml index 6a8225e9f2..65c461ebc7 100644 --- a/geoindicators/pom.xml +++ b/geoindicators/pom.xml @@ -9,7 +9,6 @@ 1.0.1-SNAPSHOT ../ - org.orbisgis.geoclimate geoindicators 1.0.1-SNAPSHOT diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GenericIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GenericIndicators.groovy index f093099421..92abeef4e9 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GenericIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GenericIndicators.groovy @@ -713,53 +713,54 @@ String typeProportion(JdbcDataSource datasource, String inputTableName, String i def outputTableName = prefix prefixName, BASE_NAME // Define the pieces of query according to each type of the input table - def queryCalc = "" - def queryCaseWh = "" + def queryCalc = [] + def queryCaseWh = [] // For the area fractions if (areaTypeAndComposition) { - queryCaseWh += " ST_AREA($GEOMETRIC_FIELD_LOW) AS AREA, " + queryCaseWh += " ST_AREA($GEOMETRIC_FIELD_LOW) AS AREA " areaTypeAndComposition.forEach { type, compo -> - queryCaseWh += "CASE WHEN $typeFieldName='${compo.join("' OR $typeFieldName='")}' THEN ST_AREA($GEOMETRIC_FIELD_LOW) END AS AREA_${type}," - queryCalc += "CASE WHEN SUM(AREA)=0 THEN 0 ELSE SUM(AREA_${type})/SUM(AREA) END AS AREA_FRACTION_${type}, " + queryCaseWh<< "CASE WHEN $typeFieldName='${compo.join("' OR $typeFieldName='")}' THEN ST_AREA($GEOMETRIC_FIELD_LOW) END AS AREA_${type}" + queryCalc << "CASE WHEN SUM(AREA)=0 THEN 0 ELSE SUM(AREA_${type})/SUM(AREA) END AS AREA_FRACTION_${type}" } } // For the floor area fractions in case the objects are buildings if (floorAreaTypeAndComposition) { - queryCaseWh += " ST_AREA($GEOMETRIC_FIELD_LOW)*$NB_LEV AS FLOOR_AREA, " + queryCaseWh << "ST_AREA($GEOMETRIC_FIELD_LOW)*$NB_LEV AS FLOOR_AREA" floorAreaTypeAndComposition.forEach { type, compo -> - queryCaseWh += "CASE WHEN $typeFieldName='${compo.join("' OR $typeFieldName='")}' THEN ST_AREA($GEOMETRIC_FIELD_LOW)*$NB_LEV END AS FLOOR_AREA_${type}," - queryCalc += "CASE WHEN SUM(FLOOR_AREA) =0 THEN 0 ELSE SUM(FLOOR_AREA_${type})/SUM(FLOOR_AREA) END AS FLOOR_AREA_FRACTION_${type}, " + queryCaseWh << "CASE WHEN $typeFieldName='${compo.join("' OR $typeFieldName='")}' THEN ST_AREA($GEOMETRIC_FIELD_LOW)*$NB_LEV END AS FLOOR_AREA_${type}" + queryCalc << "CASE WHEN SUM(FLOOR_AREA) =0 THEN 0 ELSE SUM(FLOOR_AREA_${type})/SUM(FLOOR_AREA) END AS FLOOR_AREA_FRACTION_${type} " } } // Calculates the surface of each object depending on its type datasource.execute """DROP TABLE IF EXISTS $caseWhenTab; CREATE TABLE $caseWhenTab - AS SELECT $idField, - ${queryCaseWh[0..-2]} + AS SELECT $idField + ${!queryCaseWh.isEmpty()?","+queryCaseWh.join(","):""} FROM $inputTableName""".toString() datasource.createIndex(caseWhenTab, idField) + // Calculate the proportion of each type - datasource.execute """DROP TABLE IF EXISTS $outputTableWithNull; + datasource.execute("""DROP TABLE IF EXISTS $outputTableWithNull; CREATE TABLE $outputTableWithNull - AS SELECT $idField, ${queryCalc[0..-2]} - FROM $caseWhenTab GROUP BY $idField""".toString() + AS SELECT $idField ${!queryCalc.isEmpty()?","+queryCalc.join(","):""} + FROM $caseWhenTab GROUP BY $idField""") // Set 0 as default value (for example if we characterize the building type in a RSU having no building...) def allFinalCol = datasource.getColumnNames(outputTableWithNull) allFinalCol = allFinalCol.minus([idField.toUpperCase()]) datasource.createIndex(inputUpperTableName, idField) datasource.createIndex(outputTableWithNull, idField) - def pieceOfQuery = "" + def pieceOfQuery = [] allFinalCol.each { col -> - pieceOfQuery += "COALESCE(a.$col, 0) AS $col, " + pieceOfQuery << "COALESCE(a.$col, 0) AS $col " } datasource """DROP TABLE IF EXISTS $outputTableName; CREATE TABLE $outputTableName - AS SELECT ${pieceOfQuery[0..-2]} + AS SELECT ${!pieceOfQuery.isEmpty()?pieceOfQuery.join(",")+",":""} b.$idField FROM $outputTableWithNull a RIGHT JOIN $inputUpperTableName b ON a.$idField = b.$idField; @@ -942,7 +943,7 @@ String gatherScales(JdbcDataSource datasource, String buildingTable, String bloc datasource.createIndex(scale1ScaleFin, idBlockForMerge) datasource.execute """ DROP TABLE IF EXISTS $outputTableName; CREATE TABLE $outputTableName - AS SELECT a.*, ${listblockFinalRename.join(', ')} + AS SELECT a.* ${!listblockFinalRename.isEmpty()?","+listblockFinalRename.join(', '):""} FROM $scale1ScaleFin a LEFT JOIN $blockIndicFinalScale b ON a.$idBlockForMerge = b.$idBlockForMerge;""".toString() datasource.dropTable(finalScaleTableName, scale1ScaleFin, buildIndicRsuScale) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy index 7e0a4ad091..2909d749ac 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy @@ -152,7 +152,7 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, Stri //Compute the indices for each levels and find the 8 adjacent cells datasource.execute("""DROP TABLE IF EXISTS $grid_scaling_indices; - CREATE TABLE $grid_scaling_indices as SELECT *, ${grid_levels_query.join(",")}, + CREATE TABLE $grid_scaling_indices as SELECT * ${!grid_levels_query.isEmpty()?","+grid_levels_query.join(","):""}, (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW+1 AND ID_COL=a.ID_COL) AS LCZ_PRIMARY_N, (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW+1 AND ID_COL=a.ID_COL+1) AS LCZ_PRIMARY_NE, (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW AND ID_COL=a.ID_COL+1) AS LCZ_PRIMARY_E, @@ -204,7 +204,7 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, Stri WHEN LCZ_PRIMARY= 101 THEN 14 WHEN LCZ_PRIMARY =102 THEN 15 WHEN LCZ_PRIMARY IN (103,104) THEN 16 - ELSE LCZ_PRIMARY END AS weight_lcz, + ELSE LCZ_PRIMARY END AS weight_lcz FROM $grid_scaling_indices WHERE LCZ_PRIMARY IS NOT NULL GROUP BY ID_ROW_LOD_${i}, ID_COL_LOD_${i}, LCZ_PRIMARY;""".toString()) @@ -223,7 +223,7 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, Stri and ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i} and ID_COL_LOD_${i}= a.ID_COL_LOD_${i}) AS LCZ_WARM_LOD_${i}, (select sum(count) from $lcz_count_lod where LCZ_PRIMARY in (101,102,103,104,106,107) - and ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i} and ID_COL_LOD_${i}= a.ID_COL_LOD_${i}) AS LCZ_COOL_LOD_${i}, + and ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i} and ID_COL_LOD_${i}= a.ID_COL_LOD_${i}) AS LCZ_COOL_LOD_${i} from $lcz_count_lod as a order by count desc, ID_ROW_LOD_${i}, ID_COL_LOD_${i}, weight_lcz;""".toString()) @@ -250,7 +250,7 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, Stri (SELECT LCZ_WARM_LOD_${i} FROM $lcz_count_lod_mode WHERE ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i}-1 AND ID_COL_LOD_${i}=a.ID_COL_LOD_${i}) AS LCZ_WARM_S_LOD_${i}, (SELECT LCZ_WARM_LOD_${i} FROM $lcz_count_lod_mode WHERE ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i}-1 AND ID_COL_LOD_${i}=a.ID_COL_LOD_${i}-1) AS LCZ_WARM_SW_LOD_${i}, (SELECT LCZ_WARM_LOD_${i} FROM $lcz_count_lod_mode WHERE ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i} AND ID_COL_LOD_${i}=a.ID_COL_LOD_${i}-1) AS LCZ_WARM_W_LOD_${i}, - (SELECT LCZ_WARM_LOD_${i} FROM $lcz_count_lod_mode WHERE ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i}+1 AND ID_COL_LOD_${i}=a.ID_COL_LOD_${i}-1) AS LCZ_WARM_NW_LOD_${i}, + (SELECT LCZ_WARM_LOD_${i} FROM $lcz_count_lod_mode WHERE ID_ROW_LOD_${i} = a.ID_ROW_LOD_${i}+1 AND ID_COL_LOD_${i}=a.ID_COL_LOD_${i}-1) AS LCZ_WARM_NW_LOD_${i} FROM $lcz_count_lod_mode as a; """.toString()) diff --git a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy index 140cb2a338..c276bb6122 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -485,12 +485,13 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, def missingElementsUrb = neededSurfUrb - neededSurfUrb.findAll { indUrb -> surfFracList.contains(indUrb.toUpperCase()) } if (missingElementsUrb.size() == 0) { def queryUrbSurfFrac = """DROP TABLE IF EXISTS $utrfFractionIndic; - CREATE TABLE $utrfFractionIndic AS SELECT $columnIdRsu, """ + CREATE TABLE $utrfFractionIndic AS SELECT $columnIdRsu""" + def columnsFrac =[] utrfSurfFraction.each { urbIndicator, indicatorList -> - queryUrbSurfFrac += "${indicatorList.join("+")} AS $urbIndicator, " + columnsFrac << "${indicatorList.join("+")} AS $urbIndicator " } - queryUrbSurfFrac += " FROM $surfaceFractions" - datasource.execute queryUrbSurfFrac.toString() + queryUrbSurfFrac += "${!columnsFrac.isEmpty()?","+columnsFrac.join(","):""} FROM $surfaceFractions" + datasource.execute(queryUrbSurfFrac) finalTablesToJoin.put(utrfFractionIndic, columnIdRsu) } else { throw new IllegalArgumentException("""'utrfSurfFraction' and 'surfSuperpositions' parameters given by the user are not consistent. @@ -506,12 +507,13 @@ String computeRSUIndicators(JdbcDataSource datasource, String buildingTable, def missingElementsLcz = neededSurfLcz - neededSurfLcz.findAll { indLcz -> surfFracList.contains(indLcz.toUpperCase()) } if (missingElementsLcz.size() == 0) { def querylczSurfFrac = """DROP TABLE IF EXISTS $lczFractionIndic; - CREATE TABLE $lczFractionIndic AS SELECT $columnIdRsu, """ + CREATE TABLE $lczFractionIndic AS SELECT $columnIdRsu """ + def columnsSurfFrac =[] lczSurfFraction.each { urbIndicator, indicatorList -> - querylczSurfFrac += "${indicatorList.join("+")} AS $urbIndicator, " + columnsSurfFrac << "${indicatorList.join("+")} AS $urbIndicator" } - querylczSurfFrac += " FROM $surfaceFractions" - datasource.execute querylczSurfFrac.toString() + querylczSurfFrac += "${!columnsSurfFrac.isEmpty()?","+columnsSurfFrac.join(","):""} FROM $surfaceFractions" + datasource.execute(querylczSurfFrac) finalTablesToJoin.put(lczFractionIndic, columnIdRsu) } else { throw new IllegalArgumentException("""'lczSurfFraction' and 'surfSuperpositions' parameters given by the user are not consistent. diff --git a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy index c8eea73326..121952ae4c 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -575,7 +575,7 @@ class WorkflowGeoIndicatorsTest { //Check high_vegetation_fraction > 0 countResult = datasource.firstRow("select count(*) as count from ${rsuIndicatorsTableName} WHERE high_vegetation_fraction>0".toString()) - assertEquals(25, countResult.count) + assertEquals(24, countResult.count) //Check high_vegetation_water_fraction > 0 countResult = datasource.firstRow("select count(*) as count from ${rsuIndicatorsTableName} WHERE high_vegetation_water_fraction>0".toString()) @@ -603,7 +603,7 @@ class WorkflowGeoIndicatorsTest { //Check low_vegetation_fraction > 0 countResult = datasource.firstRow("select count(*) as count from ${rsuIndicatorsTableName} WHERE low_vegetation_fraction>0".toString()) - assertEquals(53, countResult.count) + assertEquals(55, countResult.count) //Check low_vegetation_fraction > 0 countResult = datasource.firstRow("select count(*) as count from ${rsuIndicatorsTableName} WHERE impervious_fraction>0".toString()) diff --git a/osm/pom.xml b/osm/pom.xml index 53d7f7e43e..9aa506ee74 100644 --- a/osm/pom.xml +++ b/osm/pom.xml @@ -9,7 +9,6 @@ 4.0.0 osm - org.orbisgis.geoclimate 1.0.1-SNAPSHOT diff --git a/pom.xml b/pom.xml index 588e82e3c0..94806e7b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -39,16 +39,16 @@ 5.9.1 - 1.19.0 + 1.20.0 2.2.2-SNAPSHOT - 2.2.224 + 2.3.232 1.7.1 2.1.1-SNAPSHOT - 2.0.10 - 4.0.17 - 4.6.3 - 2.12.0 - 1.25.0 + 2.0.16 + 4.0.22 + 4.7.6 + 2.16.1 + 1.27.1 2.5.3 1.4.19 1.4.11 @@ -282,7 +282,7 @@ org.apache.groovy groovy-all - 4.0.17 + 4.0.22 pom diff --git a/worldpoptools/pom.xml b/worldpoptools/pom.xml index 5de9d02b06..13d3712133 100644 --- a/worldpoptools/pom.xml +++ b/worldpoptools/pom.xml @@ -9,7 +9,6 @@ 4.0.0 worldpoptools - org.orbisgis.geoclimate 1.0.1-SNAPSHOT