diff --git a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/MirrorReceiverResultIndex.java b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/MirrorReceiverResultIndex.java index 7455e1ca8..637acc2de 100644 --- a/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/MirrorReceiverResultIndex.java +++ b/noisemodelling-pathfinder/src/main/java/org/noise_planet/noisemodelling/pathfinder/MirrorReceiverResultIndex.java @@ -181,27 +181,45 @@ public void exportVisibility(StringBuilder sb, double maxPropagationDistance, WKTWriter wktWriter = new WKTWriter(); GeometryFactory factory = new GeometryFactory(); if(includeHeader) { - sb.append("the_geom,type,t\n"); + sb.append("the_geom,type,ref_index,ref_order,wall_id,t\n"); } + int refIndex = 0; for (MirrorReceiverResult res : mirrorReceiverResultList) { Polygon visibilityCone = MirrorReceiverResultIndex.createWallReflectionVisibilityCone( res.getReceiverPos(), res.getWall().getLineSegment(), maxPropagationDistance, maxPropagationDistanceFromWall); if(!visibilityCone.isEmpty()) { + int refOrder=1; + MirrorReceiverResult parent = res.getParentMirror(); + while (parent != null) { + refOrder++; + parent = parent.getParentMirror(); + } + sb.append("\""); sb.append(wktWriter.write(visibilityCone)); sb.append("\",0"); + sb.append(",").append(refIndex); + sb.append(",").append(refOrder); + sb.append(",").append(res.getWall().getOriginId()); sb.append(",").append(t).append("\n"); sb.append("\""); sb.append(wktWriter.write(factory.createPoint(res.getReceiverPos()).buffer(0.1, 12, BufferParameters.CAP_ROUND))); sb.append("\",4"); + sb.append(",").append(refIndex); + sb.append(",").append(refOrder); + sb.append(",").append(res.getWall().getOriginId()); sb.append(",").append(t).append("\n"); sb.append("\""); sb.append(wktWriter.write(factory.createLineString(new Coordinate[]{res.getWall().p0, res.getWall().p1}). buffer(0.05, 8, BufferParameters.CAP_SQUARE))); sb.append("\",1"); + sb.append(",").append(refIndex); + sb.append(",").append(refOrder); + sb.append(",").append(res.getWall().getOriginId()); sb.append(",").append(t).append("\n"); + refIndex+=1; } } sb.append("\""); @@ -267,36 +285,6 @@ public void visitItem(Object item) { if(!li.hasIntersection()) { // No reflection on this wall return; - } else { - reflectionPoint = li.getIntersection(0); - double wallReflectionPointZ = Vertex.interpolateZ(reflectionPoint, currentWallLineSegment.p0, - currentWallLineSegment.p1); - double propagationReflectionPointZ = Vertex.interpolateZ(reflectionPoint, srcMirrRcvLine.p0, - srcMirrRcvLine.p1); - if(propagationReflectionPointZ > wallReflectionPointZ) { - // The receiver image is not visible because the wall is not tall enough - return; - } - } - // Check if other surface of this wall obstruct the view - //Check if another wall is masking the current - for (ProfileBuilder.Wall otherWall : currentWall.getObstacle().getWalls()) { - if(!otherWall.equals(currentWall)) { - LineSegment otherWallSegment = otherWall.getLineSegment(); - li = new RobustLineIntersector(); - li.computeIntersection(otherWall.p0, otherWall.p1, reflectionPoint, source); - if (li.hasIntersection()) { - Coordinate otherReflectionPoint = li.getIntersection(0); - double wallReflectionPointZ = Vertex.interpolateZ(otherReflectionPoint, - otherWallSegment.p0, otherWallSegment.p1); - double propagationReflectionPointZ = Vertex.interpolateZ(otherReflectionPoint, - srcMirrRcvLine.p0, srcMirrRcvLine.p1); - if (propagationReflectionPointZ <= wallReflectionPointZ) { - // This wall is obstructing the view of the propagation line (other wall too tall) - return; - } - } - } } currentReceiverImage = currentReceiverImage.getParentMirror(); } diff --git a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestWallReflection.java b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestWallReflection.java index 1ba87fb92..42a76accb 100644 --- a/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestWallReflection.java +++ b/noisemodelling-pathfinder/src/test/java/org/noise_planet/noisemodelling/pathfinder/TestWallReflection.java @@ -113,9 +113,9 @@ public void testNReflexion() throws ParseException, IOException, SQLException { inputData.addSource(factory.createPoint(new Coordinate(599095.21, 646283.77, 1))); inputData.setComputeHorizontalDiffraction(false); inputData.setComputeVerticalDiffraction(false); - inputData.maxRefDist = 500; - inputData.maxSrcDist = 1000; - inputData.setReflexionOrder(3); + inputData.maxRefDist = 80; + inputData.maxSrcDist = 180; + inputData.setReflexionOrder(2); ComputeCnossosRays computeRays = new ComputeCnossosRays(inputData); computeRays.setThreadCount(1); @@ -130,7 +130,13 @@ public void testNReflexion() throws ParseException, IOException, SQLException { //Keep only mirror receivers potentially visible from the source List mirrorResults = receiverMirrorIndex.findCloseMirrorReceivers( inputData.sourceGeometries.get(0).getCoordinate()); - +// var lst = receiverMirrorIndex.mirrorReceiverTree.query(new Envelope(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, +// Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY)); +// for(var item : lst) { +// if(item instanceof MirrorReceiverResult) { +// mirrorResults.add((MirrorReceiverResult) item); +// } +// } List propagationPaths = computeRays.computeReflexion(receiver, inputData.sourceGeometries.get(0).getCoordinate(), false, @@ -140,7 +146,7 @@ public void testNReflexion() throws ParseException, IOException, SQLException { try { try (FileWriter fileWriter = new FileWriter("target/testVisibilityCone.csv")) { StringBuilder sb = new StringBuilder(); - receiverMirrorIndex.exportVisibility(sb, 80, 80, + receiverMirrorIndex.exportVisibility(sb, inputData.maxSrcDist, inputData.maxRefDist, 0, mirrorResults, true); fileWriter.write(sb.toString()); } @@ -148,7 +154,8 @@ public void testNReflexion() throws ParseException, IOException, SQLException { //ignore } - assertEquals(1, mirrorResults.size()); + assertEquals(16, mirrorResults.size()); + assertEquals(16, propagationPaths.size()); }