jessecambon / tidygeocoder

Geocoding Made Easy

Home Page:https://jessecambon.github.io/tidygeocoder

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Bing support

dieghernan opened this issue · comments

Following #62 , I have implemented Bing:

Docs:

About Bing batch geocoding service

It is very similar to Batch Geocoding on HERE (see #74), in the sense that it is a POST/wait/GET process with a maximum limit of 50 addresses and really slow, so the user must force batch geocoding with geo(method="bing", mode="batch")-

Regards

@dieghernan

I pulled in your PR on the bing branch. Batch geocoding is working for me, but I'm getting NA results with single geocoding:

library(tidygeocoder)
geo(sample_addresses$addr[1:3], method = 'bing', full_results = TRUE, verbose = TRUE)
#> Number of Unique Addresses: 3
#> Executing single address geocoding...
#> Number of Unique Addresses: 1
#> Querying API URL: http://dev.virtualearth.net/REST/v1/Locations
#> Passing the following parameters to the API:
#> q : "1600 Pennsylvania Ave NW Washington, DC"
#> key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> maxResults : "1"
#> 
#> HTTP Status Code: 200
#> Query completed in: 0.6 seconds
#> 
#> Number of Unique Addresses: 1
#> Querying API URL: http://dev.virtualearth.net/REST/v1/Locations
#> Passing the following parameters to the API:
#> q : "600 Montgomery St, San Francisco, CA 94111"
#> key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> maxResults : "1"
#> 
#> HTTP Status Code: 200
#> Query completed in: 0.2 seconds
#> 
#> Number of Unique Addresses: 1
#> Querying API URL: http://dev.virtualearth.net/REST/v1/Locations
#> Passing the following parameters to the API:
#> q : "11 Wall Street, New York, New York"
#> key : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
#> maxResults : "1"
#> 
#> HTTP Status Code: 200
#> Query completed in: 0.2 seconds
#> 
#> # A tibble: 3 x 3
#>   address                                      lat  long
#>   <chr>                                      <dbl> <dbl>
#> 1 1600 Pennsylvania Ave NW Washington, DC       NA    NA
#> 2 600 Montgomery St, San Francisco, CA 94111    NA    NA
#> 3 11 Wall Street, New York, New York            NA    NA

Created on 2021-03-24 by the reprex package (v1.0.0)

The only code change I made was to allow the user to pass custom_query to the batch geocoder function.

Looks like the issue was just that extract_results() wasn't getting the format it expected for latitude and longitude. The commit above fixes this.

Thanks! The extract_results() for Bing was a bit challenging, I have to say. I guess it broke after I merged main with the latest changes, good catch @jessecambon