2017-05-25 48 views
0

出於某種原因,這個代碼不打印任何節點,方式,或關係,即使它顯然不從OpenStreetMap的下載分鐘更新:回調不叫pyosmium的差異下載

import logging 
import osmium 
from osmium.replication.server import ReplicationServer 

logging.basicConfig(level=logging.DEBUG) 

class Handler(osmium.SimpleHandler): 
    def __init__(self): 
     super(Handler, self).__init__() 

    def node(self, n): 
     print('n', n.id) 

    def way(self, w): 
     print('w', w.id) 

    def relation(self, r): 
     print('r', r.id) 

h = Handler() 
rs = ReplicationServer('http://planet.openstreetmap.org/replication/minute') 
rs.apply_diffs(h, 2112110, 0.4*1024) 

結果:

$ python3 osm2rdf.py 
DEBUG:pyosmium:Downloaded change 2112110. (86 kB available in download buffer) 
DEBUG:pyosmium:Downloaded change 2112111. (36 kB available in download buffer) 
DEBUG:pyosmium:Downloaded change 2112112. (4 kB available in download buffer) 
DEBUG:pyosmium:Downloaded change 2112113. (-139 kB available in download buffer) 

Process finished with exit code 0 

注意,還沒有一個單一的「N」,「W」或「R」的變化下載後打印。

+0

見https://github.com/osmcode/pyosmium/issues/38 – mmd

+0

@mmd,謝謝,我是誰創造了這兩個,認爲這可能是我的錯誤之一。原來它不是:)很高興它解決得這麼快! – Yurik

回答

0

原來這是在pyosmium本身就是一個錯誤。關閉。