0

I am developing a proof of concept/prototype for an internal tool. The basic premise is, that we have a couple of units that have a GPS on them, and they report their location (with typical GPS accuracy in NMEA format) to a java api I have built in a cloud environment.

[Device GPS] -> [Sends Cellular GSM request to API] -> [API queries Google 
Roads] -> [Google Roads returns snapped coordinates] -> [App maps received 
coordinates]

The java API takes the reported coordinates, and essentially sends a request to the Google Maps Roads API and uses the Snap-to-road feature (this will essentially take whatever point you gave it along with an optionally traveled path of coordinates, and give you coordinates back that are essentially on the path it believes you are traveling). This is great and all, but with one setback.

IT IS EXPENSIVE.

For two devices reporting their location (similar to the way Uber or Lyft may do it) every few seconds, the cost of running this application essentially makes it a sunk cost. 24,000 queries will cost you $300-500. For one device.

We have taken a few efforts to only accept requests to the API during work hours - but that is still barely scratching the surface.

I am fairly capable at writing whatever I would need (I believe at least), or can find libraries to do what I think needs to be done - but I have no idea what recourse to take. I am thinking of something along the lines of caching requests in another table and querying that first, but I am not certain how reliable that will be.

Has anyone implemented such a solution or something similar? I just need to defray the amount of requests I send to Google Maps' API before I bankrupt this project.

2
  • 1
    Simplify the request. Only make requests when the distance has changed by greater than some threshold. Run multiple points through a simplifying algorithm (like Douglas - Peucker)
    – geocodezip
    Commented Dec 1, 2018 at 15:03
  • Still time for a comment 5 years later, perhaps call Roads API only when polyline is shown to the user. I guess there would be no need to keep this full set of expanded coordinates at the DB
    – vortal
    Commented Jul 25, 2023 at 10:57

1 Answer 1

-1

If you have not already I would think you would want to look at the Google Maps API Pricing Sheet ( https://cloud.google.com/maps-platform/pricing/sheet/? ) and talk to Google. They should be able to explain to you the correct architectural approach (caching parts of maps locally, local path processing etc.).

At https://en.wikipedia.org/wiki/Google_Maps#Google_Maps_API they explain the pricing changes and other useful details, but the section also mentions alternatives such as OpenLayers and local map hosting if your use case would allow for that.

It may helpful to better understand the scope of the devices' travel. Are the devices to be put on vehicles that only travel around a factory, or on a personal device that a user can take anywhere in the world?

2
  • Yeah - I tried that. They weren't very helpful. Their suggestion was (although not a bad one) was directing me to StackOverflow. Commented Dec 1, 2018 at 5:13
  • And in regards to the scope question, it will be a predefined route, daily. Commented Dec 1, 2018 at 5:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.