Skip to content

feat(library): add flexible polyline encoding and decoding - #1801

Open
kikoso wants to merge 1 commit into
mainfrom
feat/flexible-polyline
Open

kikoso wants to merge 1 commit into
mainfrom
feat/flexible-polyline

Conversation

@kikoso

@kikoso kikoso commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Adds FlexiblePolylineUtil to the library module, and a demo activity that decodes a sample string and draws it. PolyUtil is unchanged. No dependencies were added.

Public API: encode, decode, encodeLatLngs, decodeToLatLngs, getThirdDimension, plus FlexiblePoint, FlexiblePolyline and ThirdDimension. All are @JvmStatic. Defaults are precision 7 and no third dimension.

Differences from the codec in PolyUtil

PolyUtil FlexiblePolylineUtil
Coordinate precision fixed at 5 decimal places 0 to 15, read from the header
Header none version, precision, third dimension type and precision
Values per point 2 2 or 3
Alphabet printable ASCII from offset 63 A-Z, a-z, 0-9, -, _

decode reads the third dimension flag because a decoder that ignores it reads the third varint of each point as the next point's latitude, returning wrong coordinates for every point after the first. toLatLngs() omits the value.

Testing

./gradlew test and ./gradlew lint pass. 21 new tests, 0 lint findings in the added files.

Expected strings in the tests are fixed vectors, not round trip assertions. The two dimensional case is the worked example published in the specification. The other vectors was generated by a separate implementation written from the same document, so an encoder regression does not cancel out against a decoder regression.

No linked issue yet. The public API grows by 5 functions and 3 types, so I can open one before this leaves draft.

@kikoso
kikoso force-pushed the feat/flexible-polyline branch from 3d8e3a5 to fd2c6a0 Compare September 30, 2026 04:10
Adds FlexiblePolylineUtil to the library module, alongside the existing
PolyUtil codec. The format supports configurable precision, a header that
carries the precision with the data, and an optional third value per point.

Also adds a demo activity exercising the decoder, registered under the
Geometry category.
@kikoso
kikoso force-pushed the feat/flexible-polyline branch from fd2c6a0 to b2e846e Compare September 30, 2026 04:13
@googlemaps-bot

googlemaps-bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Coverage

Overall Project 52.64% -0.05% 🍏
Files changed 97.81% 🍏

Module Coverage
Kover Gradle Plugin XML report for :library 92.58% -0.45% 🍏
Files
Module File Coverage
Kover Gradle Plugin XML report for :library FlexiblePolyline.kt 97.81% -2.19% 🍏

@kikoso
kikoso marked this pull request as ready for review September 30, 2026 04:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants