Skip to content

fruminator/openstreetblock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenStreetBlock is a simple web service for turning a lat/lon into a block name using OpenStreetMap data.

http://github.com/fruminator/openstreetblock
http://transit.frumin.net/openstreetblock

DEPENDENCIES
-----------------------------------------------------------------------------
OpenStreetBlock depends on:
* PostgreSQL
* PostGIS
* Apache
* PHP
* Osmosis
* osm2pgsql
* git (to get the code)

FGI my friend

Why PHP?  Errr, well, ummm, hey, what's that over there?


INSTALLATION
-----------------------------------------------------------------------------
1. Install all the above dependencies
2. Get the code (for read-only download: "git clone git://github.com/fruminator/openstreetblock.git")
3. In the openstreetblock directory, mv conf.inc.php.default to conf.inc.php
4. Edit conf.inc.php to reflect your local configuration parameters (especially, your database connection)
5. Get, process, and load OpenStreetMap data as described below
6. Send requests to the osb.php script, as described in index.php


OPENSTREETMAP DATA
-----------------------------------------------------------------------------
1. Get some OpenStreetMap data in raw XML format (i.e. a .osm file).  
Easiest way is to:
- Go to http://www.openstreetmap.org/
- Navigate to a pan/zoom for which you want data
- Click the "Export" tab
- Select the OpenStreetMap XML Data option
- Hit "Export"
- When this fails, because you have chosen too large a bounding box, copy the bbox=BBOX out of the resulting URL
- Use this bounding box to request bulk OSM data:
  wget --timeout=SOME_LARGE_VALUE -O MY_FILE.osm "http://www.informationfreeway.org/api/0.6/map?bbox=BBOX
- Keep trying this until it eventually works...


A reasonable BBOX for New York City (less Staten Island) could be:
  -74.054,40.54,-73.709,40.92"

So the request could be executed with:
   wget --timeout=3600 -O nyc.osm "http://www.informationfreeway.org/api/0.6/map?bbox=-74.054,40.54,-73.709,40.92"



2. Create a PostGIS-enabled database in your PostgreSQL instance.
   Assume henceforth that this database was named 'osb'


3. Use osm2pgsql to load the .osm file into PSQL:
   osm2pgsql -d osb -l -s -p osm MY_FILE.osm
   (may also need flags for host, username, password, etc)

   from this we will use only the following tables:
   	osm_line
	osm_ways


4. Use osmosis to load the .osm file into PSQL another way:

   Create the schema osmosis looks for (to do this will require the 'hstore' psql module):
   cat /usr/share/doc/osmosis/examples/pgsql_simple_schema_0.6.sql | psql osb
   cat /usr/share/doc/osmosis/examples/pgsql_simple_schema_0.6_linestring.sql | psql osb
   cat /usr/share/doc/osmosis/examples/pgsql_simple_schema_0.6_bbox.sql | psql osb

   Then import using osmosis:
   osmosis --read-xml MY_FILE.osm --write-pgsql database=osb host=HOST user=USER
   (likewise for more DB flags.  Note, osmosis has no flag for DB port)

   From this we will use only:
   nodes
   way_nodes


5.  You probably want to VACUUM ANALYZE the whole thing after importing.

About

Simple web service for turning a lat/lon into a block name (e.g. "5th avenue between president st and union st") using OpenStreetMap data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages