From bf0dd0218c0ef1faf72898bdd82a80b87aba9790 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Wed, 21 Sep 2022 16:56:55 +0200 Subject: [PATCH 01/20] In RAYS Table export ray attenuation and time period --- .../noisemodelling/jdbc/JdbcNoiseMap.java | 8 +-- .../jdbc/LDENComputeRaysOut.java | 67 +++++++++++------ .../noisemodelling/jdbc/LDENConfig.java | 10 +-- .../jdbc/LDENPointNoiseMapFactory.java | 60 +++++++++++----- .../jdbc/LDENPointNoiseMapFactoryTest.java | 6 +- .../jdbc/PointNoiseMapTest.java | 6 +- .../pathfinder/PropagationPath.java | 71 +++++++++++++++---- .../ComputeRaysOutAttenuation.java | 30 ++++---- .../org/noise_planet/nmtutorial01/main.java | 4 +- pom.xml | 10 +-- wps_scripts/build.gradle | 14 +--- .../Noise_level_from_source.groovy | 24 ++++++- 12 files changed, 206 insertions(+), 104 deletions(-) diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/JdbcNoiseMap.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/JdbcNoiseMap.java index 5e661aa41..087083e98 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/JdbcNoiseMap.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/JdbcNoiseMap.java @@ -87,9 +87,9 @@ public JdbcNoiseMap(String buildingsTableName, String sourcesTableName) { public PropagationProcessPathData getPropagationProcessPathData(LDENConfig.TIME_PERIOD time_period) { switch (time_period) { - case TIME_PERIOD_DAY: + case DAY: return propagationProcessPathDataDay; - case TIME_PERIOD_EVENING: + case EVENING: return propagationProcessPathDataEvening; default: return propagationProcessPathDataNight; @@ -98,9 +98,9 @@ public PropagationProcessPathData getPropagationProcessPathData(LDENConfig.TIME_ public void setPropagationProcessPathData(LDENConfig.TIME_PERIOD time_period, PropagationProcessPathData propagationProcessPathData) { switch (time_period) { - case TIME_PERIOD_DAY: + case DAY: propagationProcessPathDataDay = propagationProcessPathData; - case TIME_PERIOD_EVENING: + case EVENING: propagationProcessPathDataEvening = propagationProcessPathData; default: propagationProcessPathDataNight = propagationProcessPathData; diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java index e8450ab40..c86167c01 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -53,9 +54,9 @@ public static class DENAttenuation { public double[] getTimePeriodLevel(LDENConfig.TIME_PERIOD timePeriod) { switch (timePeriod) { - case TIME_PERIOD_DAY: + case DAY: return dayLevels; - case TIME_PERIOD_EVENING: + case EVENING: return eveningLevels; default: return nightLevels; @@ -63,9 +64,9 @@ public double[] getTimePeriodLevel(LDENConfig.TIME_PERIOD timePeriod) { } public void setTimePeriodLevel(LDENConfig.TIME_PERIOD timePeriod, double [] levels) { switch (timePeriod) { - case TIME_PERIOD_DAY: + case DAY: dayLevels = levels; - case TIME_PERIOD_EVENING: + case EVENING: eveningLevels = levels; default: nightLevels = levels; @@ -116,26 +117,48 @@ public ThreadComputeRaysOut(LDENComputeRaysOut multiThreadParent) { @Override - public double[] addPropagationPaths(long sourceId, double sourceLi, long receiverId, List propagationPath) { - ldenComputeRaysOut.rayCount.addAndGet(propagationPath.size()); - if(ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() && - receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) { - for(PropagationPath path : propagationPath) { - // Copy path content in order to keep original ids for other method calls - PropagationPath pathPk = new PropagationPath(path); - pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int)receiverId).intValue()); - pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int)sourceId).intValue()); - propagationPaths.add(pathPk); + public double[] addPropagationPaths(long sourceId, double sourceLi, long receiverId, List propagationPathsParameter) { + ldenComputeRaysOut.rayCount.addAndGet(propagationPathsParameter.size()); + if(ldenComputeRaysOut.keepRays && !ldenComputeRaysOut.keepAbsorption) { + for(PropagationPath propagationPath : propagationPathsParameter) { + // Use only one ray as the ray is the same if we not keep absorption values + if (ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() && receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) { + // Copy path content in order to keep original ids for other method calls + PropagationPath pathPk = new PropagationPath(propagationPath); + pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int) receiverId).intValue()); + pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int) sourceId).intValue()); + this.propagationPaths.add(pathPk); + } else { + this.propagationPaths.add(propagationPath); + } + } + } + double[] globalLevel = null; + for(LDENConfig.TIME_PERIOD timePeriod : LDENConfig.TIME_PERIOD.values()) { + for(PropagationPath propagationPath : propagationPathsParameter) { + if (globalLevel == null) { + globalLevel = lDENThreadRaysOut[timePeriod.ordinal()].addPropagationPaths(sourceId, sourceLi, + receiverId, Collections.singletonList(propagationPath)); + } else { + globalLevel = PowerUtils.sumDbArray(globalLevel, lDENThreadRaysOut[timePeriod.ordinal()].addPropagationPaths(sourceId, sourceLi, + receiverId, Collections.singletonList(propagationPath))); + } + propagationPath.setTimePeriod(timePeriod.name()); + if(ldenComputeRaysOut.keepRays && ldenComputeRaysOut.keepAbsorption) { + // copy ray for each time period because absorption is different for each period + if (ldenComputeRaysOut.inputData != null && sourceId < ldenComputeRaysOut.inputData.sourcesPk.size() && receiverId < ldenComputeRaysOut.inputData.receiversPk.size()) { + // Copy path content in order to keep original ids for other method calls + PropagationPath pathPk = new PropagationPath(propagationPath); + pathPk.setIdReceiver(ldenComputeRaysOut.inputData.receiversPk.get((int) receiverId).intValue()); + pathPk.setIdSource(ldenComputeRaysOut.inputData.sourcesPk.get((int) sourceId).intValue()); + this.propagationPaths.add(pathPk); + } else { + this.propagationPaths.add(propagationPath); + } + } } - } else { - propagationPaths.addAll(propagationPath); } - double[] ldenLevels = lDENThreadRaysOut[0].addPropagationPaths(sourceId, sourceLi, receiverId, propagationPath); - ldenLevels = PowerUtils.sumDbArray(ldenLevels, lDENThreadRaysOut[1].addPropagationPaths(sourceId, sourceLi, - receiverId, propagationPath)); - ldenLevels = PowerUtils.sumDbArray(ldenLevels, lDENThreadRaysOut[2].addPropagationPaths(sourceId, sourceLi, - receiverId, propagationPath)); - return ldenLevels; + return globalLevel; } /** diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java index 0633c00cd..780e95021 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java @@ -29,7 +29,7 @@ * Configuration of NoiseModelling computation based on database data using standard Lden outputs */ public class LDENConfig { - public enum TIME_PERIOD {TIME_PERIOD_DAY, TIME_PERIOD_EVENING, TIME_PERIOD_NIGHT} + public enum TIME_PERIOD {DAY, EVENING, NIGHT} public enum INPUT_MODE { INPUT_MODE_TRAFFIC_FLOW, INPUT_MODE_LW_DEN, INPUT_MODE_PROBA} final INPUT_MODE input_mode; @@ -93,9 +93,9 @@ public LDENConfig(INPUT_MODE input_mode) { public PropagationProcessPathData getPropagationProcessPathData(TIME_PERIOD time_period) { switch (time_period) { - case TIME_PERIOD_DAY: + case DAY: return propagationProcessPathDataDay; - case TIME_PERIOD_EVENING: + case EVENING: return propagationProcessPathDataEvening; default: return propagationProcessPathDataNight; @@ -104,9 +104,9 @@ public PropagationProcessPathData getPropagationProcessPathData(TIME_PERIOD time public void setPropagationProcessPathData(TIME_PERIOD time_period, PropagationProcessPathData propagationProcessPathData) { switch (time_period) { - case TIME_PERIOD_DAY: + case DAY: propagationProcessPathDataDay = propagationProcessPathData; - case TIME_PERIOD_EVENING: + case EVENING: propagationProcessPathDataEvening = propagationProcessPathData; default: propagationProcessPathDataNight = propagationProcessPathData; diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactory.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactory.java index 2e366a745..300581736 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactory.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactory.java @@ -22,7 +22,9 @@ package org.noise_planet.noisemodelling.jdbc; +import org.h2gis.utilities.GeometryTableUtilities; import org.h2gis.utilities.JDBCUtilities; +import org.locationtech.jts.geom.LineString; import org.noise_planet.noisemodelling.emission.DirectionAttributes; import org.noise_planet.noisemodelling.emission.RailWayLW; import org.noise_planet.noisemodelling.jdbc.utils.StringPreparedStatements; @@ -55,6 +57,7 @@ public class LDENPointNoiseMapFactory implements PointNoiseMap.PropagationProces static final int BATCH_MAX_SIZE = 500; static final int WRITER_CACHE = 65536; LDENComputeRaysOut.LdenData ldenData = new LDENComputeRaysOut.LdenData(); + int srid; /** * Attenuation and other attributes relative to direction on sphere @@ -99,6 +102,7 @@ public void initialize(Connection connection, PointNoiseMap pointNoiseMap) throw if(ldenConfig.input_mode == LDENConfig.INPUT_MODE.INPUT_MODE_LW_DEN) { // Fetch source fields List sourceField = JDBCUtilities.getColumnNames(connection, pointNoiseMap.getSourcesTableName()); + this.srid = GeometryTableUtilities.getSRID(connection, pointNoiseMap.getSourcesTableName()); List frequencyValues = new ArrayList<>(); List allFrequencyValues = Arrays.asList(CnossosPropagationData.DEFAULT_FREQUENCIES_THIRD_OCTAVE); String period = ""; @@ -165,10 +169,10 @@ public void initialize(Connection connection, PointNoiseMap pointNoiseMap) throw * Start creating and filling database tables */ public void start() { - if(ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY) == null) { + if(ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY) == null) { throw new IllegalStateException("start() function must be called after PointNoiseMap initialization call"); } - tableWriter = new TableWriter(connection, ldenConfig, ldenData); + tableWriter = new TableWriter(connection, ldenConfig, ldenData, srid); ldenConfig.exitWhenDone = false; tableWriterThread = new Thread(tableWriter); tableWriterThread.start(); @@ -235,8 +239,9 @@ private static class TableWriter implements Runnable { double[] a_weighting; boolean started = false; Writer o; + int srid; - public TableWriter(Connection connection, LDENConfig ldenConfig, LDENComputeRaysOut.LdenData ldenData) { + public TableWriter(Connection connection, LDENConfig ldenConfig, LDENComputeRaysOut.LdenData ldenData, int srid) { this.connection = connection; this.sqlFilePath = ldenConfig.sqlOutputFile; this.ldenConfig = ldenConfig; @@ -245,28 +250,41 @@ public TableWriter(Connection connection, LDENConfig ldenConfig, LDENComputeRays for(int idfreq = 0; idfreq < a_weighting.length; idfreq++) { a_weighting[idfreq] = ldenConfig.propagationProcessPathDataDay.freq_lvl_a_weighting.get(idfreq); } + this.srid = srid; } void processRaysStack(ConcurrentLinkedDeque stack) throws SQLException { - String query; + StringBuilder query = new StringBuilder("INSERT INTO " + ldenConfig.raysTable + + "(the_geom , IDRECEIVER , IDSOURCE"); if(ldenConfig.exportProfileInRays) { - query = "INSERT INTO " + ldenConfig.raysTable + "(the_geom , IDRECEIVER , IDSOURCE, GEOJSON ) VALUES (?, ?, ?, ?);"; - } else { - query = "INSERT INTO " + ldenConfig.raysTable + "(the_geom , IDRECEIVER , IDSOURCE ) VALUES (?, ?, ?);"; + query.append(", GEOJSON"); + } + if(ldenConfig.keepAbsorption) { + query.append(", LEQ, PERIOD"); + } + query.append(") VALUES (?, ?, ?"); + if(ldenConfig.exportProfileInRays) { + query.append(", ?"); + } + if(ldenConfig.keepAbsorption) { + query.append(", ?, ?"); } + query.append(");"); // PK, GEOM, ID_RECEIVER, ID_SOURCE PreparedStatement ps; if(sqlFilePath == null) { - ps = connection.prepareStatement(query); + ps = connection.prepareStatement(query.toString()); } else { - ps = new StringPreparedStatements(o, query); + ps = new StringPreparedStatements(o, query.toString()); } int batchSize = 0; while(!stack.isEmpty()) { PropagationPath row = stack.pop(); ldenData.queueSize.decrementAndGet(); int parameterIndex = 1; - ps.setObject(parameterIndex++, row.asGeom()); + LineString lineString = row.asGeom(); + lineString.setSRID(srid); + ps.setObject(parameterIndex++, lineString); ps.setLong(parameterIndex++, row.getIdReceiver()); ps.setLong(parameterIndex++, row.getIdSource()); if(ldenConfig.exportProfileInRays) { @@ -278,6 +296,11 @@ void processRaysStack(ConcurrentLinkedDeque stack) throws SQLEx } ps.setString(parameterIndex++, geojson); } + if(ldenConfig.keepAbsorption) { + double globalValue = sumDbArray(row.absorptionData.aGlobal); + ps.setDouble(parameterIndex++, globalValue); + ps.setString(parameterIndex++, row.getTimePeriod()); + } ps.addBatch(); batchSize++; if (batchSize >= BATCH_MAX_SIZE) { @@ -411,15 +434,18 @@ public void init() throws SQLException, IOException { String q = String.format("DROP TABLE IF EXISTS %s;", ldenConfig.raysTable); processQuery(q); } - String q; + StringBuilder sb = new StringBuilder("CREATE TABLE IF NOT EXISTS " + ldenConfig.raysTable + "(pk bigint auto_increment, the_geom " + + "geometry(LINESTRING Z,"); + sb.append(srid); + sb.append("), IDRECEIVER bigint NOT NULL, IDSOURCE bigint NOT NULL"); if(ldenConfig.exportProfileInRays) { - q = "CREATE TABLE IF NOT EXISTS " + ldenConfig.raysTable + "(pk bigint auto_increment, the_geom " + - "geometry, IDRECEIVER bigint NOT NULL, IDSOURCE bigint NOT NULL, GEOJSON VARCHAR);"; - } else { - q = "CREATE TABLE IF NOT EXISTS " + ldenConfig.raysTable + "(pk bigint auto_increment, the_geom " + - "geometry, IDRECEIVER bigint NOT NULL, IDSOURCE bigint NOT NULL);"; + sb.append(", GEOJSON VARCHAR"); } - processQuery(q); + if(ldenConfig.keepAbsorption) { + sb.append(", LEQ DOUBLE, PERIOD VARCHAR"); + } + sb.append(");"); + processQuery(sb.toString()); } if(ldenConfig.computeLDay) { if(ldenConfig.dropResultsTable) { diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactoryTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactoryTest.java index 0e0f6a1d7..d567e7158 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactoryTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/LDENPointNoiseMapFactoryTest.java @@ -61,9 +61,9 @@ public void tearDown() throws Exception { public void testNoiseEmission() throws SQLException, IOException { SHPRead.importTable(connection, LDENPointNoiseMapFactoryTest.class.getResource("roads_traff.shp").getFile()); LDENConfig ldenConfig = new LDENConfig(LDENConfig.INPUT_MODE.INPUT_MODE_TRAFFIC_FLOW); - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY, new PropagationProcessPathData()); - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_EVENING, new PropagationProcessPathData()); - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_NIGHT, new PropagationProcessPathData()); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY, new PropagationProcessPathData()); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING, new PropagationProcessPathData()); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT, new PropagationProcessPathData()); ldenConfig.setCoefficientVersion(1); LDENPropagationProcessData process = new LDENPropagationProcessData(null, ldenConfig); try(Statement st = connection.createStatement()) { diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java index 98e52e391..879f06662 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java @@ -318,7 +318,7 @@ public void testLineDirectivity() throws Exception { LDENConfig ldenConfig = new LDENConfig(LDENConfig.INPUT_MODE.INPUT_MODE_LW_DEN); ldenConfig.setCoefficientVersion(1); - ldenConfig.setKeepAbsorption(true); + ldenConfig.setKeepAbsorption(false); ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY); LDENPointNoiseMapFactory ldenPointNoiseMapFactory = new LDENPointNoiseMapFactory(connection, ldenConfig); // Use train directivity functions instead of discrete directivity @@ -361,7 +361,6 @@ public void testLineDirectivity() throws Exception { // This is source orientation, not relevant to receiver position assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); assertOrientationEquals(new Orientation(330.07, -24.12, 0.0), path.raySourceReceiverDirectivity, 0.01); - assertEquals(-5.9, path.absorptionData.aSource[0], 0.1); path = rout.propagationPaths.remove(0);; assertEquals(1, path.getIdReceiver()); @@ -369,7 +368,6 @@ public void testLineDirectivity() throws Exception { distance(path.getPointList().get(0).coordinate), 0.1); assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); assertOrientationEquals(new Orientation(336.90675972385696, -19.398969693698437, 0), path.raySourceReceiverDirectivity, 0.01); - assertEquals(-7.8, path.absorptionData.aSource[0], 0.1); path = rout.propagationPaths.remove(0); assertEquals(2, path.getIdReceiver()); assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); @@ -406,7 +404,7 @@ public void testPointRayDirectivity() throws Exception { LDENConfig ldenConfig = new LDENConfig(LDENConfig.INPUT_MODE.INPUT_MODE_LW_DEN); ldenConfig.setCoefficientVersion(1); - ldenConfig.setKeepAbsorption(true); + ldenConfig.setKeepAbsorption(false); ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY); LDENPointNoiseMapFactory ldenPointNoiseMapFactory = new LDENPointNoiseMapFactory(connection, ldenConfig); // Use train directivity functions instead of discrete directivity diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java index 07e26f407..129462b9b 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java @@ -73,6 +73,7 @@ public class PropagationPath { private boolean favorable; // if true, favorable meteorological condition path int idSource; int idReceiver; + private String timePeriod=""; // time period if relevant (day, evening, night or other parameters, use LDenConfig.TIME_PERIOD) Orientation sourceOrientation = new Orientation(0,0,0); public Orientation raySourceReceiverDirectivity = new Orientation(); // direction of the source->receiver path relative to the source heading public double angle; @@ -174,8 +175,8 @@ public PropagationPath(PropagationPath other) { this.difVPoints = other.difVPoints; this.refPoints = other.refPoints; this.keepAbsorption = other.keepAbsorption; - this.absorptionData = other.absorptionData; - this.groundAttenuation = other.groundAttenuation; + this.absorptionData = new AbsorptionData(other.absorptionData); + this.groundAttenuation = new GroundAttenuation(other.groundAttenuation); this.reflectionAttenuation = other.reflectionAttenuation; this.deltaH = other.deltaH; this.deltaF = other.deltaF; @@ -191,12 +192,27 @@ public PropagationPath(PropagationPath other) { this.deltaRetroH = other.deltaRetroH; this.deltaRetroF = other.deltaRetroF; this.cutPoints = new ArrayList<>(other.cutPoints); + this.timePeriod = other.timePeriod; } public PropagationPath() { } + /** + * @return time period if relevant (day, evening, night or other parameters, use LDenConfig.TIME_PERIOD) + */ + public String getTimePeriod() { + return timePeriod; + } + + /** + * @param timePeriod time period if relevant (day, evening, night or other parameters, use LDenConfig.TIME_PERIOD) + */ + public void setTimePeriod(String timePeriod) { + this.timePeriod = timePeriod; + } + public Orientation getSourceOrientation() { return sourceOrientation; } @@ -743,17 +759,17 @@ public static void readPropagationPathListStream( DataInputStream in , ArrayList //Following classes are use for testing purpose public static class AbsorptionData { - public double[] aAtm; - public double[] aDiv; - public double[] aRef; - public double[] aBoundaryH; - public double[] aBoundaryF; - public double[] aGlobalH; - public double[] aGlobalF; - public double[] aDifH; - public double[] aDifF; - public double[] aGlobal; - public double[] aSource; // directivity attenuation + public double[] aAtm = new double[0]; + public double[] aDiv = new double[0]; + public double[] aRef = new double[0]; + public double[] aBoundaryH = new double[0]; + public double[] aBoundaryF = new double[0]; + public double[] aGlobalH = new double[0]; + public double[] aGlobalF = new double[0]; + public double[] aDifH = new double[0]; + public double[] aDifF = new double[0]; + public double[] aGlobal = new double[0]; + public double[] aSource = new double[0]; // directivity attenuation public void init(int size) { aAtm = new double[size]; @@ -768,6 +784,23 @@ public void init(int size) { aGlobal = new double[size]; aSource = new double[size]; } + + public AbsorptionData() { + } + + public AbsorptionData(AbsorptionData other) { + this.aAtm = other.aAtm.clone(); + this.aDiv = other.aDiv.clone(); + this.aRef = other.aRef.clone(); + this.aBoundaryH = other.aBoundaryH.clone(); + this.aBoundaryF = other.aBoundaryF.clone(); + this.aGlobalH = other.aGlobalH.clone(); + this.aGlobalF = other.aGlobalF.clone(); + this.aDifH = other.aDifH.clone(); + this.aDifF = other.aDifF.clone(); + this.aGlobal = other.aGlobal.clone(); + this.aSource = other.aSource.clone(); + } } public static class GroundAttenuation { @@ -786,6 +819,18 @@ public void init(int size) { cfF = new double[size]; aGroundF = new double[size]; } + + public GroundAttenuation() { + } + + public GroundAttenuation(GroundAttenuation other) { + this.wH = other.wH; + this.cfH = other.cfH; + this.aGroundH = other.aGroundH; + this.wF = other.wF; + this.cfF = other.cfF; + this.aGroundF = other.aGroundF; + } } public static class ReflectionAttenuation { diff --git a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java index f7553387f..9340a85af 100644 --- a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java +++ b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java @@ -301,9 +301,9 @@ public double[] computeAttenuation(PropagationProcessPathData data, long sourceI // @see ComputeCnossosRays#computeOrientation Vector3D fieldVectorPropagation = Orientation.rotate(proPath.getSourceOrientation(), Orientation.toVector(proPath.raySourceReceiverDirectivity), false); - int roseindex = getRoseIndex(Math.atan2(fieldVectorPropagation.getY(), fieldVectorPropagation.getX())); + int roseIndex = getRoseIndex(Math.atan2(fieldVectorPropagation.getY(), fieldVectorPropagation.getX())); // Homogenous conditions - if (data.getWindRose()[roseindex]!=1) { + if (data.getWindRose()[roseIndex] != 1) { proPath.setFavorable(false); aBoundary = EvaluateAttenuationCnossos.aBoundary(proPath, data); @@ -318,7 +318,7 @@ public double[] computeAttenuation(PropagationProcessPathData data, long sourceI } } // Favorable conditions - if (data.getWindRose()[roseindex]!=0) { + if (data.getWindRose()[roseIndex] != 0) { proPath.setFavorable(true); aBoundary = EvaluateAttenuationCnossos.aBoundary(proPath, data); aRetroDiff = EvaluateAttenuationCnossos.deltaRetrodif(proPath, data); @@ -340,12 +340,7 @@ public double[] computeAttenuation(PropagationProcessPathData data, long sourceI } // Compute attenuation under the wind conditions using the ray direction - double[] aGlobalMeteoRay = sumArrayWithPonderation(aGlobalMeteoFav, aGlobalMeteoHom, data.getWindRose()[roseindex]); - - //For testing purpose - if(keepAbsorption) { - proPath.absorptionData.aGlobal = aGlobalMeteoRay.clone(); - } + double[] aGlobalMeteoRay = sumArrayWithPonderation(aGlobalMeteoFav, aGlobalMeteoHom, data.getWindRose()[roseIndex]); // Apply attenuation due to sound direction if(inputData != null && !inputData.isOmnidirectional((int)sourceId)) { @@ -359,6 +354,17 @@ public double[] computeAttenuation(PropagationProcessPathData data, long sourceI aGlobalMeteoRay = sumArray(aGlobalMeteoRay, attSource); } + // For line source, take account of li coefficient + if(sourceLi > 1.0) { + for (int i = 0; i < aGlobalMeteoRay.length; i++) { + aGlobalMeteoRay[i] = wToDba(dbaToW(aGlobalMeteoRay[i]) * sourceLi); + } + } + // Keep global attenuation + if(keepAbsorption) { + proPath.absorptionData.aGlobal = aGlobalMeteoRay.clone(); + } + if (propagationAttenuationSpectrum != null) { propagationAttenuationSpectrum = sumDbArray(aGlobalMeteoRay, propagationAttenuationSpectrum); } else { @@ -366,12 +372,6 @@ public double[] computeAttenuation(PropagationProcessPathData data, long sourceI } } if (propagationAttenuationSpectrum != null) { - // For line source, take account of li coefficient - if(sourceLi > 1.0) { - for (int i = 0; i < propagationAttenuationSpectrum.length; i++) { - propagationAttenuationSpectrum[i] = wToDba(dbaToW(propagationAttenuationSpectrum[i]) * sourceLi); - } - } return propagationAttenuationSpectrum; } else { return new double[0]; diff --git a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java index 2bca307dd..632a9fa98 100644 --- a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java +++ b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java @@ -124,6 +124,7 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe pointNoiseMap.setMaximumPropagationDistance(100.0); pointNoiseMap.setSoundReflectionOrder(0); + pointNoiseMap.setThreadCount(1); pointNoiseMap.setComputeHorizontalDiffraction(false); pointNoiseMap.setComputeVerticalDiffraction(true); // Building height field name @@ -139,7 +140,8 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe ldenConfig.setComputeLEvening(true); ldenConfig.setComputeLNight(true); ldenConfig.setComputeLDEN(true); - ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY); + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE); + ldenConfig.setKeepAbsorption(true); LDENPointNoiseMapFactory tableWriter = new LDENPointNoiseMapFactory(connection, ldenConfig); diff --git a/pom.xml b/pom.xml index bbe7ca929..601fe39a1 100644 --- a/pom.xml +++ b/pom.xml @@ -20,12 +20,12 @@ org.locationtech.jts - 1.18.2 - 1.18.2 - 2.1.210 - 2.1.0-SNAPSHOT + 1.19.0 + 1.19.0 + 2.1.214 + 2.2.0-SNAPSHOT 1.6.0 - 1.7.32 + 1.7.36 noisemodelling-emission diff --git a/wps_scripts/build.gradle b/wps_scripts/build.gradle index 3bbc0c846..9ae2d6a4f 100644 --- a/wps_scripts/build.gradle +++ b/wps_scripts/build.gradle @@ -109,18 +109,8 @@ dependencies { implementation group: 'org.ejml', name: 'all', version: '0.29' implementation group: 'org.eclipse.emf', name: 'org.eclipse.emf.ecore', version: '2.10.1' implementation group: 'org.orbisgis', name: 'h2gis', version: '2.1.0-SNAPSHOT' - implementation('org.locationtech.jts:jts-core:1.18.2') { - version { - strictly '[1.18, 1.19[' - prefer '1.18.2' - } - } - implementation('org.locationtech.jts:jts-io:1.18.2') { - version { - strictly '[1.18, 1.19[' - prefer '1.18.2' - } - } + implementation('org.locationtech.jts:jts-core:1.19.0') + implementation('org.locationtech.jts:jts-io:1.19.0') implementation group: 'org.orbisgis', name: 'noisemodelling-emission', version: '4.0.2-SNAPSHOT' implementation group: 'org.orbisgis', name: 'noisemodelling-propagation', version: '4.0.2-SNAPSHOT' implementation group: 'org.orbisgis', name: 'noisemodelling-pathfinder', version: '4.0.2-SNAPSHOT' diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy index 0e169574f..95f8848d8 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy @@ -252,7 +252,16 @@ inputs = [ '
  • The last column 360° contains occurrences between 348.75° to 360° and 0 to 11.25°
  • Default value 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5', min : 0, max: 1, type : String.class - ] + ], + confRaysTableName : [ + name : 'Save each propagation ray into the specified table (ex:RAYS)', + title : 'Name of the ray table', + description: 'You can set a table name here in order to save all the rays computed by NoiseModelling' + + '. This table may be extremely large if there is a lot of receivers and sources. ' + + 'It will also greatly increase the computation time.' + + '

    Default value : empty (do not keep rays) ', + min : 0, max: 1, type: String.class + ], ] outputs = [ @@ -364,8 +373,12 @@ def exec(Connection connection, input) { sources_table_name = sources_table_name.toUpperCase() // Check if srid are in metric projection. int sridSources = GeometryTableUtilities.getSRID(connection, TableLocation.parse(sources_table_name)) - if (sridSources == 3785 || sridSources == 4326) throw new IllegalArgumentException("Error : Please use a metric projection for "+sources_table_name+".") - if (sridSources == 0) throw new IllegalArgumentException("Error : The table "+sources_table_name+" does not have an associated SRID.") + if (sridSources == 3785 || sridSources == 4326) { + throw new IllegalArgumentException("Error : Please use a metric projection for " + sources_table_name + ".") + } + if (sridSources == 0) { + throw new IllegalArgumentException("Error : The table " + sources_table_name + " does not have an associated SRID.") + } String receivers_table_name = input['tableReceivers'] @@ -505,6 +518,11 @@ def exec(Connection connection, input) { ldenConfig.setComputeLNight(!confSkipLnight) ldenConfig.setComputeLDEN(!confSkipLden) ldenConfig.setMergeSources(!confExportSourceId) + if (input['confRaysTableName'] && !((input['confRaysTableName'] as String).isEmpty())) { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + ldenConfig.setKeepAbsorption(true); + ldenConfig.setRaysTable(input['confRaysTableName'] as String) + } LDENPointNoiseMapFactory ldenProcessing = new LDENPointNoiseMapFactory(connection, ldenConfig) From b919fe51b193cfd171eb9b998280d291042f5556 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Wed, 21 Sep 2022 17:19:15 +0200 Subject: [PATCH 02/20] check for diff in day evening night output --- .../src/main/java/org/noise_planet/nmtutorial01/main.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java index 632a9fa98..cb6c71c91 100644 --- a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java +++ b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java @@ -152,6 +152,10 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe pointNoiseMap.initialize(connection, new EmptyProgressVisitor()); + ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY).setTemperature(20); + ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING).setTemperature(16); + ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT).setTemperature(10); + pointNoiseMap.setGridDim(1); LocalDateTime now = LocalDateTime.now(); From cc4797a0eebf46cad960888762ebae170f73cacb Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Wed, 21 Sep 2022 17:28:07 +0200 Subject: [PATCH 03/20] update wps scripts --- .../wps/NoiseModelling/Noise_level_from_source.groovy | 8 ++++---- .../wps/NoiseModelling/Noise_level_from_traffic.groovy | 8 ++++---- .../wps/NoiseModelling/Road_Emission_from_Traffic.groovy | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy index 95f8848d8..750397ec6 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy @@ -295,7 +295,7 @@ def forgeCreateTable(Sql sql, String tableName, LDENConfig ldenConfig, String ge sb.append(" (IDRECEIVER bigint NOT NULL"); } sb.append(", THE_GEOM geometry") - List freqLvl = ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY).freq_lvl; + List freqLvl = ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY).freq_lvl; for (int idfreq = 0; idfreq < freqLvl.size(); idfreq++) { sb.append(", HZ"); sb.append(freqLvl.get(idfreq)); @@ -576,9 +576,9 @@ def exec(Connection connection, input) { environmentalDataNight.setWindRose(favOccurrences) } - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY, environmentalDataDay) - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_EVENING, environmentalDataEvening) - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_NIGHT, environmentalDataNight) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY, environmentalDataDay) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING, environmentalDataEvening) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT, environmentalDataNight) // Building height field name pointNoiseMap.setHeightField("HEIGHT") diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy index 0dda1f024..eb2cedd56 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy @@ -305,7 +305,7 @@ def forgeCreateTable(Sql sql, String tableName, LDENConfig ldenConfig, String ge sb.append(" (IDRECEIVER bigint NOT NULL"); } sb.append(", THE_GEOM geometry") - PropagationProcessPathData pathData = ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY); + PropagationProcessPathData pathData = ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY); for (int idfreq = 0; idfreq < pathData.freq_lvl.size(); idfreq++) { sb.append(", HZ"); sb.append(pathData.freq_lvl.get(idfreq)); @@ -565,9 +565,9 @@ def exec(Connection connection, input) { environmentalDataNight.setWindRose(favOccurrences) } - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY, environmentalDataDay) - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_EVENING, environmentalDataEvening) - pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_NIGHT, environmentalDataNight) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY, environmentalDataDay) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING, environmentalDataEvening) + pointNoiseMap.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT, environmentalDataNight) // Building height field name pointNoiseMap.setHeightField("HEIGHT") diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Road_Emission_from_Traffic.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Road_Emission_from_Traffic.groovy index c460e850e..e866524f8 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Road_Emission_from_Traffic.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Road_Emission_from_Traffic.groovy @@ -179,9 +179,9 @@ def exec(Connection connection, input) { // Get Class to compute LW LDENConfig ldenConfig = new LDENConfig(LDENConfig.INPUT_MODE.INPUT_MODE_TRAFFIC_FLOW) ldenConfig.setCoefficientVersion(2) - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_DAY, new PropagationProcessPathData(false)); - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_EVENING, new PropagationProcessPathData(false)); - ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.TIME_PERIOD_NIGHT, new PropagationProcessPathData(false)); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY, new PropagationProcessPathData(false)); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING, new PropagationProcessPathData(false)); + ldenConfig.setPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT, new PropagationProcessPathData(false)); LDENPropagationProcessData ldenData = new LDENPropagationProcessData(null, ldenConfig) From af8d517a014d25960238e8b677bd1f97b196d2cc Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 22 Sep 2022 10:49:57 +0200 Subject: [PATCH 04/20] clean code, was moved or commented by spalominos --- .../pathfinder/PropagationPath.java | 263 ------------------ 1 file changed, 263 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java index 129462b9b..642eaf70a 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java @@ -78,7 +78,6 @@ public class PropagationPath { public Orientation raySourceReceiverDirectivity = new Orientation(); // direction of the source->receiver path relative to the source heading public double angle; double gs; - private boolean initialized = false; // computed in Augmented Path public List difHPoints = new ArrayList(); // diffraction points indices on horizontal edges public List difVPoints = new ArrayList(); // diffraction points indices on vertical edges @@ -170,7 +169,6 @@ public PropagationPath(PropagationPath other) { this.raySourceReceiverDirectivity = other.raySourceReceiverDirectivity; this.angle = other.angle; this.gs = other.gs; - this.initialized = other.initialized; this.difHPoints = other.difHPoints; this.difVPoints = other.difVPoints; this.refPoints = other.refPoints; @@ -373,15 +371,6 @@ public void readStream( DataInputStream in ) throws IOException { srSegment.readStream(in); } - - public boolean isInitialized() { - return initialized; - } - - protected void setInitialized(boolean initialized) { - this.initialized = initialized; - } - public List getPointList() {return pointList;} public List getSegmentList() {return segmentList;} @@ -405,260 +394,8 @@ public boolean isFavorable() { public void setFavorable(boolean favorable) { this.favorable = favorable; - setInitialized(false); - } - - /** - * Initialise the propagation path - */ - public void initPropagationPath() { - if(!isInitialized()) { - //computeAugmentedPath(); - //computeAugmentedSegments(); - //computeAugmentedSRPath(); - setInitialized(true); - } - } - - /** - * Initialise all values that depends of the global path - * as distances, Gpath, etc. - */ - public void computeAugmentedSRPath() { - double dPath =0 ; - - srSegment.idPtStart = 0; - srSegment.idPtFinal = pointList.size()-1; - - // In case of reflections the slanted path passes through the image sources. - if (refPoints.size()>0){ - Coordinate ini = srSegment.s; - Coordinate iniGround = srSegment.sMeanPlane; - srSegment.d =0.; - srSegment.dp = 0.; - for (int idPoint = 1; idPoint < pointList.size(); idPoint++) { - if (pointList.get(idPoint).type == PointPath.POINT_TYPE.REFL){ - srSegment.d += CGAlgorithms3D.distance(ini, pointList.get(idPoint).coordinate); - ini = pointList.get(idPoint).coordinate; - - srSegment.dp += CGAlgorithms3D.distance(iniGround, projectPointOnVector(pointList.get(idPoint).coordinate,srSegment.meanGdPlane,srSegment.pInit)); - iniGround = projectPointOnVector(pointList.get(idPoint).coordinate,srSegment.meanGdPlane,srSegment.pInit); - } - } - srSegment.d += CGAlgorithms3D.distance(ini, srSegment.r); - srSegment.dp += CGAlgorithms3D.distance(iniGround, srSegment.rMeanPlane); - } - - srSegment.dc = (favorable) ? getRayCurveLength(srSegment.d,srSegment.d): srSegment.d; - srSegment.dPath = srSegment.d; - if (difVPoints.size()>0) { - double gPath = 0; - double dpSegments = 0; - - for (int idSegment = 0; idSegment < segmentList.size(); idSegment++) { - gPath += segmentList.get(idSegment).gPath*segmentList.get(idSegment).dp; - dpSegments += segmentList.get(idSegment).dp; - } - - - for (int idPoint = 2; idPoint < pointList.size()-1; idPoint++) { - dPath += CGAlgorithms3D.distance(pointList.get(idPoint - 1).coordinate, pointList.get(idPoint).coordinate); - } - - if (pointList.size()>3){ - srSegment.eLength = dPath; - } - srSegment.dPath = dPath - + CGAlgorithms3D.distance(srSegment.s, pointList.get(1).coordinate) - + CGAlgorithms3D.distance(pointList.get(pointList.size()-2).coordinate, srSegment.r); - srSegment.dc = srSegment.d; - - double convex = 1; // if path is convex, delta is positive, otherwise negative - - srSegment.gPath = gPath/srSegment.dPath; - - srSegment.dp = srSegment.dPath; - - // todo handle with unconvex path - //if (Vector3D.dot(S,R,S,pointList.get(difVPoints.get(0)).coordinate)<0){convex = -1;} - srSegment.delta = convex * (srSegment.dPath - srSegment.d); - } - - // diffraction on horizontal edges - if (difHPoints.size()>0) { - - dPath = 0; - - // Symmetric coordinates to the gound mean plane see Figure 2.5.c - Coordinate SGroundSeg = this.segmentList.get(0).sMeanPlane; - Coordinate RGroundSeg = this.segmentList.get(segmentList.size()-1).rMeanPlane; - Coordinate Sprime = new Coordinate(2 * SGroundSeg.x - srSegment.s.x, 2 * SGroundSeg.y - srSegment.s.y, 2 * SGroundSeg.z - srSegment.s.z); - Coordinate Rprime = new Coordinate(2 * RGroundSeg.x - srSegment.r.x, 2 * RGroundSeg.y - srSegment.r.y, 2 * RGroundSeg.z - srSegment.r.z); - - double gpath = srSegment.gPath; - SegmentPath SRp = new SegmentPath(gpath, new Vector3D(srSegment.s, Rprime),srSegment.pInit); - SegmentPath SpR = new SegmentPath(gpath, new Vector3D(Sprime, srSegment.r),Sprime); - - SpR.d = dist2D(Sprime, srSegment.r); - SRp.d = dist2D(srSegment.s, Rprime); - - SRp.dp = srSegment.dp; - SpR.dp = srSegment.dp; - - if (!this.favorable){ - for (int idPoint = 2; idPoint < pointList.size()-1; idPoint++) { - dPath += dist2D(pointList.get(idPoint - 1).coordinate, pointList.get(idPoint).coordinate); - } - - if (pointList.size()>3){ - srSegment.eLength = dPath; - SpR.eLength = dPath; - SRp.eLength = dPath; - } - srSegment.dPath = dPath - + dist2D(srSegment.s, pointList.get(1).coordinate) - + dist2D(pointList.get(pointList.size()-2).coordinate,srSegment.r); - SpR.dPath = dPath - + dist2D(Sprime, pointList.get(1).coordinate) - + dist2D(pointList.get(pointList.size()-2).coordinate,srSegment.r); - SRp.dPath = dPath - + dist2D(srSegment.s, pointList.get(1).coordinate) - + dist2D(pointList.get(pointList.size()-2).coordinate, Rprime); - - SpR.dc = SpR.d; - SRp.dc = SRp.d; - srSegment.dc = srSegment.d; - - // if path is convex, delta is positive, otherwise negative - double convex = Vector3D.dot(srSegment.s, srSegment.r, srSegment.s, pointList.get(difHPoints.get(0)).coordinate)<0 ? -1 : 1; - - srSegment.delta = convex * (srSegment.dPath - srSegment.d); - SRp.delta = convex * (SRp.dPath - SRp.d); - SpR.delta = convex * (SpR.dPath - SpR.d); - } - else - { - - // if the straight sound ray SR is masked by the obstacle (1st and 2nd case in Figure 2.5.e) - for (int idPoint = 2; idPoint < pointList.size()-1; idPoint++) { - dPath += getRayCurveLength(CGAlgorithms3D.distance(pointList.get(idPoint - 1).coordinate, pointList.get(idPoint).coordinate), srSegment.d); - } - - if (difHPoints.size()>1){ - double dDif = CGAlgorithms3D.distance(pointList.get(difHPoints.get(0)).coordinate,pointList.get(difHPoints.get(difHPoints.size()-1)).coordinate); - srSegment.eLength = getRayCurveLength(dDif,srSegment.d); - SpR.eLength = srSegment.eLength; - SRp.eLength = srSegment.eLength; - } - - srSegment.dPath = dPath - + getRayCurveLength(CGAlgorithms3D.distance(srSegment.s, pointList.get(1).coordinate), srSegment.d) - + getRayCurveLength(CGAlgorithms3D.distance(pointList.get(pointList.size()-2).coordinate, srSegment.r), srSegment.d); - srSegment.dc = getRayCurveLength(srSegment.d, srSegment.d); - - if (difHPoints.size()>0) { - SpR.dPath = dPath - + getRayCurveLength(CGAlgorithms3D.distance(Sprime, pointList.get(1).coordinate), srSegment.d) - + getRayCurveLength(CGAlgorithms3D.distance(pointList.get(pointList.size() - 2).coordinate, srSegment.r), srSegment.d); - SpR.dc = getRayCurveLength(SpR.d, srSegment.d); - - SRp.dPath = dPath - + getRayCurveLength(CGAlgorithms3D.distance(srSegment.s, pointList.get(1).coordinate), srSegment.d) - + getRayCurveLength(CGAlgorithms3D.distance(pointList.get(pointList.size() - 2).coordinate, Rprime), srSegment.d); - SRp.dc = getRayCurveLength(SRp.d, srSegment.d); - } - - // todo for the multiple diffractions in favourable conditions: Eq. 2.5.28 - - // Iif the straight sound ray SR is not masked by the obstacle (3rd case in Figure 2.5.e) - if (Vector3D.dot(srSegment.s, srSegment.r , srSegment.s, pointList.get(difHPoints.get(0)).coordinate)<0) { - Coordinate A = projectPointOnVector(pointList.get(difHPoints.get(0)).coordinate,srSegment.meanGdPlane, srSegment.pInit); - double SA = getRayCurveLength(CGAlgorithms3D.distance(srSegment.s, A), srSegment.d); - double AR = getRayCurveLength(CGAlgorithms3D.distance(A, srSegment.r), srSegment.d); - double SO = getRayCurveLength(CGAlgorithms3D.distance(srSegment.s, pointList.get(difHPoints.get(0)).coordinate), srSegment.d); - double OR = getRayCurveLength(CGAlgorithms3D.distance(pointList.get(difHPoints.get(0)).coordinate, srSegment.r), srSegment.d); - double SpA = getRayCurveLength(CGAlgorithms3D.distance(Sprime, A), srSegment.d); - double ARp = getRayCurveLength(CGAlgorithms3D.distance(A, Rprime), srSegment.d); - double SpO = getRayCurveLength(CGAlgorithms3D.distance(Sprime, pointList.get(difHPoints.get(0)).coordinate), srSegment.d); - double ORp = getRayCurveLength(CGAlgorithms3D.distance(pointList.get(difHPoints.get(0)).coordinate, Rprime), srSegment.d); - srSegment.delta = 2*SA+2*AR-SO-OR-srSegment.dc; // Eq. 2.5.27 - SRp.delta = 2*SA+2*ARp-SO-ORp-SRp.dc; - SpR.delta = 2*SpA+2*AR-SpO-OR-SpR.dc; - }else { - srSegment.delta = srSegment.dPath - srSegment.dc; // Eq. 2.5.26 - SRp.delta = SRp.dPath - SRp.dc; - SpR.delta = SpR.dPath - SpR.dc; - } - } - //this.srList.add(SpR); - //this.srList.add(SRp); - } - - // see Point 5.3 Equivalent heights in AFNOR document - if (srSegment.zsH <=0){srSegment.zsH = 0.000000001;} - if (srSegment.zrH <=0){srSegment.zrH = 0.000000001;} - - - double testForm = srSegment.dp / (30 * (srSegment.zsH + srSegment.zrH)); // if <= 1, then the distinction between the type of ground located near the source and the type of ground located near the receiver is negligible. - srSegment.testFormH = testForm; - - double gPathPrime; - - // if dp <= 30(zs + zr), then the distinction between the type of ground located near the source and the type of ground located near the receiver is negligible. - // Eq. 2.5.14 - if (testForm <= 1) { - srSegment.gPathPrime = testForm * srSegment.gPath + (1 - testForm) * getGs(); - } else { - srSegment.gPathPrime = srSegment.gPath; - } - - //this.srList.set(0,SR); - - // Compute PRIME zs, zr and testForm - double zsPrime= srSegment.getZsPrime(this, srSegment); - double zrPrime = srSegment.getZrPrime(this, srSegment); - - srSegment.testFormF = srSegment.dp / (30 * (zsPrime + zrPrime)); } -/* - void computeAugmentedSegments() { - for (int idSegment = 0; idSegment < segmentList.size(); idSegment++) { - - SegmentPath seg = segmentList.get(idSegment); - - seg.idPtStart = idSegment; - seg.idPtFinal = idSegment+1; - - // see Point 5.3 Equivalent heights in AFNOR document - if (seg.zsH <=0){seg.zsH = 0.000000001;} - if (seg.zrH <=0){seg.zrH = 0.000000001;} - - seg.dc = favorable ? getRayCurveLength(seg.d, seg.d) : seg.d; - - double gs = getGs(); - - seg.testFormH = seg.dp / (30 * (seg.zsH + seg.zrH)); - - // Compute PRIME zs, zr and testForm - double zsPrime= seg.getZsPrime(this, seg ); - double zrPrime = seg.getZrPrime(this, seg); - - seg.testFormF = seg.dp / (30 * (zsPrime + zrPrime)); - - double gPathPrime; - - if (seg.testFormH <= 1) { - gPathPrime = seg.testFormH * seg.gPath + (1 - seg.testFormH) * gs; - } else { - gPathPrime = seg.gPath; - } - seg.gPathPrime = gPathPrime; - - } - - } -*/ double computeZs(SegmentPath segmentPath) { double zs = pointList.get(segmentPath.idPtStart).coordinate.z - projectPointOnSegment(pointList.get(segmentPath.idPtStart).coordinate,segmentPath.meanGdPlane,segmentPath.pInit).z; return ((zs > 0) ? zs : 0); // Section 2.5.3 - If the equivalent height of a point becomes negative, i.e. if the point is located below the mean ground plane, a null height is retained, and the equivalent point is then identical with its possible image. From 90d6a805bab2e42c84b80cac7ec84132eb2fe126 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 22 Sep 2022 13:59:08 +0200 Subject: [PATCH 05/20] fix call to diffraction parameters --- .../Noise_level_from_source.groovy | 4 ++-- .../Noise_level_from_traffic.groovy | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy index 750397ec6..936b6c682 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy @@ -535,8 +535,8 @@ def exec(Connection connection, input) { ldenProcessing.directionAttributes = DirectivityTableLoader.loadTable(connection, tableSourceDirectivity, 1) logger.info(String.format(Locale.ROOT, "Loaded %d directivity from %s table", ldenProcessing.directionAttributes.size(), tableSourceDirectivity)) } - pointNoiseMap.setComputeHorizontalDiffraction(compute_horizontal_diffraction) - pointNoiseMap.setComputeVerticalDiffraction(compute_vertical_diffraction) + pointNoiseMap.setComputeHorizontalDiffraction(compute_vertical_diffraction) + pointNoiseMap.setComputeVerticalDiffraction(compute_horizontal_diffraction) pointNoiseMap.setSoundReflectionOrder(reflexion_order) // Set environmental parameters diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy index eb2cedd56..de605d4ee 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy @@ -255,6 +255,15 @@ inputs = [ '
  • The last column 360° contains occurrences between 348.75° to 360° and 0 to 11.25°
  • Default value 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5', min : 0, max: 1, type : String.class + ], + confRaysTableName : [ + name : 'Save each propagation ray into the specified table (ex:RAYS)', + title : 'Name of the ray table', + description: 'You can set a table name here in order to save all the rays computed by NoiseModelling' + + '. This table may be extremely large if there is a lot of receivers and sources. ' + + 'It will also greatly increase the computation time.' + + '

    Default value : empty (do not keep rays) ', + min : 0, max: 1, type: String.class ] ] @@ -522,9 +531,15 @@ def exec(Connection connection, input) { ldenConfig.setComputeLDEN(!confSkipLden) ldenConfig.setMergeSources(!confExportSourceId) + if (input['confRaysTableName'] && !((input['confRaysTableName'] as String).isEmpty())) { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + ldenConfig.setKeepAbsorption(true); + ldenConfig.setRaysTable(input['confRaysTableName'] as String) + } + LDENPointNoiseMapFactory ldenProcessing = new LDENPointNoiseMapFactory(connection, ldenConfig) - pointNoiseMap.setComputeHorizontalDiffraction(compute_horizontal_diffraction) - pointNoiseMap.setComputeVerticalDiffraction(compute_vertical_diffraction) + pointNoiseMap.setComputeHorizontalDiffraction(compute_vertical_diffraction) + pointNoiseMap.setComputeVerticalDiffraction(compute_horizontal_diffraction) pointNoiseMap.setSoundReflectionOrder(reflexion_order) From cf0ca529f7ced0e49754eae4744aa2889b7c8f6e Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 22 Sep 2022 14:46:41 +0200 Subject: [PATCH 06/20] clean code --- .../noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java | 6 ------ .../noisemodelling/pathfinder/PropagationPath.java | 4 ++-- .../propagation/EvaluateAttenuationCnossos.java | 3 --- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java index c2c759daf..5ab995fb7 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java @@ -5837,12 +5837,6 @@ public void TestRegressionNaN() throws LayerDelaunayError, IOException { PropagationPath propPath = new PropagationPath(); propPath.readStream(new DataInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(path)))); - propPath.initPropagationPath(); - -// ByteArrayOutputStream bos = new ByteArrayOutputStream(); -// propPath.writeStream(new DataOutputStream(bos)); -// String newVersion = new String(Base64.getEncoder().encode(bos.toByteArray())); -// System.out.println(newVersion); PropagationProcessPathData pathData = new PropagationProcessPathData(); EvaluateAttenuationCnossos.evaluate(propPath, pathData); diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java index 642eaf70a..04161a317 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PropagationPath.java @@ -249,7 +249,7 @@ public LineString asGeom() { int i=0; double cutPointDistance = 0; int cutPointCursor = 0; - if(cutPoints.isEmpty()) { + if(cutPoints.isEmpty() || coordinates.length <= 1) { return geometryFactory.createLineString(); } for(PointPath pointPath : pointList) { @@ -271,7 +271,7 @@ public LineString asGeom() { double distanceP0P1 = p1.distance(p0); // compute ratio of pointPath position between p0 and p1 double ratio = Math.min(1, Math.max(0, (pointPath.coordinate.x - (cutPointDistance - distanceP0P1)) / distanceP0P1)); - // interpolate coordinates + // interpolate x,y coordinates rayPoint = new LineSegment(p0, p1).pointAlong(ratio); rayPoint.setZ(pointPath.coordinate.y); } diff --git a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/EvaluateAttenuationCnossos.java b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/EvaluateAttenuationCnossos.java index 7b740bca3..ec35b1470 100644 --- a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/EvaluateAttenuationCnossos.java +++ b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/EvaluateAttenuationCnossos.java @@ -458,9 +458,6 @@ public static double[] evaluate(PropagationPath path, PropagationProcessPathData } } - // init evolved path - path.initPropagationPath(); - // init atmosphere double[] alpha_atmo = data.getAlpha_atmo(); From d07060ec22aeb19bbaa47cda9c397d11fea4e3ce Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 22 Sep 2022 16:42:57 +0200 Subject: [PATCH 07/20] javadoc, fix building rendering kml, add color to propagation rays in kml --- .../pathfinder/ProfileBuilder.java | 14 +-- .../pathfinder/utils/KMLDocument.java | 87 +++++++++++++++++-- .../org/noise_planet/nmtutorial01/main.java | 16 ++-- 3 files changed, 100 insertions(+), 17 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java index 0e05a9682..6f5b0159f 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java @@ -2171,7 +2171,7 @@ public static class Building implements Obstacle { private Polygon poly; /** Height of the building. */ private final double height; - private double zTopo = 0.0; + private double zTopo = 0.0; // average Z ground /** Absorption coefficients. */ private final List alphas; @@ -2263,14 +2263,18 @@ public int getPrimaryKey() { return pk; } - //TODO use instead the min Ztopo + /** + * Compute average Z ground under the building contour + * @param profileBuilder + * @return + */ public double updateZTopo(ProfileBuilder profileBuilder) { Coordinate[] coordinates = poly.getCoordinates(); - double minZ = 0.0; + double sumZ = 0.0; for (int i = 0; i < coordinates.length-1; i++) { - minZ += profileBuilder.getZGround(coordinates[i]); + sumZ += profileBuilder.getZGround(coordinates[i]); } - zTopo = minZ/(coordinates.length-1); + zTopo = sumZ/(coordinates.length-1); return zTopo; } diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java index 3137ecb74..d8ed8c905 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java @@ -62,8 +62,10 @@ import org.cts.op.CoordinateOperationFactory; import org.cts.registry.EPSGRegistry; import org.cts.registry.RegistryManager; +import org.h2gis.utilities.dbtypes.DBUtils; import org.locationtech.jts.algorithm.Orientation; import org.locationtech.jts.geom.*; +import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.io.kml.KMLWriter; import org.noise_planet.noisemodelling.pathfinder.PointPath; import org.noise_planet.noisemodelling.pathfinder.ProfileBuilder; @@ -73,13 +75,18 @@ import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; +import java.awt.*; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -90,7 +97,7 @@ * @author Nicolas Fortin 2019 */ public class KMLDocument { -// private List buildings = new ArrayList<>(); + // private List buildings = new ArrayList<>(); // private List isoCountours = new ArrayList<>(); private final XMLStreamWriter xmlOut; private final OutputStream outputStream; @@ -100,12 +107,39 @@ public class KMLDocument { private int wgs84Precision = 7; private GeometryFactory geometryFactory = new GeometryFactory(); private CoordinateOperation transform = null; + // Color scale from 0 to 1 + private TreeMap colorScale = new TreeMap<>(); public KMLDocument(OutputStream outputStream) throws XMLStreamException { final XMLOutputFactory streamWriterFactory = XMLOutputFactory.newFactory(); this.outputStream = outputStream; xmlOut = streamWriterFactory.createXMLStreamWriter( new BufferedOutputStream(outputStream), "UTF-8"); + setDefaultColorScale(); + } + + public void setDefaultColorScale() { + colorScale.clear(); + // Set default color scale + colorScale.put(0.0, new Color(130, 166, 173)); + colorScale.put(1 / 10.0, new Color(160, 186, 191)); + colorScale.put(2 / 10.0, new Color(184, 214, 209)); + colorScale.put(3 / 10.0, new Color(206, 228, 204)); + colorScale.put(4 / 10.0, new Color(226, 242, 191)); + colorScale.put(5 / 10.0, new Color(243, 198, 131)); + colorScale.put(6 / 10.0, new Color(232, 126, 77)); + colorScale.put(7 / 10.0, new Color(205, 70, 62)); + colorScale.put(8 / 10.0, new Color(161, 26, 77)); + colorScale.put(9 / 10.0, new Color(117, 8, 92)); + colorScale.put(1.0, new Color(67, 10, 74)); + } + + public Map getColorScale() { + return new HashMap<>(colorScale); + } + + public void setColorScale(Map colorScale) { + this.colorScale = new TreeMap<>(colorScale); } /** @@ -128,7 +162,7 @@ public void setInputCRS(String crs) throws CRSException, CoordinateOperationExce // Add the appropriate registry to the CRSFactory's registry manager. Here the EPSG registry is used. RegistryManager registryManager = cRSFactory.getRegistryManager(); - registryManager.addRegistry(new EPSGRegistry()); + registryManager.addRegistry(new EPSGRegistry()); // CTS will read the EPSG registry seeking the 4326 code, when it finds it, // it will create a CoordinateReferenceSystem using the parameters found in the registry. @@ -249,6 +283,7 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea Coordinate[] original = building.getGeometry().getCoordinates(); Coordinate[] coordinates = new Coordinate[original.length]; double z = profileBuilder.getBuilding(idPoly ).getZ(); + // z is building height + average ground height for(int i = 0; i < coordinates.length; i++) { coordinates[i] = copyCoord(new Coordinate(original[i].x, original[i].y, z)); } @@ -265,8 +300,8 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea } //Write geometry writeRawXml(KMLWriter.writeGeometry(geometryFactory.createMultiPolygon( - polygons.toArray(new Polygon[polygons.size()])), Double.NaN, - wgs84Precision, true, KMLWriter.ALTITUDE_MODE_RELATIVETOGROUND)); + polygons.toArray(new Polygon[polygons.size()])), Double.NaN, + wgs84Precision, true, KMLWriter.ALTITUDE_MODE_ABSOLUTE)); xmlOut.writeEndElement();//Write Placemark xmlOut.writeEndElement();//Folder return this; @@ -307,7 +342,32 @@ public KMLDocument writeProfile(String layerName, ProfileBuilder.CutProfile prof return this; } + private String formatColorEntry(double key) { + return String.format(Locale.ROOT, "scale%g", key); + } + public KMLDocument writeRays(Collection rays) throws XMLStreamException { + double minDb = Double.MAX_VALUE; + double maxDb = -Double.MAX_VALUE; + for(PropagationPath line : rays) { + if(line.absorptionData.aGlobal != null && line.absorptionData.aGlobal.length > 0) { + double attenuationLevel = PowerUtils.sumDbArray(line.absorptionData.aGlobal); + minDb = Math.min(minDb, attenuationLevel); + maxDb = Math.max(maxDb, attenuationLevel); + } + } + for (Map.Entry colorEntry : colorScale.entrySet()) { + xmlOut.writeStartElement("Style"); + xmlOut.writeAttribute("id", formatColorEntry(colorEntry.getKey())); + xmlOut.writeStartElement("LineStyle"); + xmlOut.writeStartElement("color"); + Color color = colorEntry.getValue(); + xmlOut.writeCharacters(String.format("#FF%02x%02x%02x", color.getBlue(), color.getGreen(), color.getRed())); + xmlOut.writeEndElement(); // /color + xmlOut.writeEndElement(); // /LineStyle + xmlOut.writeEndElement(); // / Style + } + xmlOut.writeStartElement("Schema"); xmlOut.writeAttribute("name", "rays"); xmlOut.writeAttribute("id", "rays"); @@ -317,10 +377,27 @@ public KMLDocument writeRays(Collection rays) throws XMLStreamE xmlOut.writeCharacters("rays"); xmlOut.writeEndElement();//Name for(PropagationPath line : rays) { + double attenuationLevel = 0; xmlOut.writeStartElement("Placemark"); xmlOut.writeStartElement("name"); - xmlOut.writeCharacters(String.format("R:%d S:%d", line.getIdReceiver(), line.getIdSource())); + if(line.absorptionData.aGlobal != null && line.absorptionData.aGlobal.length > 0) { + attenuationLevel = PowerUtils.sumDbArray(line.absorptionData.aGlobal); + xmlOut.writeCharacters(String.format("%.1f dB R:%d S:%d", + attenuationLevel,line.getIdReceiver(), line.getIdSource())); + } else { + xmlOut.writeCharacters(String.format("R:%d S:%d", line.getIdReceiver(), line.getIdSource())); + } xmlOut.writeEndElement();//Name + if(line.absorptionData.aGlobal != null && line.absorptionData.aGlobal.length > 0) { + Map.Entry colorEntry = + colorScale.floorEntry((attenuationLevel - minDb) / (maxDb - minDb)); + if(colorEntry == null) { + colorEntry = colorScale.firstEntry(); + } + xmlOut.writeStartElement("styleUrl"); + xmlOut.writeCharacters("#" + formatColorEntry(colorEntry.getKey())); + xmlOut.writeEndElement(); //styleurl + } LineString lineString = line.asGeom(); // Apply CRS transform doTransform(lineString); diff --git a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java index cb6c71c91..7176cd746 100644 --- a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java +++ b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java @@ -47,7 +47,7 @@ import java.util.concurrent.atomic.AtomicInteger; class Main { - public final static int MAX_OUTPUT_PROPAGATION_PATHS = 50; + public final static int MAX_OUTPUT_PROPAGATION_PATHS = 50000; public static void main(String[] args) throws SQLException, IOException, LayerDelaunayError { // Init output logger @@ -140,7 +140,7 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe ldenConfig.setComputeLEvening(true); ldenConfig.setComputeLNight(true); ldenConfig.setComputeLDEN(true); - ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE); + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY); ldenConfig.setKeepAbsorption(true); LDENPointNoiseMapFactory tableWriter = new LDENPointNoiseMapFactory(connection, ldenConfig); @@ -188,12 +188,14 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe if (out instanceof ComputeRaysOutAttenuation) { ComputeRaysOutAttenuation cellStorage = (ComputeRaysOutAttenuation) out; // restrict the number of rays to export - List propagationPaths = new ArrayList<>(); + List propagationPaths = new ArrayList<>(MAX_OUTPUT_PROPAGATION_PATHS); for(PropagationPath p : ((ComputeRaysOutAttenuation)out).propagationPaths) { - if(p.getPointList().size() > 3) { - propagationPaths.add(p); - if(propagationPaths.size() > MAX_OUTPUT_PROPAGATION_PATHS) { - break; + if(p.getTimePeriod().equals(LDENConfig.TIME_PERIOD.DAY.name())) { + if (p.getPointList().size() > 3) { + propagationPaths.add(p); + if (propagationPaths.size() >= MAX_OUTPUT_PROPAGATION_PATHS) { + break; + } } } } From d11b9f63ac3ee2621267532085735ea8996af691 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 22 Sep 2022 17:20:12 +0200 Subject: [PATCH 08/20] Fix buildings definnition --- .../pathfinder/utils/KMLDocument.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java index d8ed8c905..8538b0c19 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java @@ -271,14 +271,8 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea xmlOut.writeStartElement("name"); xmlOut.writeCharacters("buildings"); xmlOut.writeEndElement();//Name - xmlOut.writeStartElement("Placemark"); - xmlOut.writeStartElement("name"); - xmlOut.writeCharacters("building"); - xmlOut.writeEndElement();//Name List buildings = profileBuilder.getBuildings(); - List polygons = new ArrayList<>(buildings.size()); int idPoly = 0; - for(ProfileBuilder.Building building : buildings) { Coordinate[] original = building.getGeometry().getCoordinates(); Coordinate[] coordinates = new Coordinate[original.length]; @@ -294,15 +288,18 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea } // Apply CRS transform doTransform(poly); - polygons.add(poly); + xmlOut.writeStartElement("Placemark"); + xmlOut.writeStartElement("name"); + xmlOut.writeCharacters("building"); + xmlOut.writeEndElement();//Name + //Write geometry + writeRawXml(KMLWriter.writeGeometry( + poly, z, + wgs84Precision, true, KMLWriter.ALTITUDE_MODE_ABSOLUTE)); + xmlOut.writeEndElement();//Write Placemark } idPoly++; } - //Write geometry - writeRawXml(KMLWriter.writeGeometry(geometryFactory.createMultiPolygon( - polygons.toArray(new Polygon[polygons.size()])), Double.NaN, - wgs84Precision, true, KMLWriter.ALTITUDE_MODE_ABSOLUTE)); - xmlOut.writeEndElement();//Write Placemark xmlOut.writeEndElement();//Folder return this; } From 1111d04b8fb31747383a0c835566a545d69695d6 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Fri, 23 Sep 2022 09:56:43 +0200 Subject: [PATCH 09/20] clean imports --- .../noisemodelling/pathfinder/utils/KMLDocument.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java index 8538b0c19..c51e2c54e 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java @@ -62,12 +62,14 @@ import org.cts.op.CoordinateOperationFactory; import org.cts.registry.EPSGRegistry; import org.cts.registry.RegistryManager; -import org.h2gis.utilities.dbtypes.DBUtils; import org.locationtech.jts.algorithm.Orientation; -import org.locationtech.jts.geom.*; +import org.locationtech.jts.geom.Coordinate; +import org.locationtech.jts.geom.CoordinateFilter; +import org.locationtech.jts.geom.Geometry; +import org.locationtech.jts.geom.GeometryFactory; +import org.locationtech.jts.geom.LineString; import org.locationtech.jts.geom.Polygon; import org.locationtech.jts.io.kml.KMLWriter; -import org.noise_planet.noisemodelling.pathfinder.PointPath; import org.noise_planet.noisemodelling.pathfinder.ProfileBuilder; import org.noise_planet.noisemodelling.pathfinder.PropagationPath; import org.noise_planet.noisemodelling.pathfinder.Triangle; @@ -75,12 +77,11 @@ import javax.xml.stream.XMLOutputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; -import java.awt.*; +import java.awt.Color; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; -import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; From 2dfb5ae92a2b146fee169d947ff838721b85b5db Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Fri, 23 Sep 2022 10:00:46 +0200 Subject: [PATCH 10/20] fix test --- .../org/noise_planet/noisemodelling/propagation/special_ray.json | 1 - 1 file changed, 1 deletion(-) diff --git a/noisemodelling-propagation/src/test/resources/org/noise_planet/noisemodelling/propagation/special_ray.json b/noisemodelling-propagation/src/test/resources/org/noise_planet/noisemodelling/propagation/special_ray.json index 2a1f033dd..57a404949 100644 --- a/noisemodelling-propagation/src/test/resources/org/noise_planet/noisemodelling/propagation/special_ray.json +++ b/noisemodelling-propagation/src/test/resources/org/noise_planet/noisemodelling/propagation/special_ray.json @@ -223,7 +223,6 @@ }, "angle" : 0.0, "gs" : 0.0, - "initialized" : false, "difHPoints" : [ 1 ], "difVPoints" : [ ], "refPoints" : [ ], From f30b9b29a4e20c17a4d705bc9579498b1c045e30 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Mon, 26 Sep 2022 11:08:40 +0200 Subject: [PATCH 11/20] Check if dem is used before exporting KML Document --- .../pathfinder/ProfileBuilder.java | 7 +++++++ .../pathfinder/utils/KMLDocument.java | 21 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java index 6f5b0159f..db2e387f5 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java @@ -1575,6 +1575,13 @@ public double getZGround(Coordinate c) { return getZGround(new CutPoint(c, TOPOGRAPHY, -1)); } + /** + * @return True if digital elevation model has been added + */ + public boolean hasDem() { + return topoTree != null && topoTree.size() > 0; + } + public double getZGround(CutPoint cut) { if(!Double.isNaN(cut.zGround)) { return cut.zGround; diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java index c51e2c54e..1c83d504c 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/KMLDocument.java @@ -274,6 +274,12 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea xmlOut.writeEndElement();//Name List buildings = profileBuilder.getBuildings(); int idPoly = 0; + KMLWriter buildingWriter = new KMLWriter(); + buildingWriter.setPrecision(wgs84Precision); + buildingWriter.setExtrude(true); + buildingWriter.setTesselate(true); + buildingWriter.setAltitudeMode(profileBuilder.hasDem() ? KMLWriter.ALTITUDE_MODE_ABSOLUTE : KMLWriter.ALTITUDE_MODE_RELATIVETOGROUND); + for(ProfileBuilder.Building building : buildings) { Coordinate[] original = building.getGeometry().getCoordinates(); Coordinate[] coordinates = new Coordinate[original.length]; @@ -294,9 +300,8 @@ public KMLDocument writeBuildings(ProfileBuilder profileBuilder) throws XMLStrea xmlOut.writeCharacters("building"); xmlOut.writeEndElement();//Name //Write geometry - writeRawXml(KMLWriter.writeGeometry( - poly, z, - wgs84Precision, true, KMLWriter.ALTITUDE_MODE_ABSOLUTE)); + buildingWriter.setZ(z); + writeRawXml(buildingWriter.write(poly)); xmlOut.writeEndElement();//Write Placemark } idPoly++; @@ -378,6 +383,13 @@ public KMLDocument writeRays(Collection rays) throws XMLStreamE double attenuationLevel = 0; xmlOut.writeStartElement("Placemark"); xmlOut.writeStartElement("name"); + boolean hasGroundElevation = false; + for(ProfileBuilder.CutPoint cutPoint : line.getCutPoints()) { + if(!Double.isNaN(cutPoint.getzGround())) { + hasGroundElevation = true; + break; + } + } if(line.absorptionData.aGlobal != null && line.absorptionData.aGlobal.length > 0) { attenuationLevel = PowerUtils.sumDbArray(line.absorptionData.aGlobal); xmlOut.writeCharacters(String.format("%.1f dB R:%d S:%d", @@ -401,7 +413,8 @@ public KMLDocument writeRays(Collection rays) throws XMLStreamE doTransform(lineString); //Write geometry writeRawXml(KMLWriter.writeGeometry(lineString, Double.NaN, - wgs84Precision, false, KMLWriter.ALTITUDE_MODE_ABSOLUTE)); + wgs84Precision, false, + hasGroundElevation ? KMLWriter.ALTITUDE_MODE_ABSOLUTE : KMLWriter.ALTITUDE_MODE_RELATIVETOGROUND)); xmlOut.writeEndElement();//Write Placemark } xmlOut.writeEndElement();//Folder From 982452960c30e6b71361ac438f2d83386d5e3435 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Mon, 26 Sep 2022 13:35:52 +0200 Subject: [PATCH 12/20] do not use synchronized list, add parameter to limit the number of rays collected --- .../jdbc/LDENComputeRaysOut.java | 31 ++- .../noisemodelling/jdbc/LDENConfig.java | 16 ++ .../jdbc/EvaluateAttenuationCnossosTest.java | 244 +++++++++--------- .../jdbc/PointNoiseMapTest.java | 25 +- .../ComputeRaysOutAttenuation.java | 5 +- 5 files changed, 183 insertions(+), 138 deletions(-) diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java index c86167c01..d711598a0 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java @@ -210,8 +210,23 @@ public void pushInStack(ConcurrentLinkedDeque stack, Collection return; } } - stack.addAll(data); - ldenComputeRaysOut.ldenData.queueSize.addAndGet(data.size()); + if(ldenConfig.getMaximumRaysOutputCount() == 0 || ldenComputeRaysOut.ldenData.totalRaysInserted.get() < ldenConfig.getMaximumRaysOutputCount()) { + long newTotalRays = ldenComputeRaysOut.ldenData.totalRaysInserted.addAndGet(data.size()); + if(ldenConfig.getMaximumRaysOutputCount() > 0 && newTotalRays > ldenConfig.getMaximumRaysOutputCount()) { + // too many rays, remove unwanted rays + int newListSize = data.size() - (int)(newTotalRays - ldenConfig.getMaximumRaysOutputCount()); + List subList = new ArrayList(newListSize); + for(PropagationPath propagationPath : data) { + subList.add(propagationPath); + if(subList.size() >= newListSize) { + break; + } + } + data = subList; + } + stack.addAll(data); + ldenComputeRaysOut.ldenData.queueSize.addAndGet(data.size()); + } } @Override @@ -220,7 +235,16 @@ public void finalizeReceiver(final long receiverId) { if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) { // Push propagation rays pushInStack(ldenComputeRaysOut.ldenData.rays, propagationPaths); - } else if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_MEMORY){ + } else if(ldenConfig.getExportRaysMethod() == LDENConfig.ExportRaysMethods.TO_MEMORY + && (ldenConfig.getMaximumRaysOutputCount() == 0 || + ldenComputeRaysOut.propagationPathsSize.get() < ldenConfig.getMaximumRaysOutputCount())){ + int newRaysSize = ldenComputeRaysOut.propagationPathsSize.addAndGet(propagationPaths.size()); + if(newRaysSize > ldenConfig.getMaximumRaysOutputCount()) { + // remove exceeded elements of the array + propagationPaths = propagationPaths.subList(0, + propagationPaths.size() - Math.min( propagationPaths.size(), + newRaysSize - ldenConfig.getMaximumRaysOutputCount())); + } ldenComputeRaysOut.propagationPaths.addAll(propagationPaths); } propagationPaths.clear(); @@ -330,6 +354,7 @@ public void finalizeReceiver(final long receiverId) { public static class LdenData { public final AtomicLong queueSize = new AtomicLong(0); + public final AtomicLong totalRaysInserted = new AtomicLong(0); public final ConcurrentLinkedDeque lDayLevels = new ConcurrentLinkedDeque<>(); public final ConcurrentLinkedDeque lEveningLevels = new ConcurrentLinkedDeque<>(); public final ConcurrentLinkedDeque lNightLevels = new ConcurrentLinkedDeque<>(); diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java index 780e95021..2fb44e82a 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java @@ -24,6 +24,7 @@ import org.noise_planet.noisemodelling.propagation.PropagationProcessPathData; import java.io.File; +import java.util.concurrent.atomic.AtomicInteger; /** * Configuration of NoiseModelling computation based on database data using standard Lden outputs @@ -68,6 +69,7 @@ public enum ExportRaysMethods {TO_RAYS_TABLE, TO_MEMORY, NONE} boolean exportProfileInRays = false; boolean keepAbsorption = false; // in rays, keep store detailed absorption data + int maximumRaysOutputCount = 0; // if export rays, do not keep more than this number of rays (0 infinite) // Maximum result stack to be inserted in database // if the stack is full, the computation core is waiting int outputMaximumQueue = 50000; @@ -102,6 +104,20 @@ public PropagationProcessPathData getPropagationProcessPathData(TIME_PERIOD time } } + /** + * @return if export rays, do not keep more than this number of rays (0 infinite) + */ + public int getMaximumRaysOutputCount() { + return maximumRaysOutputCount; + } + + /** + * @param maximumRaysOutputCount if export rays, do not keep more than this number of rays (0 infinite) + */ + public void setMaximumRaysOutputCount(int maximumRaysOutputCount) { + this.maximumRaysOutputCount = maximumRaysOutputCount; + } + public void setPropagationProcessPathData(TIME_PERIOD time_period, PropagationProcessPathData propagationProcessPathData) { switch (time_period) { case DAY: diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java index 5ab995fb7..7f8b35fbe 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java @@ -288,8 +288,8 @@ public void eastWestTest() { //Run computation computeRays.run(propDataOut); - SegmentPath s0 = propDataOut.propagationPaths.get(0).getSRSegment(); - SegmentPath s1 = propDataOut.propagationPaths.get(1).getSRSegment(); + SegmentPath s0 = propDataOut.getPropagationPaths().get(0).getSRSegment(); + SegmentPath s1 = propDataOut.getPropagationPaths().get(1).getSRSegment(); assertEquals(s0.dp, s1.dp); assertEquals(s0.testFormH, s1.testFormH); assertArrayEquals(propDataOut.receiversAttenuationLevels.pop().value, propDataOut.receiversAttenuationLevels.pop().value, Double.MIN_VALUE); @@ -337,8 +337,8 @@ public void northSouthTest() { //Run computation computeRays.run(propDataOut); - SegmentPath s0 = propDataOut.propagationPaths.get(0).getSRSegment(); - SegmentPath s1 = propDataOut.propagationPaths.get(1).getSRSegment(); + SegmentPath s0 = propDataOut.getPropagationPaths().get(0).getSRSegment(); + SegmentPath s1 = propDataOut.getPropagationPaths().get(1).getSRSegment(); assertEquals(s0.dp, s1.dp); assertEquals(s0.testFormH, s1.testFormH); assertArrayEquals(propDataOut.receiversAttenuationLevels.pop().value, propDataOut.receiversAttenuationLevels.pop().value, Double.MIN_VALUE); @@ -443,7 +443,7 @@ public void retroDiff() { //Run computation computeRays.run(propDataOut); - double[] retro = propDataOut.propagationPaths.get(1).reflectionAttenuation.dLRetro; + double[] retro = propDataOut.getPropagationPaths().get(1).reflectionAttenuation.dLRetro; for (double v : retro) { assertTrue(v > 0.); } @@ -497,21 +497,21 @@ public void TC01() { //Actual values - double[] actualWH = propDataOut.propagationPaths.get(0).groundAttenuation.wH; - double[] actualCfH = propDataOut.propagationPaths.get(0).groundAttenuation.cfH; - double[] actualAGroundH = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundH; - double[] actualWF = propDataOut.propagationPaths.get(0).groundAttenuation.wF; - double[] actualCfF = propDataOut.propagationPaths.get(0).groundAttenuation.cfF; - double[] actualAGroundF = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundF; + double[] actualWH = propDataOut.getPropagationPaths().get(0).groundAttenuation.wH; + double[] actualCfH = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfH; + double[] actualAGroundH = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundH; + double[] actualWF = propDataOut.getPropagationPaths().get(0).groundAttenuation.wF; + double[] actualCfF = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfF; + double[] actualAGroundF = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundF; double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); - double[] actualAAtm = propDataOut.propagationPaths.get(0).absorptionData.aAtm; - double[] actualADiv = propDataOut.propagationPaths.get(0).absorptionData.aDiv; - double[] actualABoundaryH = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryH; - double[] actualABoundaryF = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryF; - double[] actualLH = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); - double[] actualLF = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); - double[] actualL = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); + double[] actualAAtm = propDataOut.getPropagationPaths().get(0).absorptionData.aAtm; + double[] actualADiv = propDataOut.getPropagationPaths().get(0).absorptionData.aDiv; + double[] actualABoundaryH = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryH; + double[] actualABoundaryF = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryF; + double[] actualLH = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); + double[] actualLF = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); + double[] actualL = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); //Assertions assertDoubleArrayEquals("WH", expectedWH, actualWH, ERROR_EPSILON_LOWEST); @@ -578,21 +578,21 @@ public void TC02() { double[] expectedL = new double[]{38.07, 38.01, 37.89, 36.79, 34.29, 36.21, 31.73, 15.39}; //Actual values - double[] actualWH = propDataOut.propagationPaths.get(0).groundAttenuation.wH; - double[] actualCfH = propDataOut.propagationPaths.get(0).groundAttenuation.cfH; - double[] actualAGroundH = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundH; - double[] actualWF = propDataOut.propagationPaths.get(0).groundAttenuation.wF; - double[] actualCfF = propDataOut.propagationPaths.get(0).groundAttenuation.cfF; - double[] actualAGroundF = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundF; + double[] actualWH = propDataOut.getPropagationPaths().get(0).groundAttenuation.wH; + double[] actualCfH = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfH; + double[] actualAGroundH = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundH; + double[] actualWF = propDataOut.getPropagationPaths().get(0).groundAttenuation.wF; + double[] actualCfF = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfF; + double[] actualAGroundF = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundF; double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); - double[] actualAAtm = propDataOut.propagationPaths.get(0).absorptionData.aAtm; - double[] actualADiv = propDataOut.propagationPaths.get(0).absorptionData.aDiv; - double[] actualABoundaryH = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryH; - double[] actualABoundaryF = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryF; - double[] actualLH = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); - double[] actualLF = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); - double[] actualL = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); + double[] actualAAtm = propDataOut.getPropagationPaths().get(0).absorptionData.aAtm; + double[] actualADiv = propDataOut.getPropagationPaths().get(0).absorptionData.aDiv; + double[] actualABoundaryH = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryH; + double[] actualABoundaryF = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryF; + double[] actualLH = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); + double[] actualLF = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); + double[] actualL = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); //Assertions assertDoubleArrayEquals("WH", expectedWH, actualWH, ERROR_EPSILON_LOWEST); @@ -659,21 +659,21 @@ public void TC03() { double[] expectedL = new double[]{36.21, 36.16, 35.31, 29.71, 33.70, 34.36, 29.87, 13.54}; //Actual values - double[] actualWH = propDataOut.propagationPaths.get(0).groundAttenuation.wH; - double[] actualCfH = propDataOut.propagationPaths.get(0).groundAttenuation.cfH; - double[] actualAGroundH = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundH; - double[] actualWF = propDataOut.propagationPaths.get(0).groundAttenuation.wF; - double[] actualCfF = propDataOut.propagationPaths.get(0).groundAttenuation.cfF; - double[] actualAGroundF = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundF; + double[] actualWH = propDataOut.getPropagationPaths().get(0).groundAttenuation.wH; + double[] actualCfH = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfH; + double[] actualAGroundH = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundH; + double[] actualWF = propDataOut.getPropagationPaths().get(0).groundAttenuation.wF; + double[] actualCfF = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfF; + double[] actualAGroundF = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundF; double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); - double[] actualAAtm = propDataOut.propagationPaths.get(0).absorptionData.aAtm; - double[] actualADiv = propDataOut.propagationPaths.get(0).absorptionData.aDiv; - double[] actualABoundaryH = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryH; - double[] actualABoundaryF = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryF; - double[] actualLH = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); - double[] actualLF = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); - double[] actualL = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); + double[] actualAAtm = propDataOut.getPropagationPaths().get(0).absorptionData.aAtm; + double[] actualADiv = propDataOut.getPropagationPaths().get(0).absorptionData.aDiv; + double[] actualABoundaryH = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryH; + double[] actualABoundaryF = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryF; + double[] actualLH = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); + double[] actualLF = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); + double[] actualL = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); //Assertions assertDoubleArrayEquals("WH", expectedWH, actualWH, ERROR_EPSILON_LOWEST); @@ -744,21 +744,21 @@ public void TC04() { double[] expectedL = new double[]{37.91, 37.85, 37.73, 36.37, 34.23, 36.06, 31.57, 15.24}; //Actual values - double[] actualWH = propDataOut.propagationPaths.get(0).groundAttenuation.wH; - double[] actualCfH = propDataOut.propagationPaths.get(0).groundAttenuation.cfH; - double[] actualAGroundH = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundH; - double[] actualWF = propDataOut.propagationPaths.get(0).groundAttenuation.wF; - double[] actualCfF = propDataOut.propagationPaths.get(0).groundAttenuation.cfF; - double[] actualAGroundF = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundF; + double[] actualWH = propDataOut.getPropagationPaths().get(0).groundAttenuation.wH; + double[] actualCfH = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfH; + double[] actualAGroundH = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundH; + double[] actualWF = propDataOut.getPropagationPaths().get(0).groundAttenuation.wF; + double[] actualCfF = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfF; + double[] actualAGroundF = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundF; double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); - double[] actualAAtm = propDataOut.propagationPaths.get(0).absorptionData.aAtm; - double[] actualADiv = propDataOut.propagationPaths.get(0).absorptionData.aDiv; - double[] actualABoundaryH = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryH; - double[] actualABoundaryF = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryF; - double[] actualLH = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); - double[] actualLF = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); - double[] actualL = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); + double[] actualAAtm = propDataOut.getPropagationPaths().get(0).absorptionData.aAtm; + double[] actualADiv = propDataOut.getPropagationPaths().get(0).absorptionData.aDiv; + double[] actualABoundaryH = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryH; + double[] actualABoundaryF = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryF; + double[] actualLH = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); + double[] actualLF = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); + double[] actualL = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); //Assertions assertDoubleArrayEquals("WH", expectedWH, actualWH, ERROR_EPSILON_LOWEST); @@ -840,21 +840,21 @@ public void TC05() { double[] expectedL = new double[]{37.26, 37.21, 37.08, 36.91, 36.57, 35.41, 30.91, 14.54}; //Actual values - double[] actualWH = propDataOut.propagationPaths.get(0).groundAttenuation.wH; - double[] actualCfH = propDataOut.propagationPaths.get(0).groundAttenuation.cfH; - double[] actualAGroundH = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundH; - double[] actualWF = propDataOut.propagationPaths.get(0).groundAttenuation.wF; - double[] actualCfF = propDataOut.propagationPaths.get(0).groundAttenuation.cfF; - double[] actualAGroundF = propDataOut.propagationPaths.get(0).groundAttenuation.aGroundF; + double[] actualWH = propDataOut.getPropagationPaths().get(0).groundAttenuation.wH; + double[] actualCfH = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfH; + double[] actualAGroundH = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundH; + double[] actualWF = propDataOut.getPropagationPaths().get(0).groundAttenuation.wF; + double[] actualCfF = propDataOut.getPropagationPaths().get(0).groundAttenuation.cfF; + double[] actualAGroundF = propDataOut.getPropagationPaths().get(0).groundAttenuation.aGroundF; double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); - double[] actualAAtm = propDataOut.propagationPaths.get(0).absorptionData.aAtm; - double[] actualADiv = propDataOut.propagationPaths.get(0).absorptionData.aDiv; - double[] actualABoundaryH = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryH; - double[] actualABoundaryF = propDataOut.propagationPaths.get(0).absorptionData.aBoundaryF; - double[] actualLH = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); - double[] actualLF = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); - double[] actualL = addArray(propDataOut.propagationPaths.get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); + double[] actualAAtm = propDataOut.getPropagationPaths().get(0).absorptionData.aAtm; + double[] actualADiv = propDataOut.getPropagationPaths().get(0).absorptionData.aDiv; + double[] actualABoundaryH = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryH; + double[] actualABoundaryF = propDataOut.getPropagationPaths().get(0).absorptionData.aBoundaryF; + double[] actualLH = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalH, SOUND_POWER_LEVELS); + double[] actualLF = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobalF, SOUND_POWER_LEVELS); + double[] actualL = addArray(propDataOut.getPropagationPaths().get(0).absorptionData.aGlobal, SOUND_POWER_LEVELS); //Assertions assertDoubleArrayEquals("WH", expectedWH, actualWH, ERROR_EPSILON_LOW); @@ -947,7 +947,7 @@ public void TC06() { double[] expectedL = new double[]{37.53, 37.47, 37.33, 34.99, 36.60, 35.67, 31.18, 14.82}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSR = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSO = proPath.aBoundaryH.aGroundSO; double[] actualAGroundOR = proPath.aBoundaryH.aGroundOR; @@ -1080,7 +1080,7 @@ public void TC07() { double[] expectedL = new double[]{32.70, 31.58, 29.99, 27.89, 24.36, 21.46, 14.18, -5.05}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -1232,7 +1232,7 @@ public void TC08() { double[] expectedL = new double[]{32.69, 31.57, 29.97, 27.87, 24.32, 21.42, 14.14, -5.09}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -1311,7 +1311,7 @@ public void TC08() { expectedLF = new double[]{15.77, 12.77, 9.63, 6.43, 1.69, -1.29, -9.41, -31.03}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -1364,7 +1364,7 @@ public void TC08() { expectedLF = new double[]{29.59, 27.51, 24.96, 22.09, 17.68, 14.82, 7.36, -12.02}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -1485,7 +1485,7 @@ public void TC09() { double[] expectedL = new double[]{30.38, 28.44, 26.01, 23.24, 20.11, 16.05, 8.60, -9.89}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -1564,7 +1564,7 @@ public void TC09() { expectedLF = new double[]{14.64, 11.48, 8.31, 5.30, 1.91, -2.43, -10.56, -32.21}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; @@ -1618,7 +1618,7 @@ public void TC09() { expectedLF = new double[]{28.47, 26.39, 23.84, 20.97, 17.79, 13.70, 6.22, -13.19}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; @@ -1728,7 +1728,7 @@ public void TC10() { double[] expectedL = new double[]{40.19, 36.52, 33.38, 33.36, 33.33, 33.21, 32.74, 31.04}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -1806,7 +1806,7 @@ public void TC10() { expectedLF = new double[]{41.79, 38.22, 33.80, 29.51, 25.90, 22.57, 18.96, 13.89}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -1852,7 +1852,7 @@ public void TC10() { expectedLF = new double[]{41.79, 38.22, 33.80, 29.51, 25.90, 22.57, 18.96, 13.89}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -1948,7 +1948,7 @@ public void TC11() { double[] expectedL = new double[]{44.64, 42.04, 39.22, 36.30, 33.30, 31.21, 30.64, 28.59}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -2025,7 +2025,7 @@ public void TC11() { expectedLH = new double[]{41.28, 37.82, 33.47, 29.14, 25.48, 22.12, 18.43, 13.09}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -2066,7 +2066,7 @@ public void TC11() { expectedAGroundF = new double[]{-1.51, -1.51, -1.51, -1.51, -1.51, -1.51, -1.51, -1.51}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -2159,7 +2159,7 @@ public void TC12() { double[] expectedL = new double[]{39.78, 36.62, 32.62, 29.05, 29.00, 28.80, 28.06, 25.37}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -2237,7 +2237,7 @@ public void TC12() { expectedLF = new double[]{45.22, 43.29, 40.69, 37.20, 32.81, 28.46, 24.22, 18.34}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -2281,7 +2281,7 @@ public void TC12() { expectedAGroundF = new double[]{-1.50, -1.50, -1.50, -1.50, -1.50, -1.50, -1.50, -1.50}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -2387,7 +2387,7 @@ public void TC13() { double[] expectedL = new double[]{28.23, 24.73, 20.59, 16.85, 13.34, 10.88, 6.35, -10.14}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -2464,7 +2464,7 @@ public void TC13() { expectedLH = new double[]{20.65, 17.17, 12.77, 8.14, 4.02, -0.45, -8.20, -28.21}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -2511,7 +2511,7 @@ public void TC13() { expectedLH = new double[]{27.63, 25.32, 22.60, 19.64, 16.40, 12.27, 4.74, -14.83}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -2618,7 +2618,7 @@ public void TC14() { double[] expectedLF = new double[]{48.10, 46.42, 44.26, 41.75, 38.98, 35.95, 32.33, 26.88}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -2695,7 +2695,7 @@ public void TC14() { expectedLF = new double[]{48.23, 46.85, 44.81, 41.89, 37.86, 33.42, 29.09, 23.37}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -2748,7 +2748,7 @@ public void TC14() { expectedLF = new double[]{43.14, 40.59, 37.77, 34.74, 31.30, 26.99, 21.73, 15.12}; //Actual values - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -2863,7 +2863,7 @@ public void TC15() { double[] expectedL = new double[]{31.67, 27.42, 25.25, 25.20, 25.12, 24.81, 23.65, 19.41}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; double[] actualAGroundORH = proPath.aBoundaryH.aGroundOR; @@ -2922,7 +2922,7 @@ public void TC15() { expectedLH = new double[]{31.97, 27.66, 23.64, 20.26, 17.42, 14.07, 9.79, 2.17}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -2969,7 +2969,7 @@ public void TC15() { expectedLH = new double[]{32.81, 28.62, 24.95, 21.70, 18.55, 15.21, 10.96, 3.43}; //Actual values - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -3075,7 +3075,7 @@ public void TC16(){ double[] expectedLA = new double[]{11.06, 21.11, 28.48, 33.71, 36.57, 36.61, 31.91, 13.44}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -3135,7 +3135,7 @@ public void TC16(){ expectedL = new double[]{36.63, 36.06, 35.35, 34.51, 33.37, 31.21, 25.37, 10.90}; expectedLA = new double[]{10.10, 19.96, 26.75, 31.31, 33.37, 32.41, 26.37, 9.80}; - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -3256,7 +3256,7 @@ public void TC17() { double[] expectedLA = new double[]{11.33, 21.37, 28.73, 31.79, 36.60, 36.87, 32.18, 13.72}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -3338,7 +3338,7 @@ public void TC17() { expectedLF = new double[]{36.88, 36.31, 35.60, 29.46, 33.62, 31.46, 25.63, 11.17}; expectedLA = new double[]{10.68, 20.21, 26.98, 29.65, 33.62, 32.66, 26.63, 10.07}; - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -3564,7 +3564,7 @@ public void TC19() { double[] expectedLA = new double[]{5.34, 13.46, 18.18, 20.67, 20.74, 17.92, 10.36, -10.30}; //Actual values - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -3641,7 +3641,7 @@ public void TC19() { expectedLF = new double[]{18.77, 14.67, 11.08, 7.77, 4.39, 0.20, -7.35, -26.88}; expectedLA = new double[]{-7.43, -1.43, 2.41, 4.34, 4.39, 1.40, -6.35, -27.98}; - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -3694,7 +3694,7 @@ public void TC19() { actualL = addArray(proPath.absorptionData.aGlobal, SOUND_POWER_LEVELS); expectedLA = new double[]{0.40, 8.00, 12.67, 13.91, 14.99, 12.06, 4.41, -9.38}; - proPath = propDataOut.propagationPaths.get(2); + proPath = propDataOut.getPropagationPaths().get(2); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -3799,7 +3799,7 @@ public void TC20() { double[] expectedL = new double[]{37.41, 37.35, 37.23, 37.06, 36.73, 35.59, 31.17, 15.10}; double[] expectedLA = new double[]{11.21, 21.25, 28.63, 33.86, 36.73, 36.79, 32.17, 14.00}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -3933,7 +3933,7 @@ public void TC21() { double[] expectedL = new double[]{35.63, 35.72, 35.39, 35.34, 34.88, 33.57, 28.96, 12.68}; double[] expectedLA = new double[]{9.43, 19.62, 26.79, 32.14, 34.88, 34.77, 29.96, 11.58}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -4024,7 +4024,7 @@ public void TC21() { expectedL = new double[]{18.62, 15.68, 12.48, 9.08, 6.07, 1.86, -5.79, -25.71}; expectedLA = new double[]{3.42, 13.45, 20.82, 26.01, 28.81, 28.72, 23.84, 5.18}; - /*proPath = propDataOut.propagationPaths.get(1); + /*proPath = propDataOut.getPropagationPaths().get(1); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -4154,7 +4154,7 @@ public void TC22() { double[] expectedL = new double[]{21.94, 18.46, 14.09, 13.93, 13.62, 12.55, 8.43, -6.55}; double[] expectedLA = new double[]{-4.26, 2.36, 5.49, 10.73, 13.62, 13.75, 9.43, -7.65}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -4226,7 +4226,7 @@ public void TC22() { expectedLH = new double[]{15.12, 11.76, 7.43, 0.88, -1.57, -6.24, -14-10, -34.33}; expectedLF = new double[]{15.12, 11.69, 7.64, 2.90, -1.57, -6.24, -14.10, -34.33}; - /*proPath = propDataOut.propagationPaths.get(1);*/ + /*proPath = propDataOut.getPropagationPaths().get(1);*/ double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -4268,7 +4268,7 @@ public void TC22() { expectedLH = new double[]{13.40, 8.86, 4.40, -1.13, -2.50, -6.78, -14.58, -34.97}; expectedLF = new double[]{13.40, 8.78, 4.61, 0.99, -2.50, -6.78, -14.58, -34.97}; - //proPath = propDataOut.propagationPaths.get(1); + //proPath = propDataOut.getPropagationPaths().get(1); /*actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -4411,7 +4411,7 @@ public void TC23() { double[] expectedL = new double[]{38.90, 37.17, 36.26, 34.68, 31.42, 27.54, 22.75, 15.02}; double[] expectedLA = new double[]{12.70, 21.07, 27.66, 31.48, 31.42, 28.74, 23.75, 13.92}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -4583,7 +4583,7 @@ public void TC24() { double[] expectedL = new double[]{37.16, 32.95, 30.06, 28.23, 25.11, 22.66, 21.08, 15.34}; double[] expectedLA = new double[]{10.96, 16.85, 21.46, 25.03, 25.11, 23.86, 22.08, 14.24}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -4670,7 +4670,7 @@ public void TC24() { expectedL = new double[]{37.81, 36.06, 35.20, 33.61, 30.36, 26.47, 21.67, 13.89}; expectedLA = new double[]{11.61, 19.96, 26.60, 30.41, 30.36, 27.67, 22.67, 12.79}; - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -4819,7 +4819,7 @@ public void TC25() { double[] expectedL = new double[]{39.13, 35.50, 32.07, 28.91, 25.78, 23.26, 21.68, 15.94}; double[] expectedLA = new double[]{12.93, 19.40, 23.47, 25.71, 25.78, 24.46, 22.68, 14.84}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; double[] actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -4886,7 +4886,7 @@ public void TC25() { expectedLH = new double[]{20.84, 17.03, 13.68, 10.51, 7.31, 3.68, -1.66, -13.18}; expectedLF = new double[]{20.84, 17.03, 13.68, 10.51, 7.31, 3.68, -1.66, -13.18}; - //proPath = propDataOut.propagationPaths.get(1); + //proPath = propDataOut.getPropagationPaths().get(1); actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); actualAAtm = proPath.absorptionData.aAtm; @@ -4913,7 +4913,7 @@ public void TC25() { expectedLH = new double[]{34.73, 32.02, 29.13, 26.13, 23.04, 19.63, 14.99, 6.02}; expectedLF = new double[]{34.73, 32.02, 29.13, 26.13, 23.04, 19.63, 14.99, 6.02}; - //proPath = propDataOut.propagationPaths.get(2); + //proPath = propDataOut.getPropagationPaths().get(2); /*actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); actualAAtm = proPath.absorptionData.aAtm; @@ -4959,7 +4959,7 @@ public void TC25() { expectedLF = new double[]{41.73, 39.93, 37.67, 35.08, 32.21, 28.92, 24.34, 15.41}; expectedL = new double[]{41.70, 39.90, 37.63, 35.03, 32.16, 28.86, 24.29, 15.36}; - //proPath = propDataOut.propagationPaths.get(3); + //proPath = propDataOut.getPropagationPaths().get(3); /*actualDeltaDiffSRH = proPath.aBoundaryH.deltaDiffSR; actualAGroundSOH = proPath.aBoundaryH.aGroundSO; @@ -5083,7 +5083,7 @@ public void TC26() { double[] expectedL = new double[]{41.85, 41.81, 41.71, 41.55, 37.01, 35.78, 37.53, 29.24}; double[] expectedLA = new double[]{15.65, 25.71, 33.11, 38.35, 37.01, 36.98, 38.53, 28.14}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualWH = proPath.groundAttenuation.wH; double[] actualCfH = proPath.groundAttenuation.cfH; @@ -5131,7 +5131,7 @@ public void TC26() { expectedL = new double[]{37.81, 36.06, 35.20, 33.61, 30.36, 26.47, 21.67, 13.89}; expectedLA = new double[]{11.61, 19.96, 26.60, 30.41, 30.36, 27.67, 22.67, 12.79}; - /*proPath = propDataOut.propagationPaths.get(1); + /*proPath = propDataOut.getPropagationPaths().get(1); actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); actualAAtm = proPath.absorptionData.aAtm; @@ -5225,7 +5225,7 @@ public void TC27() { double[] expectedL = new double[]{41.85, 41.81, 41.71, 41.55, 37.01, 35.78, 37.53, 29.24}; double[] expectedLA = new double[]{15.65, 25.71, 33.11, 38.35, 37.01, 36.98, 38.53, 28.14}; - PropagationPath proPath = propDataOut.propagationPaths.get(0); + PropagationPath proPath = propDataOut.getPropagationPaths().get(0); double[] actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); double[] actualAAtm = proPath.absorptionData.aAtm; @@ -5258,7 +5258,7 @@ public void TC27() { expectedL = new double[]{37.81, 36.06, 35.20, 33.61, 30.36, 26.47, 21.67, 13.89}; expectedLA = new double[]{11.61, 19.96, 26.60, 30.41, 30.36, 27.67, 22.67, 12.79}; - proPath = propDataOut.propagationPaths.get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualAlphaAtm = propDataOut.genericMeteoData.getAlpha_atmo(); actualAAtm = proPath.absorptionData.aAtm; @@ -5681,12 +5681,12 @@ public void testReflexionConvergence() { //Actual values // number of propagation paths between two walls = reflectionOrder * 2 + 1 - assertEquals(i * 2 + 1, propDataOut.propagationPaths.size()); + assertEquals(i * 2 + 1, propDataOut.getPropagationPaths().size()); double[] sourcePower = new double[alphaWall.size()]; double[] receiverPower = new double[alphaWall.size()]; Arrays.fill(sourcePower, 70.0); - for(PropagationPath proPath : propDataOut.propagationPaths) { + for(PropagationPath proPath : propDataOut.getPropagationPaths()) { double[] attenuationGlobal = proPath.absorptionData.aGlobal; double[] contributionPower = PowerUtils.sumArray(attenuationGlobal, sourcePower); receiverPower = PowerUtils.sumDbArray(receiverPower, contributionPower); diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java index 879f06662..1fa254623 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMapTest.java @@ -272,11 +272,12 @@ public void testPointDirectivity() throws Exception { assertEquals(53.3, sl.value[0], 1); assertTrue(rout.ldenData.lDenLevels.isEmpty()); - assertEquals(2 , rout.propagationPaths.size()); - PropagationPath path = rout.propagationPaths.remove(0); + List propagationPaths = rout.getPropagationPaths(); + assertEquals(2 , propagationPaths.size()); + PropagationPath path = propagationPaths.remove(0); assertEquals(1, path.getIdReceiver()); assertEquals(new Orientation(90, 15, 0), path.getSourceOrientation()); - path = rout.propagationPaths.remove(0); + path = propagationPaths.remove(0); assertEquals(2, path.getIdReceiver()); assertEquals(new Orientation(90, 15, 0), path.getSourceOrientation()); @@ -354,7 +355,8 @@ public void testLineDirectivity() throws Exception { assertEquals(70.8, sl.value[0], 1); assertEquals(3 , rout.propagationPaths.size()); - PropagationPath path = rout.propagationPaths.remove(0); + List propagationPaths = rout.getPropagationPaths(); + PropagationPath path = propagationPaths.remove(0); assertEquals(1, path.getIdReceiver()); assertEquals(0, new Coordinate(0, 5.07). distance(path.getPointList().get(0).coordinate), 0.1); @@ -362,13 +364,13 @@ public void testLineDirectivity() throws Exception { assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); assertOrientationEquals(new Orientation(330.07, -24.12, 0.0), path.raySourceReceiverDirectivity, 0.01); - path = rout.propagationPaths.remove(0);; + path = propagationPaths.remove(0);; assertEquals(1, path.getIdReceiver()); assertEquals(0, new Coordinate(0, 5.02). distance(path.getPointList().get(0).coordinate), 0.1); assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); assertOrientationEquals(new Orientation(336.90675972385696, -19.398969693698437, 0), path.raySourceReceiverDirectivity, 0.01); - path = rout.propagationPaths.remove(0); + path = propagationPaths.remove(0); assertEquals(2, path.getIdReceiver()); assertOrientationEquals(new Orientation(45, 0.81, 0), path.getSourceOrientation(), 0.01); } else { @@ -423,20 +425,21 @@ public void testPointRayDirectivity() throws Exception { IComputeRaysOut out = pointNoiseMap.evaluateCell(connection, i, j, progressVisitor, receivers); if(out instanceof LDENComputeRaysOut) { LDENComputeRaysOut rout = (LDENComputeRaysOut) out; - assertEquals(4 , rout.propagationPaths.size()); - PropagationPath path = rout.propagationPaths.remove(0); + List propagationPaths = rout.getPropagationPaths(); + assertEquals(4 , propagationPaths.size()); + PropagationPath path = propagationPaths.remove(0); assertEquals(1, path.getIdReceiver()); // receiver is front of source assertEquals(new Orientation(0, 0, 0), path.getRaySourceReceiverDirectivity()); - path = rout.propagationPaths.remove(0); + path = propagationPaths.remove(0); assertEquals(2, path.getIdReceiver()); // receiver is behind of the source assertEquals(new Orientation(180, 0, 0), path.getRaySourceReceiverDirectivity()); - path = rout.propagationPaths.remove(0); + path = propagationPaths.remove(0); assertEquals(3, path.getIdReceiver()); // receiver is on the right of the source assertEquals(new Orientation(90, 0, 0), path.getRaySourceReceiverDirectivity()); - path = rout.propagationPaths.remove(0); + path = propagationPaths.remove(0); assertEquals(4, path.getIdReceiver()); // receiver is on the left of the source assertEquals(new Orientation(360-90, 0, 0), path.getRaySourceReceiverDirectivity()); diff --git a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java index 9340a85af..cbcd81f84 100644 --- a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java +++ b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java @@ -58,7 +58,8 @@ */ public class ComputeRaysOutAttenuation implements IComputeRaysOut { public ConcurrentLinkedDeque receiversAttenuationLevels = new ConcurrentLinkedDeque<>(); - public List propagationPaths = Collections.synchronizedList(new ArrayList()); + public Deque propagationPaths = new ConcurrentLinkedDeque(); + public AtomicInteger propagationPathsSize = new AtomicInteger(0); public PropagationProcessPathData genericMeteoData; public CnossosPropagationData inputData; @@ -388,7 +389,7 @@ public List getVerticesSoundLevel() { } public List getPropagationPaths() { - return propagationPaths; + return new ArrayList<>(propagationPaths); } public void clearPropagationPaths() { this.propagationPaths.clear();} From ea49677712f078edf65470a0e2d3bd8ec03548f3 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Mon, 26 Sep 2022 13:49:34 +0200 Subject: [PATCH 13/20] set limitation in tutorial, fix unit test with new class of propagation path attribute --- .../noisemodelling/jdbc/LDENComputeRaysOut.java | 2 +- .../noisemodelling/jdbc/LDENConfig.java | 2 +- .../propagation/ComputeRaysOutAttenuation.java | 7 ++++++- .../java/org/noise_planet/nmtutorial01/main.java | 15 +-------------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java index d711598a0..1c4607edc 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENComputeRaysOut.java @@ -239,7 +239,7 @@ public void finalizeReceiver(final long receiverId) { && (ldenConfig.getMaximumRaysOutputCount() == 0 || ldenComputeRaysOut.propagationPathsSize.get() < ldenConfig.getMaximumRaysOutputCount())){ int newRaysSize = ldenComputeRaysOut.propagationPathsSize.addAndGet(propagationPaths.size()); - if(newRaysSize > ldenConfig.getMaximumRaysOutputCount()) { + if(ldenConfig.getMaximumRaysOutputCount() > 0 && newRaysSize > ldenConfig.getMaximumRaysOutputCount()) { // remove exceeded elements of the array propagationPaths = propagationPaths.subList(0, propagationPaths.size() - Math.min( propagationPaths.size(), diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java index 2fb44e82a..342aab7eb 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/LDENConfig.java @@ -112,7 +112,7 @@ public int getMaximumRaysOutputCount() { } /** - * @param maximumRaysOutputCount if export rays, do not keep more than this number of rays (0 infinite) + * @param maximumRaysOutputCount if export rays, do not keep more than this number of rays per computation area (0 infinite) */ public void setMaximumRaysOutputCount(int maximumRaysOutputCount) { this.maximumRaysOutputCount = maximumRaysOutputCount; diff --git a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java index cbcd81f84..ad5f15cc0 100644 --- a/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java +++ b/noisemodelling-propagation/src/main/java/org/noise_planet/noisemodelling/propagation/ComputeRaysOutAttenuation.java @@ -141,6 +141,7 @@ public double[] addPropagationPaths(long sourceId, double sourceLi, long receive rayCount.addAndGet(propagationPath.size()); if(keepRays) { propagationPaths.addAll(propagationPath); + propagationPathsSize.addAndGet(propagationPath.size()); } double[] aGlobalMeteo = computeAttenuation(genericMeteoData, sourceId, sourceLi, receiverId, propagationPath); if (aGlobalMeteo != null && aGlobalMeteo.length > 0) { @@ -392,7 +393,10 @@ public List getPropagationPaths() { return new ArrayList<>(propagationPaths); } - public void clearPropagationPaths() { this.propagationPaths.clear();} + public void clearPropagationPaths() { + propagationPaths.clear(); + propagationPathsSize.set(0); + } public void appendReflexionPath(long added) { nb_reflexion_path.addAndGet(added); @@ -499,6 +503,7 @@ protected void pushResult(long receiverId, long sourceId, double[] level) { public void finalizeReceiver(final long receiverId) { if(keepRays && !propagationPaths.isEmpty()) { multiThreadParent.propagationPaths.addAll(propagationPaths); + multiThreadParent.propagationPathsSize.addAndGet(propagationPaths.size()); propagationPaths.clear(); } long receiverPK = receiverId; diff --git a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java index 7176cd746..5047c4389 100644 --- a/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java +++ b/noisemodelling-tutorial-01/src/main/java/org/noise_planet/nmtutorial01/main.java @@ -155,6 +155,7 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.DAY).setTemperature(20); ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.EVENING).setTemperature(16); ldenConfig.getPropagationProcessPathData(LDENConfig.TIME_PERIOD.NIGHT).setTemperature(10); + ldenConfig.setMaximumRaysOutputCount(MAX_OUTPUT_PROPAGATION_PATHS); // do not export more than this number of rays per computation area pointNoiseMap.setGridDim(1); @@ -187,20 +188,6 @@ public static void main(String[] args) throws SQLException, IOException, LayerDe // Export as a Google Earth 3d scene if (out instanceof ComputeRaysOutAttenuation) { ComputeRaysOutAttenuation cellStorage = (ComputeRaysOutAttenuation) out; - // restrict the number of rays to export - List propagationPaths = new ArrayList<>(MAX_OUTPUT_PROPAGATION_PATHS); - for(PropagationPath p : ((ComputeRaysOutAttenuation)out).propagationPaths) { - if(p.getTimePeriod().equals(LDENConfig.TIME_PERIOD.DAY.name())) { - if (p.getPointList().size() > 3) { - propagationPaths.add(p); - if (propagationPaths.size() >= MAX_OUTPUT_PROPAGATION_PATHS) { - break; - } - } - } - } - ((ComputeRaysOutAttenuation)out).propagationPaths.clear(); - ((ComputeRaysOutAttenuation)out).propagationPaths.addAll(propagationPaths); exportScene(String.format(Locale.ROOT,"target/scene_%d_%d.kml", cellIndex.getLatitudeIndex(), cellIndex.getLongitudeIndex()), cellStorage.inputData.profileBuilder, cellStorage); } } From 6eb1616956564c738a385181c61d831610e9c2b8 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Mon, 26 Sep 2022 14:06:46 +0200 Subject: [PATCH 14/20] About #516 check for Z ordinate when reading receiver table --- .../org/noise_planet/noisemodelling/jdbc/PointNoiseMap.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMap.java b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMap.java index 686491a21..37eaeece3 100644 --- a/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMap.java +++ b/noisemodelling-jdbc/src/main/java/org/noise_planet/noisemodelling/jdbc/PointNoiseMap.java @@ -171,6 +171,12 @@ public CnossosPropagationData prepareCell(Connection connection,int cellI, int c } Geometry pt = rs.getGeometry(); if(pt != null && !pt.isEmpty()) { + // check z value + if(pt.getCoordinate().getZ() == Coordinate.NULL_ORDINATE) { + throw new IllegalArgumentException("The table " + receiverTableName + + " contain at least one receiver without Z ordinate." + + " You must specify X,Y,Z for each recever"); + } propagationProcessData.addReceiver(receiverPk, pt.getCoordinate(), rs); } } From bfefdb66e9e17c4fcb3cba620185e2224d83f553 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Mon, 26 Sep 2022 17:07:59 +0200 Subject: [PATCH 15/20] add an option to output cell computation to kml files in wps script --- .../Noise_level_from_source.groovy | 127 ++++++++++++++---- .../Noise_level_from_traffic.groovy | 82 ++++++++--- 2 files changed, 170 insertions(+), 39 deletions(-) diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy index 936b6c682..e4139f124 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_source.groovy @@ -21,6 +21,8 @@ package org.noise_planet.noisemodelling.wps.NoiseModelling import geoserver.GeoServer import geoserver.catalog.Store import groovy.sql.Sql +import org.cts.crs.CRSException +import org.cts.op.CoordinateOperationException import org.geotools.jdbc.JDBCDataStore import org.h2gis.api.EmptyProgressVisitor import org.h2gis.api.ProgressVisitor @@ -33,6 +35,7 @@ import org.locationtech.jts.geom.GeometryFactory import org.noise_planet.noisemodelling.emission.* import org.noise_planet.noisemodelling.pathfinder.* import org.noise_planet.noisemodelling.pathfinder.utils.JVMMemoryMetric +import org.noise_planet.noisemodelling.pathfinder.utils.KMLDocument import org.noise_planet.noisemodelling.pathfinder.utils.ReceiverStatsMetric import org.noise_planet.noisemodelling.pathfinder.utils.ProfilerThread import org.noise_planet.noisemodelling.pathfinder.utils.ProgressMetric @@ -42,6 +45,8 @@ import org.noise_planet.noisemodelling.jdbc.* import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.xml.stream.XMLStreamException +import java.nio.file.Paths import java.sql.Connection import java.sql.SQLException import java.time.LocalDateTime @@ -253,13 +258,14 @@ inputs = [ min : 0, max: 1, type : String.class ], - confRaysTableName : [ - name : 'Save each propagation ray into the specified table (ex:RAYS)', - title : 'Name of the ray table', - description: 'You can set a table name here in order to save all the rays computed by NoiseModelling' + - '. This table may be extremely large if there is a lot of receivers and sources. ' + - 'It will also greatly increase the computation time.' + - '

    Default value : empty (do not keep rays) ', + confRaysName : [ + name : '', + title : 'Export r', + description: 'Save each propagation ray into the specified table (ex:RAYS) ' + + 'or file URL (ex: file:///Z:/dir/map.kml)' + + 'You can set a table name here in order to save all the rays computed by NoiseModelling' + + '. The number of rays has been limited in this script in order to avoid memory exception' + + '
    Default value : empty (do not keep rays) ', min : 0, max: 1, type: String.class ], ] @@ -347,6 +353,27 @@ def run(input) { } } +static void exportScene(String name, ProfileBuilder builder, ComputeRaysOutAttenuation result, int crs) throws IOException { + try { + FileOutputStream outData = new FileOutputStream(name); + KMLDocument kmlDocument = new KMLDocument(outData); + kmlDocument.setInputCRS("EPSG:" + crs); + kmlDocument.writeHeader(); + if(builder != null) { + kmlDocument.writeTopographic(builder.getTriangles(), builder.getVertices()); + } + if(result != null) { + kmlDocument.writeRays(result.getPropagationPaths()); + } + if(builder != null) { + kmlDocument.writeBuildings(builder); + } + kmlDocument.writeFooter(); + } catch (XMLStreamException | CoordinateOperationException | CRSException ex) { + throw new IOException(ex); + } +} + // main function of the script def exec(Connection connection, input) { @@ -392,9 +419,15 @@ def exec(Connection connection, input) { } // Check if srid are in metric projection and are all the same. int sridReceivers = GeometryTableUtilities.getSRID(connection, TableLocation.parse(receivers_table_name)) - if (sridReceivers == 3785 || sridReceivers == 4326) throw new IllegalArgumentException("Error : Please use a metric projection for "+receivers_table_name+".") - if (sridReceivers == 0) throw new IllegalArgumentException("Error : The table "+receivers_table_name+" does not have an associated SRID.") - if (sridReceivers != sridSources) throw new IllegalArgumentException("Error : The SRID of table "+sources_table_name+" and "+receivers_table_name+" are not the same.") + if (sridReceivers == 3785 || sridReceivers == 4326) { + throw new IllegalArgumentException("Error : Please use a metric projection for " + receivers_table_name + ".") + } + if (sridReceivers == 0) { + throw new IllegalArgumentException("Error : The table " + receivers_table_name + " does not have an associated SRID.") + } + if (sridReceivers != sridSources) { + throw new IllegalArgumentException("Error : The SRID of table " + sources_table_name + " and " + receivers_table_name + " are not the same.") + } String building_table_name = input['tableBuilding'] @@ -402,9 +435,15 @@ def exec(Connection connection, input) { building_table_name = building_table_name.toUpperCase() // Check if srid are in metric projection and are all the same. int sridBuildings = GeometryTableUtilities.getSRID(connection, TableLocation.parse(building_table_name)) - if (sridBuildings == 3785 || sridReceivers == 4326) throw new IllegalArgumentException("Error : Please use a metric projection for "+building_table_name+".") - if (sridBuildings == 0) throw new IllegalArgumentException("Error : The table "+building_table_name+" does not have an associated SRID.") - if (sridReceivers != sridBuildings) throw new IllegalArgumentException("Error : The SRID of table "+building_table_name+" and "+receivers_table_name+" are not the same.") + if (sridBuildings == 3785 || sridReceivers == 4326) { + throw new IllegalArgumentException("Error : Please use a metric projection for " + building_table_name + ".") + } + if (sridBuildings == 0) { + throw new IllegalArgumentException("Error : The table " + building_table_name + " does not have an associated SRID.") + } + if (sridReceivers != sridBuildings) { + throw new IllegalArgumentException("Error : The SRID of table " + building_table_name + " and " + receivers_table_name + " are not the same.") + } String dem_table_name = "" if (input['tableDEM']) { @@ -413,9 +452,15 @@ def exec(Connection connection, input) { dem_table_name = dem_table_name.toUpperCase() // Check if srid are in metric projection and are all the same. int sridDEM = GeometryTableUtilities.getSRID(connection, TableLocation.parse(dem_table_name)) - if (sridDEM == 3785 || sridReceivers == 4326) throw new IllegalArgumentException("Error : Please use a metric projection for "+dem_table_name+".") - if (sridDEM == 0) throw new IllegalArgumentException("Error : The table "+dem_table_name+" does not have an associated SRID.") - if (sridDEM != sridSources) throw new IllegalArgumentException("Error : The SRID of table "+sources_table_name+" and "+dem_table_name+" are not the same.") + if (sridDEM == 3785 || sridReceivers == 4326) { + throw new IllegalArgumentException("Error : Please use a metric projection for " + dem_table_name + ".") + } + if (sridDEM == 0) { + throw new IllegalArgumentException("Error : The table " + dem_table_name + " does not have an associated SRID.") + } + if (sridDEM != sridSources) { + throw new IllegalArgumentException("Error : The SRID of table " + sources_table_name + " and " + dem_table_name + " are not the same.") + } } @@ -426,9 +471,15 @@ def exec(Connection connection, input) { ground_table_name = ground_table_name.toUpperCase() // Check if srid are in metric projection and are all the same. int sridGROUND = GeometryTableUtilities.getSRID(connection, TableLocation.parse(ground_table_name)) - if (sridGROUND == 3785 || sridReceivers == 4326) throw new IllegalArgumentException("Error : Please use a metric projection for "+ground_table_name+".") - if (sridGROUND == 0) throw new IllegalArgumentException("Error : The table "+ground_table_name+" does not have an associated SRID.") - if (sridGROUND != sridSources) throw new IllegalArgumentException("Error : The SRID of table "+ground_table_name+" and "+sources_table_name+" are not the same.") + if (sridGROUND == 3785 || sridReceivers == 4326) { + throw new IllegalArgumentException("Error : Please use a metric projection for " + ground_table_name + ".") + } + if (sridGROUND == 0) { + throw new IllegalArgumentException("Error : The table " + ground_table_name + " does not have an associated SRID.") + } + if (sridGROUND != sridSources) { + throw new IllegalArgumentException("Error : The SRID of table " + ground_table_name + " and " + sources_table_name + " are not the same.") + } } String tableSourceDirectivity = "" @@ -518,10 +569,31 @@ def exec(Connection connection, input) { ldenConfig.setComputeLNight(!confSkipLnight) ldenConfig.setComputeLDEN(!confSkipLden) ldenConfig.setMergeSources(!confExportSourceId) - if (input['confRaysTableName'] && !((input['confRaysTableName'] as String).isEmpty())) { - ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + + int maximumRaysToExport = 5000 + + File folderExportKML = null + String kmlFileNamePrepend = "" + if (input['confRaysName'] && !((input['confRaysName'] as String).isEmpty())) { + String confRaysName = input['confRaysName'] as String + if(confRaysName.startsWith("file:")) { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY) + URL url = new URL(confRaysName) + File urlFile = new File(url.toURI()) + if(urlFile.isDirectory()) { + folderExportKML = urlFile + } else { + folderExportKML = urlFile.getParentFile() + kmlFileNamePrepend = confRaysName.substring( + Math.max(0, confRaysName.lastIndexOf(File.separator) + 1), + Math.max(0, confRaysName.lastIndexOf("."))) + } + } else { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + ldenConfig.setRaysTable(input['confRaysName'] as String) + } ldenConfig.setKeepAbsorption(true); - ldenConfig.setRaysTable(input['confRaysTableName'] as String) + ldenConfig.setMaximumRaysOutputCount(maximumRaysToExport); } LDENPointNoiseMapFactory ldenProcessing = new LDENPointNoiseMapFactory(connection, ldenConfig) @@ -642,7 +714,16 @@ def exec(Connection connection, input) { logger.info("Compute domain is " + new GeometryFactory().toGeometry(cellEnvelope)) logger.info(String.format("Compute... %.3f %% (%d receivers in this cell)", 100 * k++ / cells.size(), cells.get(cellIndex))) // Run ray propagation - pointNoiseMap.evaluateCell(connection, cellIndex.getLatitudeIndex(), cellIndex.getLongitudeIndex(), progressVisitor, receivers) + IComputeRaysOut out = pointNoiseMap.evaluateCell(connection, cellIndex.getLatitudeIndex(), cellIndex.getLongitudeIndex(), progressVisitor, receivers) + // Export as a Google Earth 3d scene + if (out instanceof ComputeRaysOutAttenuation && folderExportKML != null) { + ComputeRaysOutAttenuation cellStorage = (ComputeRaysOutAttenuation) out; + exportScene(new File(folderExportKML.getPath(), + String.format(Locale.ROOT, kmlFileNamePrepend + "_%d_%d.kml", cellIndex.getLatitudeIndex(), + cellIndex.getLongitudeIndex())).getPath(), + cellStorage.inputData.profileBuilder, cellStorage, sridSources) + } + } } finally { profilerThread.stop(); diff --git a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy index de605d4ee..09cb3dbca 100644 --- a/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy +++ b/wps_scripts/src/main/groovy/org/noise_planet/noisemodelling/wps/NoiseModelling/Noise_level_from_traffic.groovy @@ -19,6 +19,8 @@ package org.noise_planet.noisemodelling.wps.NoiseModelling import geoserver.GeoServer import geoserver.catalog.Store import groovy.sql.Sql +import org.cts.crs.CRSException +import org.cts.op.CoordinateOperationException import org.geotools.jdbc.JDBCDataStore import org.h2gis.api.EmptyProgressVisitor import org.h2gis.api.ProgressVisitor @@ -30,6 +32,7 @@ import org.h2gis.utilities.wrapper.ConnectionWrapper import org.noise_planet.noisemodelling.emission.* import org.noise_planet.noisemodelling.pathfinder.* import org.noise_planet.noisemodelling.pathfinder.utils.JVMMemoryMetric +import org.noise_planet.noisemodelling.pathfinder.utils.KMLDocument import org.noise_planet.noisemodelling.pathfinder.utils.ProfilerThread import org.noise_planet.noisemodelling.pathfinder.utils.ProgressMetric import org.noise_planet.noisemodelling.pathfinder.utils.ReceiverStatsMetric @@ -39,6 +42,7 @@ import org.noise_planet.noisemodelling.jdbc.* import org.slf4j.Logger import org.slf4j.LoggerFactory +import javax.xml.stream.XMLStreamException import java.sql.Connection import java.sql.SQLException import java.time.LocalDateTime @@ -256,13 +260,14 @@ inputs = [ min : 0, max: 1, type : String.class ], - confRaysTableName : [ - name : 'Save each propagation ray into the specified table (ex:RAYS)', - title : 'Name of the ray table', - description: 'You can set a table name here in order to save all the rays computed by NoiseModelling' + - '. This table may be extremely large if there is a lot of receivers and sources. ' + - 'It will also greatly increase the computation time.' + - '

    Default value : empty (do not keep rays) ', + confRaysName : [ + name : '', + title : 'Export r', + description: 'Save each propagation ray into the specified table (ex:RAYS) ' + + 'or file URL (ex: file:///Z:/dir/map.kml)' + + 'You can set a table name here in order to save all the rays computed by NoiseModelling' + + '. The number of rays has been limited in this script in order to avoid memory exception' + + '
    Default value : empty (do not keep rays) ', min : 0, max: 1, type: String.class ] ] @@ -352,6 +357,29 @@ def forgeCreateTable(Sql sql, String tableName, LDENConfig ldenConfig, String ge } } + +static void exportScene(String name, ProfileBuilder builder, ComputeRaysOutAttenuation result, int crs) throws IOException { + try { + FileOutputStream outData = new FileOutputStream(name); + KMLDocument kmlDocument = new KMLDocument(outData); + kmlDocument.setInputCRS("EPSG:" + crs); + kmlDocument.writeHeader(); + if(builder != null) { + kmlDocument.writeTopographic(builder.getTriangles(), builder.getVertices()); + } + if(result != null) { + kmlDocument.writeRays(result.getPropagationPaths()); + } + if(builder != null) { + kmlDocument.writeBuildings(builder); + } + kmlDocument.writeFooter(); + } catch (XMLStreamException | CoordinateOperationException | CRSException ex) { + throw new IOException(ex); + } +} + + // main function of the script def exec(Connection connection, input) { //Need to change the ConnectionWrapper to WpsConnectionWrapper to work under postGIS database @@ -531,10 +559,30 @@ def exec(Connection connection, input) { ldenConfig.setComputeLDEN(!confSkipLden) ldenConfig.setMergeSources(!confExportSourceId) - if (input['confRaysTableName'] && !((input['confRaysTableName'] as String).isEmpty())) { - ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + int maximumRaysToExport = 5000 + + File folderExportKML = null + String kmlFileNamePrepend = "" + if (input['confRaysName'] && !((input['confRaysName'] as String).isEmpty())) { + String confRaysName = input['confRaysName'] as String + if(confRaysName.startsWith("file:")) { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_MEMORY) + URL url = new URL(confRaysName) + File urlFile = new File(url.toURI()) + if(urlFile.isDirectory()) { + folderExportKML = urlFile + } else { + folderExportKML = urlFile.getParentFile() + kmlFileNamePrepend = confRaysName.substring( + Math.max(0, confRaysName.lastIndexOf(File.separator) + 1), + Math.max(0, confRaysName.lastIndexOf("."))) + } + } else { + ldenConfig.setExportRaysMethod(LDENConfig.ExportRaysMethods.TO_RAYS_TABLE) + ldenConfig.setRaysTable(input['confRaysName'] as String) + } ldenConfig.setKeepAbsorption(true); - ldenConfig.setRaysTable(input['confRaysTableName'] as String) + ldenConfig.setMaximumRaysOutputCount(maximumRaysToExport); } LDENPointNoiseMapFactory ldenProcessing = new LDENPointNoiseMapFactory(connection, ldenConfig) @@ -642,12 +690,14 @@ def exec(Connection connection, input) { new TreeSet<>(cells.keySet()).each { cellIndex -> // Run ray propagation logger.info(String.format("Compute... %.3f %% (%d receivers in this cell)", 100 * k++ / cells.size(), cells.get(cellIndex))) - IComputeRaysOut ro = pointNoiseMap.evaluateCell(connection, cellIndex.getLatitudeIndex(), cellIndex.getLongitudeIndex(), progressVisitor, receivers) - if (ro instanceof LDENComputeRaysOut) { - LDENPropagationProcessData ldenPropagationProcessData = (LDENPropagationProcessData) ro.inputData; - logger.info(String.format("This computation area contains %d receivers %d sound sources and %d buildings", - ldenPropagationProcessData.receivers.size(), ldenPropagationProcessData.sourceGeometries.size(), - ldenPropagationProcessData.profileBuilder.getBuildingCount())); + IComputeRaysOut out = pointNoiseMap.evaluateCell(connection, cellIndex.getLatitudeIndex(), cellIndex.getLongitudeIndex(), progressVisitor, receivers) + // Export as a Google Earth 3d scene + if (out instanceof ComputeRaysOutAttenuation && folderExportKML != null) { + ComputeRaysOutAttenuation cellStorage = (ComputeRaysOutAttenuation) out; + exportScene(new File(folderExportKML.getPath(), + String.format(Locale.ROOT, kmlFileNamePrepend + "_%d_%d.kml", cellIndex.getLatitudeIndex(), + cellIndex.getLongitudeIndex())).getPath(), + cellStorage.inputData.profileBuilder, cellStorage, sridSources) } } } catch(IllegalArgumentException | IllegalStateException ex) { From ad148db97518f51ebf80dcc828c3adcaf61f1588 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 29 Sep 2022 16:32:25 +0200 Subject: [PATCH 16/20] add demo python core --- Docs/scripts/noisemodelling_core.py | 78 +++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Docs/scripts/noisemodelling_core.py diff --git a/Docs/scripts/noisemodelling_core.py b/Docs/scripts/noisemodelling_core.py new file mode 100644 index 000000000..2291e9e36 --- /dev/null +++ b/Docs/scripts/noisemodelling_core.py @@ -0,0 +1,78 @@ +import jnius_config +import os +import time + +deb = time.time() +jnius_config.add_options('-Xmx4096m') +jnius_config.set_classpath('scriptrunner/lib/*') + +from jnius import autoclass + +# Imports +RoadSourceParametersCnossos = autoclass('org.noise_planet.noisemodelling.emission.RoadSourceParametersCnossos') +EvaluateRoadSourceCnossos = autoclass('org.noise_planet.noisemodelling.emission.EvaluateRoadSourceCnossos') +CnossosPropagationData = autoclass('org.noise_planet.noisemodelling.pathfinder.CnossosPropagationData') +runnerMain = autoclass('org.noisemodelling.runner.Main') +LoggerFactory = autoclass('org.slf4j.LoggerFactory') +ComputeCnossosRays = autoclass('org.noise_planet.noisemodelling.pathfinder.ComputeCnossosRays') +IComputeRaysOut = autoclass('org.noise_planet.noisemodelling.pathfinder.IComputeRaysOut') +ProfileBuilder = autoclass('org.noise_planet.noisemodelling.pathfinder.ProfileBuilder') +ProfilerThread = autoclass('org.noise_planet.noisemodelling.pathfinder.utils.ProfilerThread') +ComputeRaysOutAttenuation = autoclass('org.noise_planet.noisemodelling.propagation.ComputeRaysOutAttenuation') +PropagationProcessPathData = autoclass('org.noise_planet.noisemodelling.propagation.PropagationProcessPathData') +Coordinate = autoclass('org.locationtech.jts.geom.Coordinate') +Array = autoclass('java.lang.reflect.Array') + +def T02(): + lv_speed = 70 + lv_per_hour = 1000 + mv_speed = 70 + mv_per_hour = 1000 + hgv_speed = 70 + hgv_per_hour = 1000 + wav_speed = 70 + wav_per_hour = 1000 + wbv_speed = 70 + wbv_per_hour = 1000 + FreqParam = 8000 + Temperature = 15 + RoadSurface = "NL01" + Pm_stud = 0.5 + Ts_stud = 4 + Junc_dist = 200 + Junc_type = 1 + rsParameters = RoadSourceParametersCnossos(lv_speed, mv_speed, hgv_speed, wav_speed, wbv_speed, lv_per_hour, + mv_per_hour, hgv_per_hour, wav_per_hour, wbv_per_hour, FreqParam, + Temperature, RoadSurface, Ts_stud, Pm_stud, Junc_dist, Junc_type) + rsParameters.setSlopePercentage_without_limit(10) + rsParameters.setCoeffVer(1) + return EvaluateRoadSourceCnossos.evaluate(rsParameters) + + +def to_coordinate_array(coordinate_list): + ar = Array.newInstance(Coordinate, len(coordinate_list)) + for i, v in enumerate(coordinate_list): + ar[i] = Coordinate(v[0], v[1], v[2]) + return ar + +def propagationDemo(): + # use default env data 15°C 70% humidity 101325 Pa (octave) + defaultEnvironmentalData = PropagationProcessPathData() + # profile builder is a class that help computing intersection with 3d objects such as buildings, + # digital terrain model, ground type areas + builder = ProfileBuilder() + # Add building addWall or addBuilding + builder.addBuilding(to_coordinate_array([])) + threadData = CnossosPropagationData(builder, defaultEnvironmentalData.freq_lvl) + computeRays = ComputeCnossosRays(threadData) + + +def main(): + logger = LoggerFactory.getLogger("mainlog") + runnerMain.printBuildIdentifiers(logger) + sourceNoiseLevel = T02() # source noise level in dB(A) + + +if __name__ == '__main__': + main() + print("Done in %s " % (time.strftime("%H:%M:%S", time.gmtime(time.time() - deb)))) From d1b6d6f37b1cedd78a9c7f63a1dea740655c07ce Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Fri, 30 Sep 2022 15:08:51 +0200 Subject: [PATCH 17/20] reenable unit test --- .../jdbc/EvaluateAttenuationCnossosTest.java | 19 ++++++++++--------- .../pathfinder/ProfileBuilder.java | 3 ++- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java index 7f8b35fbe..78e38d132 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/EvaluateAttenuationCnossosTest.java @@ -3847,6 +3847,7 @@ public void TC20() { public void TC21() { //Profile building ProfileBuilder profileBuilder = new ProfileBuilder() + .setzBuildings(true) .addBuilding(new Coordinate[]{ new Coordinate(167.2, 39.5, 11.5), new Coordinate(151.6, 48.5, 11.5), @@ -3973,7 +3974,7 @@ public void TC21() { assertDoubleArrayEquals("WH - vertical plane", expectedWH, actualWH, ERROR_EPSILON_LOWEST); assertDoubleArrayEquals("CfH - vertical plane", expectedCfH, actualCfH, ERROR_EPSILON_LOWEST); assertDoubleArrayEquals("AGroundH - vertical plane", expectedAGroundH, actualAGroundH, ERROR_EPSILON_LOWEST); - /*assertDoubleArrayEquals("WF - vertical plane", expectedWF, actualWF, ERROR_EPSILON_LOWEST); + assertDoubleArrayEquals("WF - vertical plane", expectedWF, actualWF, ERROR_EPSILON_LOWEST); assertDoubleArrayEquals("CfF - vertical plane", expectedCfF, actualCfF, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("AGroundF - vertical plane", expectedAGroundF, actualAGroundF, ERROR_EPSILON_VERY_LOW); @@ -3999,9 +4000,9 @@ public void TC21() { assertDoubleArrayEquals("AAtm - vertical plane", expectedAAtm, actualAAtm, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("ADiv - vertical plane", expectedADiv, actualADiv, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("ABoundaryH - vertical plane", expectedABoundaryH, actualABoundaryH, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("ABoundaryF - vertical plane", expectedABoundaryF, actualABoundaryF, ERROR_EPSILON_VERY_LOW); + assertDoubleArrayEquals("ABoundaryF - vertical plane", expectedABoundaryF, actualABoundaryF, ERROR_EPSILON_LOW); assertDoubleArrayEquals("LH - vertical plane", expectedLH, actualLH, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("LF - vertical plane", expectedLF, actualLF, ERROR_EPSILON_VERY_LOW);*/ + assertDoubleArrayEquals("LF - vertical plane", expectedLF, actualLF, ERROR_EPSILON_LOW); assertDoubleArrayEquals("L - vertical plane", expectedL, actualL, ERROR_EPSILON_HIGH); assertDoubleArrayEquals("LA - vertical plane", expectedLA, actualLA, ERROR_EPSILON_HIGH); @@ -4024,7 +4025,7 @@ public void TC21() { expectedL = new double[]{18.62, 15.68, 12.48, 9.08, 6.07, 1.86, -5.79, -25.71}; expectedLA = new double[]{3.42, 13.45, 20.82, 26.01, 28.81, 28.72, 23.84, 5.18}; - /*proPath = propDataOut.getPropagationPaths().get(1); + proPath = propDataOut.getPropagationPaths().get(1); actualWH = proPath.groundAttenuation.wH; actualCfH = proPath.groundAttenuation.cfH; @@ -4053,15 +4054,15 @@ public void TC21() { assertDoubleArrayEquals("AlphaAtm - lateral right", expectedAlphaAtm, actualAlphaAtm, ERROR_EPSILON_LOWEST); assertDoubleArrayEquals("AAtm - lateral right", expectedAAtm, actualAAtm, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("ADiv - lateral right", expectedADiv, actualADiv, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("ABoundaryH - lateral right", expectedABoundaryH, actualABoundaryH, ERROR_EPSILON_VERY_LOW); + //assertDoubleArrayEquals("ABoundaryH - lateral right", expectedABoundaryH, actualABoundaryH, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("ABoundaryF - lateral right", expectedABoundaryF, actualABoundaryF, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("LH - lateral right", expectedLH, actualLH, ERROR_EPSILON_VERY_LOW); + //assertDoubleArrayEquals("LH - lateral right", expectedLH, actualLH, ERROR_EPSILON_VERY_LOW); assertDoubleArrayEquals("LF - lateral right", expectedLF, actualLF, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("L - lateral right", expectedL, actualL, ERROR_EPSILON_VERY_LOW); - assertDoubleArrayEquals("LA - lateral right", expectedLA, actualLA, ERROR_EPSILON_VERY_LOW);*/ + //assertDoubleArrayEquals("L - lateral right", expectedL, actualL, ERROR_EPSILON_VERY_LOW); + //assertDoubleArrayEquals("LA - lateral right", expectedLA, actualLA, ERROR_EPSILON_VERY_LOW); double[] L = addArray(propDataOut.getVerticesSoundLevel().get(0).value, new double[]{93-26.2,93-16.1,93-8.6,93-3.2,93,93+1.2,93+1.0,93-1.1}); - assertArrayEquals( new double[]{10.44,20.58,27.78,33.09,35.84,35.73,30.91,12.48},L, ERROR_EPSILON_HIGH);// Because building height definition is not in accordance with ISO + assertArrayEquals( new double[]{10.44,20.58,27.78,33.09,35.84,35.73,30.91,12.48},L, ERROR_EPSILON_MEDIUM);// Because building height definition is not in accordance with ISO } /** diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java index db2e387f5..9c9fab35d 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java @@ -156,8 +156,9 @@ public class ProfileBuilder { private boolean zBuildings = false; - public void setzBuildings(boolean zBuildings) { + public ProfileBuilder setzBuildings(boolean zBuildings) { this.zBuildings = zBuildings; + return this; } From 168ee4262e931ccd4d19cba568a5de213dffa7aa Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Fri, 30 Sep 2022 15:09:12 +0200 Subject: [PATCH 18/20] Add python script example with jnius --- Docs/scripts/noisemodelling_core.py | 78 --------------- wps_scripts/noisemodelling_jnius.py | 150 ++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 78 deletions(-) delete mode 100644 Docs/scripts/noisemodelling_core.py create mode 100644 wps_scripts/noisemodelling_jnius.py diff --git a/Docs/scripts/noisemodelling_core.py b/Docs/scripts/noisemodelling_core.py deleted file mode 100644 index 2291e9e36..000000000 --- a/Docs/scripts/noisemodelling_core.py +++ /dev/null @@ -1,78 +0,0 @@ -import jnius_config -import os -import time - -deb = time.time() -jnius_config.add_options('-Xmx4096m') -jnius_config.set_classpath('scriptrunner/lib/*') - -from jnius import autoclass - -# Imports -RoadSourceParametersCnossos = autoclass('org.noise_planet.noisemodelling.emission.RoadSourceParametersCnossos') -EvaluateRoadSourceCnossos = autoclass('org.noise_planet.noisemodelling.emission.EvaluateRoadSourceCnossos') -CnossosPropagationData = autoclass('org.noise_planet.noisemodelling.pathfinder.CnossosPropagationData') -runnerMain = autoclass('org.noisemodelling.runner.Main') -LoggerFactory = autoclass('org.slf4j.LoggerFactory') -ComputeCnossosRays = autoclass('org.noise_planet.noisemodelling.pathfinder.ComputeCnossosRays') -IComputeRaysOut = autoclass('org.noise_planet.noisemodelling.pathfinder.IComputeRaysOut') -ProfileBuilder = autoclass('org.noise_planet.noisemodelling.pathfinder.ProfileBuilder') -ProfilerThread = autoclass('org.noise_planet.noisemodelling.pathfinder.utils.ProfilerThread') -ComputeRaysOutAttenuation = autoclass('org.noise_planet.noisemodelling.propagation.ComputeRaysOutAttenuation') -PropagationProcessPathData = autoclass('org.noise_planet.noisemodelling.propagation.PropagationProcessPathData') -Coordinate = autoclass('org.locationtech.jts.geom.Coordinate') -Array = autoclass('java.lang.reflect.Array') - -def T02(): - lv_speed = 70 - lv_per_hour = 1000 - mv_speed = 70 - mv_per_hour = 1000 - hgv_speed = 70 - hgv_per_hour = 1000 - wav_speed = 70 - wav_per_hour = 1000 - wbv_speed = 70 - wbv_per_hour = 1000 - FreqParam = 8000 - Temperature = 15 - RoadSurface = "NL01" - Pm_stud = 0.5 - Ts_stud = 4 - Junc_dist = 200 - Junc_type = 1 - rsParameters = RoadSourceParametersCnossos(lv_speed, mv_speed, hgv_speed, wav_speed, wbv_speed, lv_per_hour, - mv_per_hour, hgv_per_hour, wav_per_hour, wbv_per_hour, FreqParam, - Temperature, RoadSurface, Ts_stud, Pm_stud, Junc_dist, Junc_type) - rsParameters.setSlopePercentage_without_limit(10) - rsParameters.setCoeffVer(1) - return EvaluateRoadSourceCnossos.evaluate(rsParameters) - - -def to_coordinate_array(coordinate_list): - ar = Array.newInstance(Coordinate, len(coordinate_list)) - for i, v in enumerate(coordinate_list): - ar[i] = Coordinate(v[0], v[1], v[2]) - return ar - -def propagationDemo(): - # use default env data 15°C 70% humidity 101325 Pa (octave) - defaultEnvironmentalData = PropagationProcessPathData() - # profile builder is a class that help computing intersection with 3d objects such as buildings, - # digital terrain model, ground type areas - builder = ProfileBuilder() - # Add building addWall or addBuilding - builder.addBuilding(to_coordinate_array([])) - threadData = CnossosPropagationData(builder, defaultEnvironmentalData.freq_lvl) - computeRays = ComputeCnossosRays(threadData) - - -def main(): - logger = LoggerFactory.getLogger("mainlog") - runnerMain.printBuildIdentifiers(logger) - sourceNoiseLevel = T02() # source noise level in dB(A) - - -if __name__ == '__main__': - main() - print("Done in %s " % (time.strftime("%H:%M:%S", time.gmtime(time.time() - deb)))) diff --git a/wps_scripts/noisemodelling_jnius.py b/wps_scripts/noisemodelling_jnius.py new file mode 100644 index 000000000..fee1b2269 --- /dev/null +++ b/wps_scripts/noisemodelling_jnius.py @@ -0,0 +1,150 @@ +import jnius_config +import os +import time + +deb = time.time() +jnius_config.add_options('-Xmx4096m') +# Please run the following command in order to get the libraries (linux) +# ./gradlew build -x test && cd build/distributions && unzip -o scriptrunner.zip +jnius_config.set_classpath('build/distributions/scriptrunner/lib/*') + +from jnius import autoclass + +# Imports +RoadSourceParametersCnossos = autoclass('org.noise_planet.noisemodelling.emission.RoadSourceParametersCnossos') +EvaluateRoadSourceCnossos = autoclass('org.noise_planet.noisemodelling.emission.EvaluateRoadSourceCnossos') +CnossosPropagationData = autoclass('org.noise_planet.noisemodelling.pathfinder.CnossosPropagationData') +RunnerMain = autoclass('org.noisemodelling.runner.Main') +LoggerFactory = autoclass('org.slf4j.LoggerFactory') +PropagationDataBuilder = autoclass('org.noise_planet.noisemodelling.pathfinder.PropagationDataBuilder') +ComputeCnossosRays = autoclass('org.noise_planet.noisemodelling.pathfinder.ComputeCnossosRays') +IComputeRaysOut = autoclass('org.noise_planet.noisemodelling.pathfinder.IComputeRaysOut') +ProfileBuilder = autoclass('org.noise_planet.noisemodelling.pathfinder.ProfileBuilder') +ProfilerThread = autoclass('org.noise_planet.noisemodelling.pathfinder.utils.ProfilerThread') +ComputeRaysOutAttenuation = autoclass('org.noise_planet.noisemodelling.propagation.ComputeRaysOutAttenuation') +PropagationProcessPathData = autoclass('org.noise_planet.noisemodelling.propagation.PropagationProcessPathData') +Coordinate = autoclass('org.locationtech.jts.geom.Coordinate') +Array = autoclass('java.lang.reflect.Array') + +def T02(): + lv_speed = 70 + lv_per_hour = 1000 + mv_speed = 70 + mv_per_hour = 1000 + hgv_speed = 70 + hgv_per_hour = 1000 + wav_speed = 70 + wav_per_hour = 1000 + wbv_speed = 70 + wbv_per_hour = 1000 + FreqParam = 8000 + Temperature = 15 + RoadSurface = "NL01" + Pm_stud = 0.5 + Ts_stud = 4 + Junc_dist = 200 + Junc_type = 1 + rsParameters = RoadSourceParametersCnossos(lv_speed, mv_speed, hgv_speed, wav_speed, wbv_speed, lv_per_hour, + mv_per_hour, hgv_per_hour, wav_per_hour, wbv_per_hour, FreqParam, + Temperature, RoadSurface, Ts_stud, Pm_stud, Junc_dist, Junc_type) + rsParameters.setSlopePercentage_without_limit(10) + rsParameters.setCoeffVer(1) + return EvaluateRoadSourceCnossos.evaluate(rsParameters) + + +def to_coordinate_array(coordinate_list): + ar = Array.newInstance(Coordinate, len(coordinate_list)) + for i, v in enumerate(coordinate_list): + ar[i] = Coordinate(v[0], v[1], v[2]) + return ar + + +def format_db_list(values): + return ["%.1f" % v for v in values] + +# Demo using unit test TC21 +# TC21 - Building on ground with spatially varying heights and acoustic properties +def propagation_demo(): + # use default env data 15 C 70% humidity 101325 Pa (octave) + default_environmental_data = PropagationProcessPathData() + # profile builder is a class that help computing intersection with 3d objects such as buildings, + # digital terrain model, ground type areas + + builder = ProfileBuilder() + # Add building addWall or addBuilding + # ask to use Z of polygons as the gutter (absolute roof altitude) + builder.setzBuildings(True) + builder.addBuilding(to_coordinate_array([[167.2, 39.5, 11.5], [151.6, 48.5, 11.5], [141.1, 30.3, 11.5], + [156.7, 21.3, 11.5], [159.7, 26.5, 11.5], [151.0, 31.5, 11.5], [155.5, 39.3, 11.5], + [164.2, 34.3, 11.5]])) + builder.addGroundEffect(0.0, 50.0, -20.0, 80.0, 0.9) + builder.addGroundEffect(50.0, 150.0, -20.0, 80.0, 0.5) + builder.addGroundEffect(150.0, 225.0, -20.0, 80.0, 0.2) + # Insert digital elevation model as topographic lines + builder.addTopographicLine(0, 80, 0, 225, 80, 0) \ + .addTopographicLine(225, 80, 0, 225, -20, 0) \ + .addTopographicLine(225, -20, 0, 0, -20, 0) \ + .addTopographicLine(0, -20, 0, 0, 80, 0) \ + .addTopographicLine(120, -20, 0, 120, 80, 0) \ + .addTopographicLine(185, -5, 10, 205, -5, 10) \ + .addTopographicLine(205, -5, 10, 205, 75, 10) \ + .addTopographicLine(205, 75, 10, 185, 75, 10) \ + .addTopographicLine(185, 75, 10, 185, -5, 10) + + # construct internal structures + builder.finishFeeding() + + thread_data = PropagationDataBuilder(builder) + thread_data.addSource(10, 10, 1) # x, y, z + thread_data.addReceiver(200, 25, 14) # x, y, z + thread_data.hEdgeDiff(True) # Diffraction on vertical plane + thread_data.vEdgeDiff(True) # Diffraction on horizontal plane + thread_data.setGs(0.9) # Source factor absorption (default is 0 such as +3dB) + ray_data = thread_data.build() + ray_data.reflexionOrder = 1 + default_environmental_data.setHumidity(70) + default_environmental_data.setTemperature(10) + keep_rays = True + keep_absorption = True + prop_data_out = ComputeRaysOutAttenuation(keep_rays, keep_absorption, default_environmental_data) + compute_rays = ComputeCnossosRays(ray_data) + compute_rays.setThreadCount(1) + + # Run computation + compute_rays.run(prop_data_out) + + # Read receiver noise level + receiver = prop_data_out.getVerticesSoundLevel().get(0) + source_lvl = 93 # 93 dB source level (not A weighted) + formatting = "{0:<20} " + " ".join(["{%d:>8}" % (i + 1) for i in range(len(default_environmental_data.freq_lvl))]) + l_a_top = [prop_data_out.getPropagationPaths()[0].absorptionData.aGlobal[i] + source_lvl + + default_environmental_data.freq_lvl_a_weighting[i] + for i in range(len(default_environmental_data.freq_lvl))] + l_a_right = [prop_data_out.getPropagationPaths()[1].absorptionData.aGlobal[i] + source_lvl + + default_environmental_data.freq_lvl_a_weighting[i] + for i in range(len(default_environmental_data.freq_lvl))] + l_a_left = [prop_data_out.getPropagationPaths()[2].absorptionData.aGlobal[i] + source_lvl + + default_environmental_data.freq_lvl_a_weighting[i] + for i in range(len(default_environmental_data.freq_lvl))] + print(formatting.format(*(["f in Hz"] + list(map(str, default_environmental_data.freq_lvl))))) + print(formatting.format(*(["A atmospheric/km"] + format_db_list(prop_data_out.genericMeteoData.getAlpha_atmo())))) + print(formatting.format(*(["A atmospheric dB"] + format_db_list(prop_data_out.getPropagationPaths()[0] + .absorptionData.aAtm)))) + print(formatting.format(*(["A-weighting"] + format_db_list(default_environmental_data.freq_lvl_a_weighting)))) + print(formatting.format(*(["LA in dB over top"] + format_db_list(l_a_top)))) + print(formatting.format(*(["LA in dB right"] + format_db_list(l_a_right)))) + print(formatting.format(*(["LA in dB left"] + format_db_list(l_a_left)))) + print(formatting.format(*(["LA in dB"] + format_db_list([source_lvl + receiver.value[i] + default_environmental_data.freq_lvl_a_weighting[i] + for i in range(len(default_environmental_data.freq_lvl))])))) + + +def main(): + # logger = LoggerFactory.getLogger("mainlog") + # RunnerMain.printBuildIdentifiers(logger) + source_noise_level = T02() # source noise level in dB(A) + propagation_demo() + + +if __name__ == '__main__': + main() + print("\nDone in %s " % (time.strftime("%H:%M:%S", time.gmtime(time.time() - deb)))) From a318aa67e691be772239b47ac025869ed0dc531b Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Fri, 30 Sep 2022 15:09:23 +0200 Subject: [PATCH 19/20] ignore venv python dir --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ca1fc9779..412477906 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ nbactions.xml Docs/build Docs/venv profile_*.csv - +venv/ From 6eb033bb9fc5e086f77b92c7d81eed01b13dc536 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Tue, 11 Oct 2022 10:05:55 +0200 Subject: [PATCH 20/20] Change to minimum z terrain under building instead of average z --- .../noisemodelling/pathfinder/ProfileBuilder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java index 9c9fab35d..bd822984f 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilder.java @@ -2179,7 +2179,7 @@ public static class Building implements Obstacle { private Polygon poly; /** Height of the building. */ private final double height; - private double zTopo = 0.0; // average Z ground + private double zTopo = 0.0; // minimum Z ground under building /** Absorption coefficients. */ private final List alphas; @@ -2272,17 +2272,17 @@ public int getPrimaryKey() { } /** - * Compute average Z ground under the building contour + * Compute minimum Z ground under the building contour * @param profileBuilder * @return */ public double updateZTopo(ProfileBuilder profileBuilder) { Coordinate[] coordinates = poly.getCoordinates(); - double sumZ = 0.0; + double minZ = Double.MAX_VALUE; for (int i = 0; i < coordinates.length-1; i++) { - sumZ += profileBuilder.getZGround(coordinates[i]); + minZ = Math.min(minZ, profileBuilder.getZGround(coordinates[i])); } - zTopo = sumZ/(coordinates.length-1); + zTopo = minZ; return zTopo; }