Skip to content

Commit 6dda73b

Browse files
SamuelBMartinsSamuel MartinsNitnelav
authored
Add lineSourceSpacingRatio as param of Noise_level_from_source script (#957)
* Add lineSourceSpacingRatio as param of Noise_level_from_source * Add test * faster test, verbose description * better assertion --------- Co-authored-by: Samuel Martins <samuel.martins@urbanmetrix.com> Co-authored-by: Valentin LE BESCOND <lebescond@lasa.fr>
1 parent dec582f commit 6dda73b

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

noisemodelling-scripts/src/main/groovy/org/noise_planet/noisemodelling/scripts/NoiseModelling/Noise_level_from_source.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ inputs = [
266266
description: 'Frequency field name prepend. Ex. for 1000 Hz frequency the default column name is HZ1000.',
267267
default : 'HZ',
268268
type: String.class
269+
],
270+
confLineSourceSpacingRatio: [
271+
name : 'Line source spacing ratio',
272+
title : 'Line source spacing ratio',
273+
description: 'Dictates the density of source points created from a line sound source. A higher value means more points and finer discretization : DistanceBetweenPoints = DistanceSourceToReceiver / LineSourceSpacingRatio (this parameter)',
274+
default : 2.0,
275+
type : Double.class
269276
]
270277
]
271278

@@ -432,6 +439,11 @@ def exec(Connection connection, Map input, ProgressVisitor progress) {
432439
frequencyFieldPrepend = input['frequencyFieldPrepend'] as String
433440
}
434441

442+
double confLineSourceSpacingRatio = input.getOrDefault("confLineSourceSpacingRatio", 2.0) as Double
443+
if (confLineSourceSpacingRatio <= 0) {
444+
throw new IllegalArgumentException("Error : confLineSourceSpacingRatio must be greater than 0.")
445+
}
446+
435447
// --------------------------------------------
436448
// Initialize NoiseModelling propagation part
437449
// --------------------------------------------
@@ -479,6 +491,7 @@ def exec(Connection connection, Map input, ProgressVisitor progress) {
479491
pointNoiseMap.setComputeVerticalDiffraction(compute_horizontal_diffraction)
480492
pointNoiseMap.setSoundReflectionOrder(reflexion_order)
481493
pointNoiseMap.setFrequencyFieldPrepend(frequencyFieldPrepend)
494+
pointNoiseMap.getSceneInputSettings().setLineSourceSpacingRatio(confLineSourceSpacingRatio)
482495

483496

484497
// Set environmental parameters

noisemodelling-scripts/src/test/groovy/org/noise_planet/noisemodelling/scripts/TestNoiseModelling.groovy

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,45 @@ class TestNoiseModelling extends JdbcTestCase {
345345
assertEquals(receiverCount, periodCount)
346346
}
347347
}
348+
349+
@Test
350+
void testRaysTableAndLineSourceSpacingRatio() {
351+
String RAYS_TABLE = "RAYS"
352+
Double LINE_SOURCE_RATIO = 4.0
353+
Integer EXPECTED_NB_RAYS = 125716
354+
355+
new Import_File().exec(connection,
356+
["pathFile" : TestNoiseModelling.getResource("ROADS2.shp").getPath()])
357+
358+
new Road_Emission_from_Traffic().exec(connection,
359+
["tableRoads": "ROADS2"])
360+
361+
new Import_File().exec(connection,
362+
["pathFile" : TestNoiseModelling.getResource("buildings.shp").getPath(),
363+
"inputSRID": "2154",
364+
"tableName": "buildings"])
365+
366+
new Import_File().exec(connection,
367+
["pathFile" : TestNoiseModelling.getResource("receivers.shp").getPath(),
368+
"inputSRID": "2154",
369+
"tableName": "receivers"])
370+
371+
Sql sql = new Sql(connection)
372+
373+
new Noise_level_from_source().exec(connection,
374+
["tableBuilding" : "BUILDINGS",
375+
"tableSources" : "LW_ROADS",
376+
"tableReceivers" : "RECEIVERS",
377+
"confRaysName" : RAYS_TABLE,
378+
"confLineSourceSpacingRatio": LINE_SOURCE_RATIO,
379+
"confReflOrder" : 0,
380+
"confDiffVertical" : false,
381+
"confDiffHorizontal" : false])
382+
383+
assertTrue(JDBCUtilities.tableExists(connection, RAYS_TABLE))
384+
int raysCount = sql.firstRow("SELECT COUNT(*) CPT FROM " + RAYS_TABLE)["CPT"] as Integer
385+
LOGGER.info("number or rays with confLineSourceSpacingRatio = " + LINE_SOURCE_RATIO + " : " + raysCount)
386+
assertEquals(raysCount, EXPECTED_NB_RAYS)
387+
}
388+
348389
}

0 commit comments

Comments
 (0)