waagsociety / citysdk-ld

CitySDK Linked Data API
MIT License
59 stars 4 forks source link

Importing city extracts (osm *.pbf) #35

Closed alemon212 closed 9 years ago

alemon212 commented 9 years ago

When importing an OSM extract (like e.g. Amsterdam oder an own) using the osm_importer.rb script, I get this output:

screenshot from 2014-11-25 01 52 32

Now note that I used a custom user for the postgres DB, which is configured correctly in the config.development.json file. The problem is that the script when calling osm2pgsql uses still the user postgres as default (-U postgres):

osm2pgsql = "export PGPASS=#{config[:db][:password]}; osm2pgsql --slim -j -d #{config[:db][:database]} -H #{config[:db][:host]} -l -C6000 -U postgres #{options[:osm_filename]}"

However when connecting to the db earlier for example, it uses the user specified in the config file:

database = Sequel.connect "postgres://#{config[:db][:user]}:#{config[:db][:password]}@#{config[:db][:host]}/#{config[:db][:database]}", encoding: 'UTF-8'

So it would probably make sense to change that fixed username with the one from the config. Could be like this:

osm2pgsql = "osm2pgsql --slim -j -d #{config[:db][:database]} -H #{config[:db][:host]} -l -C6000 -U #{config[:db][:user]} -W #{config[:db][:password]} #{options[:osm_filename]}"

(Still in earlier tries it didn't even work with the standard user postgres (when there was one), because no password with the option -W was specified, the result was also failed authentication.) Now when running this fixed version of the script, it can authenticate itself (although it's curious that I still have to enter the password manually), however the import fails because of other reasons:

Here's the output: screenshot from 2014-11-25 01 53 00

Looks like some tables are missing. . What could be the reason for that?? thank you very much for your help!

bertspaan commented 9 years ago

I've noticed the hard-coded -U postgres last week, but fixed this in 76a990d08ada.

The osm2pgsql errors you're encountering is caused by insufficient memory on your machine. By default, the CitySDK LD OSM importer is configured to use 6000 MB of memory, by using osm2pgsql's -C switch. I've just made this option configurable, in e85b8588be7b03805. You can specify the amount of memory osm2pgsql should use in your configuration JSON, like so:

{
  "endpoint": "…"  ,
  "owner": "…",
  "db": "…",
  "osm": {
    "cache_size": 1024
  }
}