Saturday, February 14, 2015

OpenStreetMaps and OpenLayers vs Google Maps API

As noted in several previous blog posts here I wanted to try to get a OFFLINE mapping system working with the "Driveby System".  I believe now that I've found that mapping system in OpenStreetMaps using OpenLayers.

The reason it's nice to have a LIVE map while your driving with the "Driveby System" is mainly so that you can SEE how well the system has recorded the data while you're driving.  Being able to see the results of your live drive test is handy in knowing if you missed a street, or if you should drive a street more times to get a better, more dense results (perhaps you drove too fast the first time for example).  Driving too fast results in gaps in the map.  The idea with the system is to get as continuous/dense a heatmap result as possible. (e.g. without gaps, and WITH having smooth transitions from quiet to noisy areas).

The results are quit good!  The setup is NON-Trivial (meaning it takes following quiet a long setup of directions at least with Ubuntu 14.04).  I now feel the effort was worth the time spent (about 6 hours on my slow laptop) and about 4 hours experimenting with HTML and Javascript and my PHP code including the brief learning curve to read up on how to do a heatmap using OpenLayers.

I used the following URLs to get my system setup and running:

The results are almost as accurate as Google Maps API.  I say 'almost' because it appears at least in my area that OSM may have some outdated street detail.  For example, their map tiles show a street that continues past where it actually does.  Also some of the streets don't line up exactly where my GPS shows they actually are.  On my OSM heatmap using OpenLayers this shows my path that I drove slightly offset from the actual REAL street (according to my GPS, which seems to line up VERY well on Google Maps API).

These short comings are really kind of  'ok'.  I mean it's fairly obvious in the results where you actually where vs what was rendered in the Heatmap.  At certain zoom levels they look just fine.  However when you zoom in very tight, the path I drove with my GPS doesn't line up 100% with the road shown on the map.  

Lets not forget that we'll now have TWO mapping options!  OSM/OpenLayers while live drive testing, and Google Maps API later when you are back to a stable internet connection.   I don't plan on removing the Google Maps API work I've done from Driveby.  I'm simply adding more functionality to provide options.  OPTIONS In my humble opinion are ALWAYS a good thing :-)

I think the benefits outweigh any negative issues.  For example using OSM and OpenLayers means that no live internet connection is required.  Which is AWESOME, and was the primary goal of this exercise.  The map tiles are downloaded and stored locally on my laptop well before I go for a drive test and once installed remain there.  So there is no need at all to have any internet connection.  This is important for many reasons.  Cell Data access is expensive (for some folks).  Cell Data access is unreliable in some areas of the country especially when you are attempting to drive test an area that is remote which may end up being a common use area for a system like this.  Using a tethered Internet Connection (lets face it) can be a pain in the ass causing more frustration than ultimate usefulness!  Been there done that!

Another nice aspect of using OpenLayers is that it renders a much nicer looking heatmap than my experiences with Google Map API v3.

I plan on including config setup for use with OSM and OpenLayers in the Driveby System code which is now available on GIT HUB (minus the new OSM / OL stuff just yet, because I'm still working on it's inclusion into the Driveby Project.