Archive: Mapping

April 26, 2008

iPhone LoJack - location tracking for your iPhone

Erica Sadun put together a great tool for iPhone users who'd like to keep tabs on their iPhone's location. Instead of GPS tracking, a small binary called 'findme' is used to geolocate the device based on nearby cell towers.

Combined with a simple curl shell script, a private Twitter account, and a scheduled launch daemon, your iPhone can then report its location at regular intervals, which you (or anyone you authorize) can follow using Twitter and Google Maps. You could use this to find your phone if it's lost or stolen, or you might just use it to give your friends and family a way to track your current location.

iPhone LoJack

Related posts:
Command Line Twitter
Open GPS Tracker

Posted by Jason Striegel | Apr 26, 2008 08:21 PM
Google Maps, Life, Mapping, iPhone | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

March 2, 2008

Point polygon intersection in SQL

pointpoly_20080302.jpg

update: As readers noted, it's not the 0 degrees longitude that's the problem, it's at 180 degrees where you could encounter issues. I've also escaped the gt and lt symbols. Sorry about that.

I spent the weekend participating in the F1 Website Challenge, a coding marathon in which competing teams each produce a mythical man-month's worth of web site for a worthy non-profit organization—all in the space of 24 hours.

One of the challenges my team faced during development was finding an efficient way for detecting a particular service region for a given address. Our client, Metro Meals on Wheels, has a number of different regions in which they deliver meals, with each region being served by a particular Meals on Wheels organization. These regions are defined by non-overlapping complex polygons. It's not as simple as a normal vendor search, where you return the nearest location to the requested address. Instead you need to search a database of polygons to find the particular one which intersects the address location.

One of my teammates, Mark Seemann, ended up providing a fairly elegant solution to the problem, and was able to implement it in a simple SQL query. To find out if a point intersects a polygon, it's as simple as drawing a vector from the point and seeing how many line segments of the polygon it crosses. If the number is even, it's outside the polygon. If it's odd, you have an intersection.

So let's say you have a polygon database which has a row for each line segment of a polygon. You can quickly pull all segments that intersect a vector pointing directly east of your geocoded location like this:

SELECT poly_id, segment_id
    FROM segments
    WHERE ( lnga > thelng OR lngb > thelng )
          AND ( (lata > thelat AND latb < thelat )
              OR (latb > thelat AND lata < thelat ) )

