-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored Javascript implementation for easier porting #5
Conversation
This moves all of the encoding/decoding implementation into the package instead of relying on external packages, which will make it easier to port to other languages.
|
||
compressLngLatArray( | ||
lngLatArray: Array<Array<number>>, | ||
/* parameters: CompressionParameters, */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this commented-out line of code be deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, no, because it's still being passed to the function, it's just unused by the function, which is why it's commented out. It's implementation-specific on whether or not to use that parameter, FlexiblePolyline uses it but EncodedPolyline doesn't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this to parameters?: CompressionParameters,
then I think the compiler won't complain when parameters
is unused. But if that doesn't work, I'm good with leaving this as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, sadly it still complains with that. :( Good idea though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does our coverage look on this module with the unit tests?
|
||
compressLngLatArray( | ||
lngLatArray: Array<Array<number>>, | ||
/* parameters: CompressionParameters, */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you change this to parameters?: CompressionParameters,
then I think the compiler won't complain when parameters
is unused. But if that doesn't work, I'm good with leaving this as-is.
Like this: -----------------------|---------|----------|---------|---------|-------------------
|
Description of changes:
This library will have Javascript, Swift, and Kotlin implementations. However, for Swift and Kotlin there weren't any official polyline implementations to rely on, which was going to make porting this library difficult. This PR almost completely rewrites the internals of the Javascript library to contain its own polyline implementation so that no external dependencies are needed (other than geojson). The public API and tests remain the same and continue to pass. A lot of the implementation also simplified pretty significantly because most of the error checking was easier to perform during the encoding/decoding instead of before and afterwards. All three of the supported compression/decompression algorithms (Polyline5, Polyline6, and FlexiblePolyline) now also share the same implementation, just with different initialization data.
Testing:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.