Library to read OpenStreetMap PBF-encoded files.
osmpbf, the Lisp OSM PBF format reader
What is this?
Basic support for reading nodes, ways, and relations is currently there (and it might even be somewhat performant; who knows!). Node metadata information is, however, not decoded yet.
How to use
- Download the library, and put it somewhere ASDF can find it. (For example,
git clone-ing the repo into
~/common-lisp/should do the trick.)
- Install the dependencies
flexi-streams. (If Quicklisp is installed, running
(ql:quickload :osmpbf)should do this, and load the library as well!)
- If you didn't do it with Quicklisp above, run
(asdf:load-system :osmpbf)and watch the compiler output scroll by.
Basically, you open your PBF file, specifying something like
:direction :input :element-type (unsigned-byte 8), and pass the resulting stream to
get-next-primitive-groups, repeating until you hit the end of the file.
CL-USER> (with-open-file (file "sample.pbf" :direction :input :element-type '(unsigned-byte 8)) (osmpbf:get-next-primitive-groups file)) (#<OSMPBF:PRIMITIVE-GROUP nodes: (#<NODE #653970877 (51.7636027d0, -0.22875700000000002d0) tags: NIL> #<NODE #647105170 (51.76359050000001d0, -0.23446450000000002d0) tags: NIL> #<NODE #672663476 (51.7657492d0, -0.2290703d0) tags: NIL> #<NODE #241806356 (51.7689451d0, -0.23266170000000003d0) tags: NIL> ... snip ...)
:element-type bit is important; if you leave it out, it'll yell at you.
To figure out how to actually get useful things from the data returned, have a look at
the goodies in the
osmtypes.lisp file, and their associated documentation.
On that note...
Is currently in the form of docstrings. Use the Source, Luke!