diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPointWall.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPointWall.java index 85e33facc..2235dd2c6 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPointWall.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/profilebuilder/CutPointWall.java @@ -9,7 +9,6 @@ package org.noise_planet.noisemodelling.pathfinder.profilebuilder; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.LineSegment; @@ -37,9 +36,9 @@ public class CutPointWall extends CutPoint { /** This point encounter this kind of limit * - We can enter or exit a polygon * - pass a line (a wall without width) */ - public enum INTERSECTION_TYPE { AREA_ENTER, AREA_EXIT, LINE_ENTER_EXIT} + public enum INTERSECTION_TYPE {BUILDING_ENTER, BUILDING_EXIT, THIN_WALL_ENTER_EXIT} - public INTERSECTION_TYPE intersectionType = INTERSECTION_TYPE.LINE_ENTER_EXIT; + public INTERSECTION_TYPE intersectionType = INTERSECTION_TYPE.THIN_WALL_ENTER_EXIT; /** Database primary key value of the obstacle */ @JsonInclude(JsonInclude.Include.NON_NULL) 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 7b12e5098..6adae4ecb 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 @@ -171,36 +171,46 @@ public static List computePtsGround(List pts, List= 0 && cut instanceof CutPointTopography)) { - pts2D.add(coordinate); + // we will ignore topographic point if we are over a building + if (!(overArea && cut instanceof CutPointTopography)) { + pts2D.add(new Coordinate(cut.getCoordinate().x, cut.getCoordinate().y, cut.getzGround())); + } } - if(index != null) { + if (index != null) { index.add(pts2D.size() - 1); } } 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 c745eef35..f81d8799a 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 @@ -12,7 +12,6 @@ import org.locationtech.jts.algorithm.Angle; import org.locationtech.jts.algorithm.CGAlgorithms3D; import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.CoordinateSequence; import org.locationtech.jts.geom.Envelope; import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.GeometryFactory; @@ -1025,7 +1024,7 @@ private boolean processWall(int processedWallIndex, Coordinate intersection, Wal CutPointWall cutPointWall = new CutPointWall(processedWallIndex, intersection, facetLine.getLineSegment(), facetLine.alphas); - cutPointWall.intersectionType = CutPointWall.INTERSECTION_TYPE.LINE_ENTER_EXIT; + cutPointWall.intersectionType = CutPointWall.INTERSECTION_TYPE.THIN_WALL_ENTER_EXIT; if(facetLine.primaryKey >= 0) { cutPointWall.setPk(facetLine.primaryKey); } @@ -1059,9 +1058,9 @@ private boolean processBuilding(int processedWallIndex, Coordinate intersection, Coordinate exteriorPoint = exteriorVector.add(Vector2D.create(intersection)).toCoordinate(); // exterior point closer to source so we know that we enter the building if(exteriorPoint.distance(fullLine.p0) < intersection.distance(fullLine.p0)) { - wallCutPoint.intersectionType = CutPointWall.INTERSECTION_TYPE.AREA_ENTER; + wallCutPoint.intersectionType = CutPointWall.INTERSECTION_TYPE.BUILDING_ENTER; } else { - wallCutPoint.intersectionType = CutPointWall.INTERSECTION_TYPE.AREA_EXIT; + wallCutPoint.intersectionType = CutPointWall.INTERSECTION_TYPE.BUILDING_EXIT; } if (zRayReceiverSource <= intersection.z) { 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 3a514be27..48184e60e 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 @@ -21,11 +21,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.noise_planet.noisemodelling.pathfinder.PathFinderTest.assertZProfil; /** * Test class dedicated to {@link ProfileBuilder}. @@ -294,6 +296,62 @@ public void testRelativeSourceLineProjection() throws ParseException { new Coordinate(120.0, 33.16, 1.0), new Coordinate(185.0, 46.84, 11.0), new Coordinate(200.0, 50.0, 11.0)); - PathFinderTest.assertZProfil(expectedProfile, Arrays.asList(scene.sourceGeometries.get(0).getCoordinates())); + assertZProfil(expectedProfile, Arrays.asList(scene.sourceGeometries.get(0).getCoordinates())); + } + + + @Test + public void test2DGroundProfile() { + + //Profile building (from TC15) + ProfileBuilder profileBuilder = new ProfileBuilder() + .addBuilding(new Coordinate[]{ + new Coordinate(55.0, 5.0, 8), + new Coordinate(65.0, 5.0, 8), + new Coordinate(65.0, 15.0, 8), + new Coordinate(55.0, 15.0, 8), + }) + .addBuilding(new Coordinate[]{ + new Coordinate(70.0, 14.5, 12), + new Coordinate(80.0, 10.2, 12), + new Coordinate(80.0, 20.2, 12), + }) + .addBuilding(new Coordinate[]{ + new Coordinate(90.1, 19.5, 10), + new Coordinate(93.3, 17.8, 10), + new Coordinate(87.3, 6.6, 10), + new Coordinate(84.1, 8.3, 10), + }); + profileBuilder.addGroundEffect(0, 100, 0.0, 150, 0.5); + profileBuilder.setzBuildings(true); + profileBuilder.finishFeeding(); + + CutProfile cutProfile = profileBuilder.getProfile(new Coordinate(50,10,1), new Coordinate(100, 15, 5)); + + assertEquals(9, cutProfile.cutPoints.size()); + + List zProfile = cutProfile.computePts2DGround(); + + /* Table 148 */ + List expectedZProfile = new ArrayList<>(); + expectedZProfile.add(new Coordinate(0.00, 0.00)); + expectedZProfile.add(new Coordinate(5.02, 0.00)); + expectedZProfile.add(new Coordinate(5.02, 8.00)); + expectedZProfile.add(new Coordinate(15.07, 8.0)); + expectedZProfile.add(new Coordinate(15.08, 0.0)); + expectedZProfile.add(new Coordinate(24.81, 0.0)); + expectedZProfile.add(new Coordinate(24.81, 12.0)); + expectedZProfile.add(new Coordinate(30.15, 12.0)); + expectedZProfile.add(new Coordinate(30.15, 0.00)); + expectedZProfile.add(new Coordinate(37.19, 0.0)); + expectedZProfile.add(new Coordinate(37.19, 10.0)); + expectedZProfile.add(new Coordinate(41.52, 10.0)); + expectedZProfile.add(new Coordinate(41.52, 0.0)); + expectedZProfile.add(new Coordinate(50.25, 0.0)); + + //Assertion + assertZProfil(expectedZProfile, zProfile); + + } }