Thursday, July 14, 2011

Road Trip!!!!!

Going on a road trip soon? If so, you might appreciate some of the upgrades the Trip Planner got with that Big Update a couple of nights ago. =)

I didn't really want to muck around with the trip planner, but alas, the lengthy tentacles that grew out of custom locations reached out and affected all sorts of subsystems along the way, and those changes effectively thrashed the trip planner to pieces. After all was said and done, the trip planner didn't work. Not even close. It was beyond help--it either needed to be replaced or retired. But the trip planner as we knew it was finished.

Amanda and I held a private ceremony to celebrate its demise--that trip planner had problems and often times I thought the results it returned were almost worse than worthless. I certainly wouldn't miss it, but I knew a lot of people on Atlas Quest would. No, I couldn't retire the trip planner permanently. No, I needed to create a replacement.

Of course, when building a replacement, I put some thought into what I should do differently for Trip Planner 2.0 and fix those pesky issues that plagued Trip Planner 1.0.

The first thing that needed fixing was a no brainer: The distances off-path from the route were highly inaccurate because distances were measured from the city center that the box was in--not the actual location of the letterbox. When I first created the trip planner, way back in 2004, Atlas Quest did not support addresses at all. It supported cities and only cities, and the trip planner was therefore designed to work with cities and only cities. I never upgraded the trip planner to work with addresses when the addressing feature came along.

Now that a complete replacement of the trip planner was necessary, I needed to fix this problem.

I also had another idea for the trip planner which I thought would be useful--a list of how far along the route that the letterboxes were located. If you run a search for all boxes on I-5 between Sacramento and Seattle, it would be nice to know that the next box in the list is 1.3 miles beyond the one you just found. In fact, wouldn't it be cool if, when you left Sacramento, you could reset the trip odometer to 0 and watch the numbers click off right where the boxes would be along the route? I was certain I could implement something to that effect, and by golly, I was going to try.

And finally, due to technical reasons I won't bore you with, there was a very limited number of large cities that the trip planner allowed you to use as starting and ending points along the route. I wanted to fix that so you could search between almost any two locations along a route.

Again, I toiled for weeks, rebuilding the trip planner from scratch. And finally, I finished, and I was immensely pleased with my work. =)

Let's admire it, shall we? Take these search results of all boxes located within 5 miles of I-5 between Sacramento and Seattle. The most obvious change is that the results have a new column: distance. The first box is just 0.2 miles out of Sacramento, and as you scroll down the list, you'll see the distance get larger and larger until you mile marker 730.1 in Seattle. (You'll have to change to the last page of the search results to see the Seattle boxes.)

This, I think, is very cool. Maybe not earth shattering, but still, very cool. =)

Now, if you examine the list closely, you'll notice that a lot of Sacramento boxes aren't in it. In fact, a lot of boxes from all of the large cities that I-5 goes through aren't in it. I mentioned yesterday that the geocoders now return information to me about the size of a location, and in Sacramento's case, it tells AQ that Sacramento has a radius of approximately 11.43 miles. So AQ thinks, "Hmm.... Any box listed as being somewhere in the city of Sacramento might be as far as 11.43 miles off of I-5, and this person only wants to see boxes that are known to be within 5 miles of I-5. Therefore, I better not display these boxes."

Weed, CA, however, is a much smaller town, and the geocoders report that it's only 2.8 miles wide. Therefore, AQ thinks, "Hmmm... Any box listed as being somewhere in the town of Weed is a maximum of 2.8 miles away. I may not know where in Weed this letterbox is located, but it doesn't matter--I know it's less than 5 miles away, so I'll display these boxes."

