Class PolylineUtils


  • public final class PolylineUtils
    extends java.lang.Object
    Polyline utils class contains method that can decode/encode a polyline, simplify a line, and more.
    Since:
    1.0.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<Point> decode​(java.lang.String encodedPath, int precision)
      Decodes an encoded path string into a sequence of Point.
      static java.lang.String encode​(java.util.List<Point> path, int precision)
      Encodes a sequence of Points into an encoded path string.
      static java.util.List<Point> simplify​(java.util.List<Point> points)
      Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
      static java.util.List<Point> simplify​(java.util.List<Point> points, boolean highestQuality)
      Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
      static java.util.List<Point> simplify​(java.util.List<Point> points, double tolerance)
      Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
      static java.util.List<Point> simplify​(java.util.List<Point> points, double tolerance, boolean highestQuality)
      Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • encode

        @NonNull
        public static java.lang.String encode​(@NonNull
                                              java.util.List<Point> path,
                                              int precision)
        Encodes a sequence of Points into an encoded path string.
        Parameters:
        path - list of Points making up the line
        precision - OSRMv4 uses 6, OSRMv5 and Google uses 5
        Returns:
        a String representing a path string
        Since:
        1.0.0
      • simplify

        @NonNull
        public static java.util.List<Point> simplify​(@NonNull
                                                     java.util.List<Point> points)
        Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
        Parameters:
        points - an array of points
        Returns:
        an array of simplified points
        Since:
        1.2.0
        See Also:
        JavaScript implementation
      • simplify

        @NonNull
        public static java.util.List<Point> simplify​(@NonNull
                                                     java.util.List<Point> points,
                                                     double tolerance)
        Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
        Parameters:
        points - an array of points
        tolerance - affects the amount of simplification (in the same metric as the point coordinates)
        Returns:
        an array of simplified points
        Since:
        1.2.0
        See Also:
        JavaScript implementation
      • simplify

        @NonNull
        public static java.util.List<Point> simplify​(@NonNull
                                                     java.util.List<Point> points,
                                                     boolean highestQuality)
        Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
        Parameters:
        points - an array of points
        highestQuality - excludes distance-based preprocessing step which leads to highest quality simplification
        Returns:
        an array of simplified points
        Since:
        1.2.0
        See Also:
        JavaScript implementation
      • simplify

        @NonNull
        public static java.util.List<Point> simplify​(@NonNull
                                                     java.util.List<Point> points,
                                                     double tolerance,
                                                     boolean highestQuality)
        Reduces the number of points in a polyline while retaining its shape, giving a performance boost when processing it and also reducing visual noise.
        Parameters:
        points - an array of points
        tolerance - affects the amount of simplification (in the same metric as the point coordinates)
        highestQuality - excludes distance-based preprocessing step which leads to highest quality simplification
        Returns:
        an array of simplified points
        Since:
        1.2.0
        See Also:
        JavaScript implementation