From 24f4b2ad6c974d12c06113806adc54026caacac3 Mon Sep 17 00:00:00 2001 From: nkuehnel Date: Thu, 19 Dec 2024 13:35:57 +0100 Subject: [PATCH] Noise maintenance: Add an option to independently enable or disable reflection calculation, regardless of noise shielding. --- .../contrib/noise/NoiseConfigGroup.java | 23 +- .../contrib/noise/RLS19NoiseImmission.java | 34 +-- .../contrib/noise/ReflectionContext.java | 35 +-- .../contrib/noise/ShieldingContext.java | 249 ++++++++---------- 4 files changed, 159 insertions(+), 182 deletions(-) diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java index c2c9bc8d039..0833d66f019 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/NoiseConfigGroup.java @@ -43,7 +43,7 @@ * Provides the parameters required to build a simple grid with some basic spatial functionality. * Provides the parameters required to compute noise emissions, immissions and damages. * - * @author ikaddoura + * @author ikaddoura, nkuehnel */ public final class NoiseConfigGroup extends ReflectiveConfigGroup { @@ -81,6 +81,7 @@ public final class NoiseConfigGroup extends ReflectiveConfigGroup { private static final String RECEIVER_POINT_GAP_CMT = "horizontal and vertical distance between receiver points in x-/y-coordinate units"; private static final String WRITE_OUTPUT_ITERATION_CMT = "Specifies how often the noise-specific output is written out."; private static final String CONSIDER_NOISE_BARRIERS = "considerNoiseBarriers"; + private static final String CONSIDER_NOISE_REFLECTION = "considerNoiseReflection"; private static final String NOISE_BARRIERS_GEOJSON_FILE = "noiseBarriersGeojsonPath"; private static final String NOISE_BARRIERS_SOURCE_CRS = "source coordinate reference system of noise barriers geojson file"; private static final String NETWORK_MODES_TO_IGNORE = "networkModesToIgnore"; @@ -142,6 +143,7 @@ public enum NoiseAllocationApproach { private double noiseTollFactor = 1.0; private boolean considerNoiseBarriers = false; + private boolean considerNoiseReflection = false; private String noiseBarriersFilePath = null; private String noiseBarriersSourceCrs = null; @@ -204,6 +206,7 @@ public Map getComments() { comments.put(NOISE_TOLL_FACTOR, "To be used for sensitivity analysis. Default: 1.0 (= the parameter has no effect)"); comments.put(CONSIDER_NOISE_BARRIERS, "Set to 'true' if noise barriers / building shielding should be considered. Otherwise set to 'false'."); + comments.put(CONSIDER_NOISE_REFLECTION, "Set to 'true' if reflections should be considered. Otherwise set to 'false'. Has a considerable performance impact."); comments.put(NOISE_BARRIERS_GEOJSON_FILE, "Path to the geojson file for noise barriers."); comments.put(NOISE_BARRIERS_SOURCE_CRS, "Source coordinate reference system of noise barriers geojson file."); @@ -308,6 +311,14 @@ private void checkNoiseParametersForConsistency(Config config) { + " It is therefore recommended not to use speeds outside of the range of valid parameters!"); } + if(considerNoiseReflection) { + if (!this.considerNoiseBarriers) { + if (this.noiseBarriersFilePath == null || "".equals(this.noiseBarriersFilePath)) { + log.warn("Cannot consider noise reflection without a specified file path to the geojson file of barriers / buildings."); + this.considerNoiseBarriers = false; + } + } + } if (this.considerNoiseBarriers) { if (this.noiseBarriersFilePath == null || "".equals(this.noiseBarriersFilePath)) { log.warn("Cannot consider noise barriers without a specified file path to the geojson file of barriers / buildings."); @@ -782,6 +793,16 @@ public void setConsiderNoiseBarriers(boolean considerNoiseBarriers) { this.considerNoiseBarriers = considerNoiseBarriers; } + @StringGetter(CONSIDER_NOISE_REFLECTION) + public boolean isConsiderNoiseReflection() { + return this.considerNoiseReflection; + } + + @StringSetter(CONSIDER_NOISE_REFLECTION) + public void setConsiderNoiseReflection(boolean considerNoiseReflection) { + this.considerNoiseReflection = considerNoiseReflection; + } + @StringGetter(NOISE_BARRIERS_GEOJSON_FILE) public String getNoiseBarriersFilePath() { return this.noiseBarriersFilePath; diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java index 1e8f1cd2563..e0bb566141c 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/RLS19NoiseImmission.java @@ -101,7 +101,9 @@ public double calculateCorrection(double projectedDistance, NoiseReceiverPoint n @Override public void setCurrentRp(NoiseReceiverPoint nrp) { - reflection.setCurrentReceiver(nrp); + if(noiseParams.isConsiderNoiseReflection()) { + reflection.setCurrentReceiver(nrp); + } } private double getSectionsCorrection(NoiseReceiverPoint nrp, Link link) { @@ -127,10 +129,12 @@ private double getSubSectionsCorrection(Coordinate nrpCoordinate, LineSegment se final double sectionCorrection = 10 * Math.log10(length) - calculateCorrection(nrpCoordinate, segment, null); correctionTemp += Math.pow(10, 0.1*sectionCorrection); - final Set reflectionLinks = reflection.getReflections(segment); - for(ReflectionContext.ReflectionTuple reflection: reflectionLinks) { - double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink.getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink, reflection.facade); - correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + if(noiseParams.isConsiderNoiseReflection()) { + final Set reflectionLinks = reflection.getReflections(segment); + for (ReflectionContext.ReflectionTuple reflection : reflectionLinks) { + double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink().getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink(), reflection.facade()); + correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + } } } else { double lMid = length / 2; @@ -149,10 +153,12 @@ private double getSubSectionsCorrection(Coordinate nrpCoordinate, LineSegment se final double sectionCorrection = 10 * Math.log10(central.getLength()) - calculateCorrection(nrpCoordinate, central, null); correctionTemp += Math.pow(10, 0.1 * sectionCorrection); - final Set reflectionLinks = reflection.getReflections(central); - for(ReflectionContext.ReflectionTuple reflection: reflectionLinks) { - double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink.getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink, reflection.facade); - correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + if(noiseParams.isConsiderNoiseReflection()) { + final Set reflectionLinks = reflection.getReflections(central); + for (ReflectionContext.ReflectionTuple reflection : reflectionLinks) { + double sectionCorrectionReflection = 10 * Math.log10(reflection.reflectionLink().getLength()) - calculateCorrection(nrpCoordinate, reflection.reflectionLink(), reflection.facade()); + correctionTemp += Math.pow(10, 0.1 * sectionCorrectionReflection); + } } correctionTemp += getSubSectionsCorrection(nrpCoordinate, leftRemaining); @@ -174,7 +180,10 @@ private double calculateCorrection(Coordinate nrp, LineSegment segment, LineSegm //to maintain the correct signs. nk, Sep'20 double intersectionCorrection = intersection.calculateIntersectionCorrection(coordinate); - double multipleReflectionCorrection = reflection.getMultipleReflectionCorrection(segment); + double multipleReflectionCorrection = 0; + if(noiseParams.isConsiderNoiseReflection()) { + multipleReflectionCorrection = reflection.getMultipleReflectionCorrection(segment); + } double geometricDivergence = 20 * Math.log10(distance) + 10 * Math.log10(2 * Math.PI); double airDampeningFactor = distance / 200.; @@ -191,11 +200,6 @@ private double calculateCorrection(Coordinate nrp, LineSegment segment, LineSegm } else { return geometricDivergence + airDampeningFactor - intersectionCorrection + groundDampening ; } - - //TODO: implement reflection - if someone is looking for a (bachelor) thesis... -// double firstReflectionCorrection = 0; -// double secondReflectionCorrection = 0; -// return dampeningCorrection + firstReflectionCorrection + secondReflectionCorrection; } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java index 02639ac3d3b..145367afee6 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/ReflectionContext.java @@ -1,5 +1,6 @@ package org.matsim.contrib.noise; +import jakarta.inject.Inject; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.locationtech.jts.algorithm.Angle; @@ -7,7 +8,6 @@ import org.locationtech.jts.geom.util.AffineTransformation; import org.matsim.core.config.Config; -import jakarta.inject.Inject; import java.util.*; /** @@ -15,18 +15,19 @@ * * @author nkuehnel */ -public class ReflectionContext { +public final class ReflectionContext { static final double SCAN_LINE_LENGTH = 1; - private final static Logger logger = LogManager.getLogger(org.matsim.contrib.noise.ShieldingContext.class); + private final static Logger logger = LogManager.getLogger(ReflectionContext.class); private Set visibleEdges; private Coordinate receiver; - private BarrierContext barrierContext; - private GeometryFactory geomFactory = new GeometryFactory(); + private final BarrierContext barrierContext; + private final GeometryFactory geomFactory = new GeometryFactory(); + record ReflectionTuple(LineSegment facade, LineSegment reflectionLink) { } @Inject ReflectionContext(BarrierContext barrierContext) { @@ -38,6 +39,7 @@ public class ReflectionContext { } void setCurrentReceiver(NoiseReceiverPoint nrp) { + receiver = new Coordinate(nrp.getCoord().getX(), nrp.getCoord().getY()); final Collection candidates = @@ -60,7 +62,7 @@ void setCurrentReceiver(NoiseReceiverPoint nrp) { } - Set findVisibleEdgesOfPolygon(List polygonEdges, Coordinate coordinate) { + private Set findVisibleEdgesOfPolygon(List polygonEdges, Coordinate coordinate) { Coordinate coordXinc = new Coordinate(coordinate.x + 1, coordinate.y); @@ -155,13 +157,9 @@ Set getReflections(LineSegment originalLink) { } } return reflections; -// return Collections.EMPTY_SET; } double getMultipleReflectionCorrection(LineSegment segment) { - if(this.receiver.x == 1420 && this.receiver.y == 20) { - System.out.println("jo"); - } final Coordinate coordinate = segment.midPoint(); Coordinate candidateRight = getReflectionSegment(coordinate, segment, 400); @@ -174,7 +172,7 @@ Set getReflections(LineSegment originalLink) { } else { return 0; } - if (candidateLeft != null && candidateRight != null){ + if (candidateLeft != null){ double w = candidateLeft.distance(candidateRight); return Math.min(2 * Math.min(candidateLeft.z, candidateRight.z) / w, 1.6); } @@ -265,7 +263,7 @@ private boolean hit(LineSegment facade, LineSegment originalLink) { return true; } - static boolean intersects(LineSegment segment1, LineSegment segment2) { + private static boolean intersects(LineSegment segment1, LineSegment segment2) { double dx0 = segment1.p1.x - segment1.p0.x; double dx1 = segment2.p1.x - segment2.p0.x; @@ -277,17 +275,6 @@ static boolean intersects(LineSegment segment1, LineSegment segment2) { double p1 = dy1 * (segment2.p1.x - segment1.p1.x) - dx1 * (segment2.p1.y - segment1.p1.y); double p2 = dy0 * (segment1.p1.x - segment2.p0.x) - dx0 * (segment1.p1.y - segment2.p0.y); double p3 = dy0 * (segment1.p1.x - segment2.p1.x) - dx0 * (segment1.p1.y - segment2.p1.y); - return (p0 * p1 <= 0) & (p2 * p3 <= 0); - } - - - static class ReflectionTuple { - final LineSegment facade; - final LineSegment reflectionLink; - - public ReflectionTuple(LineSegment facade, LineSegment reflectionLink) { - this.facade = facade; - this.reflectionLink = reflectionLink; - } + return (p0 * p1 <= 0) && (p2 * p3 <= 0); } } diff --git a/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java b/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java index 97af40ce515..ea4e97ca7e6 100644 --- a/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java +++ b/contribs/noise/src/main/java/org/matsim/contrib/noise/ShieldingContext.java @@ -24,8 +24,6 @@ final class ShieldingContext { private final static Logger logger = LogManager.getLogger(ShieldingContext.class); - //STRtree increases performance by ~40% by reducing the amount of potential - //obstruction candidates. nkuehnel, mar '20 private final static double GROUND_HEIGHT = 0.5; private final ShieldingCorrection shieldingCorrection; @@ -35,7 +33,6 @@ final class ShieldingContext { ShieldingContext(Config config, ShieldingCorrection shieldingCorrection, BarrierContext barrierContext) { this.shieldingCorrection = shieldingCorrection; this.barrierContext = barrierContext; - NoiseConfigGroup noiseParams = ConfigUtils.addOrGetModule(config, NoiseConfigGroup.class); } ShieldingContext(ShieldingCorrection shieldingCorrection, BarrierContext barrierContext) { @@ -51,83 +48,73 @@ final class ShieldingContext { final Coordinate midPoint = segment.midPoint(); midPoint.z = GROUND_HEIGHT; -// final Point fromPoint = GeometryUtils.createGeotoolsPoint(link.getFromNode().getCoord()); -// final Point toPoint = GeometryUtils.createGeotoolsPoint(link.getToNode().getCoord()); - - Coordinate from = segment.p0; - Coordinate to = segment.p1; - LineString projectedLineOfSight = constructLineOfSight(rpPoint, midPoint); -// LineString fromLineOfSight = constructLineOfSight(rpPoint, from); -// LineString toLineOfSight = constructLineOfSight(rpPoint, to); NavigableMap edgeCandidates = getObstructionEdges(rpPoint, midPoint, projectedLineOfSight); edgeCandidates.put(projectedLineOfSight.getLength(), midPoint); - if (!edgeCandidates.isEmpty()) { - Coordinate lastFixedEdge = rpPoint; - Coordinate tmpEdge = rpPoint; - double currentHeight = GROUND_HEIGHT; + Coordinate lastFixedEdge = rpPoint; + Coordinate tmpEdge = rpPoint; + double currentHeight = GROUND_HEIGHT; - List consideredEdges = new ArrayList<>(); + List consideredEdges = new ArrayList<>(); - double distToCurrentEdge = 0; - while (lastFixedEdge != midPoint) { - if (edgeCandidates.isEmpty()) { - logger.warn("Skipping obstacle as distance appears to be 0."); - return correctionTermShielding; - } - Iterator edgesIterator = edgeCandidates.values().iterator(); - double maxSlope = Double.NEGATIVE_INFINITY; - double tmpDistance = 0; - while (edgesIterator.hasNext()) { - Coordinate edge = edgesIterator.next(); - double distance = lastFixedEdge.distance(edge); - double slope = (edge.z - currentHeight) / distance; - if (slope >= maxSlope) { - maxSlope = slope; - tmpEdge = edge; - tmpDistance = distance; - } + double distToCurrentEdge = 0; + while (lastFixedEdge != midPoint) { + if (edgeCandidates.isEmpty()) { + logger.warn("Skipping obstacle as distance appears to be 0."); + return correctionTermShielding; + } + Iterator edgesIterator = edgeCandidates.values().iterator(); + double maxSlope = Double.NEGATIVE_INFINITY; + double tmpDistance = 0; + while (edgesIterator.hasNext()) { + Coordinate edge = edgesIterator.next(); + double distance = lastFixedEdge.distance(edge); + double slope = (edge.z - currentHeight) / distance; + if (slope >= maxSlope) { + maxSlope = slope; + tmpEdge = edge; + tmpDistance = distance; } - lastFixedEdge = tmpEdge; - distToCurrentEdge += tmpDistance; - currentHeight = tmpEdge.z; - consideredEdges.add(lastFixedEdge); - edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); } + lastFixedEdge = tmpEdge; + distToCurrentEdge += tmpDistance; + currentHeight = tmpEdge.z; + consideredEdges.add(lastFixedEdge); + edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); + } - consideredEdges.remove(midPoint); + consideredEdges.remove(midPoint); - if (consideredEdges.isEmpty()) { - return correctionTermShielding; - } + if (consideredEdges.isEmpty()) { + return correctionTermShielding; + } - final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; - double firstEdgeDistance = rpPoint.distance(consideredEdges.get(0)); - double receiverToFirstEdgeDistance - = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); - - double shieldingDepth = 0; - - Iterator it = consideredEdges.iterator(); - Coordinate edgeTemp = it.next(); - while (it.hasNext()) { - Coordinate edge = it.next(); - double xyDiff = edgeTemp.distance(edge); - double zDiff = edgeTemp.z - edge.z; - shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); - edgeTemp = edge; - } + final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; + double firstEdgeDistance = rpPoint.distance(consideredEdges.get(0)); + double receiverToFirstEdgeDistance + = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); + + double shieldingDepth = 0; + + Iterator it = consideredEdges.iterator(); + Coordinate edgeTemp = it.next(); + while (it.hasNext()) { + Coordinate edge = it.next(); + double xyDiff = edgeTemp.distance(edge); + double zDiff = edgeTemp.z - edge.z; + shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); + edgeTemp = edge; + } - final double lastEdgeSourceXYDiff = midPoint.distance(edgeTemp); - final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; - double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff - + lastEdgeSourceZDiff * lastEdgeSourceZDiff); + final double lastEdgeSourceXYDiff = midPoint.distance(edgeTemp); + final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; + double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff + + lastEdgeSourceZDiff * lastEdgeSourceZDiff); - correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( - rpPoint.distance(midPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); - } + correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( + rpPoint.distance(midPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); return correctionTermShielding; } @@ -170,7 +157,6 @@ private ConcurrentSkipListMap getObstructionEdges(Coordinate //using intersects() and intersection() directly on the jts geometry. nkuehnel, aug '20 final Set intersections = intersection((Polygon) noiseBarrier.getGeometry().getGeometry(), directLineOfSight.getCoordinates()); - for (Coordinate coordinate : intersections) { coordinate.z = noiseBarrier.getHeight(); final double distance = receiver.distance(coordinate); @@ -226,25 +212,7 @@ private LineString constructLineOfSight(Coordinate receiver, Coordinate source) private Set intersection(Polygon polygon, Coordinate[] coords) { - - Set externalIntersections = intersection(polygon.getExteriorRing(), coords); - -// Set internalIntersections = null; -// for (int i = 0; i < polygon.getNumInteriorRing(); i++) { -// Set intersects = intersection(polygon.getInteriorRingN(i), coords); -// if (!intersects.isEmpty()) { -// if (internalIntersections == null) { -// internalIntersections = new HashSet<>(); -// } -// internalIntersections.addAll(intersects); -// } -// } - -// if(internalIntersections != null) { -// externalIntersections.addAll(internalIntersections); -// } - - return externalIntersections; + return intersection(polygon.getExteriorRing(), coords); } private Set intersection(LineString ring, Coordinate[] coords) { @@ -285,7 +253,6 @@ private static boolean intersects(Polygon polygon, LineString string) { } - /** * determines the shielding value z for a receiver point for a given link emission source */ @@ -305,70 +272,68 @@ private static boolean intersects(Polygon polygon, LineString string) { NavigableMap edgeCandidates = getObstructionEdges(rpPoint, projectedPoint, projectedLineOfSight, fromLineOfSight, toLineOfSight); edgeCandidates.put(projectedLineOfSight.getLength(), projectedPoint.getCoordinate()); - if (!edgeCandidates.isEmpty()) { - Coordinate lastFixedEdge = rpPoint.getCoordinate(); - Coordinate tmpEdge = rpPoint.getCoordinate(); - double currentHeight = GROUND_HEIGHT; + Coordinate lastFixedEdge = rpPoint.getCoordinate(); + Coordinate tmpEdge = rpPoint.getCoordinate(); + double currentHeight = GROUND_HEIGHT; - List consideredEdges = new ArrayList<>(); + List consideredEdges = new ArrayList<>(); - double distToCurrentEdge = 0; - while (lastFixedEdge != projectedPoint.getCoordinate()) { - if (edgeCandidates.isEmpty()) { - logger.warn("Skipping obstacle as distance appears to be 0."); - return correctionTermShielding; - } - Iterator edgesIterator = edgeCandidates.values().iterator(); - double maxSlope = Double.NEGATIVE_INFINITY; - double tmpDistance = 0; - while (edgesIterator.hasNext()) { - Coordinate edge = edgesIterator.next(); - double distance = lastFixedEdge.distance(edge); - double slope = (edge.z - currentHeight) / distance; - if (slope >= maxSlope) { - maxSlope = slope; - tmpEdge = edge; - tmpDistance = distance; - } + double distToCurrentEdge = 0; + while (lastFixedEdge != projectedPoint.getCoordinate()) { + if (edgeCandidates.isEmpty()) { + logger.warn("Skipping obstacle as distance appears to be 0."); + return correctionTermShielding; + } + Iterator edgesIterator = edgeCandidates.values().iterator(); + double maxSlope = Double.NEGATIVE_INFINITY; + double tmpDistance = 0; + while (edgesIterator.hasNext()) { + Coordinate edge = edgesIterator.next(); + double distance = lastFixedEdge.distance(edge); + double slope = (edge.z - currentHeight) / distance; + if (slope >= maxSlope) { + maxSlope = slope; + tmpEdge = edge; + tmpDistance = distance; } - lastFixedEdge = tmpEdge; - distToCurrentEdge += tmpDistance; - currentHeight = tmpEdge.z; - consideredEdges.add(lastFixedEdge); - edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); } + lastFixedEdge = tmpEdge; + distToCurrentEdge += tmpDistance; + currentHeight = tmpEdge.z; + consideredEdges.add(lastFixedEdge); + edgeCandidates = edgeCandidates.tailMap(distToCurrentEdge, false); + } - consideredEdges.remove(projectedPoint.getCoordinate()); + consideredEdges.remove(projectedPoint.getCoordinate()); - if (consideredEdges.isEmpty()) { - return correctionTermShielding; - } + if (consideredEdges.isEmpty()) { + return correctionTermShielding; + } - final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.get(0).z; - double firstEdgeDistance = rpPoint.getCoordinate().distance(consideredEdges.get(0)); - double receiverToFirstEdgeDistance - = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); - - double shieldingDepth = 0; - - Iterator it = consideredEdges.iterator(); - Coordinate edgeTemp = it.next(); - while (it.hasNext()) { - Coordinate edge = it.next(); - double xyDiff = edgeTemp.distance(edge); - double zDiff = edgeTemp.z - edge.z; - shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); - edgeTemp = edge; - } + final double firstEdgeYDiff = GROUND_HEIGHT - consideredEdges.getFirst().z; + double firstEdgeDistance = rpPoint.getCoordinate().distance(consideredEdges.getFirst()); + double receiverToFirstEdgeDistance + = Math.sqrt(firstEdgeYDiff * firstEdgeYDiff + firstEdgeDistance * firstEdgeDistance); + + double shieldingDepth = 0; + + Iterator it = consideredEdges.iterator(); + Coordinate edgeTemp = it.next(); + while (it.hasNext()) { + Coordinate edge = it.next(); + double xyDiff = edgeTemp.distance(edge); + double zDiff = edgeTemp.z - edge.z; + shieldingDepth += Math.sqrt(xyDiff * xyDiff + zDiff * zDiff); + edgeTemp = edge; + } - final double lastEdgeSourceXYDiff = projectedPoint.getCoordinate().distance(edgeTemp); - final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; - double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff - + lastEdgeSourceZDiff * lastEdgeSourceZDiff); + final double lastEdgeSourceXYDiff = projectedPoint.getCoordinate().distance(edgeTemp); + final double lastEdgeSourceZDiff = GROUND_HEIGHT - edgeTemp.z; + double lastEdgeToSourceDistance = Math.sqrt(lastEdgeSourceXYDiff * lastEdgeSourceXYDiff + + lastEdgeSourceZDiff * lastEdgeSourceZDiff); - correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( - rpPoint.distance(projectedPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); - } + correctionTermShielding = shieldingCorrection.calculateShieldingCorrection( + rpPoint.distance(projectedPoint), lastEdgeToSourceDistance, receiverToFirstEdgeDistance, shieldingDepth); return correctionTermShielding; } }