Tuesday, 29 January 2013

OSM with NYC station

Recently the movement for open map has reached a tipping point where it has very useful data to be harvested for mobile application. Using OSM, a user can easily identify those subway station near her location. Below is a simple map search that I have developed for NYC Subway Time.


It is a simple map with nearby subway station for line 1. The map search is dynamic in the sense that as you pan the map, more stations will appear. I will be adding the station name beside each icon (looking for better icon to represent New York subway..).

Android code:

String lon0 = Float.parseFloat(longitude)-0.01+"";
String lon1 = Float.parseFloat(longitude)+0.01+"";
String lat0 = Float.parseFloat(latitude)-0.01+"";
String lat1 = Float.parseFloat(latitude)+0.01+"";
url = "http://www.overpass-api.de/api/xapi?node[bbox="+lon0+","+lat0+","+lon1+","+lat1+"][railway=station]";

OSM response:

<node id="1482281254" lat="40.8850229" lon="-73.9006967">
<tag k="name" v="238th Street (1)"/>
<tag k="railway" v="station"/>
<tag k="wheelchair" v="no"/>
</node>

Only 2 locations are required, the lower left and the upper right. The critical point is the railway=station. It fetches all the subway station in the region. 

Ultimately, I am pushing for dynamic lines to be drawn on the map. I envision a real map with stop location and subway line. Users can have a sense of the distance between stops an zoom in the map to view its surrounding. It is a frontier that needs lots of programming hours, but it is fun!

OSM combined with MTA recently opened train data makes life better for New Yorker!




No comments:

Post a Comment