Problem with imposm.parser and coords.callback

380 views
Skip to first unread message

Groppo

unread,
Oct 27, 2012, 10:49:07 AM10/27/12
to imp...@googlegroups.com
Hello,
I'm an OpenStreetMap contributor.

I'm trying to use imposm.parser (1.0.3-1) installed from Ubuntu 12.10 official repositories
(CPU: Intel® Core™2 Duo CPU T8100 @ 2.10GHz × 2 ).

If I use a coords_callback on an .osm file it works fine, but it does not if I parse the same file converted to pbf (with osmconverter), because granularity == None.

- This is the simple script:

# example file http://download.gfoss.it/osm/osm/regioni/molise.pbf
from imposm.parser import OSMParser

# Simple class that handles the parsed OSM data.
class CoordsCounter(object):
    coordsNum = 0

    def coords(self, coords):
        # callback method for coords
        for osm_id, lon, lat in coords:
            self.coordsNum += 1

# Instantiate counter and parser and start parsing
counter = CoordsCounter()
p = OSMParser(concurrency=4, coords_callback=counter.coords)

print "Coords in OSM file:"
p.parse('molise.osm')
print counter.coordsNum

print "Coords in PBF file:"
p.parse('molise.pbf')
print counter.coordsNum


- and this the output:

Coords in OSM file:
260467
Coords in PBF file:
Process PBFParserProcess-2:1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/multiproc.py", line 35, in run
    size=pos['blob_size'])
  File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 72, in parse
    self.handle_nodes(reader)
  File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 83, in handle_nodes
    for node in reader.nodes():
  File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 207, in nodes
    last_lat += coord_scale * (lat_offset + (granularity * lats[i]))
TypeError: unsupported operand type(s) for *: 'NoneType' and 'long'

Could you tell me what I am doing wrong?

Thank you for any hint,
Groppo

Oliver Tonnhofer

unread,
Oct 29, 2012, 3:05:53 AM10/29/12
to imp...@googlegroups.com
Hi,

On 27.10.2012, at 16:49, Groppo wrote:
> If I use a coords_callback on an .osm file it works fine, but it does not if I parse the same file converted to pbf (with osmconverter), because granularity == None.
> [...]
> Process PBFParserProcess-2:1:
> Traceback (most recent call last):
> File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
> self.run()
> File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/multiproc.py", line 35, in run
> size=pos['blob_size'])
> File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 72, in parse
> self.handle_nodes(reader)
> File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 83, in handle_nodes
> for node in reader.nodes():
> File "/usr/lib/python2.7/dist-packages/imposm/parser/pbf/parser.py", line 207, in nodes
> last_lat += coord_scale * (lat_offset + (granularity * lats[i]))
> TypeError: unsupported operand type(s) for *: 'NoneType' and 'long'


This is odd. granularity should be set to 100 from the PBF parser itself by default. Can you upload an example PBF file created with osmconverter?


Regards,
Oliver

--
Oliver Tonnhofer | Omniscale GmbH & Co KG | http://omniscale.de
http://mapproxy.org | https://github.com/olt | @oltonn






Groppo

unread,
Oct 29, 2012, 5:05:10 AM10/29/12
to imp...@googlegroups.com, o...@omniscale.de
Hi,

On Monday, October 29, 2012 8:05:57 AM UTC+1, Oliver Tonnhofer wrote:
...

This is odd. granularity should be set to 100 from the PBF parser itself by default. Can you upload an example PBF file created with osmconverter?

I downloaded some data with JOSM:
https://dl.dropbox.com/u/41550819/osmconvert_examples/example.osm

and converted them to PBF with:
"osmconvert example.osm -o=example.pbf"
https://dl.dropbox.com/u/41550819/osmconvert_examples/example.pbf


Ciao,
Groppo

Groppo

unread,
Oct 29, 2012, 3:09:39 PM10/29/12
to imp...@googlegroups.com, o...@omniscale.de
I forgot to say that I'm using the 64 bit version of Ubuntu.
I don't know if this is important.

Thanks,
Groppo


Alexandre Vallette

unread,
Dec 14, 2012, 6:12:35 AM12/14/12
to imp...@googlegroups.com, o...@omniscale.de
Hi i have exactly the same problem.

Alexandre Vallette

unread,
Dec 14, 2012, 6:30:01 AM12/14/12
to imp...@googlegroups.com, o...@omniscale.de
i solved it in a dirty manner by changing line 207 of /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/imposm/parser/pbf/parser.py
it works fine
(mac 64 bit)

Oliver Tonnhofer

unread,
Dec 14, 2012, 7:16:04 AM12/14/12
to imp...@googlegroups.com

On 14.12.2012, at 12:30, Alexandre Vallette wrote:

> i solved it in a dirty manner by changing line 207 of /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/imposm/parser/pbf/parser.py
> it works fine
> (mac 64 bit)

What change did you make and what version of Protobuf did you use?
Reply all
Reply to author
Forward
0 new messages