File tree Expand file tree Collapse file tree 3 files changed +32
-0
lines changed
Expand file tree Collapse file tree 3 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import osmium as o
2+ import sys
3+
4+ class WayHandler (o .SimpleHandler ):
5+
6+ def __init__ (self , idx ):
7+ o .SimpleHandler .__init__ (self )
8+ self .idx = idx
9+
10+ def way (self , w ):
11+ for n in w .nodes :
12+ n .lat , n .lon # throws an exception if the coordinates are missing
13+ loc = idx .get (n .ref )
14+ print w .id , len (w .nodes )
15+
16+ if len (sys .argv ) != 3 :
17+ print "Usage: python create_nodecache.py <osm file> <node cache>"
18+ exit ()
19+
20+ reader = o .io .Reader (sys .argv [1 ], o .osm .osm_entity_bits .WAY )
21+
22+ idxfile = open (sys .argv [2 ], 'a+b' )
23+ print sys .argv [2 ],idxfile .fileno ()
24+
25+ idx = o .index .DenseLocationMapFile (idxfile .fileno ())
26+ lh = o .NodeLocationsForWays (idx )
27+
28+ o .apply (reader , lh , WayHandler (idx ))
29+
30+ reader .close ()
Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ BOOST_PYTHON_MODULE(_osm)
6262 .add_property (" lon" , &osmium::NodeRef::lon)
6363 .add_property (" lat" , &osmium::NodeRef::lat)
6464 .add_property (" ref" , &osmium::NodeRef::ref)
65+ .add_property (" location" , static_cast <osmium::Location (osmium::NodeRef::*)() const >(&osmium::NodeRef::location))
6566 ;
6667 class_<osmium::WayNodeList, boost::noncopyable>(" WayNodeList" , no_init)
6768 .def (" __len__" , &osmium::WayNodeList::size)
Original file line number Diff line number Diff line change @@ -57,4 +57,5 @@ BOOST_PYTHON_MODULE(_osmium)
5757 def (" apply" , &apply_reader_simple<VirtualHandler>);
5858 def (" apply" , &apply_reader_simple<osmium::handler::NodeLocationsForWays<DenseLocationMapFile>>);
5959 def (" apply" , &apply_reader_simple_with_location<SparseLocationTable>);
60+ def (" apply" , &apply_reader_simple_with_location<DenseLocationMapFile>);
6061}
You can’t perform that action at this time.
0 commit comments