Skip to content

Commit

Permalink
Add efficient ways to fetch head/last of a Line
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers authored and echeipesh committed Nov 10, 2017
1 parent 9e57c86 commit 1a30cc4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vector/src/main/scala/geotrellis/vector/Line.scala
Expand Up @@ -82,6 +82,12 @@ case class Line(jtsGeom: jts.LineString) extends Geometry
lazy val boundary: OneDimensionBoundaryResult =
jtsGeom.getBoundary

/* The first [[Point]] in this Line, which we know to exist. */
def head: Point = jtsGeom.getPointN(0)

/* The last [[Point]] in this Line, which we know to exist. */
def last: Point = jtsGeom.getPointN(jtsGeom.getNumPoints - 1)

/** Returns the points which determine this line (i.e. its vertices */
def points: Array[Point] = vertices

Expand Down

0 comments on commit 1a30cc4

Please sign in to comment.