Skip to content
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

Real batch geocoding for TomTom #325

Merged
merged 10 commits into from
Feb 7, 2022
Merged

Real batch geocoding for TomTom #325

merged 10 commits into from
Feb 7, 2022

Conversation

charly22
Copy link
Contributor

@charly22 charly22 commented Feb 2, 2022

What does this PR do?

Changes the strategy used to geocoding in batch using async batch TomTom API

Brief of changes

  • AbstractGeocoder calls _batchGeocode of the provider who has this implemented or throws an error if it doesn't.
  • Geocoder call batchGeocode catching the not implemented error to fallback to the pool-of-promises legacy strategy
  • TomTomGeocoder implements _batchGeocode calling the TomTom Batch APIs to 1. Create a job, 2. Poll the job status 3. Download the results when it's done
  • Added support to limit and country parameters for TomTom (see TODOs)

Additionally

  • I've sort of hacked the FetchAdapter to allow the return of the full response in order to check status codes, batch API it's not as simple as getting JSON results,
  • Added a POST support to FetchAdaptar (I haven't done for the rest of the adapter, but I believe they're deprecated, I'm I right)
  • removed querystring deprecated dependency on FetchAdapter

TODOs

  • Update README.md with new TomTom parameters @nchaulet I'd appreciate your help here. Thanks :)

Sorry, something went wrong.

@charly22
Copy link
Contributor Author

charly22 commented Feb 3, 2022

@nchaulet I'm sure that looking into this it isn't among your top priorities, I'm wondering if you have had a chance to look at this because I'm planning to add this very same support for Here sooner than later and these changes depend on this PR. Thanks!

@nchaulet
Copy link
Owner

nchaulet commented Feb 4, 2022

Hi @charly22 I took a first look at this and it looks good to me, I still want to run it locally too, I have one suggestion that I would love you to address.

@@ -61,21 +61,32 @@ Geocoder.prototype.reverse = function(query, callback) {
* @return promise
*/
Geocoder.prototype.batchGeocode = function(values, callback) {
return BPromise.resolve(values)
return BPromise.resolve()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will make sense to move that part to the abstract geocoder and to rely on the existence of _batchGeocoder instead of relying on throwing an error to have a fallback

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does make sense, in fact, it was my first approach but I can't remember why I've fallen back to this way. I'll give it another try

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 🙂

Copy link
Owner

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look goods to me 🚀 going to do some more manual test but hopefully I will publish a new version with that change this week

@nchaulet nchaulet merged commit 17a7019 into nchaulet:master Feb 7, 2022
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.

None yet

2 participants