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 d123487707..7a538febfc 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/GridIndicators.groovy @@ -49,8 +49,8 @@ String gridPopulation(JdbcDataSource datasource, String gridTable, String popula def outputTableName = postfix BASE_NAME //Indexing table - datasource.createSpatialIndex(gridTable,"the_geom") - datasource.createSpatialIndex(populationTable,"the_geom") + datasource.createSpatialIndex(gridTable, "the_geom") + datasource.createSpatialIndex(populationTable, "the_geom") def popColumns = [] def sum_popColumns = [] if (populationColumns) { @@ -124,11 +124,11 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, int def grid_scaling_indices = postfix("grid_scaling_indices") def grid_levels_query = [] int grid_offset = 3 - int offsetCol = 0 + int offsetCol = 1 for (int i in 1..nb_levels) { int level = Math.pow(grid_offset, i) grid_levels_query << " (CAST (ABS(ID_ROW-1)/${level} AS INT)+1) AS ID_ROW_LOD_$i," + - "(CAST (ABS(ID_COL-1)/${level} AS INT)+$offsetCol) AS ID_COL_LOD_$i" + "(CAST (ABS(ID_COL-1)/${level} AS INT)+$offsetCol-1) AS ID_COL_LOD_$i" offsetCol++ } @@ -136,7 +136,7 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, int datasource.execute("""DROP TABLE IF EXISTS $grid_scaling_indices; CREATE TABLE $grid_scaling_indices as SELECT *, ${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+1=a.ID_COL) AS LCZ_PRIMARY_NE, + (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, (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW-1 AND ID_COL=a.ID_COL+1) AS LCZ_PRIMARY_SE, (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW-1 AND ID_COL=a.ID_COL) AS LCZ_PRIMARY_S, @@ -145,9 +145,9 @@ String multiscaleLCZGrid(JdbcDataSource datasource, String grid_indicators, int (SELECT LCZ_PRIMARY FROM $grid_indicators WHERE ID_ROW = a.ID_ROW+1 AND ID_COL=a.ID_COL-1) AS LCZ_PRIMARY_NW FROM $grid_indicators as a; """.toString()) - def tablesToDrop =[] + def tablesToDrop = [] def tableLevelToJoin = grid_scaling_indices - tablesToDrop<