Skip to content

Commit

Permalink
Update test.
Browse files Browse the repository at this point in the history
  • Loading branch information
pierromond committed Nov 19, 2024
1 parent 351c7fd commit 49497da
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->

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

}
}


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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 49497da

Please sign in to comment.