From ca5f9839c55cce97541ac9fb0390e887e82a6e15 Mon Sep 17 00:00:00 2001 From: nicolas-f Date: Thu, 17 Oct 2024 16:43:04 +0200 Subject: [PATCH] remove duplicate code, stop propagation early if horizontal edge diffraction is disabled and we found an intersection with topo or buildings/Walls --- .../jdbc/AttenuationCnossosTest.java | 2 + .../noisemodelling/pathfinder/PathFinder.java | 56 +++--- .../pathfinder/profilebuilder/CutProfile.java | 34 +--- .../profilebuilder/ProfileBuilder.java | 171 ++++++++++-------- .../pathfinder/PathFinderTest.java | 44 ++--- .../pathfinder/ProfileBuilderTest.java | 4 +- .../pathfinder/TestPathFinder.java | 2 +- 7 files changed, 146 insertions(+), 167 deletions(-) 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 3e4acba5f..7bb23b61b 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 @@ -562,6 +562,8 @@ public void TC01() throws IOException { //Run computation computeRays.run(propDataOut); + assertEquals(1, propDataOut.getPropagationPaths().size()); + //Expected values double[] expectedWH = new double[]{0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00}; double[] expectedCfH = new double[]{194.16, 194.16, 194.16, 194.16, 194.16, 194.16, 194.16, 194.16}; diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PathFinder.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PathFinder.java index f75fbef09..9f6f05ccd 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PathFinder.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/PathFinder.java @@ -296,28 +296,24 @@ public List directPath(Coordinate srcCoord, int srcId, Orientation int rcvId, boolean verticalDiffraction, boolean horizontalDiffraction, boolean bodyBarrier) { List pathsParameters = new ArrayList<>(); - CutProfile cutProfile = data.profileBuilder.getProfile(srcCoord, rcvCoord, data.gS); + CutProfile cutProfile = data.profileBuilder.getProfile(srcCoord, rcvCoord, data.gS, !verticalDiffraction); cutProfile.setSrcOrientation(orientation); - //If the field is free, simplify the computation - if(cutProfile.isFreeField()) { - pathsParameters.add(computeFreeField(cutProfile, data, true)); + + if(verticalDiffraction || cutProfile.isFreeField()) { + CnossosPath hEdgePath = computeHEdgeDiffraction(cutProfile, bodyBarrier); + if (hEdgePath != null) { + pathsParameters.add(hEdgePath); + } } - else if(verticalDiffraction || horizontalDiffraction) { - if (verticalDiffraction) { - CnossosPath pathParameters = computeHEdgeDiffraction(cutProfile, bodyBarrier); - if(pathParameters != null) { - pathsParameters.add(pathParameters); - } + + if (horizontalDiffraction) { + CnossosPath vEdgePath = computeVEdgeDiffraction(srcCoord, rcvCoord, data, LEFT, orientation); + if (vEdgePath != null && vEdgePath.getPointList() != null) { + pathsParameters.add(vEdgePath); } - if (horizontalDiffraction) { - CnossosPath pathParameters = computeVEdgeDiffraction(srcCoord, rcvCoord, data, LEFT, orientation); - if (pathParameters != null && pathParameters.getPointList() != null) { - pathsParameters.add(pathParameters); - } - pathParameters = computeVEdgeDiffraction(srcCoord, rcvCoord, data, RIGHT, orientation); - if (pathParameters != null && pathParameters.getPointList() != null) { - pathsParameters.add(pathParameters); - } + vEdgePath = computeVEdgeDiffraction(srcCoord, rcvCoord, data, RIGHT, orientation); + if (vEdgePath != null && vEdgePath.getPointList() != null) { + pathsParameters.add(vEdgePath); } } @@ -677,7 +673,7 @@ public CnossosPath computeVEdgeDiffraction(Coordinate rcvCoord, Coordinate srcCo double d = 0; List allCutPoints = new ArrayList<>(); for(int i=0; i computeReflexion(Coordinate rcvCoord, Coordinate srcCoo for (int idPt = 0; idPt < rayPath.size() - 1; idPt++) { Coordinate firstPt = rayPath.get(idPt).getReceiverPos(); MirrorReceiver refl = rayPath.get(idPt + 1); - CutProfile profile = data.profileBuilder.getProfile(firstPt, refl.getReceiverPos(), data.gS); + CutProfile profile = data.profileBuilder.getProfile(firstPt, refl.getReceiverPos(), data.gS, true); if (profile.intersectTopography() || profile.intersectBuilding() ) { validReflection = false; break; @@ -1446,8 +1442,7 @@ public List computeReflexion(Coordinate rcvCoord, Coordinate srcCoo List allCutPoints = new ArrayList<>(); List res = new ArrayList<>(); for(int i=0; i cut.getType().equals(BUILDING) || cut.getType().equals(TOPOGRAPHY) || cut.getType().equals(RECEIVER)) .map(CutPoint::getCoordinate) @@ -1606,23 +1601,22 @@ public static double splitLineStringIntoPoints(LineString geom, double segmentSi * @param profileBuilder * @return computed lineString */ - private static LineString splitLineString(LineString lineString, ProfileBuilder profileBuilder) { + private static LineString splitLineSource(LineString lineString, ProfileBuilder profileBuilder) { List newGeomCoordinates = new ArrayList<>(); Coordinate[] coordinates = lineString.getCoordinates(); for(int idPoint = 0; idPoint < coordinates.length - 1; idPoint++) { Coordinate p0 = coordinates[idPoint]; Coordinate p1 = coordinates[idPoint + 1]; - double p1p0Length = p1.distance(p0); - List groundProfileCoordinates = profileBuilder.getTopographicProfile(p0, p1); + List groundProfileCoordinates = new ArrayList<>(); + profileBuilder.fetchTopographicProfile(groundProfileCoordinates, p0, p1, false); // add first point of source newGeomCoordinates.add(p0); // add intermediate points located at the edges of MNT triangle mesh // but the Z value should be still relative to the ground // ,so we interpolate the Z (height) values of the source for(Coordinate intermediatePoint : groundProfileCoordinates) { - Vector2D v = new Vector2D(p0, intermediatePoint); - Coordinate relativePoint = new Coordinate(intermediatePoint.x, intermediatePoint.y, - p0.z + ((v.length() / p1p0Length) * (p1.z - p0.z))); + Coordinate relativePoint = new Coordinate(intermediatePoint); + relativePoint.z = Vertex.interpolateZ(intermediatePoint, p0, p1); newGeomCoordinates.add(relativePoint); } } @@ -1640,11 +1634,11 @@ public void makeSourceRelativeZToAbsolute() { Geometry offsetGeometry = source.copy(); if(source instanceof LineString) { - offsetGeometry = splitLineString((LineString) source, data.profileBuilder); + offsetGeometry = splitLineSource((LineString) source, data.profileBuilder); } else if(source instanceof MultiLineString) { LineString[] newGeom = new LineString[source.getNumGeometries()]; for(int idGeom = 0; idGeom < source.getNumGeometries(); idGeom++) { - newGeom[idGeom] = splitLineString((LineString) source.getGeometryN(idGeom), + newGeom[idGeom] = splitLineSource((LineString) source.getGeometryN(idGeom), data.profileBuilder); } offsetGeometry = GEOMETRY_FACTORY.createMultiLineString(newGeom); diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutProfile.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutProfile.java index d8c3350ec..2d43b4d25 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutProfile.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutProfile.java @@ -235,39 +235,7 @@ public double getGPath() { * @return */ public boolean isFreeField() { - if(isFreeField == null) { - isFreeField = true; - Coordinate s = getSource().getCoordinate(); - Coordinate r = getReceiver().getCoordinate(); - List tmp = new ArrayList<>(); - boolean allMatch = true; - for(CutPoint cut : pts) { - if(cut.getType() == BUILDING || cut.getType() == WALL) { - tmp.add(cut); - } - else if(cut.getType() == TOPOGRAPHY) { - tmp.add(cut); - } - if(!(cut.getCoordinate().equals(s) || cut.getCoordinate().equals(r))) { - allMatch = false; - } - } - if(allMatch) { - return true; - } - List ptsWithouGroundEffect = pts.stream() - .filter(cut -> !cut.getType().equals(GROUND_EFFECT)) - .collect(Collectors.toList()); - for(CutPoint pt : ptsWithouGroundEffect) { - double[] distanceSRpt = distance3D(source.getCoordinate(), receiver.getCoordinate(), pt.getCoordinate()); - if(distanceSRpt[0]>0 && distanceSRpt[1]>0) { - isFreeField = false; - distanceToSR = distanceSRpt[0]; - break; - } - } - } - return isFreeField; + return hasBuildingInter || hasTopographyInter; } /** 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 a01e9e48c..0883b160e 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 @@ -36,14 +36,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -946,7 +939,7 @@ public List getWallsIn(Envelope env) { * @return Cutting profile. */ public CutProfile getProfile(Coordinate c0, Coordinate c1) { - return getProfile(c0, c1, 0.0); + return getProfile(c0, c1, 0.0, false); } /** @@ -982,9 +975,11 @@ public static List splitSegment(Coordinate c0, Coordinate c1, doubl * @param sourceCoordinate Starting point. * @param receiverCoordinate Ending point. * @param gS Default source absorption ground effect value if no ground absorption value is found + * @param stopAtObstacleOverSourceReceiver If an obstacle is found higher than then segment sourceCoordinate + * receiverCoordinate, stop computing and a CutProfile with intersection information * @return Cutting profile. */ - public CutProfile getProfile(Coordinate sourceCoordinate, Coordinate receiverCoordinate, double gS) { + public CutProfile getProfile(Coordinate sourceCoordinate, Coordinate receiverCoordinate, double gS, boolean stopAtObstacleOverSourceReceiver) { CutProfile profile = new CutProfile(); // Add sourceCoordinate @@ -998,13 +993,19 @@ public CutProfile getProfile(Coordinate sourceCoordinate, Coordinate receiverCoo //Fetch topography evolution between sourceCoordinate and receiverCoordinate if(topoTree != null) { - addTopoCutPts(sourceCoordinate, receiverCoordinate, profile); + addTopoCutPts(sourceCoordinate, receiverCoordinate, profile, stopAtObstacleOverSourceReceiver); + if(stopAtObstacleOverSourceReceiver && profile.hasTopographyInter) { + return profile; + } } //Add Buildings/Walls and Ground effect transition points if(rtree != null) { LineSegment fullLine = new LineSegment(sourceCoordinate, receiverCoordinate); - addGroundBuildingCutPts(fullLine, profile); + addGroundBuildingCutPts(fullLine, profile, stopAtObstacleOverSourceReceiver); + if(stopAtObstacleOverSourceReceiver && profile.hasBuildingInter) { + return profile; + } } // Add receiver point @@ -1051,70 +1052,74 @@ public int getIntersectingGroundAbsorption(Geometry query) { * Fetch intersection of a line segment with Buildings lines/Walls lines/Ground Effect lines * @param fullLine P0 to P1 query for the profile of buildings * @param profile Object to feed the results (out) + * @param stopAtObstacleOverSourceReceiver If an obstacle is found higher than then segment sourceCoordinate + * receiverCoordinate, stop computing and set #CutProfile.hasBuildingInter to buildings in profile data */ - private void addGroundBuildingCutPts(LineSegment fullLine, CutProfile profile) { - Vector2D directionBefore = Vector2D.create(fullLine.p1, fullLine.p0).normalize().multiply(MILLIMETER); + private void addGroundBuildingCutPts(LineSegment fullLine, CutProfile profile, boolean stopAtObstacleOverSourceReceiver) { Vector2D directionAfter = Vector2D.create(fullLine.p0, fullLine.p1).normalize().multiply(MILLIMETER); // Collect all objects where envelope intersects all sub-segments of fullLine - Set indexes = new HashSet<>(); + Set processed = new HashSet<>(); // Segmented fullLine, this is the query for rTree indexes // Split line into segments for structures based on RTree in order to limit the number of queries // (for large area of the line segment envelope) List lines = splitSegment(fullLine.p0, fullLine.p1, maxLineLength); for (LineSegment line : lines) { - indexes.addAll(rtree.query(new Envelope(line.p0, line.p1))); - } - for (int i : indexes) { - Wall facetLine = processedWalls.get(i); - Coordinate intersection = fullLine.intersection(facetLine.ls); - if (intersection != null) { - intersection = new Coordinate(intersection); - if(!isNaN(facetLine.p0.z) && !isNaN(facetLine.p1.z)) { - // same z in the line, so useless to compute interpolation between points - if(Double.compare(facetLine.p0.z, facetLine.p1.z) == 0) { - intersection.z = facetLine.p0.z; - } else { - intersection.z = Vertex.interpolateZ(intersection, facetLine.p0, facetLine.p1); - } - } - if(facetLine.type == IntersectionType.BUILDING) { - CutPoint pt = profile.addBuildingCutPt(intersection, facetLine.originId, i,false); - pt.setGroundCoef(Scene.DEFAULT_G_BUILDING); - pt.setWallAlpha(buildings.get(facetLine.getOriginId()).alphas); - // add a point at the bottom of the building on the exterior side of the building - Vector2D facetVector = Vector2D.create(facetLine.p0, facetLine.p1); - // exterior polygon segments are CW, so the exterior of the polygon is on the left side of the vector - // it works also with polygon holes as interiors are CCW - Vector2D exteriorVector = facetVector.rotate(LEFT_SIDE).normalize().multiply(MILLIMETER); - Coordinate exteriorPoint = exteriorVector.add(Vector2D.create(intersection)).toCoordinate(); - CutPoint exteriorPointCutPoint = profile.addBuildingCutPt(exteriorPoint, facetLine.originId, i,false); - if(topoTree == null) { - exteriorPointCutPoint.coordinate.setZ(0.0); - } else { - exteriorPointCutPoint.coordinate.setZ(getZGround(exteriorPointCutPoint)); - pt.zGround = exteriorPointCutPoint.coordinate.z; - exteriorPointCutPoint.zGround = exteriorPointCutPoint.coordinate.z; - } - } else if(facetLine.type == IntersectionType.WALL) { - profile.addWallCutPt(intersection, facetLine.originId, false, facetLine.alphas); - } else if(facetLine.type == GROUND_EFFECT) { - // we hit the border of a ground effect - // we need to add a new point with the new value of the ground effect - // we will query for the point that lie after the intersection with the ground effect border - // in order to have the new value of the ground effect, if there is nothing at this location - // we fall back to the default value of ground effect - // if this is another ground effect it will be processed in another loop (two intersections on the same coordinate) - // retrieve the ground coefficient after the intersection in the direction of the profile - // this method will solve the question if we enter a new ground absorption or we will leave one - Point afterIntersectionPoint = FACTORY.createPoint(Vector2D.create(intersection).add(directionAfter).toCoordinate()); - GroundAbsorption groundAbsorption = groundAbsorptions.get(facetLine.getOriginId()); - if(groundAbsorption.geom.intersects(afterIntersectionPoint)) { - // we enter a new ground effect - profile.addGroundCutPt(intersection, facetLine.getOriginId(), groundAbsorption.getCoefficient()); - } else { - // no new ground effect, we fall back to default G - profile.addGroundCutPt(intersection, facetLine.getOriginId(), Scene.DEFAULT_G); + for (Object result : rtree.query(new Envelope(line.p0, line.p1))) { + if(result instanceof Integer && !processed.contains((Integer)result)) { + processed.add((Integer) result); + int i = (Integer) result; + Wall facetLine = processedWalls.get(i); + Coordinate intersection = fullLine.intersection(facetLine.ls); + if (intersection != null) { + intersection = new Coordinate(intersection); + if (!isNaN(facetLine.p0.z) && !isNaN(facetLine.p1.z)) { + // same z in the line, so useless to compute interpolation between points + if (Double.compare(facetLine.p0.z, facetLine.p1.z) == 0) { + intersection.z = facetLine.p0.z; + } else { + intersection.z = Vertex.interpolateZ(intersection, facetLine.p0, facetLine.p1); + } + } + if (facetLine.type == IntersectionType.BUILDING) { + CutPoint pt = profile.addBuildingCutPt(intersection, facetLine.originId, i, false); + pt.setGroundCoef(Scene.DEFAULT_G_BUILDING); + pt.setWallAlpha(buildings.get(facetLine.getOriginId()).alphas); + // add a point at the bottom of the building on the exterior side of the building + Vector2D facetVector = Vector2D.create(facetLine.p0, facetLine.p1); + // exterior polygon segments are CW, so the exterior of the polygon is on the left side of the vector + // it works also with polygon holes as interiors are CCW + Vector2D exteriorVector = facetVector.rotate(LEFT_SIDE).normalize().multiply(MILLIMETER); + Coordinate exteriorPoint = exteriorVector.add(Vector2D.create(intersection)).toCoordinate(); + CutPoint exteriorPointCutPoint = profile.addBuildingCutPt(exteriorPoint, facetLine.originId, i, false); + if (topoTree == null) { + exteriorPointCutPoint.coordinate.setZ(0.0); + } else { + exteriorPointCutPoint.coordinate.setZ(getZGround(exteriorPointCutPoint)); + pt.zGround = exteriorPointCutPoint.coordinate.z; + exteriorPointCutPoint.zGround = exteriorPointCutPoint.coordinate.z; + } + } else if (facetLine.type == IntersectionType.WALL) { + profile.addWallCutPt(intersection, facetLine.originId, false, facetLine.alphas); + } else if (facetLine.type == GROUND_EFFECT) { + // we hit the border of a ground effect + // we need to add a new point with the new value of the ground effect + // we will query for the point that lie after the intersection with the ground effect border + // in order to have the new value of the ground effect, if there is nothing at this location + // we fall back to the default value of ground effect + // if this is another ground effect it will be processed in another loop (two intersections on the same coordinate) + // retrieve the ground coefficient after the intersection in the direction of the profile + // this method will solve the question if we enter a new ground absorption or we will leave one + Point afterIntersectionPoint = FACTORY.createPoint(Vector2D.create(intersection).add(directionAfter).toCoordinate()); + GroundAbsorption groundAbsorption = groundAbsorptions.get(facetLine.getOriginId()); + if (groundAbsorption.geom.intersects(afterIntersectionPoint)) { + // we enter a new ground effect + profile.addGroundCutPt(intersection, facetLine.getOriginId(), groundAbsorption.getCoefficient()); + } else { + // no new ground effect, we fall back to default G + profile.addGroundCutPt(intersection, facetLine.getOriginId(), Scene.DEFAULT_G); + } + } } } } @@ -1249,8 +1254,10 @@ public int getTriangleIdByCoordinate(Coordinate pt) { * @param p2 * @param profile */ - public void addTopoCutPts(Coordinate p1, Coordinate p2, CutProfile profile) { - List coordinates = getTopographicProfile(p1, p2); + public void addTopoCutPts(Coordinate p1, Coordinate p2, CutProfile profile, boolean stopAtObstacleOverSourceReceiver) { + List coordinates = new ArrayList<>(); + boolean freeField = fetchTopographicProfile(coordinates, p1, p2, stopAtObstacleOverSourceReceiver); + profile.hasTopographyInter = !freeField; // Remove unnecessary points ArrayList retainedCoordinates = new ArrayList<>(coordinates.size()); for(int i =0; i < coordinates.size(); i++) { @@ -1328,16 +1335,16 @@ boolean findClosestTriangleIntersection(LineSegment segment, final Coordinate in } /** - * - * @param p1 - * @param p2 - * @return + * Fetch all intersections with TIN + * @param p1 first point + * @param p2 second point + * @param stopAtObstacleOverSourceReceiver Stop fetching intersections if the segment p1-p2 is intersecting with TIN + * @return True if the segment p1-p2 is not intersecting with DEM */ - public List getTopographicProfile(Coordinate p1, Coordinate p2) { + public boolean fetchTopographicProfile(List outputPoints,Coordinate p1, Coordinate p2, boolean stopAtObstacleOverSourceReceiver) { if(topoTree == null) { - return new ArrayList<>(); + return true; } - List outputPoints = new ArrayList<>(); //get origin triangle id int curTriP1 = getTriangleIdByCoordinate(p1); LineSegment propaLine = new LineSegment(p1, p2); @@ -1350,7 +1357,8 @@ public List getTopographicProfile(Coordinate p1, Coordinate p2) { outputPoints.add(intersectionPt); curTriP1 = minDistanceTriangle.get(); } else { - return outputPoints; + // out of DEM propagation area + return true; } } HashSet navigationHistory = new HashSet(); @@ -1363,10 +1371,17 @@ public List getTopographicProfile(Coordinate p1, Coordinate p2) { // extract X,Y,Z values of intersection with triangle segment if(!Double.isNaN(intersectionPt.z)) { outputPoints.add(intersectionPt); + if(stopAtObstacleOverSourceReceiver) { + Coordinate closestPointOnPropagationLine = propaLine.closestPoint(intersectionPt); + double interpolatedZ = Vertex.interpolateZ(closestPointOnPropagationLine, propaLine.p0, propaLine.p1); + if(interpolatedZ < intersectionPt.z) { + return false; + } + } } navigationTri = propaTri; } - return outputPoints; + return true; } /** diff --git a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/PathFinderTest.java b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/PathFinderTest.java index 3fa4093a4..afce02ead 100644 --- a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/PathFinderTest.java +++ b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/PathFinderTest.java @@ -303,7 +303,7 @@ public void TC06() { - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); // Test R-CRIT table 27 @@ -403,7 +403,7 @@ public void TC07() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -487,7 +487,7 @@ public void TC08() { computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); //Expected values @@ -580,7 +580,7 @@ public void TC09() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); //Expected values @@ -663,7 +663,7 @@ public void TC10() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -742,7 +742,7 @@ public void TC11() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -819,7 +819,7 @@ public void TC12() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -903,7 +903,7 @@ public void TC13() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); //Expected values @@ -978,7 +978,7 @@ public void TC14() { computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1062,7 +1062,7 @@ public void TC15() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1154,7 +1154,7 @@ public void TC16() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1246,7 +1246,7 @@ public void TC17() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1357,7 +1357,7 @@ public void TC18() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1467,7 +1467,7 @@ public void TC19() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1548,7 +1548,7 @@ public void TC20() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1625,7 +1625,7 @@ public void TC21() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1737,7 +1737,7 @@ public void TC22(){ //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1836,7 +1836,7 @@ public void TC23() { //Run computation computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -1946,7 +1946,7 @@ public void TC24() { computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -2026,7 +2026,7 @@ public void TC25(){ computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -2144,7 +2144,7 @@ public void TC27(){ computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); @@ -2293,7 +2293,7 @@ public void TC28(){ computeRays.run(propDataOut); - CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS); + CutProfile cutProfile = computeRays.getData().profileBuilder.getProfile(rayData.sourceGeometries.get(0).getCoordinate(), rayData.receivers.get(0), computeRays.getData().gS, false); List result = computeRays.computePts2DGround(cutProfile, rayData); diff --git a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilderTest.java b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilderTest.java index 219b22633..fd2b4a685 100644 --- a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilderTest.java +++ b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/ProfileBuilderTest.java @@ -312,7 +312,7 @@ public void testComplexTopographic() throws IOException, XMLStreamException, CRS cutStart.setZ(profileBuilder.getZGround(new CutPoint(cutStart, ProfileBuilder.IntersectionType.TOPOGRAPHY, 0))); Coordinate cutEnd = new Coordinate(envDomain.getMinX() + envDomain.getWidth() * testPoint[2], envDomain.getMinY() + envDomain.getHeight() * testPoint[3]); cutEnd.setZ(profileBuilder.getZGround(new CutPoint(cutEnd, ProfileBuilder.IntersectionType.TOPOGRAPHY, 0))); - profileBuilder.getProfile(cutStart, cutEnd, 0); + profileBuilder.getProfile(cutStart, cutEnd, 0, false); } } logger.info(String.format(Locale.ROOT, "Building topography profile in average of %f ms", (double)(System.currentTimeMillis() - start) / (loops - startLoop))); @@ -354,7 +354,7 @@ public void testProfileTopographicGroundEffectWall() throws Exception { Coordinate receiver = new Coordinate(200, 50, 14); Coordinate source = new Coordinate(10, 10, 1); - CutProfile cutProfile = profileBuilder.getProfile(source, receiver, 0); + CutProfile cutProfile = profileBuilder.getProfile(source, receiver, 0, false); assertEquals(7, cutProfile.getCutPoints().size()); assertEquals(0, cutProfile.getCutPoints().get(0).getCoordinate().distance3D(new Coordinate(10, 10, 1)), 0.001); assertEquals(0, cutProfile.getCutPoints().get(1).getCoordinate().distance3D(new Coordinate(50, 18.421, 0)), 0.001); diff --git a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestPathFinder.java b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestPathFinder.java index 5a10bb17f..80c3401f7 100644 --- a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestPathFinder.java +++ b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestPathFinder.java @@ -130,7 +130,7 @@ public void TestcomputeVerticalEdgeDiffraction() throws ParseException { } @Test - public void TestSplitLineStringIntoPoints() { + public void TestSplitLineSourceIntoPoints() { GeometryFactory factory = new GeometryFactory(); List sourcePoints = new ArrayList<>(); // source line is split in 3 parts of 2.5 meters