Artifact
c4e98390d87015bf1e4c92085ac364adf2f14dee:
Wiki page
[ReadOSM] by
sandro
2020-08-02 10:23:08.
0000: 44 20 32 30 32 30 2d 30 38 2d 30 32 54 31 30 3a D 2020-08-02T10:
0010: 32 33 3a 30 38 2e 37 39 38 0a 4c 20 52 65 61 64 23:08.798.L Read
0020: 4f 53 4d 0a 50 20 34 32 66 36 37 64 61 62 31 66 OSM.P 42f67dab1f
0030: 62 38 31 61 66 35 61 66 33 63 64 64 39 39 64 39 b81af5af3cdd99d9
0040: 35 37 32 39 39 39 65 66 62 35 37 64 33 38 0a 55 572999efb57d38.U
0050: 20 73 61 6e 64 72 6f 0a 57 20 32 38 39 39 0a 3c sandro.W 2899.<
0060: 74 61 62 6c 65 20 63 65 6c 6c 73 70 61 63 69 6e table cellspacin
0070: 67 3d 22 31 30 22 20 63 65 6c 6c 70 61 64 64 69 g="10" cellpaddi
0080: 6e 67 3d 22 33 30 22 3e 3c 74 72 3e 0d 0a 3c 74 ng="30"><tr>..<t
0090: 64 20 62 67 63 6f 6c 6f 72 3d 22 23 66 30 66 30 d bgcolor="#f0f0
00a0: 66 38 22 20 77 69 64 74 68 3d 22 35 30 25 22 3e f8" width="50%">
00b0: 0d 0a 52 65 61 64 4f 53 4d 20 69 73 20 61 6e 20 ..ReadOSM is an
00c0: 3c 62 3e 3c 69 3e 6f 70 65 6e 20 73 6f 75 72 63 <b><i>open sourc
00d0: 65 3c 69 3e 3c 2f 62 3e 20 6c 69 62 72 61 72 79 e<i></b> library
00e0: 20 74 6f 20 65 78 74 72 61 63 74 20 76 61 6c 69 to extract vali
00f0: 64 20 64 61 74 61 20 66 72 6f 6d 20 77 69 74 68 d data from with
0100: 69 6e 20 61 6e 20 4f 70 65 6e 20 53 74 72 65 65 in an Open Stree
0110: 74 20 4d 61 70 20 69 6e 70 75 74 20 66 69 6c 65 t Map input file
0120: 2e 20 53 75 63 68 20 4f 53 4d 20 66 69 6c 65 73 . Such OSM files
0130: 20 63 6f 6d 65 20 69 6e 20 74 77 6f 20 64 69 66 come in two dif
0140: 66 65 72 65 6e 74 20 66 6f 72 6d 61 74 73 3a 3c ferent formats:<
0150: 75 6c 3e 0d 0a 3c 6c 69 3e 66 69 6c 65 73 20 69 ul>..<li>files i
0160: 64 65 6e 74 69 66 69 65 64 20 62 79 20 74 68 65 dentified by the
0170: 20 3c 62 3e 2e 6f 73 6d 3c 2f 62 3e 20 73 75 66 <b>.osm</b> suf
0180: 66 69 78 20 73 69 6d 70 6c 79 20 61 72 65 20 70 fix simply are p
0190: 6c 61 69 6e 20 58 4d 4c 20 66 69 6c 65 73 2e 3c lain XML files.<
01a0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 66 69 6c 65 73 20 /li>..<li>files
01b0: 69 64 65 6e 74 69 66 69 65 64 20 62 79 20 74 68 identified by th
01c0: 65 20 3c 62 3e 2e 6f 73 6d 2e 70 62 66 3c 2f 62 e <b>.osm.pbf</b
01d0: 3e 20 73 75 66 66 69 78 20 64 6f 65 73 20 63 6f > suffix does co
01e0: 6e 74 61 69 6e 74 20 74 68 65 20 73 61 6d 65 20 ntaint the same
01f0: 69 64 65 6e 74 69 63 61 6c 20 64 61 74 61 2c 20 identical data,
0200: 62 75 74 20 61 64 6f 70 74 69 6e 67 20 74 68 65 but adopting the
0210: 20 47 6f 6f 67 6c 65 27 73 20 50 72 6f 74 6f 63 Google's Protoc
0220: 6f 6c 20 42 75 66 66 65 72 20 73 65 72 69 61 6c ol Buffer serial
0230: 69 7a 61 74 69 6f 6e 20 66 6f 72 6d 61 74 20 61 ization format a
0240: 6e 64 20 74 68 75 73 20 72 65 71 75 69 72 69 6e nd thus requirin
0250: 67 20 6d 75 63 68 20 6c 65 73 73 20 73 74 6f 72 g much less stor
0260: 61 67 65 20 73 70 61 63 65 2e 3c 2f 6c 69 3e 0d age space.</li>.
0270: 0a 3c 2f 75 6c 3e 3c 62 72 3e 0d 0a 54 68 65 20 .</ul><br>..The
0280: 52 65 61 64 4f 53 4d 20 64 65 73 69 67 6e 20 67 ReadOSM design g
0290: 6f 61 6c 73 20 61 72 65 3a 3c 75 6c 3e 0d 0a 3c oals are:<ul>..<
02a0: 6c 69 3e 74 6f 20 62 65 20 73 69 6d 70 6c 65 20 li>to be simple
02b0: 61 6e 64 20 6c 69 67 68 74 77 65 69 67 68 74 3c and lightweight<
02c0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 74 6f 20 62 65 20 /li>..<li>to be
02d0: 73 74 61 62 6c 65 2c 20 72 6f 62 75 73 74 20 61 stable, robust a
02e0: 6e 64 20 65 66 66 69 63 69 65 6e 74 3c 2f 6c 69 nd efficient</li
02f0: 3e 0d 0a 3c 6c 69 3e 74 6f 20 62 65 20 65 61 73 >..<li>to be eas
0300: 69 6c 79 20 61 6e 64 20 75 6e 69 76 65 72 73 61 ily and universa
0310: 6c 6c 79 20 70 6f 72 74 61 62 6c 65 3c 2f 6c 69 lly portable</li
0320: 3e 0d 0a 3c 6c 69 3e 6d 61 6b 69 6e 67 20 74 68 >..<li>making th
0330: 65 20 77 68 6f 6c 65 20 70 61 72 73 69 6e 67 20 e whole parsing
0340: 70 72 6f 63 65 73 73 20 6f 66 20 62 6f 74 68 20 process of both
0350: 3c 62 3e 2e 6f 73 6d 3c 2f 62 3e 20 6f 72 20 3c <b>.osm</b> or <
0360: 62 3e 2e 6f 73 6d 2e 70 62 66 3c 2f 62 3e 20 66 b>.osm.pbf</b> f
0370: 69 6c 65 73 20 63 6f 6d 70 6c 65 74 65 6c 79 20 iles completely
0380: 74 72 61 6e 73 70 61 72 65 6e 74 20 66 72 6f 6d transparent from
0390: 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e the application
03a0: 20 6f 77 6e 20 70 65 72 73 70 65 63 74 69 76 65 own perspective
03b0: 2e 3c 2f 6c 69 3e 3c 2f 75 6c 3e 0d 0a 0d 0a 52 .</li></ul>....R
03c0: 65 61 64 4f 53 4d 20 69 73 20 73 74 72 75 63 74 eadOSM is struct
03d0: 75 72 61 6c 6c 79 20 73 69 6d 70 6c 65 20 61 6e urally simple an
03e0: 64 20 71 75 69 74 65 20 6c 69 67 68 74 2d 77 65 d quite light-we
03f0: 69 67 68 74 20 28 74 79 70 69 63 61 6c 6c 79 20 ight (typically
0400: 61 62 6f 75 74 20 32 30 4b 20 6f 66 20 6f 62 6a about 20K of obj
0410: 65 63 74 20 63 6f 64 65 2c 20 73 74 72 69 70 70 ect code, stripp
0420: 65 64 29 2e 20 0d 0a 0d 0a 52 65 61 64 4f 53 4d ed). ....ReadOSM
0430: 20 69 73 20 6c 69 63 65 6e 73 65 64 20 75 6e 64 is licensed und
0440: 65 72 20 74 68 65 20 3c 61 20 68 72 65 66 3d 22 er the <a href="
0450: 68 74 74 70 3a 2f 2f 77 77 77 2e 6d 6f 7a 69 6c http://www.mozil
0460: 6c 61 2e 6f 72 67 2f 4d 50 4c 2f 62 6f 69 6c 65 la.org/MPL/boile
0470: 72 70 6c 61 74 65 2d 31 2e 31 2f 6d 70 6c 2d 74 rplate-1.1/mpl-t
0480: 72 69 2d 6c 69 63 65 6e 73 65 2d 68 74 6d 6c 22 ri-license-html"
0490: 3e 4d 50 4c 20 74 72 69 2d 6c 69 63 65 6e 73 65 >MPL tri-license
04a0: 3c 2f 61 3e 20 74 65 72 6d 73 3b 20 79 6f 75 20 </a> terms; you
04b0: 61 72 65 20 66 72 65 65 20 74 6f 20 63 68 6f 6f are free to choo
04c0: 73 65 20 74 68 65 20 62 65 73 74 2d 66 69 74 20 se the best-fit
04d0: 6c 69 63 65 6e 73 65 20 62 65 74 77 65 65 6e 3a license between:
04e0: 3c 75 6c 3e 0d 0a 3c 6c 69 3e 74 68 65 20 3c 61 <ul>..<li>the <a
04f0: 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 href="http://ww
0500: 77 2e 6d 6f 7a 69 6c 6c 61 2e 6f 72 67 2f 4d 50 w.mozilla.org/MP
0510: 4c 2f 4d 50 4c 2d 31 2e 31 2e 68 74 6d 6c 22 3e L/MPL-1.1.html">
0520: 4d 50 4c 20 31 2e 31 3c 2f 61 3e 3c 2f 6c 69 3e MPL 1.1</a></li>
0530: 0d 0a 3c 6c 69 3e 74 68 65 20 3c 61 20 68 72 65 ..<li>the <a hre
0540: 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 6e f="http://www.gn
0550: 75 2e 6f 72 67 2f 6c 69 63 65 6e 73 65 73 2f 67 u.org/licenses/g
0560: 70 6c 2d 32 2e 30 2e 68 74 6d 6c 23 54 4f 43 31 pl-2.0.html#TOC1
0570: 22 3e 47 50 4c 20 76 32 2e 30 3c 2f 61 3e 20 6f ">GPL v2.0</a> o
0580: 72 20 61 6e 79 20 73 75 62 73 65 71 75 65 6e 74 r any subsequent
0590: 20 76 65 72 73 69 6f 6e 3c 2f 6c 69 3e 0d 0a 3c version</li>..<
05a0: 6c 69 3e 74 68 65 20 3c 61 20 68 72 65 66 3d 22 li>the <a href="
05b0: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 6e 75 2e 6f http://www.gnu.o
05c0: 72 67 2f 6c 69 63 65 6e 73 65 73 2f 6c 67 70 6c rg/licenses/lgpl
05d0: 2d 32 2e 31 2e 68 74 6d 6c 22 3e 4c 47 50 4c 20 -2.1.html">LGPL
05e0: 76 32 2e 31 3c 2f 61 3e 20 6f 72 20 61 6e 79 20 v2.1</a> or any
05f0: 73 75 62 73 65 71 75 65 6e 74 20 76 65 72 73 69 subsequent versi
0600: 6f 6e 3c 2f 6c 69 3e 3c 2f 75 6c 3e 0d 0a 3c 2f on</li></ul>..</
0610: 74 64 3e 0d 0a 3c 74 64 3e 0d 0a 3c 74 61 62 6c td>..<td>..<tabl
0620: 65 20 63 65 6c 6c 70 61 64 64 69 6e 67 3d 22 32 e cellpadding="2
0630: 30 22 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 53 74 72 0">..<tr><td>Str
0640: 69 63 74 6c 79 20 72 65 6c 61 74 65 64 20 3c 62 ictly related <b
0650: 3e 70 72 6f 6a 65 63 74 73 3c 2f 62 3e 3a 3c 75 >projects</b>:<u
0660: 6c 3e 0d 0a 3c 6c 69 3e 3c 61 20 68 72 65 66 3d l>..<li><a href=
0670: 22 2f 66 6f 73 73 69 6c 2f 73 70 61 74 69 61 6c "/fossil/spatial
0680: 69 74 65 2d 74 6f 6f 6c 73 22 3e 73 70 61 74 69 ite-tools">spati
0690: 61 6c 69 74 65 2d 74 6f 6f 6c 73 3c 2f 61 3e 3c alite-tools</a><
06a0: 2f 6c 69 3e 0d 0a 3c 6c 69 3e 62 61 63 6b 20 74 /li>..<li>back t
06b0: 6f 20 74 68 65 20 3c 61 20 68 72 65 66 3d 22 68 o the <a href="h
06c0: 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 ttp://www.gaia-g
06d0: 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 22 is.it/gaia-sins"
06e0: 3e 47 61 69 61 2d 53 49 4e 53 3c 2f 61 3e 20 68 >Gaia-SINS</a> h
06f0: 6f 6d 65 20 70 61 67 65 3c 2f 6c 69 3e 3c 2f 75 ome page</li></u
0700: 6c 3e 0d 0a 3c 2f 74 64 3e 3c 2f 74 72 3e 0d 0a l>..</td></tr>..
0710: 3c 74 72 3e 3c 74 64 3e 3c 62 3e 53 6f 75 72 63 <tr><td><b>Sourc
0720: 65 73 3c 2f 62 3e 3a 20 63 75 72 72 65 6e 74 20 es</b>: current
0730: 76 65 72 73 69 6f 6e 20 69 73 20 3c 62 3e 31 2e version is <b>1.
0740: 31 2e 30 61 3c 2f 62 3e 20 28 3c 69 3e 72 65 6c 1.0a</b> (<i>rel
0750: 65 61 73 65 64 20 6f 6e 20 32 30 32 30 2d 30 38 eased on 2020-08
0760: 2d 30 32 29 3c 2f 69 3e 3c 75 6c 3e 0d 0a 3c 6c -02)</i><ul>..<l
0770: 69 3e 64 6f 77 6e 6c 6f 61 64 20 3c 61 20 68 72 i>download <a hr
0780: 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 ef="http://www.g
0790: 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d aia-gis.it/gaia-
07a0: 73 69 6e 73 2f 72 65 61 64 6f 73 6d 2d 31 2e 31 sins/readosm-1.1
07b0: 2e 30 61 2e 74 61 72 2e 67 7a 22 3e 72 65 61 64 .0a.tar.gz">read
07c0: 6f 73 6d 2d 31 2e 31 2e 30 2e 74 61 72 2e 67 7a osm-1.1.0.tar.gz
07d0: 3c 2f 61 3e 20 28 74 61 72 62 61 6c 6c 2c 20 2e </a> (tarball, .
07e0: 74 61 72 2e 67 7a 29 3c 2f 6c 69 3e 0d 0a 3c 6c tar.gz)</li>..<l
07f0: 69 3e 64 6f 77 6e 6c 6f 61 64 20 3c 61 20 68 72 i>download <a hr
0800: 65 66 3d 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 ef="http://www.g
0810: 61 69 61 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d aia-gis.it/gaia-
0820: 73 69 6e 73 2f 72 65 61 64 6f 73 6d 2d 31 2e 31 sins/readosm-1.1
0830: 2e 30 61 2e 7a 69 70 22 3e 72 65 61 64 6f 73 6d .0a.zip">readosm
0840: 2d 31 2e 31 2e 30 2e 7a 69 70 3c 2f 61 3e 20 28 -1.1.0.zip</a> (
0850: 7a 69 70 66 69 6c 65 2c 20 2e 7a 69 70 29 3c 2f zipfile, .zip)</
0860: 6c 69 3e 0d 0a 3c 6c 69 3e 62 72 6f 77 73 65 20 li>..<li>browse
0870: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f <a href="http://
0880: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f www.gaia-gis.it/
0890: 67 61 69 61 2d 73 69 6e 73 2f 72 65 61 64 6f 73 gaia-sins/reados
08a0: 6d 2d 73 6f 75 72 63 65 73 22 3e 6f 6c 64 65 72 m-sources">older
08b0: 20 76 65 72 73 69 6f 6e 73 3c 2f 61 3e 3c 2f 6c versions</a></l
08c0: 69 3e 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e 3c 2f i></ul>..</td></
08d0: 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 3e 44 6f 78 tr>..<tr><td>Dox
08e0: 79 67 65 6e 20 3c 62 3e 64 6f 63 75 6d 65 6e 74 ygen <b>document
08f0: 61 74 69 6f 6e 3c 2f 62 3e 3a 3c 75 6c 3e 0d 0a ation</b>:<ul>..
0900: 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 68 74 74 <li><a href="htt
0910: 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d 67 69 73 p://www.gaia-gis
0920: 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 2f 72 65 .it/gaia-sins/re
0930: 61 64 6f 73 6d 2d 31 2e 31 2e 30 2d 64 6f 78 79 adosm-1.1.0-doxy
0940: 2d 64 6f 63 2f 69 6e 64 65 78 2e 68 74 6d 6c 22 -doc/index.html"
0950: 3e 6f 6e 6c 69 6e 65 3c 2f 61 3e 20 48 54 4d 4c >online</a> HTML
0960: 20 6f 76 65 72 76 69 65 77 20 64 6f 63 3c 2f 6c overview doc</l
0970: 69 3e 0d 0a 3c 6c 69 3e 3c 61 20 68 72 65 66 3d i>..<li><a href=
0980: 22 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 "http://www.gaia
0990: 2d 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e -gis.it/gaia-sin
09a0: 73 2f 72 65 61 64 6f 73 6d 2d 31 2e 31 2e 30 2d s/readosm-1.1.0-
09b0: 64 6f 78 79 2d 64 6f 63 2e 74 61 72 2e 67 7a 22 doxy-doc.tar.gz"
09c0: 3e 64 6f 77 6e 6c 6f 61 64 3c 2f 61 3e 20 48 54 >download</a> HT
09d0: 4d 4c 20 6f 76 65 72 76 69 65 77 20 74 61 72 62 ML overview tarb
09e0: 61 6c 6c 20 28 74 61 72 2e 67 7a 29 3c 2f 6c 69 all (tar.gz)</li
09f0: 3e 0d 0a 3c 6c 69 3e 3c 61 20 68 72 65 66 3d 22 >..<li><a href="
0a00: 68 74 74 70 3a 2f 2f 77 77 77 2e 67 61 69 61 2d http://www.gaia-
0a10: 67 69 73 2e 69 74 2f 67 61 69 61 2d 73 69 6e 73 gis.it/gaia-sins
0a20: 2f 72 65 61 64 6f 73 6d 2d 31 2e 31 2e 30 2d 64 /readosm-1.1.0-d
0a30: 6f 78 79 2d 64 6f 63 2e 7a 69 70 22 3e 64 6f 77 oxy-doc.zip">dow
0a40: 6e 6c 6f 61 64 3c 2f 61 3e 20 48 54 4d 4c 20 6f nload</a> HTML o
0a50: 76 65 72 76 69 65 77 20 7a 69 70 66 69 6c 65 20 verview zipfile
0a60: 28 7a 69 70 29 3c 2f 6c 69 3e 0d 0a 3c 6c 69 3e (zip)</li>..<li>
0a70: 3c 61 20 68 72 65 66 3d 22 68 74 74 70 3a 2f 2f <a href="http://
0a80: 77 77 77 2e 67 61 69 61 2d 67 69 73 2e 69 74 2f www.gaia-gis.it/
0a90: 67 61 69 61 2d 73 69 6e 73 2f 72 65 61 64 6f 73 gaia-sins/reados
0aa0: 6d 2d 31 2e 31 2e 30 2d 64 6f 63 2e 70 64 66 22 m-1.1.0-doc.pdf"
0ab0: 3e 50 44 46 3c 2f 61 3e 20 20 6f 66 20 66 75 6c >PDF</a> of ful
0ac0: 6c 20 64 6f 63 75 6d 65 6e 74 61 74 69 6f 6e 3c l documentation<
0ad0: 2f 6c 69 3e 3c 2f 75 6c 3e 0d 0a 3c 2f 74 64 3e /li></ul>..</td>
0ae0: 3c 2f 74 72 3e 0d 0a 3c 74 72 3e 3c 74 64 20 62 </tr>..<tr><td b
0af0: 67 63 6f 6c 6f 72 3d 22 23 65 30 66 66 39 30 22 gcolor="#e0ff90"
0b00: 3e 3c 62 3e 4c 75 61 3c 2f 62 3e 20 62 69 6e 64 ><b>Lua</b> bind
0b10: 69 6e 67 20 61 76 61 69 6c 61 62 6c 65 20 66 72 ing available fr
0b20: 6f 6d 20 3c 61 20 68 72 65 66 3d 22 68 74 74 70 om <a href="http
0b30: 73 3a 2f 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 67 s://github.com/g
0b40: 65 6f 66 66 6c 65 79 6c 61 6e 64 2f 6c 75 61 2d eoffleyland/lua-
0b50: 72 65 61 64 6f 73 6d 22 3e 68 74 74 70 73 3a 2f readosm">https:/
0b60: 2f 67 69 74 68 75 62 2e 63 6f 6d 2f 67 65 6f 66 /github.com/geof
0b70: 66 6c 65 79 6c 61 6e 64 2f 6c 75 61 2d 72 65 61 fleyland/lua-rea
0b80: 64 6f 73 6d 3c 2f 61 3e 0d 0a 3c 2f 74 64 3e 3c dosm</a>..</td><
0b90: 2f 74 72 3e 0d 0a 3c 2f 74 61 62 6c 65 3e 3c 2f /tr>..</table></
0ba0: 74 64 3e 0d 0a 3c 2f 74 72 3e 3c 2f 74 61 62 6c td>..</tr></tabl
0bb0: 65 3e 0a 5a 20 32 31 62 30 63 30 63 34 64 65 34 e>.Z 21b0c0c4de4
0bc0: 62 39 64 63 33 36 38 65 63 30 38 34 64 62 32 62 b9dc368ec084db2b
0bd0: 35 34 34 65 62 0a 544eb.