Skip to content

mvexel/xapi-servlet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Java XAPI

The Java XAPI is a partial implementation of the XAPI read-only OSM server in Java. It is implemented as a servlet and uses pieces of Osmosis to perform the database queries.

See the OSM Wiki for more information about XAPI: http://wiki.openstreetmap.org/wiki/Xapi

Installation

These setup steps assume you're working on a Ubuntu 9.x/10.x installation.

  1. Make sure you have the required packages installed:

    sudo apt-get install postgresql-8.4 postgresql-8.4-postgis postgresql-8.4-hstore-new

  2. Set up an Osmosis pgsnapshot 0.6 schema in a PostGIS database:

    sudo su - postgres (These commands are meant to be run as user postgres)

    createdb xapi

    createlang plpgsql xapi

    createuser xapi You do want the user to be a superuser.

    echo "alter role xapi password 'xapi';" | psql -d xapi

    psql -d xapi -f /usr/share/postgresql/8.4/contrib/postgis.sql

    psql -d xapi -f /usr/share/postgresql/8.4/contrib/spatial_ref_sys.sql

    psql -d xapi -f /usr/share/postgresql/8.4/contrib/hstore-new.sql

    Under postgresql 9.1 install the package postgresql-contrib-9.1 and run the command psql -d xapi -c "CREATE EXTENSION hstore"

    psql -d xapi -f ~/osmosis/package/script/pgsnapshot_schema_0.6.sql

    psql -d xapi -f ~/osmosis/package/script/pgsnapshot_schema_0.6_linestring.sql

    psql -d xapi -f ~/osmosis/package/script/pgsnapshot_schema_0.6_relcollection.sql (This is experimental and may not be included in your copy of Osmosis yet.)

    echo "CREATE INDEX idx_nodes_tags ON nodes USING GIN(tags);" | psql -d xapi

    echo "CREATE INDEX idx_ways_tags ON ways USING GIN(tags);" | psql -d xapi

    echo "CREATE INDEX idx_relations_tags ON relations USING GIN(tags);" | psql -d xapi

    exit (Brings us back to original user.)

  3. Import a planet file (or other piece of OSM data)

    bzcat planet-latest.osm.bz2 | bin/osmosis --read-xml file="/dev/stdin" --write-pgsql user="xapi" database="xapi"

  4. Grab the latest XAPI war and deploy it with a servlet container like Tomcat or Jetty.

Development

I used Maven for the dependency and build management. Make sure you have mvn installed before doing any of this.

  1. Clone the github xapi-servlet repo

  2. Check out the Osmosis SVN code and Compile the JARs by executing ant publish from the root osmosis directory.

  3. Manually install the Osmosis dependencies into your local Maven repository by executing mvn install:install-file -DgroupId=org.openstreetmap.osmosis -DartifactId=pgsnapshot -Dversion=0.39 -Dpackaging=jar -Dfile=build/binary/osmosis-pgsnapshot.jar from the Osmosis core, pgsnapshot, hstore-jdbc and xml directories.

  4. Finally, run mvn compile war:war from the xapi-servlet directory to generate a deployable servlet war.

  • Note that this will fail if you don't have the JSON or PBF Osmosis JARs installed (You're not missing anything: I don't specify how to do that in this readme). To fix that, comment out the two dependency blocks in the pom.xml that mention pbf or json. At the moment the PBF and JSON output is removed to make it easier to add the planetDate timestamp to the output.

Known Issues

See the issues list for all issues, but these limit functionality:

  1. Bug 7 - Relation queries ignore any bounding box predicates.

  2. Bug 12 - Relations aren't included in the "all elements" query.

  3. PBF and JSON support was removed in f0f003 to make it easier to add the planetDate functionality.

Thanks

This app was built on the shoulders of other people's open source code:

  • bretth's Osmosis: for the database schema and querying code
  • emacsen's xapi-ui: for the HTML debugging page he created to help build XAPI query URLs
  • zere (and MapQuest's) help with everything; especially the parser!

About

XAPI Servlet

A Java servlet implementation of XAPI using Osmosis to do the heavy lifting.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%