Batch requests?

95 views
Skip to first unread message

Anthony Atkins

unread,
Oct 13, 2020, 1:50:03 PM10/13/20
to Plus Codes Community Forum
Is there a method that would allow for batch requests? I'd like to request a code for each address in my database (around 33k), is the only way to do this is one at a time?

Thanks,

theriverm...@gmail.com

unread,
Oct 13, 2020, 2:05:48 PM10/13/20
to Plus Codes Community Forum

Hi,

Perhaps if it is an MSAccess database, you could try my VBA script from here:

Given a table that includes lon lat fields, it will generate an additional field containing pluscodes to the accuracy of the "+"
My issue on GitHub was asking for clarification on calculating the pluscode to the right of the "+"

My script can work on tables of about 50k records, however, I found that, for some reason, the script works better on larger tables when they are stored as separate CSV files. 

Anthony Atkins

unread,
Oct 14, 2020, 9:32:13 AM10/14/20
to Plus Codes Community Forum
Unfortunately, I'm working with dbf tables. I was hoping that there was a separate API call that would allow me to send batches of requests.  How in the world are you getting your script to run so quickly? 
Thanks

Barry Hunter

unread,
Oct 14, 2020, 9:57:45 AM10/14/20
to Plus Codes Community Forum
The 'algorithm' for computing the plus code from the lat/long values, is in general pretty simple. A modern computer can compute it pretty easily. 

There would almost certainly be more overhead in reading and writing data back to the database, than computing the plus code. 


But mention of an 'API' are you perhaps meaning you using a geocoder, to convert a textual address, into a lat/long coordinate?. Then either converting that to a pluscode yourself, or using an geocoder that has a built support for generating plus codes. 

... in which case its finding if that particular API has a batch mode. Using a API, may introduce significant 'network' overhead, so a batch mode may make sense if one exists. 
But it depends what API you use. 


That VBA script is not using a Geocoder API. 





--
Public site: http://www.openlocationcode.com/
Github project: https://github.com/google/open-location-code
Demo site: http://plus.codes/
---
You received this message because you are subscribed to the Google Groups "Plus Codes Community Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to open-location-c...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/open-location-code/024d993f-9f69-40f0-b822-a90a43f1660en%40googlegroups.com.

theriverm...@gmail.com

unread,
Oct 14, 2020, 10:05:37 AM10/14/20
to Plus Codes Community Forum
LOL, I have no idea how/why my script works so quickly!

Yes, there are APIs available. However, as you already have the data neat-n-tidy in a table, it might be easier to use the database to do the algorithm.
An API such as:  https://github.com/google/open-location-code/wiki/Plus-codes-API  returns a rather long JSON email for each lon/lat which would then need further scripting to retrieve the pluscode. 

Yes, it is unfortunate that your tables are dbf. However, if you do have MSAccess, it can import and/or link to dbf files. From there, my example script could be used.

Does your table's location data change much/frequently or is it referencial/historic?

Depending on your circumstances, I'd happily add a pluscode field to your table for you. For privacy issues, you may want to edit the table to only include the lon/lat and the index/primary key.

Bare in mind, though, that my script presently is accurate to the "+" part of the pluscode - which gives a global reference to a square measuring  275 metres on the side 

Message has been deleted

theriverm...@gmail.com

unread,
Oct 14, 2020, 10:36:20 AM10/14/20
to Plus Codes Community Forum
Also, the original source I used that describes how to calculate plus codes now seems to be missing!

However, I've now just found another description of the algorithm and I'll now try to use it to complete my original MSAccess script.



How to convert GPS coordinates to Open Location codes?

From GPS coordinates:

Example: (lat, long) = 48.8583,2.2923

1- add 90° to the latitude and 180° to the longitude

Example: 48.8583+90=138.858348.8583+90=138.8583, 2.2923+180=182.29232.2923+180=182.2923

2- multiply the values by 8000 (= 20 ^ 3)

Example: 138.8583×8000=1110866.4138.8583×8000=1110866.4, 182.2923×8000=1458338.4182.2923×8000=1458338.4

3- convert the values obtained to base 20 (with the alphabet 23456789CFGHJMPQRVWX) by limiting yourself to the whole part and supplementing with initial zeros if the result has less than 5 digits.

Example: 1110866(10)=[6,18,17,3,6](20)=8WV58(20OLC)1110866(10)=[6,18,17,3,6](20)=8WV58(20OLC), 1458338(10)=[9,2,5,16,18](20)=F47RW(20OLC)1458338(10)=[9,2,5,16,18](20)=F47RW(20OLC)

4- insert the 2 times52 times5 characters obtained by alternating latitude then longitude and write the result in the form 'XXXXXXXX + XX'

Example: 8WV58 and F47RW give 8F,W4,V7,5R,8W or the plus code 8FW4V75R+8W

How to recognize a Open Location codes?

The Open Location (OLC) codes are in the format XXXXXXXX+XX or sometimes XXXX+XX Place (the first 4 characters are deleted) this second form requires a database in order to know the place which allows to find the 4 first characters.

Codes have a + hence their nickname plus codes

The Google company created these codes which are used more and more, thanks to Google Maps, any reference to the search engine is a clue.


Reply all
Reply to author
Forward
0 new messages