Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade deps #991

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
## Changelog for v1.0.1

- Upgrade dependencies H2, H2GIS, JTS and Groovy
1 change: 0 additions & 1 deletion geoindicators/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<version>1.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<groupId>org.orbisgis.geoclimate</groupId>
<artifactId>geoindicators</artifactId>
<version>1.0.1-SNAPSHOT</version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand All @@ -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())

Expand All @@ -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())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
1 change: 0 additions & 1 deletion osm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>osm</artifactId>
<groupId>org.orbisgis.geoclimate</groupId>
<version>1.0.1-SNAPSHOT</version>

<!-- Project Information -->
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@

<!-- Dependencies versions -->
<junit-version>5.9.1</junit-version>
<jts-version>1.19.0</jts-version>
<jts-version>1.20.0</jts-version>
<h2gis-version>2.2.2-SNAPSHOT</h2gis-version>
<h2-version>2.2.224</h2-version>
<h2-version>2.3.232</h2-version>
<cts-version>1.7.1</cts-version>
<orbisdata-version>2.1.1-SNAPSHOT</orbisdata-version>
<slf4j-version>2.0.10</slf4j-version>
<groovy-version>4.0.17</groovy-version>
<picocli-version>4.6.3</picocli-version>
<commons-io-version>2.12.0</commons-io-version>
<commons-compress-version>1.25.0</commons-compress-version>
<slf4j-version>2.0.16</slf4j-version>
<groovy-version>4.0.22</groovy-version>
<picocli-version>4.7.6</picocli-version>
<commons-io-version>2.16.1</commons-io-version>
<commons-compress-version>1.27.1</commons-compress-version>
<smile-version>2.5.3</smile-version>
<xstream-version>1.4.19</xstream-version>
<logback-version>1.4.11</logback-version>
Expand Down Expand Up @@ -282,7 +282,7 @@
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>4.0.17</version>
<version>4.0.22</version>
<type>pom</type>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion worldpoptools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>worldpoptools</artifactId>
<groupId>org.orbisgis.geoclimate</groupId>
<version>1.0.1-SNAPSHOT</version>

<!-- Project Information -->
Expand Down
Loading