deptofdefense / move.mil

The entry point website to the Defense Personal Property System (DPS).
https://www.move.mil
Other
15 stars 15 forks source link

PPM Estimator: Use Google Maps Directions API to calculate distances #406

Closed jamesatheyDDS closed 6 years ago

jamesatheyDDS commented 6 years ago

Checklist

I have…

Summary of Changes

This pull request…

It turns out that PPMs do not use Basepoint City to Basepoint City distance, like HHGs. Instead, DPS asks DTOD for the distance between the full ZIP5 codes to calculate the distance.

Since we don't want to rely on DTOD for the move.mil portal, this PR asks Google for the distance instead. It uses the same GOOGLE_MAPS_API_KEY environment variable as Locator Maps.

This is more accurate than the previously used ZIP3-to-ZIP3 distances, but is not identical to what DTOD would return for the same query, since DTOD uses a different data source and takes trucking restrictions into account.

Removing the stored ZIP3-to-ZIP3 distance data also reduces the time needed to seed.

One downside to this change is that estimates take slightly longer to calculate, due to the call to Google's API.

Testing

To verify the changes proposed in this pull request…

  1. clone this repo,
  2. git checkout ppm-zip5-distance,
  3. set up development dependencies according to CONTRIBUTING.md,
  4. run bin/rails server, and
  5. load up http://localhost:3000 in the Web browser of your choice.