Class PolylineUtils

java.lang.Object
com.mapbox.geojson.utils.PolylineUtils

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

    Modifier and Type
    Method
    Description
    static List<Point>
    decode(String encodedPath, int precision)
    Decodes an encoded path string into a sequence of Point.
    static String
    encode(List<Point> path, int precision)
    Encodes a sequence of Points into an encoded path string.
    static List<Point>
    simplify(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 List<Point>
    simplify(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 List<Point>
    simplify(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 List<Point>
    simplify(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 Details

    • decode

      @NonNull public static List<Point> decode(@NonNull String encodedPath, int precision)
      Decodes an encoded path string into a sequence of Point.
      Parameters:
      encodedPath - a String representing an encoded path string
      precision - OSRMv4 uses 6, OSRMv5 and Google uses 5
      Returns:
      list of Point making up the line
      Since:
      1.0.0
      See Also:
    • encode

      @NonNull public static String encode(@NonNull 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 List<Point> simplify(@NonNull 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:
    • simplify

      @NonNull public static List<Point> simplify(@NonNull 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:
    • simplify

      @NonNull public static List<Point> simplify(@NonNull 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:
    • simplify

      @NonNull public static List<Point> simplify(@NonNull 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: