Class RamerDouglasPeucker

java.lang.Object
com.graphhopper.util.RamerDouglasPeucker

public class RamerDouglasPeucker extends Object
Simplifies a list of 2D points which are not too far away. http://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm

Calling simplify is thread safe.

Author:
Peter Karich
  • Constructor Details

    • RamerDouglasPeucker

      public RamerDouglasPeucker()
  • Method Details

    • setApproximation

      public void setApproximation(boolean a)
    • setMaxDistance

      public RamerDouglasPeucker setMaxDistance(double dist)
      maximum distance of discrepancy (from the normal way) in meter
    • setElevationMaxDistance

      public RamerDouglasPeucker setElevationMaxDistance(double dist)
      maximum elevation distance of discrepancy (from the normal way) in meters
    • simplify

      public int simplify(PointList points)
      Simplifies the points, from index 0 to size-1.

      It is a wrapper method for simplify(PointList, int, int).

      Returns:
      The number removed points
    • simplify

      public int simplify(PointList points, int fromIndex, int lastIndex)
    • simplify

      public int simplify(PointList points, int fromIndex, int lastIndex, boolean compress)
      Simplifies a part of the points. The fromIndex and lastIndex are guaranteed to be kept.
      Parameters:
      points - The PointList to simplify
      fromIndex - Start index to simplify, should be <= lastIndex
      lastIndex - Simplify up to this index
      compress - Whether the points shall be compressed or not, if set to false no points are actually removed, but instead their lat/lon/ele is only set to NaN
      Returns:
      The number of removed points