From 49497daf956f706a664bf373c9e5d21995f5863f Mon Sep 17 00:00:00 2001 From: Pierre Aumond Date: Tue, 19 Nov 2024 13:41:35 +0100 Subject: [PATCH] Update test. --- .../Ind_Vehicles_2_Noisy_Vehicles.groovy | 38 ++++---- .../wps/TestNoiseModelling.groovy | 88 ++++++++++++++++++- 2 files changed, 106 insertions(+), 20 deletions(-) diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Ind_Vehicles_2_Noisy_Vehicles.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Ind_Vehicles_2_Noisy_Vehicles.groovy index abb4db18b..ea837abd0 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Ind_Vehicles_2_Noisy_Vehicles.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Ind_Vehicles_2_Noisy_Vehicles.groovy @@ -615,6 +615,24 @@ class VehicleEmissionProcessData { def qry = 'INSERT INTO LW_VEHICLE(IT , THE_GEOM,Hz63, Hz125, Hz250, Hz500, Hz1000,Hz2000, Hz4000, Hz8000) VALUES (?,?,?,?,?,?,?,?,?,?);' if (fileFormat.equals("SUMO")){ + // Remplissage des variables avec le contenu du fichier SUMO + sql.eachRow('SELECT THE_GEOM, SPEED, ID, TIMESTEP FROM ' + tablename + ';') { row -> + + Geometry the_geom = (Geometry) row[0] + double speed = (double) row[1] + String id_veh = (String) row[2] + int timestep = (int) row[3] + + double[] carLevel = getCarsLevel(speed*3.6, id_veh) + sql.withBatch(100, qry) { ps -> + ps.addBatch(timestep as Integer, the_geom as Geometry, + carLevel[0] as Double, carLevel[1] as Double, carLevel[2] as Double, + carLevel[3] as Double, carLevel[4] as Double, carLevel[5] as Double, + carLevel[6] as Double, carLevel[7] as Double) + } + + } + } else if (fileFormat.equals("SYMUVIA")){ // Remplissage des variables avec le contenu du fichier SUMO sql.eachRow('SELECT THE_GEOM, SPEED, ID, TIMESTEP FROM ' + tablename + ';') { row -> @@ -632,26 +650,10 @@ class VehicleEmissionProcessData { } } - } else{ - // Remplissage des variables avec le contenu du fichier plan d'exp - sql.eachRow('SELECT THE_GEOM, SPEED, ID, TIMESTEP FROM ' + tablename + ';') { row -> - Geometry the_geom = (Geometry) row[0] - double speed = (double) row[1] - String id_veh = (String) row[2] - int timestep = (int) row[3] + } else { + System.out.println("Unknown File Format") - - double[] carLevel = getCarsLevel(speed*3.6, id_veh) - - sql.withBatch(100, qry) { ps -> - ps.addBatch(timestep as Integer, the_geom as Geometry, - carLevel[0] as Double, carLevel[1] as Double, carLevel[2] as Double, - carLevel[3] as Double, carLevel[4] as Double, carLevel[5] as Double, - carLevel[6] as Double, carLevel[7] as Double) - } - - } } diff --git a/wps_scripts/src/test/groovy/org/noise_planet/noisemodelling/wps/TestNoiseModelling.groovy b/wps_scripts/src/test/groovy/org/noise_planet/noisemodelling/wps/TestNoiseModelling.groovy index 57bd35c57..9a857999a 100644 --- a/wps_scripts/src/test/groovy/org/noise_planet/noisemodelling/wps/TestNoiseModelling.groovy +++ b/wps_scripts/src/test/groovy/org/noise_planet/noisemodelling/wps/TestNoiseModelling.groovy @@ -116,7 +116,10 @@ class TestNoiseModelling extends JdbcTestCase { }*/ @Test - void testDynamicRoadEmissionPropagationVehicles() { + /** + * as SUMO or SYMUVIA or Drone input + */ + void testDynamicIndividualVehicles() { // SHPRead.importTable(connection, TestDatabaseManager.getResource("ROADS2.shp").getPath()) @@ -191,9 +194,90 @@ class TestNoiseModelling extends JdbcTestCase { "columnName" : "LEQA" ]) - assertEquals("The columns LEQA and LEQ have been added to the table: LT_GEOM_VAL.", res) + assertEquals("The columns LEQA and LEQ have been added to the table: LT_GEOM_PROBA.", res) } + @Test + /** + * as MatSim input + */ + void testDynamicFlow() { + + // SHPRead.importTable(connection, TestDatabaseManager.getResource("ROADS2.shp").getPath()) + + + new Import_File().exec(connection, + ["pathFile" : TestDatabaseManager.getResource("Dynamic/buildings_nm_ready_pop_heights.shp").getPath() , + "inputSRID": "32635", + "tableName": "buildings"]) + + + new Import_File().exec(connection, + ["pathFile" :TestDatabaseManager.getResource("Dynamic/network_tartu_32635_.geojson").getPath() , + "inputSRID": "32635", + "tableName": "network_tartu"]) + + new Add_Primary_Key().exec(connection, + ["pkName" :"PK", + "tableName": "network_tartu"]) + + new Import_File().exec(connection, + ["pathFile" : TestDatabaseManager.getResource("Dynamic/receivers_python_method0_50m_pop.shp").getPath() , + "inputSRID": "32635", + "tableName": "receivers"]) + + new Import_File().exec(connection, + ["pathFile" : TestDatabaseManager.getResource("Dynamic/SUMO.geojson").getPath() , + "inputSRID": "32635", + "tableName": "vehicle"]) + + + new Set_Height().exec(connection, + [ "tableName":"RECEIVERS", + "height": 1.5 + ]) + + // create a function to define a network + String res = new Point_Source_0dB_From_Network().exec(connection, + ["tableRoads": "network_tartu", + "gridStep" : 10 + ]) + + // create a function to get LW values from Vehicles + res = new Ind_Vehicles_2_Noisy_Vehicles().exec(connection, + ["tableVehicles": "vehicle", + "distance2snap" : 30, + "fileFormat" : "SUMO"]) + + + res = new Noise_level_from_source().exec(connection, + ["tableBuilding" : "BUILDINGS", + "tableSources" : "SOURCES_0DB", + "tableReceivers": "RECEIVERS", + "maxError" : 0.0, + "confMaxSrcDist" : 150, + "confDiffHorizontal" : false, + "confExportSourceId": true, + "confSkipLday":true, + "confSkipLevening":true, + "confSkipLnight":true, + "confSkipLden":true + ]) + + res = new Noise_From_Attenuation_Matrix().exec(connection, + ["lwTable" : "LW_DYNAMIC_GEOM", + "attenuationTable" : "LDAY_GEOM", + "outputTable" : "LT_GEOM_PROBA" + ]) + + + res = new DynamicIndicators().exec(connection, + ["tableName" : "LT_GEOM_PROBA", + "columnName" : "LEQA" + ]) + + assertEquals("The columns LEQA and LEQ have been added to the table: LT_GEOM_PROBA.", res) + } @Test