From b047744378f0a80e5cc0ad1e9873bac9edeb2a88 Mon Sep 17 00:00:00 2001 From: James McClain Date: Fri, 10 Mar 2017 17:22:45 -0500 Subject: [PATCH] Improve Comment --- .../geotrellis/raster/viewshed/R2Viewshed.scala | 14 ++++++-------- .../spark/viewshed/IterativeViewshed.scala | 8 +++----- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/raster/src/main/scala/geotrellis/raster/viewshed/R2Viewshed.scala b/raster/src/main/scala/geotrellis/raster/viewshed/R2Viewshed.scala index cffd40c8dd..0a9dfd9927 100644 --- a/raster/src/main/scala/geotrellis/raster/viewshed/R2Viewshed.scala +++ b/raster/src/main/scala/geotrellis/raster/viewshed/R2Viewshed.scala @@ -206,8 +206,7 @@ object R2Viewshed extends Serializable { rays: Array[Ray], edgeCallback: EdgeCallback, op: AggregationOperator, - curve: Boolean = true, - debug: Boolean = false + curve: Boolean = true ): Tile = { val cols = elevationTile.cols val rows = elevationTile.rows @@ -219,30 +218,30 @@ object R2Viewshed extends Serializable { val m = (y0 - y1).toDouble / (x0 - x1) from match { - case _: FromInside if inTile => Some(DirectedSegment(x0, y0, x1, y1, theta)) + case _: FromInside if inTile => Some(DirectedSegment(x0,y0,x1,y1,theta)) case _: FromInside if !inTile => throw new Exception case _: FromNorth => val y2 = rows-1 val x2 = math.round(((y2 - y1) / m) + x1).toInt - if ((0 <= x2 && x2 < cols) && (y2 <= y0 && -math.sin(theta) > 0)) + if ((0 <= x2 && x2 < cols) && (y2 <= y0 && -math.sin(theta) > 0.0)) Some(DirectedSegment(x2,y2,x1,y1,theta)) else None case _: FromEast => val x2 = cols-1 val y2 = math.round((m * (x2 - x1)) + y1).toInt - if ((0 <= y2 && y2 < rows) && (x2 <= x0 && -math.cos(theta) > 0)) + if ((0 <= y2 && y2 < rows) && (x2 <= x0 && -math.cos(theta) > 0.0)) Some(DirectedSegment(x2,y2,x1,y1,theta)) else None case _: FromSouth => val y2 = 0 val x2 = math.round(((y2 - y1) / m) + x1).toInt - if ((0 <= x2 && x2 < cols) && (y2 >= y0 && math.sin(theta) > 0)) + if ((0 <= x2 && x2 < cols) && (y2 >= y0 && math.sin(theta) > 0.0)) Some(DirectedSegment(x2,y2,x1,y1,theta)) else None case _: FromWest => val x2 = 0 val y2 = math.round((m * (x2 - x1)) + y1).toInt - if ((0 <= y2 && y2 < rows) && (x2 >= x0 && math.cos(theta) > 0)) + if ((0 <= y2 && y2 < rows) && (x2 >= x0 && math.cos(theta) > 0.0)) Some(DirectedSegment(x2,y2,x1,y1,theta)) else None } @@ -341,7 +340,6 @@ object R2Viewshed extends Serializable { .flatMap({ row => clip(startCol,startRow,cols-1,row) }) .foreach({ seg => alpha = thetaToAlpha(from, rays, seg.theta); terminated = false - if (debug) println(s"--- $alpha | $seg | ${rays.head} | ${rays.last}") Rasterizer.foreachCellInGridLine(seg.x0, seg.y0, seg.x1, seg.y1, null, re, false)(callback) if (!terminated) edgeCallback(Ray(seg.theta, alpha), FromWest()) }) diff --git a/spark/src/main/scala/geotrellis/spark/viewshed/IterativeViewshed.scala b/spark/src/main/scala/geotrellis/spark/viewshed/IterativeViewshed.scala index 5243830b18..a1d178086e 100644 --- a/spark/src/main/scala/geotrellis/spark/viewshed/IterativeViewshed.scala +++ b/spark/src/main/scala/geotrellis/spark/viewshed/IterativeViewshed.scala @@ -169,9 +169,8 @@ object IterativeViewshed { .toMap val heights = sc.broadcast(_heights) - // Create RDD of viewsheds; the tile containing the starting point - // is complete and the accumulator contains the rays emanating - // from that. + // Create RDD of viewsheds; after this, the accumulator contains + // the rays emanating from the starting points. var sheds: RDD[(K, V, MutableArrayTile)] = elevation.map({ case (k, v) => val key = implicitly[SpatialKey](k) val tile = implicitly[Tile](v) @@ -244,8 +243,7 @@ object IterativeViewshed { from, sortedRays, rayCatcherFn(key, index), - op, curve, - false //(key == SpatialKey(116,196) && from.isInstanceOf[FromEast]) + op, curve ) }) })