That will return you a list of all line segments that you would cross if you walked directly east from the location at [thelat,thelng] (yes, this assumes you don't cross 180 degrees longitude). To determine the polygon (or polygons) that intersect our address, it's as simple as grouping by poly and returning all rows that have an odd number of matches:

SELECT poly_id, COUNT(segment_id) AS segment_count
    FROM segments
    WHERE ( lnga > thelng OR lngb > thelng )
          AND ( (lata > thelat AND latb < thelat )
              OR (latb > thelat AND lata < thelat ) )
          AND segment_count%2 = 1
    GROUP BY poly_id

Of course, the world isn't flat, though I've treated it this way for simplicity. If you wanted this to work for all cases, you'd need to limit your search to a particular distance and translate the coordinates so that the search didn't cross 180 degrees longitude.

Posted by Jason Striegel | Mar 2, 2008 07:15 PM
Google Maps, Mapping, SQL | Permalink | Comments (16) | TrackBack | Digg It | Tag w/del.icio.us

February 18, 2008

Actionscript mapping APIs

flashmap_20080218.jpg

Yahoo recently released an official AS3 API for Yahoo! Maps, which provides another option for Flash-based GIS applications. This adds to Mapquest's official AS3 API and a couple of partially-complete, open source AS2 APIs for Google Maps.

All of these services provide the traditional AJAX APIs, of course, and that's perfect for a lot of uses. By using Flash as the rendering engine, though, there are new options available for the developer. Things like incremental scaling between tile sets, map rotation, and more advanced multi-level vector and raster overlays immediately come to mind.

Yahoo! Maps for ActionScript 3.0 - Link
Google Maps Flash Interface - Link
MapQuest AS3 API - Link
UMap: Google Maps Flash Overlay (flash above above AJAX map) - Link

Posted by Jason Striegel | Feb 18, 2008 07:07 PM
Flash, Google Maps, Mapping, Yahoo! | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

December 1, 2007

The hackers in your neighborhood

gmaps_collabmapping2_200712.jpg

Google recently added a collaboration feature to the "My Maps" area of Google Maps. Similar to the collaborative document editing in Google Docs, when you've made a map you can click the "Collaborate" link and share your map with specific people or the entire world. What's cool is that when you do the latter, you've effectively created a map wiki that anyone can edit, expand upon, and help maintain.

After messing around with the new collaboration feature for a bit, it occurred to me that we should make a map where we hackers can add our own markers and share interests and projects with each other. It might be a good way to network with people around you, and it's also just cool to see what projects people are working on around the world.

gmaps_collabmapping3_200712.jpg

So I went ahead and created the hackers in your neighborhood, an open-access collaborative map that we can use to map the hacker world. Some of my favorite hackers at Make and Craft have added themselves to the map already, but I'd love to see how far we can push this... maybe it'll become too many data points for gmaps to handle.

Just connect to the map, log in to your Google account, and you'll find an "Edit" button on the left. Clicking this will put the map in edit mode, where you can drag a new marker onto the map for yourself. Toss your name into the title and put your interests and project websites in the description field.

If you have a programming or robotics club, toss that in there too and give it a red marker or something.

gmaps_collabmapping_2007120.jpg

I should mention something else about the collaborative feature. As you can see above, it looks like PT from Makezine has tagged my digital hood with some mapfiti.

The one downside of the collaboration feature is that someone might end up vandalizing your work. In reality, though, most of these open-collaborative projects end up working really well just on good faith and community policing. It's why large open source projects work. It's why Wikipedia works. Frankly, I think Phil's Make: tag looks pretty sweet over Minneapolis anyway.

The Hackers in Your Neighborhood - Link

Posted by Jason Striegel | Dec 1, 2007 05:39 PM
Google Maps, Lifehacker, Mapping | Permalink | Comments (4) | TrackBack | Digg It | Tag w/del.icio.us

November 13, 2007

Sculpty Earth: topographic globe with dynamic weather in Second Life

New World Notes posted an interview with Zora Spoonhammer, a Second Life hacker who created an enormous in-world earth model, complete with dynamic weather that's pulled from real world weather sources:

"Come back up here!" Zora Spoonhammer shouts after him, before he disappears over the horizon. "He's my husband in real life. He's silly that way." She's a developer in the game industry, she explains, "and I think some of it is women in games don't get a lot of recognition in the industry as is. So he's sensitive to that." On the other hand, few men have wives who build dynamic planets in their spare time.

Sculpty Earth's model is generated by a C++ program, using USGS elevation data to define the model's geography. The Earth's textures are processed and down-rezzed from NASA's Blue Marble images, and there's a semi-transparent shell that surrounds the globe, displaying an animated cloud texture. The cloud texture is generated from real-time data and displays the last 24 hours of real life weather history.

Zora talks about a lot of the data sources that were used and links to a few resources for building your own SL models and software. Definately worth a read if you are interested in mapping applications or developing apps in Second Life.

SL Topographic Globe With Dynamic Weather - Link
Blue Marble - Link

Posted by Jason Striegel | Nov 13, 2007 07:43 PM
Gaming, Mapping | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

October 22, 2007

iPhone OpenStreetMap

iphoneosm_20071022.jpg

If you have a jailbreak'd iPhone, you can update the Maps.app database with tiles from OpenStreetMap. Mikel Maron figured out how to update the Maps sqlite DB and was able to import the street tiles for London.

My first idea was to modify the configuration or constant that the Maps App used for constructing Google Maps tile requests. Andrew helped with decompiling and pointers to other files, but we had no luck as yet. But looking at the app or at the GMM module in a hex editor, there appeared to be SQL inserts of tile pointers .. perhaps Maps was using a database to cache requested tiles. Searching through the filesystem found MapTiles.sqlitedb. That db has just two tables..

This is slick. You still use the built-in Maps interface, but you can add whatever you like to its database. Technically you could alter the database with any map tiles you like. One idea would be to make an alternate database file and fill it with topo-maps. Just swap the file out and you can use the Maps application when you're backpacking.

OpenStreetMap on the iPhone - Link
OpenStreetMap - Link
SQLite Tutorial - Link

Posted by Jason Striegel | Oct 22, 2007 06:47 PM
Google Maps, Mapping, iPhone | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

October 15, 2007

Geotag your videos

geovideo_20071015.jpg

The latest version of Google Earth added a layer for geotagged YouTube videos. So far, it seems like a lot of people are using this feature for documenting landmarks, attractions and live recordings of things like music, sporting events, backpacking trips, urban skateboarding, etc.

If you have a geospatially relevant video that you want to put on the map, it's pretty easy. Just upload your video to YouTube, open the "Date and Map Options" tab in the video information panel, and drag the marker to the correct location. You can zoom in to get a more precise location, or just enter the lat/lon manually with the following format: "geo:lat=yy.yyyy geo:lon=xx.xxxx".

Posted by Jason Striegel | Oct 15, 2007 07:22 PM
Google Maps, Mapping, YouTube | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

September 27, 2007

Packet Garden

packetgarden_20070927.jpg

Packet Garden is a network visualization tool that maps your network traffic into a 3D representation, sprouting little plants on a globe whenever a connection is made.

To do this, Packet Garden takes note of all the servers you visit, their geographical location and the kinds of data you access. Uploads make hills and downloads valleys, their location determined by numbers taken from internet address itself. The size of each hill or valley is based on how much data is sent or received. Plants are also grown for each protocol detected by the software; if you visit a website, an 'HTTP plant' is grown. If you share some files via eMule, a 'Peer to Peer plant' is grown, and so on.

Packet Garden is GNU licenced and written in Python, so you can give it a try on supported Linux, Windows, and Mac machines. It doesn't run on Intel macs, unfortunately. As far as I can tell, Soya3D (the 3D library it uses) is the culprit and has not been compiled under this architecture. Anyone want to take a stab at porting this? I'm not familiar with the package, but it might be as simple as installing all Soya's required libraries and running a python make script.

Packet Garden. Grow a world from network traffic - Link
Soya3D - Link

Posted by Jason Striegel | Sep 27, 2007 09:39 PM
Linux, Mac, Mapping, Network Security, Windows | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

September 15, 2007

Gameboy Advance GPS

gbagps_20070914.jpg

Here's one of my favorite portable gaming hacks, the GBA GPS. It's a project that always comes to mind whenever I hear about some piece of homebrew development hardware falling under legal scrutiny.

People are always creating amazing things when closed hardware is hacked open for amateur development.

I own Magellan meridian GPS, many efforts were done to create custom maps for the receiver (see Links to my Magellan GPS page). But most of the mapping receivers (Magellan, Garmin) use vector graphics, this is very good for scaling, search, and huge amount of data. But sometimes much more convenient to have raster map with the current position on the map. I developed this GBA based mapping receiver to use scanned maps with GPS the way I like. This was done for fun, but I found this device very useful. I am using this device as a car navigator in the city.

The GBA GPS - Link

Posted by Jason Striegel | Sep 15, 2007 12:17 AM
Gaming, Mapping | Permalink | Comments (1) | TrackBack | Digg It | Tag w/del.icio.us

August 2, 2007

HOWTO: use latitude and longitude with Google Maps

gmaplatlon_20070802.jpg

Whether you want to quickly add a waypoint to your GPS, or view a map of a known location, it can often be convenient to use real latitude and longitude values with Google Maps instead of dealing with street addresses.

Rerieving a map for a lat/lon value is simple enough with Google Maps. You can simply enter the decimal latitude and longitude into the search form instead of a street address.

However, if you're viewing a map and you want to retrieve the lat/lon location, there unfortunately isn't a convenient "get latitude and longitude" button. Google Maps deals with latitude and longitude locations internally, though, so with this little snippet of javascript, you can easily get the job done:

javascript:void(prompt('',gApplication.getMap().getCenter())

This will return the coordinates of the map's center point. You might want to double-click a position on the map before running the above code. Doing so will reposition that point to the center of the map automatically.

Get Latitude and Longitude values from Google Maps - [via] Link

Posted by Jason Striegel | Aug 2, 2007 07:50 PM
Google Maps, Mapping | Permalink | Comments (7) | TrackBack | Digg It | Tag w/del.icio.us

May 20, 2007

Cross country motorcycle map mashup

motorcyclegmaps_20070520.jpg
Ryan from 5Pears.org stopped by the Hacks booth at the Maker Faire yesterday. He's been traveling for the last 50 days across the country on his bike, using his phone and a GPS to automatically update a map which details the route he's taken, where he is, and where he's stopped for things like gas and food.

When you're on the road that long and mapping your adventure in real-time, there's a bit of a security need that needs to be considered. Ryan wanted to let his friends and family know where he is, but he didn't exactly want to give out information about where he is currently camping. His solution was to have the PHP script that runs his site monitor his location for movement. If he's been staying within the the same general location, the data won't be plotted to the map until he's moved somewhere else.

5 Pears travel blog - Link.

Posted by Jason Striegel | May 20, 2007 10:08 AM
Google Maps, Mapping, Travel | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

March 13, 2007

Use Google Earth as GPS

Google GPS

In the latest installment of Kevin Kelly's Cool Tools, Alexander Rose shows how to use Google Earth to provide cost-effective GPS mapping in real time:

I have been doing a lot of exploring and surveying in the desert recently, and have been trying to find the right GPS mapping solution. The solution I found incorporated stuff I already had (laptop and GPS) with the help of some excellent, nearly free software. The best part is that it works even better than the $900 in-car GPS solutions as it uses always up-to-date satellite data, and is easily sharable.


Basically you run Google Earth and use some great donation-ware to link it in real time to a GPS. This means that your mapping software and maps worldwide are not only free, but you also get hi-res satellite views and in some cases 3D buildings (in downtown areas).

The trick of this hack is getting Google Earth to work offline, when you're disconnected from the Internet, by updating the cache for your destination before you leave. Alexander's favorite part if his setup allows him to save a route and share it with others. Check out his post for complete software, hardware, and connection details.


Related:

Posted by | Mar 13, 2007 06:02 AM
Google Maps, Mapping | Permalink | Comments (1) | TrackBack | Digg It | Tag w/del.icio.us

February 16, 2007

Open Source Javascript Mapping

ciafact_20070215.jpg
If you're building any sort of web interface for geospatial data, take a peek at OpenLayers.

OpenLayers implements a (still-developing) JavaScript API for building rich web-based geographic applications, similar to the Google Maps and MSN Virtual Earth APIs, with one important difference -- OpenLayers is Free Software, developed for and by the Open Source software community.

OpenLayers is being used as a front end for a lot of interesting datasets. My current favorite is a map interface to the CIA World Factbook (pictured above). You can click on any country in the world and quickly find out statistics like birth rate, population, and number of cell phones. Did you know that there are almost 10 times as many cell phones than land lines in Chad?

Resources:

Posted by Jason Striegel | Feb 16, 2007 12:00 AM
Mapping | Permalink | Comments (0) | TrackBack | Digg It | Tag w/del.icio.us

February 3, 2007

Simple Zip Code Geocoding

mpls_20070203.jpg

The ability to geocode, or translate into latitude and longitude, postal codes is a fairly useful hack to have in your programming toolbox. Quick and dirty zip geocoding allows you to do some neat things fairly efficiently and with a minimal amount of code. Though it's U.S. centric, it allows you to add location-based functionality to your apps without requiring any real personal information to be transfered or stored.

If your application only needs to convert a zip code (or any address) into a lat/lon coordinate, say for simple mapping purposes, the easiest solution is to use the Google Maps Geocoding API. In addition to the client-side javascript functionality, you can directly query the geocoding system from php using an http request like this:

http://maps.google.com/maps/geo?q=12345&output=xml&key=yourkeyhere

Just change 12345 to the zip (or any address) that you are looking up, and "yourkeyhere" should be your Google Map API key, which you can obtain here. Developer.com has a good PHP example for making use of the returned XML in your server-side code.

Often times, it's useful to be able to do zip lookups based on a geographic region. Maybe you want a list of all zip codes within a certain radius or bounding box. Applications for this could include clustering map items that are near eachother, or searching a database for items that are nearest to a given location. For this, it's really nice to have a MySQL table that contains zip codes along with their lat/lon coordinates. Fortunately, several people have compiled this sort of information from public domain data, and you can even download a full MySQL table dump here, for free.

At this point, it's a pretty simple matter to query the database for location-based information. For instance, let's say you have a web site with a guestbook that allows guests to leave their name and zip. You could easily whip up an application that tells your guests how many other guests are in their area by using a basic bounding box with a query like this:

SELECT guest.name from guest, zipcode
WHERE guest.zip = zipcode.zip
AND zipcode.lat < [maxlat] AND zipcode.lat > [minlat]
AND zipcode.lng < [maxlng] AND zipcode.lng > [minlng]

These are just a few ideas, but hopefully this should be enough to get you started. If you have some good ideas for other geocoding applications (or any mapping/gis hacks in general), please give us a shout in the comments.

Posted by Jason Striegel | Feb 3, 2007 09:42 PM
Ajax, Google Maps, Mapping, MySQL | Permalink | Comments (3) | TrackBack | Digg It | Tag w/del.icio.us

January 24, 2007

Chart Your Route with Virtual Pedometers

WalkRunJog

To prepare routes of varying lengths while training for her first marathon, The Marathon Mama (a.k.a. Kristina Pinto, my wife) used to simply drive from the house and clock distances using her car's trip odometer. But training for her second marathon, this time as a mother, she began to realize:

It can get tedious to drive around with a toddler in the back seat asking, "Where we going?" as we pass our house several times to measure various routes. Besides, I often forget the mileage of my routes.
In the past, she'd used a rolling "pen" to calculate mileage on a printed map (the roller increments as it rolls along the route, with calculations needing to be made for scale), but she always doubted its accuracy. Thankfully, her training partners (she'll be running the Boston Marathon for charity, as part of the Dana-Farber Marathon Challenge) turned her on to some much more efficient and practical solutions, provided by third-party Google Maps mashups:
For city runners who jog on a lot of one-way streets, or any of you who walk or run and are looking to chart out the mileage on a new route: you don't need to get in your car to clock the miles anymore. There are several free websites that will help you out and determine the miles of a path anywhere in the country.
  • You can calculate your own route or check out other people's preferred paths at WalkJogRun.
  • Another DFMC runner recommended Gmaps Pedometer, which offers similar services.
She concludes, "Now you don't have to get off your seat to count your miles, but you still have to get off the chair to actually run them."


Related:

Posted by | Jan 24, 2007 06:30 AM
Google Maps, Life, Lifehacker, Mapping, Parenting | Permalink | Comments (2) | TrackBack | Digg It | Tag w/del.icio.us

Bloggers

Welcome to the Hacks Blog!

Brian Jepson.Brian Jepson


Jason Striegel.Jason Striegel


Philip Torrone.Phillip Torrone



See all of the books in the Hacks Series!
Advertise here.

Recent Posts

www.flickr.com
photos in Hacks More photos in Hacks