full-path / ridesheet

Google apps script support for a Google Sheets-based demand-responsive trip scheduling and reporting system.
MIT License
5 stars 4 forks source link

Update geocoding to match changes from Google's geocoding API #37

Closed keviniano closed 2 years ago

keviniano commented 2 years ago

Current getGeocode code distinguishes exact addresses from approximate matches by looking at the boolean at result["results"][0]["partial_match"]. Due to apparently undocumented changes to the JSON returned by the Google geocoding API, this flag is no longer reliable and now appears to include cases where a POI (e.g., "USPS Lakeview OR") returns an exact address. The result is that when exact addresses are returned, they are considered errors and not returned to the user.

There are a couple of possible new candidates for distinguishing exact addresses from more approximate ones:

Based on a small bit of testing, the first option appears to be more reliable. It's unclear what the types array returns under a variety of cases.

Example 1 - Exact address in, exact address out.txt Example 2 - POI ("USPS lakeview or") in, exact address out.txt Example 3 - POI ("post office lakeview or") in, approximate location out.txt