Skip to content

Commit

Permalink
Add Citations
Browse files Browse the repository at this point in the history
  • Loading branch information
James McClain committed Jun 14, 2017
1 parent 65d154e commit ac9fa3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ import geotrellis.raster._
import spire.syntax.cfor._

/**
* Created by jchien on 4/30/14.
*/
* Created by jchien on 4/30/14.
*
* This appears to be an implementation of the DEM/Xdraw Viewshed
* algorithm from [1].
*
* 1. Franklin, Wm Randolph, and Clark Ray.
* "Higher isn’t necessarily better: Visibility algorithms and experiments."
* Advances in GIS research: sixth international symposium on spatial data handling. Vol. 2.
* Taylor & Francis Edinburgh, 1994.
*/
object ApproxViewshed extends Serializable {

def apply(r: Tile, col: Int, row: Int): Tile = {
Expand Down Expand Up @@ -49,7 +57,7 @@ object ApproxViewshed extends Serializable {

if (layer == 1) {
tile.setDouble(x,y,z)
}else {
} else {
val xVal = math.abs(1.0 / (startRow - y)) * (startCol - x) + x
val xInt = xVal.toInt

Expand Down Expand Up @@ -87,7 +95,7 @@ object ApproxViewshed extends Serializable {
val closestHeight = {
if (startCol == x) {
tile.getDouble(x - math.signum(x - startCol), y)
}else if (yVal.isValidInt) {
} else if (yVal.isValidInt) {
tile.getDouble(x - math.signum(x - startCol), yInt)
} else { // need linear interpolation
(yInt + 1 - yVal) * tile.getDouble(x - math.signum(x-startCol), yInt) +
Expand All @@ -101,7 +109,7 @@ object ApproxViewshed extends Serializable {
)
} else {
tile.setDouble(x, y,
math.max(z, -1.0 / (startCol - (x+1)) * (k-closestHeight) + closestHeight)
math.max(z, -1.0 / (startCol - (x+1)) * (k - closestHeight) + closestHeight)
)
}
}
Expand Down
12 changes: 10 additions & 2 deletions raster/src/main/scala/geotrellis/raster/viewshed/Viewshed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ import geotrellis.raster._
import spire.syntax.cfor._

/**
* Created by jchien on 4/24/14.
*/
* Created by jchien on 4/24/14.
*
* This appears to be an implementation of the R3 Viewshed algorithm
* from [1].
*
* 1. Franklin, Wm Randolph, and Clark Ray.
* "Higher isn’t necessarily better: Visibility algorithms and experiments."
* Advances in GIS research: sixth international symposium on spatial data handling. Vol. 2.
* Taylor & Francis Edinburgh, 1994.
*/
object Viewshed extends Serializable {
def apply(r: Tile, startCol: Int, startRow: Int): Tile = {
val (cols, rows) = r.dimensions
Expand Down

0 comments on commit ac9fa3f

Please sign in to comment.