Package com.mapbox.geojson.utils
Class PolylineUtils
- java.lang.Object
-
- com.mapbox.geojson.utils.PolylineUtils
-
public final class PolylineUtils extends java.lang.ObjectPolyline 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 ofPoint.static java.lang.Stringencode(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.
-
-
-
Method Detail
-
decode
@NonNull public static java.util.List<Point> decode(@NonNull java.lang.String encodedPath, int precision)
Decodes an encoded path string into a sequence ofPoint.- Parameters:
encodedPath- a String representing an encoded path stringprecision- OSRMv4 uses 6, OSRMv5 and Google uses 5- Returns:
- list of
Pointmaking up the line - Since:
- 1.0.0
- See Also:
- Part of algorithm came from this source, Part of algorithm came from this source.
-
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 ofPoints making up the lineprecision- 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 pointstolerance- 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 pointshighestQuality- 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 pointstolerance- 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
-
-