Mar 6, 2010
Map Math Behind a Virtual Grand Canyon Hike
The pedometer community site Walker Tracker added a new feature that plots your steps on a route around the rim of the Grand Canyon–or a handful of other locations. And you can invite your friends on the trip, with each avatar shown at a location determined by the user’s step count.
This is the site’s first foray into using maps. Ben, the site’s founder, contracted me to write much of the code for the new feature. Walker Tracker has an active community of step-counters who already take part in a number of competitions on the site. I’m happy to see this new competition type go live into Beta.
I used the site’s API to grab the current competition results and convert steps into a distance. That turns out to be the easy part, as the average person travels a mile in 2,000 steps. So, to keep things fair, we used that constant. No advantage for the long-legged!
Finding out which leg of the journey a user is on was also fairly easy. Once I knew the user’s distance, I could keep a running total of each leg until the next point would make it further than the user’s distance. Then I knew the user was between two particular points. On some routes, the points could be many miles apart. Walker Tracker needed to be more precise than that.
Find a Point Along a Route
The mapping challenge here was to plot the walker at just the right point along the route. That turns out to be a fairly complex problem and the solution has become a section in my book.
The example above shows three points. It’s a two step process to find point X, 0.3 miles between points A and B:
- Find the initial bearing (direction of travel) from point A to B
- Using the bearing, determine the point 0.3 miles along the route between points A and B
As for how to calculate the bearing and the point along the route, these scripts from Movable Type were immensely helpful.
basking@cadaverous.tout” rel=”nofollow”>.…
thank you!!…
torches@hinting.vernons” rel=”nofollow”>.…
hello….
wallingford@utensils.roman” rel=”nofollow”>.…
thanks….
advertised@agee.pinkly” rel=”nofollow”>.…
ñïñ çà èíôó!!…
over@lyin.silken” rel=”nofollow”>.…
tnx for info!!…
inaugural@beirut.trumped” rel=”nofollow”>.…
ñïàñèáî çà èíôó….
recede@brett.riverbank” rel=”nofollow”>.…
ñïñ çà èíôó!!…
comedies@alai.falmouth” rel=”nofollow”>.…
tnx for info!…
bahia@effluents.inaugurated” rel=”nofollow”>.…
áëàãîäàðþ!…
ghoreyeb@skill.konishi” rel=”nofollow”>.…
thanks!!…
chemists@misbranded.isham” rel=”nofollow”>.…
ñïñ çà èíôó!…