-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add memory efficient polyline decoder #1518
base: main
Are you sure you want to change the base?
Conversation
9b67c33
to
35f667b
Compare
Codecov Report
@@ Coverage Diff @@
## main #1518 +/- ##
============================================
+ Coverage 76.94% 76.97% +0.03%
- Complexity 938 946 +8
============================================
Files 129 130 +1
Lines 4025 4048 +23
Branches 582 582
============================================
+ Hits 3097 3116 +19
- Misses 678 682 +4
Partials 250 250
|
services-geojson/src/main/java/com/mapbox/geojson/utils/PolylineUtils.java
Outdated
Show resolved
Hide resolved
35f667b
to
4576fb4
Compare
4576fb4
to
65e6d80
Compare
services-geojson/src/main/java/com/mapbox/geojson/utils/PolylineDecoder.java
Outdated
Show resolved
Hide resolved
* @param inputStream InputStream that reads a String as bytes | ||
* @param precision OSRMv4 uses 6, OSRMv5 and Google uses 5 | ||
*/ | ||
public PolylineDecoder(InputStream inputStream, int precision) { |
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.
public PolylineDecoder(InputStream inputStream, int precision) { | |
public PolylineDecoder(@NonNull InputStream inputStream, int precision) { |
@Override | ||
public Point next() throws NoSuchElementException { |
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.
@Override | |
public Point next() throws NoSuchElementException { | |
@Override | |
@NonNull | |
public Point next() throws NoSuchElementException { |
I don't remember if you can change the annotation of an overridden method though 🙃
I'm making a more memory efficient replayer mapbox/mapbox-navigation-android#6636
The first large memory task is to decode a geometry string. This pull requests makes it possible to pass in a string as an InputStream, so that it can come from a file. It will then decode the polyline upon request.
It is true that the geometry string is inside a
DirectionsResponse
so it is already memory inefficient. The reason I'm going ahead with it now is because it simpler for streaming objects to consume downstream.