diff --git a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/AttenuationCnossosTest.java b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/AttenuationCnossosTest.java index 44f617719..e3323bd58 100644 --- a/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/AttenuationCnossosTest.java +++ b/noisemodelling-jdbc/src/test/java/org/noise_planet/noisemodelling/jdbc/AttenuationCnossosTest.java @@ -421,6 +421,9 @@ public void northSouthTest() { //Run computation computeRays.run(propDataOut); + + assertEquals(2, propDataOut.getPropagationPaths().size()); + SegmentPath s0 = propDataOut.getPropagationPaths().get(0).getSRSegment(); SegmentPath s1 = propDataOut.getPropagationPaths().get(1).getSRSegment(); assertEquals(s0.dp, s1.dp); @@ -562,8 +565,6 @@ public void TC01() throws IOException { //Run computation computeRays.run(propDataOut); - exportRays("src/test/resources/org/noise_planet/noisemodelling/jdbc/rays.json", propDataOut); - assertEquals(1, propDataOut.getPropagationPaths().size()); //Expected values diff --git a/noisemodelling-jdbc/src/test/resources/org/noise_planet/noisemodelling/jdbc/rays.json b/noisemodelling-jdbc/src/test/resources/org/noise_planet/noisemodelling/jdbc/rays.json deleted file mode 100644 index 39282596a..000000000 --- a/noisemodelling-jdbc/src/test/resources/org/noise_planet/noisemodelling/jdbc/rays.json +++ /dev/null @@ -1,289 +0,0 @@ -{ - "receiversAttenuationLevels" : [ { - "sourceId" : 0, - "receiverId" : 0, - "value" : [ -53.05230812548203, -53.10847837913621, -53.23128457990157, -53.40304061719519, -53.738947283312044, -54.90527585681099, -59.39216202679357, -75.72547709749335 ], - "receiverPosition" : null - } ], - "pathParameters" : [ { - "cutPoints" : [ { - "coordinate" : { - "x" : 10.0, - "y" : 10.0, - "z" : 1.0 - }, - "type" : "SOURCE", - "id" : -1, - "buildingId" : -1, - "wallId" : -1, - "height" : 0.0, - "zGround" : "NaN", - "groundCoef" : 0.0, - "wallAlpha" : [ ], - "corner" : false - }, { - "coordinate" : { - "x" : 200.0, - "y" : 50.0, - "z" : 4.0 - }, - "type" : "RECEIVER", - "id" : -1, - "buildingId" : -1, - "wallId" : -1, - "height" : 0.0, - "zGround" : "NaN", - "groundCoef" : 0.0, - "wallAlpha" : [ ], - "corner" : false - } ], - "srSegment" : { - "gPath" : 0.0, - "meanGdPlane" : null, - "pInit" : null, - "s" : { - "x" : 0.0, - "y" : 1.0, - "z" : "NaN" - }, - "r" : { - "x" : 194.164878389476, - "y" : 4.0, - "z" : "NaN" - }, - "a" : 0.0, - "b" : 0.0, - "idPtStart" : 0, - "idPtFinal" : 0, - "gPathPrime" : 0.0, - "gw" : null, - "gm" : null, - "zsH" : 1.0, - "zrH" : 4.0, - "testFormH" : 1.2944325225965068, - "sMeanPlane" : { - "x" : 0.0, - "y" : 0.0, - "z" : "NaN" - }, - "rMeanPlane" : { - "x" : 194.164878389476, - "y" : 0.0, - "z" : "NaN" - }, - "sPrime" : { - "x" : 0.0, - "y" : -1.0, - "z" : "NaN" - }, - "rPrime" : { - "x" : 194.164878389476, - "y" : -4.0, - "z" : "NaN" - }, - "zsF" : 1.3837978540673712, - "zrF" : 6.645797854067372, - "testFormF" : 0.806038416906298, - "dPath" : null, - "d" : 194.18805318556548, - "dc" : null, - "dp" : 194.164878389476, - "eLength" : 0.0, - "delta" : 1.0, - "dPrime" : 0.0, - "deltaPrime" : 0.0 - }, - "pointList" : [ { - "coordinate" : { - "x" : 0.0, - "y" : 1.0, - "z" : "NaN" - }, - "altitude" : 0.0, - "alphaWall" : [ ], - "buildingId" : -1, - "wallId" : -1, - "e" : 0.0, - "orientation" : { - "yaw" : 78.11134196037204, - "pitch" : 0.8851943970824109, - "roll" : 0.0 - }, - "buildingHeight" : 0.0, - "type" : "SRCE", - "bodyBarrier" : false - }, { - "coordinate" : { - "x" : 194.164878389476, - "y" : 4.0, - "z" : "NaN" - }, - "altitude" : 0.0, - "alphaWall" : [ ], - "buildingId" : -1, - "wallId" : -1, - "e" : 0.0, - "orientation" : null, - "buildingHeight" : 0.0, - "type" : "RECV", - "bodyBarrier" : false - } ], - "segmentList" : [ { - "gPath" : 0.0, - "meanGdPlane" : null, - "pInit" : null, - "s" : { - "x" : 0.0, - "y" : 1.0, - "z" : "NaN" - }, - "r" : { - "x" : 194.164878389476, - "y" : 4.0, - "z" : "NaN" - }, - "a" : 0.0, - "b" : 0.0, - "idPtStart" : 0, - "idPtFinal" : 0, - "gPathPrime" : 0.0, - "gw" : null, - "gm" : null, - "zsH" : 1.0, - "zrH" : 4.0, - "testFormH" : 1.2944325225965068, - "sMeanPlane" : { - "x" : 0.0, - "y" : 0.0, - "z" : "NaN" - }, - "rMeanPlane" : { - "x" : 194.164878389476, - "y" : 0.0, - "z" : "NaN" - }, - "sPrime" : { - "x" : 0.0, - "y" : -1.0, - "z" : "NaN" - }, - "rPrime" : { - "x" : 194.164878389476, - "y" : -4.0, - "z" : "NaN" - }, - "zsF" : 1.3837978540673712, - "zrF" : 6.645797854067372, - "testFormF" : 0.806038416906298, - "dPath" : null, - "d" : 194.18805318556548, - "dc" : null, - "dp" : 194.164878389476, - "eLength" : 0.0, - "delta" : 1.0, - "dPrime" : 0.0, - "deltaPrime" : 0.0 - } ], - "favorable" : true, - "idSource" : 0, - "idReceiver" : 0, - "timePeriod" : "", - "sourceOrientation" : { - "yaw" : 0.0, - "pitch" : 0.0, - "roll" : 0.0 - }, - "raySourceReceiverDirectivity" : { - "yaw" : 78.11134196037204, - "pitch" : 0.8851943970824109, - "roll" : 0.0 - }, - "angle" : -2.9340964271545906, - "gs" : 0.0, - "difHPoints" : [ ], - "difVPoints" : [ ], - "refPoints" : [ ], - "keepAbsorption" : true, - "reflectionAbsorption" : { - "dLRetro" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "dLAbs" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] - }, - "aAtm" : [ 0.023630312292303182, 0.07980056594648334, 0.20260676671184508, 0.3743628040054611, 0.7102694701223206, 1.8765980436212626, 6.363484213603849, 22.69679928430363 ], - "aDiv" : [ 56.76445015560211, 56.76445015560211, 56.76445015560211, 56.76445015560211, 56.76445015560211, 56.76445015560211, 56.76445015560211, 56.76445015560211 ], - "aRef" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "double_aBoundaryH" : [ -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0 ], - "double_aBoundaryF" : [ -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557 ], - "aGlobalH" : [ -53.78808046789442, -53.8442507215486, -53.96705692231396, -54.13881295960758, -54.47471962572443, -55.64104819922338, -60.12793436920596, -76.46124943990574 ], - "aGlobalF" : [ -52.42331629151586, -52.47948654517004, -52.6022927459354, -52.77404878322902, -53.109955449345875, -54.27628402284482, -58.7631701928274, -75.09648526352719 ], - "aDifH" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aDifF" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aGlobal" : [ -53.05230812548203, -53.10847837913621, -53.23128457990157, -53.40304061719519, -53.738947283312044, -54.90527585681099, -59.39216202679357, -75.72547709749335 ], - "aSource" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaH" : 1.7976931348623157E308, - "deltaF" : 1.7976931348623157E308, - "deltaPrimeH" : 1.7976931348623157E308, - "deltaPrimeF" : 1.7976931348623157E308, - "deltaSPrimeRH" : 1.7976931348623157E308, - "deltaSRPrimeH" : 1.7976931348623157E308, - "aBoundaryH" : { - "deltaDiffSR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aGroundSO" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aGroundOR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaDiffSPrimeR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaDiffSRPrime" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaGroundSO" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaGroundOR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aDiff" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "init" : true - }, - "aBoundaryF" : { - "deltaDiffSR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aGroundSO" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aGroundOR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaDiffSPrimeR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaDiffSRPrime" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaGroundSO" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "deltaGroundOR" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "aDiff" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "init" : true - }, - "groundAttenuation" : { - "wH" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "cfH" : [ 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476 ], - "aGroundH" : [ -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0 ], - "wF" : [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], - "cfF" : [ 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476, 194.164878389476 ], - "aGroundF" : [ -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557, -4.364764176378557 ] - }, - "deltaSPrimeRF" : 1.7976931348623157E308, - "deltaSRPrimeF" : 1.7976931348623157E308, - "e" : 0.0, - "deltaRetroH" : 1.7976931348623157E308, - "deltaRetroF" : 1.7976931348623157E308 - } ], - "propagationPathsSize" : 1, - "genericMeteoData" : { - "freq_lvl" : [ 63, 125, 250, 500, 1000, 2000, 4000, 8000 ], - "freq_lvl_exact" : [ 63.0957344, 125.892541, 251.188643, 501.187234, 1000.0, 1995.26231, 3981.07171, 7943.28235 ], - "freq_lvl_a_weighting" : [ -26.2, -16.1, -8.6, -3.2, 0.0, 1.2, 1.0, -1.1 ], - "temperature" : 10.0, - "celerity" : 337.2955510831529, - "humidity" : 70.0, - "pressure" : 101325.0, - "alpha_atmo" : [ 0.12168777586807634, 0.4109447756305903, 1.0433534060833016, 1.9278364341380012, 3.6576373184172626, 9.663818205273378, 32.76969983072503, 116.88051304893943 ], - "defaultOccurance" : 0.5, - "gDisc" : true, - "prime2520" : false, - "windRose" : [ 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 ] - }, - "inputData" : null, - "exportPaths" : true, - "exportAttenuationMatrix" : true, - "rayCount" : 1, - "nb_couple_receiver_src" : 0, - "nb_obstr_test" : 0, - "nb_image_receiver" : 0, - "nb_reflexion_path" : 0, - "nb_diffraction_path" : 0, - "cellComputed" : 0 -} \ No newline at end of file diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPoint.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPoint.java index 4efb2408a..dab03b836 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPoint.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPoint.java @@ -27,8 +27,6 @@ public class CutPoint implements Comparable { int buildingId = -1; /** Identifier of the wall containing the point. -1 if no wall. */ int wallId = -1; - /** Height of the building containing the point. NaN of no building. */ - double height = Double.NaN; /** Topographic height of the point. */ double zGround = Double.NaN; /** Ground effect coefficient. 0 if there is no coefficient. */ @@ -68,7 +66,6 @@ public CutPoint(CutPoint cut) { this.wallId = cut.wallId; this.groundCoef = cut.groundCoef; this.wallAlpha = new ArrayList<>(cut.wallAlpha); - this.height = cut.height; this.zGround = cut.zGround; this.corner = cut.corner; } @@ -111,21 +108,13 @@ public void setGroundCoef(double groundCoef) { this.groundCoef = groundCoef; } - /** - * Sets the building height. - * @param height The building height. - */ - public void setHeight(double height) { - this.height = height; - } - /** * Sets the topographic height. * @param zGround The topographic height. */ - /*public void setzGround(double zGround) { + public void setZGround(double zGround) { this.zGround = zGround; - }*/ + } /** * Sets the wall alpha. @@ -175,14 +164,6 @@ public double getGroundCoef() { return groundCoef; } - /** - * Retrieve the height of the building containing the point. If there is no building, returns NaN. - * @return The building height, or NaN if no building. - */ - public double getHeight() { - return height; - } - /** * Retrieve the topographic height of the point. * @return The topographic height of the point. @@ -205,17 +186,17 @@ public ProfileBuilder.IntersectionType getType() { @Override public String toString() { - String str = ""; - str += type.name(); - str += " "; - str += "(" + coordinate.x +"," + coordinate.y +"," + coordinate.z + ") ; "; - str += "grd : " + groundCoef + " ; "; - str += "topoH : " + zGround + " ; "; - str += "buildH : " + height + " ; "; - str += "buildId : " + buildingId + " ; "; - str += "alpha : " + wallAlpha + " ; "; - str += "id : " + id + " ; "; - return str; + return "CutPoint{" + + "coordinate=" + coordinate + + ", type=" + type + + ", id=" + id + + ", buildingId=" + buildingId + + ", wallId=" + wallId + + ", zGround=" + zGround + + ", groundCoef=" + groundCoef + + ", wallAlpha=" + wallAlpha + + ", corner=" + corner + + '}'; } /** diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/GroundAbsorption.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/GroundAbsorption.java index e43afb188..fd281c23c 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/GroundAbsorption.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/GroundAbsorption.java @@ -25,6 +25,7 @@ public class GroundAbsorption { */ public GroundAbsorption(Geometry geom, double coef) { this.geom = geom; + this.geom.normalize(); this.coef = coef; } diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/ProfileBuilder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/ProfileBuilder.java index 593e71f29..5d07f474d 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/ProfileBuilder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/ProfileBuilder.java @@ -1033,9 +1033,10 @@ public CutProfile getProfile(Coordinate sourceCoordinate, Coordinate receiverCoo if(Double.isNaN(cutPoint.zGround)) { if(nextPointIndex <= pointIndex) { // look for next reference Z ground point - for (nextPointIndex = pointIndex + 1; nextPointIndex < profile.pts.size(); nextPointIndex++) { - CutPoint nextPoint = profile.pts.get(nextPointIndex); + for (int i = pointIndex + 1; i < profile.pts.size(); i++) { + CutPoint nextPoint = profile.pts.get(i); if (!Double.isNaN(nextPoint.zGround)) { + nextPointIndex = i; break; } } @@ -1140,7 +1141,7 @@ private void addGroundBuildingCutPts(LineSegment fullLine, CutProfile profile, b if (groundAbsorption.geom.intersects(afterIntersectionPoint)) { // we enter a new ground effect profile.addGroundCutPt(intersection, facetLine.getOriginId(), groundAbsorption.getCoefficient()); - } else { + } else if(getIntersectingGroundAbsorption(afterIntersectionPoint) == -1){ // no new ground effect, we fall back to default G profile.addGroundCutPt(intersection, facetLine.getOriginId(), Scene.DEFAULT_G); } diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/documents/GeoJSONDocument.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/documents/GeoJSONDocument.java index 609ad37ef..5f778a40f 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/documents/GeoJSONDocument.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/utils/documents/GeoJSONDocument.java @@ -154,7 +154,6 @@ public void writeCutPoint(CutPoint cutPoint) throws IOException { } if(cutPoint.getBuildingId() != - 1) { jsonGenerator.writeNumberField("building", cutPoint.getBuildingId()); - jsonGenerator.writeNumberField("height", cutPoint.getHeight()); jsonGenerator.writeStringField("alpha", cutPoint.getWallAlpha().stream(). map(aDouble -> String.format("%.2f", aDouble)).collect(Collectors.joining(","))); }