Skip to content

Commit

Permalink
Merge pull request #2175 from locationtech/fix/cgw/geometry-isempty
Browse files Browse the repository at this point in the history
Expose `isEmpty` for Geometries
  • Loading branch information
echeipesh committed May 2, 2017
2 parents 3a30cde + 11fe077 commit 70e29bf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions vector/src/main/scala/geotrellis/vector/Geometry.scala
Expand Up @@ -34,6 +34,18 @@ trait Geometry {
def isValid: Boolean =
jtsGeom.isValid

/** Is this Geometry empty? This is faster than checking manually like:
* {{{
* val mp: MultiPoint = ...
* val ps: Array[Point] = mp.points // `.points` is a lazy val with processing overhead
*
* ps.isEmpty // possible, but mp.isEmpty is faster
* }}}
* It would be similar for [[MultiLine]] or [[MultiPolygon]].
*/
def isEmpty: Boolean =
jtsGeom.isEmpty

/** Calculate the distance to another Geometry */
def distance(other: Geometry): Double =
jtsGeom.distance(other.jtsGeom)
Expand Down

0 comments on commit 70e29bf

Please sign in to comment.