Additionally, distances are now calculated based on the known address of the location--not simply the city center, so calculated distances will be much more accurate. (Unless, of course, the letterbox has no address listed, at which point it'll use the city center for lack of a better reference point.)

In a nutshell, the distances off path will be much more accurate than ever before. In fact, they're so accurate, you might very well spot inaccuracies in the route.

When I originally created the trip planner, I pulled up maps and plotted the route one city at a time along its entire length. It was tedious and slow, and knowing that distances would only be as accurate as the city center, I took shortcuts. When the road had a series of sharp switchbacks, I plotted a straight line directly through it. If the route I plotted was off the actual route by a mile, no big deal--my shortcuts would be hidden in the calculations for city centers. (This is also why you might notice that Google Maps calculates the distance of I-5 from Sacramento to Seattle as 753 miles while AQ calculates 730 miles--skip a switchback or turn here and there, and it starts to add up!)

Fast forward to today--and now that calculated distances are much more accurate, my shortcuts from before have caught up with me. Discrepancies in the actual distances vs calculated distances will likely be due to my sloppy route plotting. I need to replot every route that AQ supports, but that could take months of effort, and I didn't feel it was necessary to hold up the update for this to be completed. It will happen, eventually, but in the meantime, the calculated distances are much better than before already--my plotted routes rarely went more than a mile away from the actual route while the city-centered calculations were often off by ten miles or more.

So there's still room for improvement in the off-path distances, and the trip planner still needs some work. The code that runs it is fantastic! The data that went into it--not so fantastic, and you should be aware of those limitations.

Now--a little about how to run a trip planner search. On the Simple Search page, it looks much like it did before: You select a route, then the starting point, then the ending point. The options for starting and ending points, however, are much more extensive than before. You'll see all the large cities like before, but a lot of the smaller towns the route travels through. The I-5 corridor has a whopping 97 towns to select from! That's about the only new thing to note there, though.

Running a trip planner search from the Advanced Search page is a bit more of a challenge. You won't find a "trip planner" a search type option anymore--it's all done through that "Location" box. To run a a trip planner search, you type in a location like this:

ALONG i-5 FROM sacramento, ca TO seattle, wa

The words ALONG, FROM, and TO are keywords that help AQ divide the text into pieces it can understand, and you can use pretty much anything as a location. Cities are the most obvious, but you could search from a specific address within a city, or a zip code, or a geographical feature, etc. Also, you don't have to fussy about the order you use the keywords. Equal to the above statement, any of these would also work:

ALONG i-5 TO seattle, wa FROM sacramento, ca
TO seattle, wa FROM sacramento, ca ALONG i-5
TO seattle, wa ALONG i-5 FROM sacramento, ca
FROM sacramento, ca TO seattle, wa ALONG i-5

I'll also mention that the first keyword is actually optional, and the following searches are exactly the same as the four above as far as AQ is concerned:

i-5 TO seattle, wa FROM sacramento, ca
seattle, wa FROM sacramento, ca ALONG i-5
seattle, wa ALONG i-5 FROM sacramento, ca
sacramento, ca TO seattle, wa ALONG i-5

I've put the keywords in all caps just so they stand out, but that's not required. Lowercase keywords work just as well.

Now, let's say you try running a trip planner search that looks like this:

ALONG i-5 FROM boston, ma TO seattle, wa

See the problem? I-5 doesn't run between Boston and Seattle. AQ is smart enough to figure this out (which is kind of surprising, really, because AQ really isn't very smart at all). But rather than give you an error, it tries to fulfill your request the best that it can and turns your search into a linear search. It runs a straight line search from Boston to Seattle. If this is sufficient for you purposes, great. If not... well, you'll need to adjust your search and try again. =)

Using the trip planner on the Advanced Search page is a bit more complicated than before, but it's the ultimate in power allowing you to specify a start and end point anywhere along a route. If you can't remember how to run the search, there's help a click away by clicking the help button by the location. Or, alternatively, you can use the simple search page to run the search, then edit the search if you want to tweak the results more than the simple page would allow you to do directly.

And finally, you can use a trip planner wherever you see this location option in a search--including event searches!  So, for instance, you can search for all events within 30 miles of I-5 between Sacramento and Seattle. A neat little perk. The output of the results isn't as cool as with letterboxes--there's not a special column for distances or distance off path of the events since I figured when an event takes place is more important than how far it is between two events on different dates. I doubt this feature will be used often, but it's there if you ever need it! =)

And.... I think that covers all that's new with the trip planner. It's bigger and better than ever before! And I'm not even done updating it. ;o)


Anonymous said...

Can you search from an address to a known event, along a road and get a list of boxes between you and the event?


Ryan said...

Yes. =) If you use the trip planner, you're limited to the relatively limited support for routes I've listed. If the area between you and the event doesn't follow a supported route, however, you can still run a linear search (or two, or three, or more of them) between the two points as necessary.

Goofy girl said...

you wonderful person you!!

Ari C'rona said...

As the trip navigator, this is awesome! Thanks, Ryan! :o)

BNYRBT said...

Nice, very, very nice! Thank-you for all this work. BNYRBT