NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I'm trying to set up my own Rails Port OSM API server as my application needs to make a very large number of map queries.

I finally have everything looking like it should work but when I query a region of the map that has been populated from a .osm file using osm2pgsql I just get the wrapper nodes with no actual content returned. It's as though the region I'm querying has not been populated with data.

The details:

I'm using an Ubuntu 16.04 running on a Virtual Machine.

I followed all steps described here: https://github.com/openstreetmap/openstreetmap-website/blob/master/INSTALL.md . But I had to change a few things due to version and package name changes. So I ended up installing these:

sudo apt-get install ruby libruby ruby-dev \
                 libmagickwand-dev libxml2-dev libxslt1-dev nodejs \
                 apache2 apache2-dev build-essential git-core \
                 postgresql postgresql-contrib libpq-dev postgresql-server-dev-all \
                 libsasl2-dev imagemagick
sudo gem install bundler

I got error messages later on in the process regarding not having svgo installed, so I also ended up installing this to get rid of the errors:

sudo apt-get install npm
sudo npm install -g svgo

# and due to https://github.com/nodejs/node-v0.x-archive/issues/3911 :
sudo ln -s /usr/bin/nodejs /usr/bin/node

To fix some other errors I got when trying to run osm2pgsql I found I had to add PostGIS support to database:

psql -U <user> <database>
e.g. psql -U myusername openstreetmap
at prompt type:
    CREATE EXTENSION postgis;
    \q      // to exit

I got hold of the Bonn, Germany .osm.bz2 file from mapzen.com/data/metro-extracts/

I populated this into the database:

osm2pgsql -s -U myusername -d openstreetmap bonn_germany.osm.bz2

I carefully examined the log generated and there were no errors and the import seemed to be successful.

I started the Rails Port webserver: bundle exec rails server

From a webpage on the same PC I did a REST query for a small region that is inside Bonn:

localhost:3000/api/0.6/map?bbox=7.0974,50.7321,7.0982,50.7325

I got a response so I know the server is running, but the response just contained the following:

   <osm version="0.6" generator="OpenStreetMap server" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">

        <bounds minlat="50.7321" minlon="7.0974" maxlat="50.7325" maxlon="7.0982">

    </osm>

So I'm just getting the wrapper nodes with no data for the region inside the bounding box.

If I make the same query to the public server:

www.openstreetmap.com/api/0.6/map?bbox=7.0974,50.7321,7.0982,50.7325

Then I get a long list of nodes and ways from inside the bounding box as expected.

Any idea what I am doing wrong?

Thanks

asked 06 Aug '16, 01:45

techtonic's gravatar image

techtonic
11114
accept rate: 0%

edited 06 Aug '16, 01:54

Setting up a rails port just for a number of map calls seems to be quite a lot of overhead to me. I would possibly suggest to set up your own Overpass API instance and use the map call available there. I may be a bit biased, though... Can you shed some light on how many calls you're planning to run per minute and what your coverage area looks like?

(06 Aug '16, 08:14) mmd

@mmd I need to perform a map query to get the nodes and ways (not interested in image tiles) on an array of approx 2km x 2km tiles covering most of central Europe. Plus we need to edit the database locally using other GIS tools in ways that would not be beneficial to the OSM community, so it would not be right to do it to the public copy. I am definitely looking at Overpass as a possibility for reading the finished map in a more efficient manner. I'm kinda new to OSM so still trying to figure out what is possible.

(07 Aug '16, 07:16) techtonic

The rails port uses a database schema that is different from osm2pgsql's, hence osm2pgsql is the wrong tool to use if you want to populate a database for use with the rails port. You must use osmosis with the "APIDB" schema instead.

permanent link

answered 06 Aug '16, 21:30

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks, I was not aware of that and it sounds like a probable cause of my problem. I did try using Osmosis to import a few times but had trouble getting it to connect to the postgresql database. I will try again when I get back to work next week.

(07 Aug '16, 07:20) techtonic

I finally got osmosis to connect to database by removing password requirement from pg_hba.conf. Importing the same .osm file with osmosis works and now I am getting valid data returned :) Thanks for the help!

(08 Aug '16, 21:02) techtonic

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×290
×123
×39
×11

question asked: 06 Aug '16, 01:45

question was seen: 4,582 times

last updated: 08 Aug '16, 21:02

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum