joto / osmium

C++/Javascript framework for working with OSM files.
http://wiki.openstreetmap.org/wiki/Osmium
GNU General Public License v3.0
123 stars 31 forks source link

osmjs: failed to add attribute 'id' #63

Closed StyXman closed 11 years ago

StyXman commented 11 years ago

I was trying to extract some info from a .pbf file[1] into a shapefile and I got that error message. I used a config file which is almost the example in the README file:

shapefile('poi').
    type(POINT).
    column('id', INTEGER, 10).
    column('type', STRING, 32).
    column('name', STRING, 32);

node('amenity').
    output('poi').
        attr('type', 'amenity').
        attr('name');

I executed osmjs as:

$ osmjs -2 -i osm2shape -j split.js provence-alpes-cote-d-azur.osm.pbf
terminate called after throwing an instance of std::runtime_error
  what():  failed  to add attribute 'id'
Aborted

Am I missing something?

[1] http://download.geofabrik.de/openstreetmap/europe/france/provence-alpes-cote-d-azur.osm.pbf

StyXman commented 11 years ago

I fixed it by adding the column 'id' by hand:

node('amenity').
    output('poi').
        attr ('id').
        attr('type', 'amenity').
        attr('name');

so it's the README who should be fixed :)

joto commented 11 years ago

Your fix is wrong, all ids end up as (null). The problem is that the id field is defined as integer which is not enough for 64 bit ids. It has to be defined as a large-enough string. I fixed this in the README, the example .js files were already okay. Fix for README is in 22ed2f6.