Skip to content

Commit

Permalink
projection cones where filtered out by checking other walls of the sa…
Browse files Browse the repository at this point in the history
…me main polygon
  • Loading branch information
nicolas-f committed Oct 7, 2024
1 parent f7f41a5 commit 068849a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("\"");
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -130,7 +130,13 @@ public void testNReflexion() throws ParseException, IOException, SQLException {
//Keep only mirror receivers potentially visible from the source
List<MirrorReceiverResult> 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<PropagationPath> propagationPaths = computeRays.computeReflexion(receiver,
inputData.sourceGeometries.get(0).getCoordinate(), false,
Expand All @@ -140,15 +146,16 @@ 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());
}
} catch (IOException ex) {
//ignore
}

assertEquals(1, mirrorResults.size());
assertEquals(16, mirrorResults.size());
assertEquals(16, propagationPaths.size());

}

Expand Down

0 comments on commit 068849a

Please sign in to comment.