Skip to content

Commit

Permalink
Make Point6D a top-level type
Browse files Browse the repository at this point in the history
- Hidden inside of `IterativeViewshed`, it wouldn't appear in Scaladocs and was
  a pain to import.
  • Loading branch information
fosskers authored and echeipesh committed Nov 10, 2017
1 parent fee357e commit e910d58
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ import org.apache.spark.util.AccumulatorV2
import scala.collection.mutable
import scala.reflect.ClassTag

/**
* @param x: x-coordinate (in the units used by the layer)
* @param y: y-coordinate (in the units used by the layer)
* @param viewHeight: view height (in units of "meters") if positive then height above the surface, if negative then absolute height
* @param angle: the angle in radians (about the z-axis) of the "camera"
* @param fieldOfView: the field of view of the "camera" in radians
* @param altitude: the absolute altitude to query; if -∞ then use the terrain height
*/
case class Point6D(
x: Double,
y: Double,
viewHeight: Double,
angle: Double,
fieldOfView: Double,
altitude: Double
)

/**
* A Spark-enabled implementation of R2 [1] viewshed.
Expand All @@ -49,23 +65,6 @@ import scala.reflect.ClassTag
*/
object IterativeViewshed {

/**
* x: x-coordinate (in the units used by the layer)
* y: y-coordinate (in the units used by the layer)
* viewHeight: view height (in units of "meters") if positive then height above the surface, if negative then absolute height
* angle: the angle in radians (about the z-axis) of the "camera"
* fieldOfView: the field of view of the "camera" in radians
* altitude: the absolute altitude to query; if -∞ then use the terrain height
*/
case class Point6D(
x: Double,
y: Double,
viewHeight: Double,
angle: Double,
fieldOfView: Double,
altitude: Double
)

implicit def coordinatesToPoints(points: Seq[jts.Coordinate]): Seq[Point6D] =
points.map({ p => Point6D(p.x, p.y, p.z, 0, -1.0, Double.NegativeInfinity) })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package geotrellis.spark.viewshed
import geotrellis.raster.{Tile, DoubleArrayTile}
import geotrellis.raster.viewshed.R2Viewshed._
import geotrellis.spark._
import geotrellis.spark.viewshed.IterativeViewshed.Point6D
import geotrellis.util.MethodExtensions

import org.apache.spark.rdd.RDD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class IterativeViewshedSpec extends FunSpec
val list = for (col <- 0 to 2; row <- 0 to 2) yield (SpatialKey(col, row), tile)
ContextRDD(sc.parallelize(list), tileLayerMetadata)
}
val point = IterativeViewshed.Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point = Point6D(7, 7, -0.0, 0, -1.0, ninf)
val viewshed = rdd.viewshed(
points = List(point),
maxDistance = Double.PositiveInfinity,
Expand All @@ -74,7 +74,7 @@ class IterativeViewshedSpec extends FunSpec
ContextRDD(sc.parallelize(list), tileLayerMetadata)
}

val point = IterativeViewshed.Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point = Point6D(7, 7, -0.0, 0, -1.0, ninf)
val viewshed = IterativeViewshed(rdd, List(point),
maxDistance = Double.PositiveInfinity,
curvature = false,
Expand All @@ -98,7 +98,7 @@ class IterativeViewshedSpec extends FunSpec
val list = for (col <- 0 to 2; row <- 0 to 2) yield (if (col == 1 && row == 2) (SpatialKey(col, row), specialTile); else (SpatialKey(col, row), tile))
ContextRDD(sc.parallelize(list), tileLayerMetadata)
}
val point = IterativeViewshed.Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point = Point6D(7, 7, -0.0, 0, -1.0, ninf)
val viewshed = rdd.viewshed(
points = List(point),
maxDistance = Double.PositiveInfinity,
Expand Down Expand Up @@ -132,9 +132,9 @@ class IterativeViewshedSpec extends FunSpec
val list = for (col <- 0 to 2; row <- 0 to 2) yield (SpatialKey(col, row), tile)
ContextRDD(sc.parallelize(list), tileLayerMetadata)
}
val point1 = IterativeViewshed.Point6D(2, 7, -0.0, 0, -1.0, ninf)
val point2 = IterativeViewshed.Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point3 = IterativeViewshed.Point6D(12, 7, -0.0, 0, -1.0, ninf)
val point1 = Point6D(2, 7, -0.0, 0, -1.0, ninf)
val point2 = Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point3 = Point6D(12, 7, -0.0, 0, -1.0, ninf)
val viewshed = rdd.viewshed(
points = List(point1, point2, point3),
maxDistance = Double.PositiveInfinity,
Expand Down Expand Up @@ -167,9 +167,9 @@ class IterativeViewshedSpec extends FunSpec
ContextRDD(sc.parallelize(list), tileLayerMetadata)
}

val point1 = IterativeViewshed.Point6D(2, 7, -0.0, 0, -1.0, ninf)
val point2 = IterativeViewshed.Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point3 = IterativeViewshed.Point6D(12, 7, -0.0, 0, -1.0, ninf)
val point1 = Point6D(2, 7, -0.0, 0, -1.0, ninf)
val point2 = Point6D(7, 7, -0.0, 0, -1.0, ninf)
val point3 = Point6D(12, 7, -0.0, 0, -1.0, ninf)
val expected = 3
val viewshed = rdd.viewshed(
points = List(point1, point2, point3),
Expand Down

0 comments on commit e910d58

Please sign in to comment.