From 4e158be06df291543cba4a377727c66ee67cc703 Mon Sep 17 00:00:00 2001 From: jeremy Date: Tue, 7 Nov 2023 17:38:24 +0100 Subject: [PATCH] Add TYPO_SECOND in UTRF tables and a corresponding test --- .../geoclimate/geoindicators/WorkflowGeoIndicators.groovy | 6 +++++- .../geoindicators/WorkflowGeoIndicatorsTest.groovy | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 610feeb4f6..b72d412288 100644 --- a/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy +++ b/geoindicators/src/main/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicators.groovy @@ -829,6 +829,7 @@ Map computeTypologyIndicators(JdbcDataSource datasource, String building_indicat def CORRESPONDENCE_TAB_UTRF = ["ba" : 1, "bgh": 2, "icif": 3, "icio": 4, "id": 5, "local": 6, "pcif": 7, "pcio": 8, "pd": 9, "psc": 10] def nameColTypoMaj = "TYPO_MAJ" + def nameColTypoSecond = "TYPO_SECOND" // Output Lcz (and urbanTypo) table names are set to null in case LCZ indicators (and urban typo) are not calculated def rsuLcz = null @@ -974,7 +975,10 @@ Map computeTypologyIndicators(JdbcDataSource datasource, String building_indicat ELSE b.UNIQUENESS_VALUE END AS UNIQUENESS_VALUE, CASE WHEN b.UNIQUENESS_VALUE=-1 THEN NULL - ELSE LOWER(SUBSTRING(b.EXTREMUM_COL FROM 6)) END AS $nameColTypoMaj + ELSE LOWER(SUBSTRING(b.EXTREMUM_COL FROM 6)) END AS $nameColTypoMaj, + CASE WHEN b.UNIQUENESS_VALUE=-1 + THEN NULL + ELSE LOWER(SUBSTRING(b.EXTREMUM_COL2 FROM 6)) END AS $nameColTypoSecond FROM TEMPO_DISTRIB a LEFT JOIN $resultsDistrib b ON a.$COLUMN_ID_RSU=b.$COLUMN_ID_RSU""".toString() } 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 13ac4da1a8..b98528bc03 100644 --- a/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy +++ b/geoindicators/src/test/groovy/org/orbisgis/geoclimate/geoindicators/WorkflowGeoIndicatorsTest.groovy @@ -197,6 +197,10 @@ class WorkflowGeoIndicatorsTest { // Check that the sum of proportion (or building floor area) for each RSU is equal to 1 def utrfFloorArea = datasource."$geoIndicatorsCompute_i.rsu_utrf_floor_area" def colUtrfFloorArea = utrfFloorArea.getColumns() + + // Test that the TYPO_SECOND is inside the RSU UTRF table + assertEquals colUtrfFloorArea.count("TYPO_SECOND"), 1 + colUtrfFloorArea = colUtrfFloorArea.minus(["ID_RSU", "THE_GEOM", "TYPO_MAJ", "TYPO_SECOND", "UNIQUENESS_VALUE"]) def countSumFloorAreaEqual1 = datasource.firstRow("""SELECT COUNT(*) AS NB FROM ${geoIndicatorsCompute_i.rsu_utrf_floor_area}