Object FlexiblePolylineUtil

  • All Implemented Interfaces:

    
    public class FlexiblePolylineUtil
    
                        

    Encodes and decodes the HERE Flexible Polyline format, an open compact encoding for coordinate sequences published at https://github.com/heremaps/flexible-polyline.

    The format is a superset of the Encoded Polyline Algorithm Format handled by PolyUtil.decode and PolyUtil.encode. It differs in three ways:

    • precision is configurable rather than fixed at five decimal places;

    • a header travels with the data, so a decoder reads the precision out of the string instead of having to be told out of band;

    • each point may carry an optional third value such as altitude or level.

    It also uses the URL safe base64 alphabet, so encoded strings need no escaping in query parameters or JSON. PolyUtil handles the Google format.

    Written from the published specification.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • encodeLatLngs

        @JvmOverloads() final static String encodeLatLngs(List<LatLng> path, Integer precision)

        Encodes a sequence of LatLng values as a two dimensional flexible polyline.

        Parameters:
        path - The points to encode, in order.
        precision - The number of decimal places to preserve, in the range 0..15.
        Returns:

        The encoded polyline, including its header.

      • encodeLatLngs

        @JvmOverloads() final static String encodeLatLngs(List<LatLng> path)

        Encodes a sequence of LatLng values as a two dimensional flexible polyline.

        Parameters:
        path - The points to encode, in order.
        Returns:

        The encoded polyline, including its header.

      • encode

        @JvmOverloads() final static String encode(List<FlexiblePoint> points, Integer precision, ThirdDimension thirdDimension, Integer thirdDimensionPrecision)

        Encodes a sequence of points as a flexible polyline.

        When thirdDimension is anything other than ThirdDimension.ABSENT, every point must supply a FlexiblePoint.thirdDimensionValue, because the format stores one third value per point and cannot represent a gap.

        Parameters:
        points - The points to encode, in order.
        precision - The number of decimal places to preserve for latitude and longitude, in the range 0..15.
        thirdDimension - The kind of third value carried by points.
        thirdDimensionPrecision - The number of decimal places to preserve for the third value, in the range 0..15.
        Returns:

        The encoded polyline, including its header.

      • decode

         final static FlexiblePolyline decode(String encoded)

        Decodes a flexible polyline, reading its precision and third dimension from the header.

        Parameters:
        encoded - The encoded polyline.
        Returns:

        The decoded points together with the header parameters.

      • decodeToLatLngs

         final static List<LatLng> decodeToLatLngs(String encoded)

        Decodes a flexible polyline into a path ready to draw on a map, discarding any third dimension.

        Parameters:
        encoded - The encoded polyline.
        Returns:

        The decoded two dimensional path.

      • getThirdDimension

         final static ThirdDimension getThirdDimension(String encoded)

        Returns the third dimension declared by an encoded polyline without decoding its points.

        Parameters:
        encoded - The encoded polyline.
        Returns:

        The kind of third value the polyline carries.