Merge tag 'debian/1.10.0-1' into stretch-backports
Bas Couwenberg
5 years ago
5 | 5 | |
6 | 6 | language: generic |
7 | 7 | |
8 | sudo: false | |
8 | dist: xenial | |
9 | 9 | |
10 | dist: trusty | |
10 | #----------------------------------------------------------------------------- | |
11 | ||
12 | # Save common build configurations as shortcuts, so we can reference them later. | |
13 | addons_shortcuts: | |
14 | addons_clang35: &clang35 | |
15 | apt: | |
16 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
17 | packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'clang-3.5'] | |
18 | addons_clang38: &clang38 | |
19 | apt: | |
20 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-3.8'] | |
21 | addons_clang39: &clang39 | |
22 | apt: | |
23 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-3.9'] | |
24 | addons_clang50: &clang50 | |
25 | apt: | |
26 | sources: ['ubuntu-toolchain-r-test'] | |
27 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-5.0'] | |
28 | addons_clang60: &clang60 | |
29 | apt: | |
30 | sources: ['ubuntu-toolchain-r-test'] | |
31 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-6.0'] | |
32 | addons_gcc48: &gcc48 | |
33 | apt: | |
34 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
35 | packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-4.8', 'gcc-4.8'] | |
36 | addons_gcc49: &gcc49 | |
37 | apt: | |
38 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
39 | packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-4.9', 'gcc-4.9'] | |
40 | addons_gcc5: &gcc5 | |
41 | apt: | |
42 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-5', 'gcc-5'] | |
43 | addons_gcc6: &gcc6 | |
44 | apt: | |
45 | sources: ['ubuntu-toolchain-r-test'] | |
46 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-6', 'gcc-6'] | |
47 | addons_gcc7: &gcc7 | |
48 | apt: | |
49 | sources: ['ubuntu-toolchain-r-test'] | |
50 | packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-7', 'gcc-7'] | |
11 | 51 | |
12 | 52 | #----------------------------------------------------------------------------- |
13 | 53 | |
14 | 54 | matrix: |
15 | 55 | include: |
16 | 56 | |
17 | # 1/ Linux Clang Builds | |
18 | - os: linux | |
19 | compiler: linux-clang35-release | |
20 | addons: | |
21 | apt: | |
22 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
23 | packages: ['clang-3.5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
24 | env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Release' | |
57 | # Linux Clang Builds | |
25 | 58 | |
26 | 59 | - os: linux |
27 | 60 | compiler: linux-clang35-dev |
28 | addons: | |
29 | apt: | |
30 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
31 | packages: ['clang-3.5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
61 | addons: *clang35 | |
32 | 62 | env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Dev' |
33 | ||
34 | ||
35 | - os: linux | |
36 | compiler: linux-clang38-release | |
37 | addons: | |
38 | apt: | |
39 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
40 | packages: ['clang-3.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
41 | env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Release' | |
63 | dist: trusty | |
42 | 64 | |
43 | 65 | - os: linux |
44 | 66 | compiler: linux-clang38-dev |
45 | addons: | |
46 | apt: | |
47 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
48 | packages: ['clang-3.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
67 | addons: *clang38 | |
49 | 68 | env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Dev' |
50 | ||
51 | ||
52 | - os: linux | |
53 | compiler: linux-clang39-release | |
54 | addons: | |
55 | apt: | |
56 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
57 | packages: ['clang-3.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
58 | env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Release' | |
59 | 69 | |
60 | 70 | - os: linux |
61 | 71 | compiler: linux-clang39-dev |
62 | addons: | |
63 | apt: | |
64 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
65 | packages: ['clang-3.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
72 | addons: *clang39 | |
66 | 73 | env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Dev' |
67 | ||
68 | ||
69 | - os: linux | |
70 | compiler: linux-clang40-release | |
71 | addons: | |
72 | apt: | |
73 | sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test', 'boost-latest'] | |
74 | packages: ['clang-4.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
75 | env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Release' | |
76 | ||
77 | - os: linux | |
78 | compiler: linux-clang40-dev | |
79 | addons: | |
80 | apt: | |
81 | sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test', 'boost-latest'] | |
82 | packages: ['clang-4.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
83 | env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Dev' | |
84 | ||
85 | ||
86 | - os: linux | |
87 | compiler: linux-clang50-release | |
88 | addons: | |
89 | apt: | |
90 | sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest'] | |
91 | packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
92 | env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Release' | |
93 | 74 | |
94 | 75 | - os: linux |
95 | 76 | compiler: linux-clang50-dev |
96 | addons: | |
97 | apt: | |
98 | sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest'] | |
99 | packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
77 | addons: *clang50 | |
100 | 78 | env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Dev' |
101 | 79 | |
102 | # Disabled because it creates false-positives on the old travis systems | |
103 | # - os: linux | |
104 | # compiler: linux-clang50-debug | |
105 | # addons: | |
106 | # apt: | |
107 | # sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest'] | |
108 | # packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-6', 'gcc-6'] | |
109 | # env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Debug' | |
80 | - os: linux | |
81 | compiler: linux-clang60-dev | |
82 | addons: *clang60 | |
83 | env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Dev' | |
84 | ||
85 | # Disabled, because it is triggered by the rapidjson library | |
86 | # - os: linux | |
87 | # compiler: linux-clang60-debug | |
88 | # addons: *clang60 | |
89 | # env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Debug' | |
110 | 90 | # CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer" |
111 | 91 | # LDFLAGS="-fsanitize=address,undefined,integer" |
112 | # # LSAN doesn't work on container-based system | |
113 | # sudo: required | |
92 | ||
93 | - os: linux | |
94 | compiler: linux-clang60-release | |
95 | addons: *clang60 | |
96 | env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Release' | |
114 | 97 | |
115 | 98 | |
116 | # 2/ Linux GCC Builds | |
117 | - os: linux | |
118 | compiler: linux-gcc48-release | |
119 | addons: | |
120 | apt: | |
121 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
122 | packages: ['g++-4.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
123 | env: CC='gcc-4.8' CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Release' | |
99 | # Linux GCC Builds | |
124 | 100 | |
125 | 101 | - os: linux |
126 | 102 | compiler: linux-gcc48-dev |
127 | addons: | |
128 | apt: | |
129 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
130 | packages: ['g++-4.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
103 | addons: *gcc48 | |
131 | 104 | env: CC='gcc-4.8' CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Dev' |
132 | ||
133 | ||
134 | - os: linux | |
135 | compiler: linux-gcc49-release | |
136 | addons: | |
137 | apt: | |
138 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
139 | packages: ['g++-4.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
140 | env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Release' | |
105 | dist: trusty | |
141 | 106 | |
142 | 107 | - os: linux |
143 | 108 | compiler: linux-gcc49-dev |
144 | addons: | |
145 | apt: | |
146 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
147 | packages: ['g++-4.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
109 | addons: *gcc49 | |
148 | 110 | env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Dev' |
149 | ||
150 | ||
151 | - os: linux | |
152 | compiler: linux-gcc5-release | |
153 | addons: | |
154 | apt: | |
155 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
156 | packages: ['g++-5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
157 | env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Release' | |
111 | dist: trusty | |
158 | 112 | |
159 | 113 | - os: linux |
160 | 114 | compiler: linux-gcc5-dev |
161 | addons: | |
162 | apt: | |
163 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
164 | packages: ['g++-5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
115 | addons: *gcc5 | |
165 | 116 | env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Dev' |
166 | ||
167 | ||
168 | - os: linux | |
169 | compiler: linux-gcc6-release | |
170 | addons: | |
171 | apt: | |
172 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
173 | packages: ['g++-6', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
174 | env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Release' | |
175 | 117 | |
176 | 118 | - os: linux |
177 | 119 | compiler: linux-gcc6-dev |
178 | addons: | |
179 | apt: | |
180 | sources: ['ubuntu-toolchain-r-test', 'boost-latest'] | |
181 | packages: ['g++-6', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc'] | |
120 | addons: *gcc6 | |
182 | 121 | env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Dev' |
183 | 122 | |
123 | - os: linux | |
124 | compiler: linux-gcc7-dev | |
125 | addons: *gcc7 | |
126 | env: CC='gcc-7' CXX='g++-7' BUILD_TYPE='Dev' | |
184 | 127 | |
185 | # 3/ OSX Clang Builds | |
186 | - os: osx | |
187 | osx_image: xcode6.4 | |
188 | compiler: xcode64-clang-release | |
189 | env: CXX='clang++' BUILD_TYPE='Release' | |
190 | ||
191 | - os: osx | |
192 | osx_image: xcode6.4 | |
193 | compiler: xcode64-clang-dev | |
194 | env: CXX='clang++' BUILD_TYPE='Dev' | |
128 | - os: linux | |
129 | compiler: linux-gcc7-release | |
130 | addons: *gcc7 | |
131 | env: CC='gcc-7' CXX='g++-7' BUILD_TYPE='Release' | |
195 | 132 | |
196 | 133 | |
197 | - os: osx | |
198 | osx_image: xcode7 | |
199 | compiler: xcode7-clang-release | |
200 | env: CXX='clang++' BUILD_TYPE='Release' | |
201 | ||
202 | - os: osx | |
203 | osx_image: xcode7 | |
204 | compiler: xcode7-clang-dev | |
205 | env: CXX='clang++' BUILD_TYPE='Dev' | |
206 | ||
207 | ||
208 | - os: osx | |
209 | osx_image: xcode8.3 | |
210 | compiler: xcode8-clang-release | |
211 | env: CXX='clang++' BUILD_TYPE='Release' | |
134 | # OSX Clang Builds | |
212 | 135 | |
213 | 136 | - os: osx |
214 | 137 | osx_image: xcode8.3 |
215 | 138 | compiler: xcode8-clang-dev |
139 | env: CXX='clang++' BUILD_TYPE='Dev' | |
140 | ||
141 | - os: osx | |
142 | osx_image: xcode9.4 | |
143 | compiler: xcode9-clang-dev | |
144 | env: CXX='clang++' BUILD_TYPE='Dev' | |
145 | ||
146 | - os: osx | |
147 | osx_image: xcode10.1 | |
148 | compiler: xcode10-clang-release | |
149 | env: CXX='clang++' BUILD_TYPE='Release' | |
150 | ||
151 | - os: osx | |
152 | osx_image: xcode10.1 | |
153 | compiler: xcode10-clang-dev | |
216 | 154 | env: CXX='clang++' BUILD_TYPE='Dev' |
217 | 155 | |
218 | 156 | #----------------------------------------------------------------------------- |
10 | 10 | ### Changed |
11 | 11 | |
12 | 12 | ### Fixed |
13 | ||
14 | ||
15 | ## [1.10.0] - 2018-12-10 | |
16 | ||
17 | ### Added | |
18 | ||
19 | * The `fileinfo` command now has an `--object-type`/`-t` option like some | |
20 | other commands. | |
21 | * Extended `fileinfo` command to show internal buffer counts and sizes. | |
22 | * Add `--strategy` option to `sort` command. New `multipass` strategy which | |
23 | reads the input file(s) three times making the sort a bit slower, but also | |
24 | using less memory. | |
25 | * New option `--remove-tags`/`-t` to `tags-filter` command. When used the | |
26 | tags of all objects that are not matching the filter expression but are | |
27 | included as references are removed. | |
28 | * New option for smart extract strategy: `complete-partial-relations=X` will | |
29 | complete all relations with at least X percent of their members already in | |
30 | the extract. | |
31 | * New export format "pg" creates a file in the PostgreSQL COPY text format | |
32 | with the GEOMETRY as WKB and the tags in JSON(B) format. This can be | |
33 | imported into a PostgreSQL/PostGIS database very quickly. | |
34 | ||
35 | ### Changed | |
36 | ||
37 | * Show better error message if output directory is missing for `extract` | |
38 | command. | |
39 | ||
40 | ### Fixed | |
41 | ||
42 | * Several fixes for the `tags-filter` command which could lead to wrong | |
43 | results. | |
13 | 44 | |
14 | 45 | |
15 | 46 | ## [1.9.1] - 2018-08-18 |
443 | 474 | - Minor updates to documentation and build system |
444 | 475 | |
445 | 476 | |
446 | [unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.9.1...HEAD | |
477 | [unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.10.0...HEAD | |
478 | [1.10.0]: https://github.com/osmcode/osmium-tool/compare/v1.9.1...v1.10.0 | |
447 | 479 | [1.9.1]: https://github.com/osmcode/osmium-tool/compare/v1.9.0...v1.9.1 |
448 | 480 | [1.9.0]: https://github.com/osmcode/osmium-tool/compare/v1.8.0...v1.9.0 |
449 | 481 | [1.8.0]: https://github.com/osmcode/osmium-tool/compare/v1.7.1...v1.8.0 |
24 | 24 | project(osmium) |
25 | 25 | |
26 | 26 | set(OSMIUM_VERSION_MAJOR 1) |
27 | set(OSMIUM_VERSION_MINOR 9) | |
28 | set(OSMIUM_VERSION_PATCH 1) | |
27 | set(OSMIUM_VERSION_MINOR 10) | |
28 | set(OSMIUM_VERSION_PATCH 0) | |
29 | 29 | |
30 | 30 | set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERSION_PATCH}) |
31 | 31 | |
43 | 43 | find_package(Boost 1.55.0 REQUIRED COMPONENTS program_options) |
44 | 44 | include_directories(SYSTEM ${Boost_INCLUDE_DIRS}) |
45 | 45 | |
46 | find_package(Osmium 2.14.2 REQUIRED COMPONENTS io) | |
46 | find_package(Osmium 2.15.0 REQUIRED COMPONENTS io) | |
47 | 47 | include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS}) |
48 | 48 | |
49 | 49 | |
230 | 230 | util.cpp |
231 | 231 | command_help.cpp |
232 | 232 | export/export_format_json.cpp |
233 | export/export_format_pg.cpp | |
233 | 234 | export/export_format_text.cpp |
234 | 235 | export/export_handler.cpp |
235 | 236 | extract/extract_bbox.cpp |
15 | 15 | |
16 | 16 | You also need the following libraries: |
17 | 17 | |
18 | Libosmium (>= 2.14.2) | |
18 | Libosmium (>= 2.15.0) | |
19 | 19 | https://osmcode.org/libosmium |
20 | 20 | Debian/Ubuntu: libosmium2-dev |
21 | 21 | Fedora/CentOS: libosmium-devel |
107 | 107 | Please read the CMake documentation and get familiar with the `cmake` and |
108 | 108 | `ccmake` tools which have many more options. |
109 | 109 | |
110 | On Windows you can compile with the Visual Studio C++ compiler using the | |
111 | batch script `build-local.bat`. This script calls `build-appveyor.bat` | |
112 | which downloads some precompiled libraries. You can also download and | |
113 | compile all the prerequisites yourself. | |
110 | On Windows you can compile with the Visual Studio C++ compiler and nmake. | |
111 | The necessary dependencies can be installed with [conda](https://conda.io). | |
112 | See `appveyor.yml` for the necessary commands to compile osmium-tool. | |
114 | 113 | |
115 | 114 | |
116 | 115 | ## Documentation |
70 | 70 | |
71 | 71 | # Check libosmium version number |
72 | 72 | if(Osmium_FIND_VERSION) |
73 | if(NOT EXISTS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp") | |
74 | message(FATAL_ERROR "Missing ${OSMIUM_INCLUDE_DIR}/osmium/version.hpp. Either your libosmium version is too old, or libosmium wasn't found in the place you said.") | |
75 | endif() | |
73 | 76 | file(STRINGS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp" _libosmium_version_define REGEX "#define LIBOSMIUM_VERSION_STRING") |
74 | 77 | if("${_libosmium_version_define}" MATCHES "#define LIBOSMIUM_VERSION_STRING \"([0-9.]+)\"") |
75 | 78 | set(_libosmium_version "${CMAKE_MATCH_1}") |
0 | osmium-tool (1.10.0-1) unstable; urgency=medium | |
1 | ||
2 | * New upstream release. | |
3 | * Drop patches, included upstream. | |
4 | ||
5 | -- Bas Couwenberg <sebastic@debian.org> Mon, 10 Dec 2018 16:54:26 +0100 | |
6 | ||
7 | osmium-tool (1.9.1-2) unstable; urgency=medium | |
8 | ||
9 | * Bump Standards-Version to 4.2.1, no changes. | |
10 | * Add upstream patches to fix FTBFS with libosmium 2.15.0. | |
11 | (closes: #916109) | |
12 | * Bump minimum required libosmium2-dev to 2.15.0. | |
13 | ||
14 | -- Bas Couwenberg <sebastic@debian.org> Mon, 10 Dec 2018 12:20:36 +0100 | |
15 | ||
0 | 16 | osmium-tool (1.9.1-1~bpo9+1) stretch-backports; urgency=medium |
1 | 17 | |
2 | 18 | * Rebuild for stretch-backports. |
8 | 8 | libboost-program-options-dev, |
9 | 9 | libbz2-dev, |
10 | 10 | libexpat1-dev, |
11 | libosmium2-dev (>= 2.14.2), | |
11 | libosmium2-dev (>= 2.15.0), | |
12 | 12 | pandoc, |
13 | 13 | zlib1g-dev |
14 | Standards-Version: 4.2.0 | |
14 | Standards-Version: 4.2.1 | |
15 | 15 | Vcs-Browser: https://salsa.debian.org/debian-gis-team/osmium-tool/ |
16 | 16 | Vcs-Git: https://salsa.debian.org/debian-gis-team/osmium-tool.git -b stretch-backports |
17 | 17 | Homepage: https://osmcode.org/osmium-tool/ |
0 | 0 | { |
1 | "directory": "/tmp/", | |
1 | "directory": "/tmp/foobar", | |
2 | 2 | "extracts": [ |
3 | 3 | { |
4 | 4 | "output": "dresden.osm.pbf", |
286 | 286 | * `geojsonseq` (alias: `jsonseq`): GeoJSON Text Sequence (RFC8142). Each line |
287 | 287 | (beginning with a RS (0x1e, record separator) and ending in a linefeed |
288 | 288 | character) contains one GeoJSON object. Used for streaming GeoJSON. |
289 | * `pg`: PostgreSQL COPY text format. One line per object containing the | |
290 | WGS84 geometry as WKB, the tags in JSON format and, optionally, more columns | |
291 | for id and attributes. You have to create the table manually, then use the | |
292 | PostgreSQL COPY command to import the data. Enable verbose output to see | |
293 | the SQL commands needed to create the table and load the data. | |
289 | 294 | * `text` (alias: `txt`): A simple text format with the geometry in WKT format |
290 | 295 | followed by the comma-delimited tags. This is mainly intended for debugging |
291 | 296 | at the moment. THE FORMAT MIGHT CHANGE WITHOUT NOTICE! |
328 | 328 | relations can be huge, so if you include them, be aware your result might be |
329 | 329 | huge. |
330 | 330 | |
331 | The **smart** strategy allows another option "-S complete-partial-relations=X". | |
332 | If this is set, all relations that have more than X percent of their members | |
333 | already in the extract will have their full set of members in the extract. So | |
334 | this allows completing almost complete relations. It can be useful for instance | |
335 | to make sure a boundary relation is complete even if some of it is outside the | |
336 | polygon used for extraction. | |
337 | ||
331 | 338 | |
332 | 339 | # DIAGNOSTICS |
333 | 340 | |
351 | 358 | extracts times the highest node ID used divided by 8. For the *complete_ways* |
352 | 359 | twice that and for the *smart* strategy a bit more. |
353 | 360 | |
361 | If you want to split a large file into many extracts, do this in several | |
362 | steps. First create several larger extracts and then split them again and | |
363 | again into smaller pieces. | |
364 | ||
354 | 365 | |
355 | 366 | # EXAMPLES |
356 | 367 |
71 | 71 | -j, --json |
72 | 72 | : Output in JSON format. Can not be used together with --get. |
73 | 73 | |
74 | -t, --object-type=TYPE | |
75 | : Read only objects of given type (*node*, *way*, *relation*, *changeset*). | |
76 | By default all types are read. This option can be given multiple times. | |
77 | This only takes effect if the **--extended** option is also used. | |
78 | ||
74 | 79 | @MAN_COMMON_OPTIONS@ |
75 | 80 | @MAN_PROGRESS_OPTIONS@ |
76 | 81 | @MAN_INPUT_OPTIONS@ |
110 | 115 | data.maxid.ways - INTEGER |
111 | 116 | data.maxid.relations - INTEGER |
112 | 117 | data.maxid.changesets - INTEGER |
118 | data.buffers.count - INTEGER | |
119 | data.buffers.size - INTEGER | |
120 | data.buffers.capcity - INTEGER | |
113 | 121 | metadata.all_objects.version - BOOL (yes|no) |
114 | 122 | metadata.all_objects.timestamp - BOOL (yes|no) |
115 | 123 | metadata.all_objects.changeset - BOOL (yes|no) |
28 | 28 | |
29 | 29 | This commands reads its input file(s) only once and writes its output file |
30 | 30 | in one go so it can be streamed, ie. it can read from STDIN and write to |
31 | STDOUT. | |
31 | STDOUT. (Unless the *multipass* strategy is used.) | |
32 | ||
33 | # OPTIONS | |
34 | ||
35 | -s, --strategy=STRATEGY | |
36 | : Sorting strategy. The "simple" strategy reads all input files into memory, | |
37 | does the sorting and writes everything out. The "multipass" strategy reads | |
38 | the input files in three passes, one for nodes, one for ways, and one for | |
39 | relations. After reading all objects of each type, they are sorted and | |
40 | written out. This is a bit slower than the "simple" strategy, but uses | |
41 | less memory. The "multi" strategy doesn't work when reading from STDIN. | |
42 | Default: "simple". | |
32 | 43 | |
33 | 44 | |
34 | 45 | @MAN_COMMON_OPTIONS@ |
34 | 34 | |
35 | 35 | -e FILE, --expressions=FILE |
36 | 36 | : Read expressions from the specified file, one per line. Empty lines are |
37 | ignored. Everything after the comment character (#) is also ignored. The | |
37 | ignored. Everything after the comment character (#) is also ignored. See | |
38 | 38 | the **FILTER EXPRESSIONS** section for further details. |
39 | 39 | |
40 | 40 | -i, --invert-match |
43 | 43 | -R, --omit-referenced |
44 | 44 | : Omit the nodes referenced from matching ways and members referenced from |
45 | 45 | matching relations. |
46 | ||
47 | -t, --remove-tags | |
48 | : Remove tags from objects that are not matching the filter expression but | |
49 | are included to complete references (nodes in ways and members of | |
50 | relations). If an object is both matching the filter and used as a | |
51 | reference it will keep its tags. | |
46 | 52 | |
47 | 53 | @MAN_COMMON_OPTIONS@ |
48 | 54 | @MAN_PROGRESS_OPTIONS@ |
20 | 20 | : Allow an existing output file to be overwritten. Normally **osmium** will |
21 | 21 | refuse to write over an existing file. |
22 | 22 | |
23 | --output-header=OPTION | |
24 | : Add output header option. This option can be given several times. See the | |
25 | *libosmium manual* for a list of allowed header options. | |
23 | --output-header=OPTION=VALUE | |
24 | : Add output header option. This command line option can be used multiple | |
25 | times for different OPTIONs. See the *libosmium manual* for a list of | |
26 | available header options. |
29 | 29 | #include <cstdlib> |
30 | 30 | #include <iostream> |
31 | 31 | |
32 | po::options_description Command::add_common_options(bool with_progress) { | |
33 | po::options_description options("COMMON OPTIONS"); | |
32 | po::options_description Command::add_common_options(const bool with_progress) { | |
33 | po::options_description options{"COMMON OPTIONS"}; | |
34 | 34 | |
35 | 35 | auto opts = options.add_options() |
36 | 36 | ("help,h", "Show usage help") |
86 | 86 | } else if (t == "c" || t == "changeset") { |
87 | 87 | m_osm_entity_bits |= osmium::osm_entity_bits::changeset; |
88 | 88 | } else { |
89 | throw argument_error{std::string{"Unknown object type '"} + t + "' (Allowed are 'node', 'way', 'relation', and 'changeset')."}; | |
89 | throw argument_error{std::string{"Unknown object type '"} | |
90 | + t | |
91 | + "' (Allowed are 'node', 'way', 'relation', and 'changeset')."}; | |
90 | 92 | } |
91 | 93 | } |
92 | 94 | } else { |
23 | 23 | */ |
24 | 24 | |
25 | 25 | #include <osmium/io/file.hpp> |
26 | #include <osmium/io/header.hpp> | |
26 | 27 | #include <osmium/io/writer_options.hpp> |
27 | 28 | #include <osmium/osm/entity_bits.hpp> |
28 | 29 | #include <osmium/util/file.hpp> |
40 | 41 | const char* get_osmium_version() noexcept; |
41 | 42 | const char* get_osmium_long_version() noexcept; |
42 | 43 | const char* get_libosmium_version() noexcept; |
43 | ||
44 | namespace osmium { | |
45 | ||
46 | namespace io { | |
47 | class Header; | |
48 | } // namespace io | |
49 | ||
50 | } // namespace osmium | |
51 | 44 | |
52 | 45 | class CommandFactory; |
53 | 46 |
26 | 26 | |
27 | 27 | #include <osmium/handler/node_locations_for_ways.hpp> |
28 | 28 | #include <osmium/index/map/all.hpp> |
29 | ||
30 | namespace osmium { | |
31 | ||
32 | namespace io { | |
33 | class Reader; | |
34 | class Writer; | |
35 | } // namespace io | |
36 | ||
37 | class ProgressBar; | |
38 | ||
39 | } // namespace osmium | |
29 | #include <osmium/io/reader.hpp> | |
30 | #include <osmium/io/writer.hpp> | |
31 | #include <osmium/util/progress_bar.hpp> | |
40 | 32 | |
41 | 33 | #include <string> |
42 | 34 | #include <vector> |
46 | 38 | |
47 | 39 | class CommandAddLocationsToWays : public Command, public with_multiple_osm_inputs, public with_osm_output { |
48 | 40 | |
49 | void copy_data(osmium::ProgressBar& progress_bar, osmium::io::Reader& reader, osmium::io::Writer& writer, location_handler_type& location_handler); | |
50 | ||
51 | 41 | std::string m_index_type_name; |
52 | 42 | bool m_keep_untagged_nodes = false; |
53 | 43 | bool m_ignore_missing_nodes = false; |
44 | ||
45 | void copy_data(osmium::ProgressBar& progress_bar, osmium::io::Reader& reader, osmium::io::Writer& writer, location_handler_type& location_handler); | |
54 | 46 | |
55 | 47 | public: |
56 | 48 |
33 | 33 | |
34 | 34 | class CommandChangesetFilter : public Command, public with_single_osm_input, public with_osm_output { |
35 | 35 | |
36 | std::string m_user; | |
37 | osmium::Box m_box; | |
38 | osmium::Timestamp m_after = osmium::start_of_time(); | |
39 | osmium::Timestamp m_before = osmium::end_of_time(); | |
40 | osmium::user_id_type m_uid = 0; | |
41 | ||
36 | 42 | bool m_with_discussion = false; |
37 | 43 | bool m_without_discussion = false; |
38 | 44 | bool m_with_changes = false; |
39 | 45 | bool m_without_changes = false; |
40 | 46 | bool m_open = false; |
41 | 47 | bool m_closed = false; |
42 | osmium::user_id_type m_uid = 0; | |
43 | std::string m_user; | |
44 | osmium::Timestamp m_after = osmium::start_of_time(); | |
45 | osmium::Timestamp m_before = osmium::end_of_time(); | |
46 | osmium::Box m_box; | |
47 | 48 | |
48 | 49 | public: |
49 | 50 |
24 | 24 | |
25 | 25 | #include "cmd.hpp" // IWYU pragma: export |
26 | 26 | |
27 | #include <osmium/io/writer.hpp> | |
27 | 28 | #include <osmium/memory/buffer.hpp> |
28 | ||
29 | namespace osmium { | |
30 | ||
31 | namespace io { | |
32 | class Writer; | |
33 | } // namespace io | |
34 | ||
35 | class OSMObject; | |
36 | ||
37 | } // namespace osmium | |
29 | #include <osmium/osm/object.hpp> | |
38 | 30 | |
39 | 31 | #include <string> |
40 | 32 | #include <vector> |
24 | 24 | #include "util.hpp" |
25 | 25 | |
26 | 26 | #include "export/export_format_json.hpp" |
27 | #include "export/export_format_pg.hpp" | |
27 | 28 | #include "export/export_format_text.hpp" |
28 | 29 | #include "export/export_handler.hpp" |
29 | 30 | |
194 | 195 | |
195 | 196 | void CommandExport::canonicalize_output_format() { |
196 | 197 | for (auto& c : m_output_format) { |
197 | c = std::tolower(c); | |
198 | c = static_cast<char>(std::tolower(c)); | |
198 | 199 | } |
199 | 200 | |
200 | 201 | if (m_output_format == "json") { |
364 | 365 | |
365 | 366 | canonicalize_output_format(); |
366 | 367 | |
367 | if (m_output_format != "geojson" && m_output_format != "geojsonseq" && m_output_format != "text") { | |
368 | throw argument_error{"Set output format with --output-format or -f to 'geojson', 'geojsonseq', or 'text'."}; | |
368 | if (m_output_format != "geojson" && m_output_format != "geojsonseq" && m_output_format != "pg" && m_output_format != "text") { | |
369 | throw argument_error{"Set output format with --output-format or -f to 'geojson', 'geojsonseq', 'pg', or 'text'."}; | |
369 | 370 | } |
370 | 371 | |
371 | 372 | if (vm.count("overwrite")) { |
489 | 490 | return std::unique_ptr<ExportFormat>{new ExportFormatJSON{output_format, output_filename, overwrite, fsync, options}}; |
490 | 491 | } |
491 | 492 | |
493 | if (output_format == "pg") { | |
494 | return std::unique_ptr<ExportFormat>{new ExportFormatPg{output_format, output_filename, overwrite, fsync, options}}; | |
495 | } | |
496 | ||
492 | 497 | if (output_format == "text") { |
493 | 498 | return std::unique_ptr<ExportFormat>{new ExportFormatText{output_format, output_filename, overwrite, fsync, options}}; |
494 | 499 | } |
510 | 515 | m_area_ruleset.init_filter(); |
511 | 516 | |
512 | 517 | auto handler = create_handler(m_output_format, m_output_filename, m_output_overwrite, m_fsync, m_options); |
518 | if (m_vout.verbose()) { | |
519 | handler->debug_output(m_vout, m_output_filename); | |
520 | } | |
521 | ||
513 | 522 | ExportHandler export_handler{std::move(handler), m_linear_ruleset, m_area_ruleset, m_geometry_types, m_show_errors, m_stop_on_error}; |
514 | 523 | osmium::handler::CheckOrder check_order_handler; |
515 | 524 |
55 | 55 | #include <iostream> |
56 | 56 | #include <memory> |
57 | 57 | #include <string> |
58 | #include <sys/stat.h> | |
59 | #include <sys/types.h> | |
58 | 60 | #include <vector> |
61 | ||
62 | #ifdef _WIN32 | |
63 | # ifndef WIN32_LEAN_AND_MEAN | |
64 | # define WIN32_LEAN_AND_MEAN // Prevent winsock.h inclusion; avoid winsock2.h conflict | |
65 | # endif | |
66 | # include <io.h> | |
67 | #endif | |
68 | ||
69 | #ifndef _MSC_VER | |
70 | # include <unistd.h> | |
71 | #endif | |
59 | 72 | |
60 | 73 | namespace { |
61 | 74 | |
196 | 209 | |
197 | 210 | } // anonymous namespace |
198 | 211 | |
212 | static bool is_existing_directory(const char* name) { | |
213 | #ifdef _MSC_VER | |
214 | // Windows implementation | |
215 | // https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx | |
216 | struct _stat64 s{}; | |
217 | if (::_stati64(name, &s) != 0) { | |
218 | return false; | |
219 | } | |
220 | return s.st_mode & _S_IFDIR; | |
221 | #else | |
222 | // Unix implementation | |
223 | struct stat s; // NOLINT clang-tidy | |
224 | if (::stat(name, &s) != 0) { | |
225 | return false; | |
226 | } | |
227 | return S_ISDIR(s.st_mode); // NOLINT(hicpp-signed-bitwise) | |
228 | #endif | |
229 | } | |
230 | ||
199 | 231 | void CommandExtract::set_directory(const std::string& directory) { |
232 | if (!is_existing_directory(directory.c_str())) { | |
233 | throw config_error{"Output directory is missing or not accessible: " + directory}; | |
234 | } | |
200 | 235 | m_output_directory = directory; |
201 | 236 | if (m_output_directory.empty() || m_output_directory.back() != '/') { |
202 | 237 | m_output_directory += '/'; |
38 | 38 | |
39 | 39 | static const std::size_t initial_buffer_size = 10 * 1024; |
40 | 40 | |
41 | std::vector<std::unique_ptr<Extract>> m_extracts; | |
42 | osmium::Options m_options; | |
41 | 43 | std::string m_config_file_name; |
42 | 44 | std::string m_config_directory; |
43 | 45 | std::string m_output_directory; |
44 | osmium::Options m_options; | |
45 | 46 | std::string m_strategy_name; |
47 | osmium::memory::Buffer m_buffer{initial_buffer_size, osmium::memory::Buffer::auto_grow::yes}; | |
46 | 48 | std::unique_ptr<ExtractStrategy> m_strategy; |
47 | std::vector<std::unique_ptr<Extract>> m_extracts; | |
48 | osmium::memory::Buffer m_buffer{initial_buffer_size, osmium::memory::Buffer::auto_grow::yes}; | |
49 | 49 | bool m_with_history = false; |
50 | 50 | bool m_set_bounds = false; |
51 | 51 |
45 | 45 | #include <boost/program_options.hpp> |
46 | 46 | |
47 | 47 | #include <algorithm> |
48 | #include <cmath> | |
48 | 49 | #include <cstdint> |
49 | 50 | #include <iostream> |
50 | 51 | #include <iterator> |
69 | 70 | uint64_t ways = 0; |
70 | 71 | uint64_t relations = 0; |
71 | 72 | |
73 | uint64_t buffers_count = 0; | |
74 | uint64_t buffers_size = 0; | |
75 | uint64_t buffers_capacity = 0; | |
76 | ||
72 | 77 | osmium::min_op<osmium::object_id_type> smallest_changeset_id{}; |
73 | 78 | osmium::min_op<osmium::object_id_type> smallest_node_id{}; |
74 | 79 | osmium::min_op<osmium::object_id_type> smallest_way_id{}; |
286 | 291 | |
287 | 292 | std::cout << " All objects have following metadata attributes: " << info_handler.metadata_all_objects << "\n"; |
288 | 293 | std::cout << " Some objects have following metadata attributes: " << info_handler.metadata_some_objects << "\n"; |
294 | ||
295 | const auto num_objects = info_handler.changesets + info_handler.nodes + info_handler.ways + info_handler.relations; | |
296 | std::cout << " Number of buffers: " << info_handler.buffers_count; | |
297 | if (num_objects != 0) { | |
298 | std::cout << " (avg " << (num_objects / info_handler.buffers_count) << " objects per buffer)\n"; | |
299 | } else { | |
300 | std::cout << '\n'; | |
301 | } | |
302 | ||
303 | const auto buffers_size = static_cast<double>(info_handler.buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
304 | std::cout << " Sum of buffer sizes: " << info_handler.buffers_size << " (" << buffers_size << " GB)\n"; | |
305 | ||
306 | const auto buffers_capacity= static_cast<double>(info_handler.buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
307 | ||
308 | if (info_handler.buffers_capacity != 0) { | |
309 | const auto fill_factor = std::round(100 * static_cast<double>(info_handler.buffers_size) / static_cast<double>(info_handler.buffers_capacity)); | |
310 | std::cout << " Sum of buffer capacities: " << info_handler.buffers_capacity << " (" << buffers_capacity << " GB, " << fill_factor << "% full)\n"; | |
311 | } else { | |
312 | std::cout << " Sum of buffer capacities: 0 (0 GB)\n"; | |
313 | } | |
289 | 314 | } |
290 | 315 | |
291 | 316 | }; // class HumanReadableOutput |
429 | 454 | m_writer.Int64(get_largest(info_handler.largest_way_id())); |
430 | 455 | m_writer.String("relations"); |
431 | 456 | m_writer.Int64(get_largest(info_handler.largest_relation_id())); |
457 | m_writer.EndObject(); | |
458 | ||
459 | m_writer.String("buffers"); | |
460 | m_writer.StartObject(); | |
461 | m_writer.String("count"); | |
462 | m_writer.Int64(get_largest(info_handler.buffers_count)); | |
463 | m_writer.String("size"); | |
464 | m_writer.Int64(get_largest(info_handler.buffers_size)); | |
465 | m_writer.String("capacity"); | |
466 | m_writer.Int64(get_largest(info_handler.buffers_capacity)); | |
432 | 467 | m_writer.EndObject(); |
433 | 468 | |
434 | 469 | m_writer.String("metadata"); |
613 | 648 | return; |
614 | 649 | } |
615 | 650 | |
651 | if (m_get_value == "data.buffers.count") { | |
652 | std::cout << info_handler.buffers_count << "\n"; | |
653 | return; | |
654 | } | |
655 | if (m_get_value == "data.buffers.size") { | |
656 | std::cout << info_handler.buffers_size << "\n"; | |
657 | return; | |
658 | } | |
659 | if (m_get_value == "data.buffers.capacity") { | |
660 | std::cout << info_handler.buffers_capacity << "\n"; | |
661 | return; | |
662 | } | |
663 | ||
616 | 664 | if (m_get_value == "metadata.all_objects.version") { |
617 | 665 | std::cout << (info_handler.metadata_all_objects.version() ? "yes\n" : "no\n"); |
618 | 666 | return; |
669 | 717 | ("json,j", "JSON output") |
670 | 718 | ("crc,c", "Calculate CRC") |
671 | 719 | ("no-crc", "Do not calculate CRC") |
720 | ("object-type,t", po::value<std::vector<std::string>>(), "Read only objects of given type (node, way, relation, changeset)") | |
672 | 721 | ; |
673 | 722 | |
674 | 723 | po::options_description opts_common{add_common_options()}; |
694 | 743 | |
695 | 744 | setup_common(vm, desc); |
696 | 745 | setup_progress(vm); |
746 | setup_object_type_nwrc(vm); | |
697 | 747 | |
698 | 748 | if (vm.count("extended")) { |
699 | 749 | m_extended = true; |
742 | 792 | "data.maxid.ways", |
743 | 793 | "data.maxid.relations", |
744 | 794 | "data.maxid.changesets", |
795 | "data.buffers.count", | |
796 | "data.buffers.size", | |
797 | "data.buffers.capacity", | |
745 | 798 | "metadata.all_objects.version", |
746 | 799 | "metadata.all_objects.timestamp", |
747 | 800 | "metadata.all_objects.changeset", |
790 | 843 | show_single_input_arguments(m_vout); |
791 | 844 | |
792 | 845 | m_vout << " other options:\n"; |
846 | show_object_types(m_vout); | |
793 | 847 | m_vout << " extended output: " << (m_extended ? "yes\n" : "no\n"); |
794 | 848 | m_vout << " calculate CRC: " << (m_calculate_crc ? "yes\n" : "no\n"); |
795 | 849 | } |
807 | 861 | output->set_crc(m_calculate_crc); |
808 | 862 | output->file(m_input_filename, m_input_file); |
809 | 863 | |
810 | osmium::io::Reader reader{m_input_file, m_extended ? osmium::osm_entity_bits::all : osmium::osm_entity_bits::nothing}; | |
864 | osmium::io::Reader reader{m_input_file, m_extended ? osm_entity_bits() : osmium::osm_entity_bits::nothing}; | |
811 | 865 | osmium::io::Header header{reader.header()}; |
812 | 866 | output->header(header); |
813 | 867 | |
816 | 870 | osmium::ProgressBar progress_bar{reader.file_size(), display_progress()}; |
817 | 871 | while (osmium::memory::Buffer buffer = reader.read()) { |
818 | 872 | progress_bar.update(reader.offset()); |
873 | ++info_handler.buffers_count; | |
874 | info_handler.buffers_size += buffer.committed(); | |
875 | info_handler.buffers_capacity += buffer.capacity(); | |
819 | 876 | osmium::apply(buffer, info_handler); |
820 | 877 | } |
821 | 878 | progress_bar.done(); |
29 | 29 | |
30 | 30 | class CommandFileinfo : public Command, public with_single_osm_input { |
31 | 31 | |
32 | std::string m_get_value; | |
32 | 33 | bool m_extended = false; |
33 | 34 | bool m_json_output = false; |
34 | 35 | bool m_calculate_crc = false; |
35 | std::string m_get_value; | |
36 | 36 | |
37 | 37 | public: |
38 | 38 |
27 | 27 | #include <osmium/fwd.hpp> |
28 | 28 | #include <osmium/index/id_set.hpp> |
29 | 29 | #include <osmium/index/nwr_array.hpp> |
30 | #include <osmium/index/relations_map.hpp> | |
30 | 31 | #include <osmium/osm/entity_bits.hpp> |
31 | 32 | #include <osmium/osm/item_type.hpp> |
32 | 33 | #include <osmium/osm/types.hpp> |
36 | 37 | #include <string> |
37 | 38 | #include <vector> |
38 | 39 | |
39 | namespace osmium { | |
40 | class CommandGetId : public Command, public with_single_osm_input, public with_osm_output { | |
40 | 41 | |
41 | namespace index { | |
42 | class RelationsMapIndex; | |
43 | } // namespace index | |
44 | ||
45 | } // namespace osmium | |
46 | ||
47 | class CommandGetId : public Command, public with_single_osm_input, public with_osm_output { | |
42 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids; | |
48 | 43 | |
49 | 44 | osmium::item_type m_default_item_type = osmium::item_type::node; |
50 | 45 | |
51 | 46 | bool m_add_referenced_objects = false; |
52 | 47 | bool m_work_with_history = false; |
53 | 48 | bool m_verbose_ids = false; |
54 | ||
55 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids; | |
56 | 49 | |
57 | 50 | osmium::osm_entity_bits::type get_needed_types() const; |
58 | 51 | std::size_t count_ids() const noexcept; |
27 | 27 | #include <osmium/fwd.hpp> |
28 | 28 | #include <osmium/index/id_set.hpp> |
29 | 29 | #include <osmium/index/nwr_array.hpp> |
30 | #include <osmium/index/relations_map.hpp> | |
30 | 31 | #include <osmium/osm/entity_bits.hpp> |
31 | 32 | #include <osmium/osm/item_type.hpp> |
32 | 33 | #include <osmium/osm/types.hpp> |
36 | 37 | #include <string> |
37 | 38 | #include <vector> |
38 | 39 | |
39 | namespace osmium { | |
40 | class CommandGetParents : public Command, public with_single_osm_input, public with_osm_output { | |
40 | 41 | |
41 | namespace index { | |
42 | class RelationsMapIndex; | |
43 | } // namespace index | |
44 | ||
45 | } // namespace osmium | |
46 | ||
47 | class CommandGetParents : public Command, public with_single_osm_input, public with_osm_output { | |
42 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids; | |
48 | 43 | |
49 | 44 | osmium::item_type m_default_item_type = osmium::item_type::node; |
50 | 45 | |
51 | 46 | bool m_add_self = false; |
52 | 47 | bool m_verbose_ids = false; |
53 | ||
54 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids; | |
55 | 48 | |
56 | 49 | osmium::osm_entity_bits::type get_needed_types() const; |
57 | 50 |
49 | 49 | } |
50 | 50 | |
51 | 51 | bool CommandHelp::run() { |
52 | auto commands = m_command_factory.help(); | |
52 | const auto commands = m_command_factory.help(); | |
53 | 53 | |
54 | 54 | if (m_topic == "help") { |
55 | 55 | std::cout << "Usage: " << synopsis() |
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
80 | std::string description = m_command_factory.get_description(m_topic); | |
80 | const auto description = m_command_factory.get_description(m_topic); | |
81 | 81 | if (!description.empty()) { |
82 | 82 | show_help(m_topic, std::string{"osmium "} + m_topic + ": " + description); |
83 | 83 | return true; |
22 | 22 | #include "command_merge.hpp" |
23 | 23 | #include "util.hpp" |
24 | 24 | |
25 | #include <osmium/io/file.hpp> | |
25 | 26 | #include <osmium/io/header.hpp> |
26 | 27 | #include <osmium/io/input_iterator.hpp> |
27 | 28 | #include <osmium/io/output_iterator.hpp> |
43 | 44 | #include <utility> |
44 | 45 | #include <vector> |
45 | 46 | |
46 | namespace osmium { | |
47 | ||
48 | namespace io { | |
49 | class File; | |
50 | } // namespace io | |
51 | ||
52 | } // namespace osmium | |
53 | ||
54 | 47 | bool CommandMerge::setup(const std::vector<std::string>& arguments) { |
55 | 48 | po::options_description opts_cmd{"COMMAND OPTIONS"}; |
56 | 49 |
22 | 22 | #include "command_merge_changes.hpp" |
23 | 23 | #include "util.hpp" |
24 | 24 | |
25 | #include <osmium/io/file.hpp> | |
25 | 26 | #include <osmium/io/header.hpp> |
26 | 27 | #include <osmium/io/output_iterator.hpp> |
27 | 28 | #include <osmium/io/reader.hpp> |
40 | 41 | #include <string> |
41 | 42 | #include <utility> |
42 | 43 | #include <vector> |
43 | ||
44 | namespace osmium { | |
45 | ||
46 | namespace io { | |
47 | class File; | |
48 | } // namespace io | |
49 | ||
50 | } // namespace osmium | |
51 | 44 | |
52 | 45 | bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) { |
53 | 46 | po::options_description opts_cmd{"COMMAND OPTIONS"}; |
22 | 22 | #include "exception.hpp" |
23 | 23 | |
24 | 24 | #include <osmium/io/detail/read_write.hpp> |
25 | #include <osmium/io/file.hpp> | |
25 | 26 | #include <osmium/io/header.hpp> |
26 | 27 | #include <osmium/io/input_iterator.hpp> |
27 | 28 | #include <osmium/io/reader.hpp> |
53 | 54 | #ifdef _WIN32 |
54 | 55 | # include <io.h> |
55 | 56 | #endif |
56 | ||
57 | namespace osmium { | |
58 | ||
59 | namespace io { | |
60 | class File; | |
61 | } // namespace io | |
62 | ||
63 | } // namespace osmium | |
64 | 57 | |
65 | 58 | osmium::object_id_type id_map::add_offset_to_id(osmium::object_id_type id) const noexcept { |
66 | 59 | if (m_start_id < 0) { |
20 | 20 | */ |
21 | 21 | |
22 | 22 | #include "command_sort.hpp" |
23 | #include "exception.hpp" | |
23 | 24 | #include "util.hpp" |
24 | 25 | |
25 | 26 | #include <osmium/io/header.hpp> |
50 | 51 | po::options_description hidden; |
51 | 52 | hidden.add_options() |
52 | 53 | ("input-filenames", po::value<std::vector<std::string>>(), "OSM input files") |
54 | ("strategy,s", po::value<std::string>(), "Strategy (default: simple)") | |
53 | 55 | ; |
54 | 56 | |
55 | 57 | po::options_description desc; |
74 | 76 | m_filenames = vm["input-filenames"].as<std::vector<std::string>>(); |
75 | 77 | } |
76 | 78 | |
79 | if (vm.count("strategy")) { | |
80 | m_strategy = vm["strategy"].as<std::string>(); | |
81 | if (m_strategy != "simple" && m_strategy != "multipass") { | |
82 | throw argument_error{"Unknown strategy: " + m_strategy}; | |
83 | } | |
84 | } | |
85 | ||
77 | 86 | return true; |
78 | 87 | } |
79 | 88 | |
80 | 89 | void CommandSort::show_arguments() { |
81 | 90 | show_multiple_inputs_arguments(m_vout); |
82 | 91 | show_output_arguments(m_vout); |
83 | } | |
84 | ||
85 | bool CommandSort::run() { | |
92 | ||
93 | m_vout << " other options:\n"; | |
94 | m_vout << " strategy: " << m_strategy << "\n"; | |
95 | } | |
96 | ||
97 | bool CommandSort::run_single_pass() { | |
86 | 98 | std::vector<osmium::memory::Buffer> data; |
87 | 99 | osmium::ObjectPointerCollection objects; |
88 | 100 | |
89 | 101 | osmium::Box bounding_box; |
102 | ||
103 | uint64_t buffers_count = 0; | |
104 | uint64_t buffers_size = 0; | |
105 | uint64_t buffers_capacity = 0; | |
90 | 106 | |
91 | 107 | m_vout << "Reading contents of input files...\n"; |
92 | 108 | osmium::ProgressBar progress_bar{file_size_sum(m_input_files), display_progress()}; |
95 | 111 | osmium::io::Header header{reader.header()}; |
96 | 112 | bounding_box.extend(header.joined_boxes()); |
97 | 113 | while (osmium::memory::Buffer buffer = reader.read()) { |
114 | ++buffers_count; | |
115 | buffers_size += buffer.committed(); | |
116 | buffers_capacity += buffer.capacity(); | |
98 | 117 | progress_bar.update(reader.offset()); |
99 | 118 | osmium::apply(buffer, objects); |
100 | 119 | data.push_back(std::move(buffer)); |
103 | 122 | reader.close(); |
104 | 123 | } |
105 | 124 | progress_bar.done(); |
125 | ||
126 | m_vout << "Number of buffers: " << buffers_count << "\n"; | |
127 | ||
128 | const auto buffers_size_rounded = static_cast<double>(buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
129 | m_vout << "Sum of buffer sizes: " << buffers_size << " (" << buffers_size_rounded << " GB)\n"; | |
130 | ||
131 | const auto buffers_capacity_rounded = static_cast<double>(buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
132 | ||
133 | if (buffers_capacity != 0) { | |
134 | const auto fill_factor = std::round(100 * static_cast<double>(buffers_size) / static_cast<double>(buffers_capacity)); | |
135 | m_vout << "Sum of buffer capacities: " << buffers_capacity << " (" << buffers_capacity_rounded << " GB, " << fill_factor << "% full)\n"; | |
136 | } else { | |
137 | m_vout << "Sum of buffer capacities: 0 (0 GB)\n"; | |
138 | } | |
106 | 139 | |
107 | 140 | m_vout << "Opening output file...\n"; |
108 | 141 | osmium::io::Header header; |
129 | 162 | return true; |
130 | 163 | } |
131 | 164 | |
165 | bool CommandSort::run_multi_pass() { | |
166 | osmium::Box bounding_box; | |
167 | ||
168 | m_vout << "Reading input file headers...\n"; | |
169 | for (const std::string& file_name : m_filenames) { | |
170 | osmium::io::Reader reader{file_name, osmium::osm_entity_bits::nothing}; | |
171 | osmium::io::Header header{reader.header()}; | |
172 | bounding_box.extend(header.joined_boxes()); | |
173 | reader.close(); | |
174 | } | |
175 | ||
176 | m_vout << "Opening output file...\n"; | |
177 | osmium::io::Header header; | |
178 | setup_header(header); | |
179 | if (bounding_box) { | |
180 | header.add_box(bounding_box); | |
181 | } | |
182 | ||
183 | osmium::io::Writer writer{m_output_file, header, m_output_overwrite, m_fsync}; | |
184 | ||
185 | osmium::ProgressBar progress_bar{file_size_sum(m_input_files) * 3, display_progress()}; | |
186 | ||
187 | int pass = 1; | |
188 | for (const auto entity : {osmium::osm_entity_bits::node, osmium::osm_entity_bits::way, osmium::osm_entity_bits::relation}) { | |
189 | std::vector<osmium::memory::Buffer> data; | |
190 | osmium::ObjectPointerCollection objects; | |
191 | ||
192 | uint64_t buffers_count = 0; | |
193 | uint64_t buffers_size = 0; | |
194 | uint64_t buffers_capacity = 0; | |
195 | ||
196 | m_vout << "Pass " << pass++ << "...\n"; | |
197 | m_vout << "Reading contents of input files...\n"; | |
198 | for (const std::string& file_name : m_filenames) { | |
199 | osmium::io::Reader reader{file_name, entity}; | |
200 | osmium::io::Header header{reader.header()}; | |
201 | bounding_box.extend(header.joined_boxes()); | |
202 | while (osmium::memory::Buffer buffer = reader.read()) { | |
203 | ++buffers_count; | |
204 | buffers_size += buffer.committed(); | |
205 | buffers_capacity += buffer.capacity(); | |
206 | progress_bar.update(reader.offset()); | |
207 | osmium::apply(buffer, objects); | |
208 | data.push_back(std::move(buffer)); | |
209 | } | |
210 | progress_bar.file_done(reader.file_size()); | |
211 | reader.close(); | |
212 | } | |
213 | ||
214 | if (m_vout.verbose()) { | |
215 | progress_bar.remove(); | |
216 | } | |
217 | ||
218 | m_vout << "Number of buffers: " << buffers_count << "\n"; | |
219 | ||
220 | const auto buffers_size_rounded = static_cast<double>(buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
221 | m_vout << "Sum of buffer sizes: " << buffers_size << " (" << buffers_size_rounded << " GB)\n"; | |
222 | ||
223 | const auto buffers_capacity_rounded = static_cast<double>(buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division) | |
224 | ||
225 | if (buffers_capacity != 0) { | |
226 | const auto fill_factor = std::round(100 * static_cast<double>(buffers_size) / static_cast<double>(buffers_capacity)); | |
227 | m_vout << "Sum of buffer capacities: " << buffers_capacity << " (" << buffers_capacity_rounded << " GB, " << fill_factor << "% full)\n"; | |
228 | } else { | |
229 | m_vout << "Sum of buffer capacities: 0 (0 GB)\n"; | |
230 | } | |
231 | ||
232 | m_vout << "Sorting data...\n"; | |
233 | objects.sort(osmium::object_order_type_id_version()); | |
234 | ||
235 | m_vout << "Writing out sorted data...\n"; | |
236 | auto out = osmium::io::make_output_iterator(writer); | |
237 | std::copy(objects.begin(), objects.end(), out); | |
238 | } | |
239 | ||
240 | progress_bar.done(); | |
241 | ||
242 | m_vout << "Closing output file...\n"; | |
243 | writer.close(); | |
244 | ||
245 | show_memory_used(); | |
246 | m_vout << "Done.\n"; | |
247 | ||
248 | return true; | |
249 | } | |
250 | ||
251 | bool CommandSort::run() { | |
252 | if (m_strategy == "simple") { | |
253 | return run_single_pass(); | |
254 | } | |
255 | return run_multi_pass(); | |
256 | } | |
257 |
30 | 30 | class CommandSort : public Command, public with_multiple_osm_inputs, public with_osm_output { |
31 | 31 | |
32 | 32 | std::vector<std::string> m_filenames; |
33 | std::string m_strategy{"simple"}; | |
33 | 34 | |
34 | 35 | public: |
35 | 36 | |
40 | 41 | bool setup(const std::vector<std::string>& arguments) override final; |
41 | 42 | |
42 | 43 | void show_arguments() override final; |
44 | ||
45 | bool run_single_pass(); | |
46 | ||
47 | bool run_multi_pass(); | |
43 | 48 | |
44 | 49 | bool run() override final; |
45 | 50 |
88 | 88 | ("expressions,e", po::value<std::string>(), "Read filter expressions from file") |
89 | 89 | ("invert-match,i", "Invert the sense of matching, exclude objects with matching tags") |
90 | 90 | ("omit-referenced,R", "Omit referenced objects") |
91 | ("remove-tags,t", "Remove tags from non-matching objects") | |
91 | 92 | ; |
92 | 93 | |
93 | 94 | po::options_description opts_common{add_common_options()}; |
127 | 128 | |
128 | 129 | if (vm.count("invert-match")) { |
129 | 130 | m_invert_match = true; |
131 | } | |
132 | ||
133 | if (vm.count("remove-tags")) { | |
134 | m_remove_tags = true; | |
130 | 135 | } |
131 | 136 | |
132 | 137 | if (vm.count("expression-list")) { |
155 | 160 | } |
156 | 161 | |
157 | 162 | osmium::osm_entity_bits::type CommandTagsFilter::get_needed_types() const { |
163 | if (m_invert_match) { | |
164 | return osmium::osm_entity_bits::nwr; | |
165 | } | |
166 | ||
158 | 167 | osmium::osm_entity_bits::type types = osmium::osm_entity_bits::nothing; |
159 | 168 | |
160 | if (!m_ids(osmium::item_type::node).empty() || !m_filters(osmium::item_type::node).empty()) { | |
169 | if (!m_referenced_ids(osmium::item_type::node).empty() || !m_filters(osmium::item_type::node).empty()) { | |
161 | 170 | types |= osmium::osm_entity_bits::node; |
162 | 171 | } |
163 | if (!m_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) { | |
172 | if (!m_referenced_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) { | |
164 | 173 | types |= osmium::osm_entity_bits::way; |
165 | 174 | } |
166 | if (!m_ids(osmium::item_type::relation).empty() || !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty()) { | |
175 | if (!m_referenced_ids(osmium::item_type::relation).empty() || !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty()) { | |
167 | 176 | types |= osmium::osm_entity_bits::relation; |
168 | 177 | } |
169 | 178 | |
172 | 181 | |
173 | 182 | void CommandTagsFilter::add_nodes(const osmium::Way& way) { |
174 | 183 | for (const auto& nr : way.nodes()) { |
175 | m_ids(osmium::item_type::node).set(nr.positive_ref()); | |
184 | m_referenced_ids(osmium::item_type::node).set(nr.positive_ref()); | |
176 | 185 | } |
177 | 186 | } |
178 | 187 | |
179 | 188 | void CommandTagsFilter::add_members(const osmium::Relation& relation) { |
180 | 189 | for (const auto& member : relation.members()) { |
181 | m_ids(member.type()).set(member.positive_ref()); | |
190 | m_referenced_ids(member.type()).set(member.positive_ref()); | |
182 | 191 | } |
183 | 192 | } |
184 | 193 | |
224 | 233 | |
225 | 234 | void CommandTagsFilter::mark_rel_ids(const osmium::index::RelationsMapIndex& rel_in_rel, osmium::object_id_type parent_id) { |
226 | 235 | rel_in_rel.for_each(parent_id, [&](osmium::unsigned_object_id_type member_id) { |
227 | if (m_ids(osmium::item_type::relation).check_and_set(member_id)) { | |
236 | if (m_referenced_ids(osmium::item_type::relation).check_and_set(member_id)) { | |
228 | 237 | mark_rel_ids(rel_in_rel, member_id); |
229 | 238 | } |
230 | 239 | }); |
234 | 243 | m_vout << " Reading input file to find relations in relations...\n"; |
235 | 244 | osmium::index::RelationsMapStash stash; |
236 | 245 | |
246 | ++m_count_passes; | |
237 | 247 | osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::relation}; |
238 | 248 | while (osmium::memory::Buffer buffer = reader.read()) { |
239 | 249 | for (const auto& relation : buffer.select<osmium::Relation>()) { |
240 | 250 | stash.add_members(relation); |
241 | 251 | if (matches_relation(relation) != m_invert_match) { |
242 | m_ids(osmium::item_type::relation).set(relation.positive_id()); | |
252 | m_matching_ids(osmium::item_type::relation).set(relation.positive_id()); | |
253 | for (const auto& member : relation.members()) { | |
254 | if (member.type() == osmium::item_type::node) { | |
255 | m_referenced_ids(osmium::item_type::node).set(member.positive_ref()); | |
256 | } else if (member.type() == osmium::item_type::way) { | |
257 | m_referenced_ids(osmium::item_type::way).set(member.positive_ref()); | |
258 | } | |
259 | } | |
243 | 260 | } |
244 | 261 | } |
245 | 262 | } |
250 | 267 | } |
251 | 268 | |
252 | 269 | const auto rel_in_rel = stash.build_parent_to_member_index(); |
253 | for (const osmium::unsigned_object_id_type id : m_ids(osmium::item_type::relation)) { | |
270 | for (const osmium::unsigned_object_id_type id : m_referenced_ids(osmium::item_type::relation)) { | |
254 | 271 | mark_rel_ids(rel_in_rel, id); |
255 | 272 | } |
256 | 273 | |
260 | 277 | void CommandTagsFilter::find_nodes_and_ways_in_relations() { |
261 | 278 | m_vout << " Reading input file to find nodes/ways in relations...\n"; |
262 | 279 | |
280 | ++m_count_passes; | |
263 | 281 | osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::relation}; |
264 | 282 | while (osmium::memory::Buffer buffer = reader.read()) { |
265 | 283 | for (const auto& relation : buffer.select<osmium::Relation>()) { |
266 | if (m_ids(osmium::item_type::relation).get(relation.positive_id())) { | |
284 | if (m_referenced_ids(osmium::item_type::relation).get(relation.positive_id())) { | |
267 | 285 | for (const auto& member : relation.members()) { |
268 | 286 | if (member.type() == osmium::item_type::node) { |
269 | m_ids(osmium::item_type::node).set(member.positive_ref()); | |
287 | m_referenced_ids(osmium::item_type::node).set(member.positive_ref()); | |
270 | 288 | } else if (member.type() == osmium::item_type::way) { |
271 | m_ids(osmium::item_type::way).set(member.positive_ref()); | |
289 | m_referenced_ids(osmium::item_type::way).set(member.positive_ref()); | |
272 | 290 | } |
273 | 291 | } |
274 | 292 | } |
280 | 298 | void CommandTagsFilter::find_nodes_in_ways() { |
281 | 299 | m_vout << " Reading input file to find nodes in ways...\n"; |
282 | 300 | |
301 | ++m_count_passes; | |
283 | 302 | osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::way}; |
284 | 303 | while (osmium::memory::Buffer buffer = reader.read()) { |
285 | 304 | for (const auto& way : buffer.select<osmium::Way>()) { |
286 | if (m_ids(osmium::item_type::way).get(way.positive_id())) { | |
305 | if (m_referenced_ids(osmium::item_type::way).get(way.positive_id())) { | |
287 | 306 | add_nodes(way); |
288 | 307 | } else if (matches_way(way) != m_invert_match) { |
289 | m_ids(osmium::item_type::way).set(way.positive_id()); | |
308 | m_matching_ids(osmium::item_type::way).set(way.positive_id()); | |
290 | 309 | add_nodes(way); |
291 | 310 | } |
292 | 311 | } |
296 | 315 | |
297 | 316 | void CommandTagsFilter::find_referenced_objects() { |
298 | 317 | m_vout << "Following references...\n"; |
299 | bool todo = !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty(); | |
318 | bool todo = !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty() || m_invert_match; | |
300 | 319 | if (todo) { |
301 | 320 | todo = find_relations_in_relations(); |
302 | 321 | } |
305 | 324 | find_nodes_and_ways_in_relations(); |
306 | 325 | } |
307 | 326 | |
308 | if (!m_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) { | |
327 | if (!m_referenced_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) { | |
309 | 328 | find_nodes_in_ways(); |
310 | 329 | } |
311 | 330 | m_vout << "Done following references.\n"; |
317 | 336 | } |
318 | 337 | |
319 | 338 | m_vout << "Opening input file...\n"; |
339 | ++m_count_passes; | |
320 | 340 | osmium::io::Reader reader{m_input_file, get_needed_types()}; |
321 | 341 | |
322 | 342 | m_vout << "Opening output file...\n"; |
329 | 349 | osmium::ProgressBar progress_bar{reader.file_size(), display_progress()}; |
330 | 350 | while (osmium::memory::Buffer buffer = reader.read()) { |
331 | 351 | progress_bar.update(reader.offset()); |
332 | for (const auto& object : buffer.select<osmium::OSMObject>()) { | |
333 | if (m_ids(object.type()).get(object.positive_id())) { | |
352 | for (auto& object : buffer.select<osmium::OSMObject>()) { | |
353 | if (m_matching_ids(object.type()).get(object.positive_id())) { | |
334 | 354 | writer(object); |
335 | } else if (!m_add_referenced_objects || object.type() == osmium::item_type::node) { | |
336 | if (matches_object(object) != m_invert_match) { | |
337 | writer(object); | |
355 | } else if ((!m_add_referenced_objects || object.type() == osmium::item_type::node) && matches_object(object) != m_invert_match) { | |
356 | writer(object); | |
357 | } else if (m_referenced_ids(object.type()).get(object.positive_id())) { | |
358 | if (m_remove_tags) { | |
359 | object.remove_tags(); | |
338 | 360 | } |
361 | writer(object); | |
339 | 362 | } |
340 | 363 | } |
341 | 364 | } |
349 | 372 | |
350 | 373 | show_memory_used(); |
351 | 374 | |
375 | m_vout << "Needed " << m_count_passes << " passes through the input file.\n"; | |
352 | 376 | m_vout << "Done.\n"; |
353 | 377 | |
354 | 378 | return true; |
27 | 27 | #include <osmium/fwd.hpp> |
28 | 28 | #include <osmium/index/id_set.hpp> |
29 | 29 | #include <osmium/index/nwr_array.hpp> |
30 | #include <osmium/index/relations_map.hpp> | |
30 | 31 | #include <osmium/osm/entity_bits.hpp> |
31 | 32 | #include <osmium/osm/item_type.hpp> |
32 | 33 | #include <osmium/osm/types.hpp> |
35 | 36 | #include <string> |
36 | 37 | #include <vector> |
37 | 38 | |
38 | namespace osmium { | |
39 | ||
40 | namespace index { | |
41 | class RelationsMapIndex; | |
42 | } // namespace index | |
43 | ||
44 | } // namespace osmium | |
45 | ||
46 | 39 | class CommandTagsFilter : public Command, public with_single_osm_input, public with_osm_output { |
47 | ||
48 | bool m_add_referenced_objects = true; | |
49 | bool m_invert_match = false; | |
50 | 40 | |
51 | 41 | osmium::nwr_array<osmium::TagsFilter> m_filters; |
52 | 42 | osmium::TagsFilter m_area_filters; |
53 | 43 | |
54 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids; | |
44 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_matching_ids; | |
45 | osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_referenced_ids; | |
46 | ||
47 | int m_count_passes = 0; | |
48 | bool m_add_referenced_objects = true; | |
49 | bool m_invert_match = false; | |
50 | bool m_remove_tags = false; | |
55 | 51 | |
56 | 52 | osmium::osm_entity_bits::type get_needed_types() const; |
57 | 53 |
27 | 27 | #include <osmium/fwd.hpp> |
28 | 28 | #include <osmium/io/writer_options.hpp> |
29 | 29 | #include <osmium/osm/object.hpp> |
30 | #include <osmium/util/verbose_output.hpp> | |
30 | 31 | |
31 | 32 | #include <cstdint> |
32 | 33 | |
62 | 63 | virtual void area(const osmium::Area&) = 0; |
63 | 64 | |
64 | 65 | virtual void close() = 0; |
66 | ||
67 | virtual void debug_output(osmium::VerboseOutput& /*out*/, const std::string& /*filename*/) { | |
68 | } | |
65 | 69 | |
66 | 70 | template <typename TFunc> |
67 | 71 | bool add_tags(const osmium::OSMObject& object, TFunc&& func) { |
105 | 105 | |
106 | 106 | if (!options().version.empty()) { |
107 | 107 | m_writer.String(options().version); |
108 | m_writer.Int(object.version()); | |
108 | m_writer.Int64(object.version()); | |
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!options().changeset.empty()) { |
112 | 112 | m_writer.String(options().changeset); |
113 | m_writer.Int(object.changeset()); | |
113 | m_writer.Int64(object.changeset()); | |
114 | 114 | } |
115 | 115 | |
116 | 116 | if (!options().uid.empty()) { |
117 | 117 | m_writer.String(options().uid); |
118 | m_writer.Int(object.uid()); | |
118 | m_writer.Int64(object.uid()); | |
119 | 119 | } |
120 | 120 | |
121 | 121 | if (!options().user.empty()) { |
0 | /* | |
1 | ||
2 | Osmium -- OpenStreetMap data manipulation command line tool | |
3 | http://osmcode.org/osmium-tool/ | |
4 | ||
5 | Copyright (C) 2013-2018 Jochen Topf <jochen@topf.org> | |
6 | ||
7 | This program is free software: you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation, either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <https://www.gnu.org/licenses/>. | |
19 | ||
20 | */ | |
21 | ||
22 | #include "export_format_pg.hpp" | |
23 | ||
24 | #include <osmium/io/detail/read_write.hpp> | |
25 | #include <osmium/io/detail/string_util.hpp> | |
26 | ||
27 | #ifndef RAPIDJSON_HAS_STDSTRING | |
28 | # define RAPIDJSON_HAS_STDSTRING 1 | |
29 | #endif | |
30 | #include <rapidjson/writer.h> | |
31 | #include <rapidjson/stringbuffer.h> | |
32 | ||
33 | #include <limits> | |
34 | #include <string> | |
35 | ||
36 | enum { | |
37 | initial_buffer_size = 1024u * 1024u | |
38 | }; | |
39 | ||
40 | enum { | |
41 | flush_buffer_size = 800u * 1024u | |
42 | }; | |
43 | ||
44 | ExportFormatPg::ExportFormatPg(const std::string& /*output_format*/, | |
45 | const std::string& output_filename, | |
46 | osmium::io::overwrite overwrite, | |
47 | osmium::io::fsync fsync, | |
48 | const options_type& options) : | |
49 | ExportFormat(options), | |
50 | m_fd(osmium::io::detail::open_for_writing(output_filename, overwrite)), | |
51 | m_fsync(fsync) { | |
52 | m_buffer.reserve(initial_buffer_size); | |
53 | } | |
54 | ||
55 | void ExportFormatPg::flush_to_output() { | |
56 | osmium::io::detail::reliable_write(m_fd, m_buffer.data(), m_buffer.size()); | |
57 | m_buffer.clear(); | |
58 | m_commit_size = 0; | |
59 | } | |
60 | ||
61 | void ExportFormatPg::start_feature(const char type, const osmium::object_id_type id) { | |
62 | m_buffer.resize(m_commit_size); | |
63 | if (options().unique_id == unique_id_type::counter) { | |
64 | m_buffer.append(std::to_string(m_count + 1)); | |
65 | m_buffer += '\t'; | |
66 | } else if (options().unique_id == unique_id_type::type_id) { | |
67 | m_buffer += type; | |
68 | m_buffer.append(std::to_string(id)); | |
69 | m_buffer += '\t'; | |
70 | } | |
71 | } | |
72 | ||
73 | void ExportFormatPg::append_pg_escaped(const char* str, std::size_t size = std::numeric_limits<std::size_t>::max()) { | |
74 | while (size-- > 0 && *str != '\0') { | |
75 | switch (*str) { | |
76 | case '\\': | |
77 | m_buffer += '\\'; | |
78 | m_buffer += '\\'; | |
79 | break; | |
80 | case '\n': | |
81 | m_buffer += '\\'; | |
82 | m_buffer += 'n'; | |
83 | break; | |
84 | case '\r': | |
85 | m_buffer += '\\'; | |
86 | m_buffer += 'r'; | |
87 | break; | |
88 | case '\t': | |
89 | m_buffer += '\\'; | |
90 | m_buffer += 't'; | |
91 | break; | |
92 | default: | |
93 | m_buffer += *str; | |
94 | } | |
95 | ++str; | |
96 | } | |
97 | } | |
98 | ||
99 | void ExportFormatPg::add_attributes(const osmium::OSMObject& object) { | |
100 | if (!options().type.empty()) { | |
101 | if (object.type() == osmium::item_type::area) { | |
102 | if (static_cast<const osmium::Area&>(object).from_way()) { | |
103 | m_buffer.append("way"); | |
104 | } else { | |
105 | m_buffer.append("relation"); | |
106 | } | |
107 | } else { | |
108 | m_buffer.append(osmium::item_type_to_name(object.type())); | |
109 | } | |
110 | m_buffer += '\t'; | |
111 | } | |
112 | ||
113 | if (!options().id.empty()) { | |
114 | m_buffer.append(std::to_string(object.type() == osmium::item_type::area ? osmium::area_id_to_object_id(object.id()) : object.id())); | |
115 | m_buffer += '\t'; | |
116 | } | |
117 | ||
118 | if (!options().version.empty()) { | |
119 | m_buffer.append(std::to_string(object.version())); | |
120 | m_buffer += '\t'; | |
121 | } | |
122 | ||
123 | if (!options().changeset.empty()) { | |
124 | m_buffer.append(std::to_string(object.changeset())); | |
125 | m_buffer += '\t'; | |
126 | } | |
127 | ||
128 | if (!options().uid.empty()) { | |
129 | m_buffer.append(std::to_string(object.uid())); | |
130 | m_buffer += '\t'; | |
131 | } | |
132 | ||
133 | if (!options().user.empty()) { | |
134 | append_pg_escaped(object.user()); | |
135 | m_buffer += '\t'; | |
136 | } | |
137 | ||
138 | if (!options().timestamp.empty()) { | |
139 | m_buffer.append(object.timestamp().to_iso()); | |
140 | m_buffer += '\t'; | |
141 | } | |
142 | ||
143 | if (!options().way_nodes.empty()) { | |
144 | if (object.type() == osmium::item_type::way) { | |
145 | m_buffer += '{'; | |
146 | for (const auto& nr : static_cast<const osmium::Way&>(object).nodes()) { | |
147 | m_buffer.append(std::to_string(nr.ref())); | |
148 | m_buffer += ','; | |
149 | } | |
150 | if (m_buffer.back() == ',') { | |
151 | m_buffer.back() = '}'; | |
152 | } else { | |
153 | m_buffer += '}'; | |
154 | } | |
155 | } else { | |
156 | m_buffer += '\\'; | |
157 | m_buffer += 'N'; | |
158 | } | |
159 | m_buffer += '\t'; | |
160 | } | |
161 | } | |
162 | ||
163 | bool ExportFormatPg::add_tags(const osmium::OSMObject& object) { | |
164 | bool has_tags = false; | |
165 | ||
166 | rapidjson::StringBuffer stream; | |
167 | rapidjson::Writer<rapidjson::StringBuffer> writer{stream}; | |
168 | ||
169 | writer.StartObject(); | |
170 | for (const auto& tag : object.tags()) { | |
171 | if (options().tags_filter(tag)) { | |
172 | has_tags = true; | |
173 | writer.Key(tag.key()); | |
174 | writer.String(tag.value()); | |
175 | } | |
176 | } | |
177 | writer.EndObject(); | |
178 | ||
179 | append_pg_escaped(stream.GetString(), stream.GetSize()); | |
180 | ||
181 | return has_tags; | |
182 | } | |
183 | ||
184 | void ExportFormatPg::finish_feature(const osmium::OSMObject& object) { | |
185 | m_buffer += '\t'; | |
186 | add_attributes(object); | |
187 | ||
188 | if (add_tags(object) || options().keep_untagged) { | |
189 | m_buffer += '\n'; | |
190 | ||
191 | m_commit_size = m_buffer.size(); | |
192 | ||
193 | ++m_count; | |
194 | ||
195 | if (m_buffer.size() > flush_buffer_size) { | |
196 | flush_to_output(); | |
197 | } | |
198 | } | |
199 | } | |
200 | ||
201 | void ExportFormatPg::node(const osmium::Node& node) { | |
202 | start_feature('n', node.id()); | |
203 | m_buffer.append(m_factory.create_point(node)); | |
204 | finish_feature(node); | |
205 | } | |
206 | ||
207 | void ExportFormatPg::way(const osmium::Way& way) { | |
208 | start_feature('w', way.id()); | |
209 | m_buffer.append(m_factory.create_linestring(way)); | |
210 | finish_feature(way); | |
211 | } | |
212 | ||
213 | void ExportFormatPg::area(const osmium::Area& area) { | |
214 | start_feature('a', area.id()); | |
215 | m_buffer.append(m_factory.create_multipolygon(area)); | |
216 | finish_feature(area); | |
217 | } | |
218 | ||
219 | void ExportFormatPg::close() { | |
220 | if (m_fd > 0) { | |
221 | flush_to_output(); | |
222 | if (m_fsync == osmium::io::fsync::yes) { | |
223 | osmium::io::detail::reliable_fsync(m_fd); | |
224 | } | |
225 | ::close(m_fd); | |
226 | m_fd = -1; | |
227 | } | |
228 | } | |
229 | ||
230 | void ExportFormatPg::debug_output(osmium::VerboseOutput& out, const std::string& filename) { | |
231 | out << '\n'; | |
232 | out << "Create table with something like this:\n"; | |
233 | out << "CREATE TABLE osmdata (\n"; | |
234 | ||
235 | if (options().unique_id == unique_id_type::counter) { | |
236 | out << " id BIGINT PRIMARY KEY,\n"; | |
237 | } else if (options().unique_id == unique_id_type::type_id) { | |
238 | out << " id VARCHAR PRIMARY KEY,\n"; | |
239 | } | |
240 | ||
241 | out << " geom GEOMETRY,\n"; | |
242 | ||
243 | if (!options().type.empty()) { | |
244 | out << " osm_type VARCHAR,\n"; | |
245 | } | |
246 | ||
247 | if (!options().id.empty()) { | |
248 | out << " osm_id BIGINT,\n"; | |
249 | } | |
250 | ||
251 | if (!options().version.empty()) { | |
252 | out << " version INTEGER,\n"; | |
253 | } | |
254 | ||
255 | if (!options().changeset.empty()) { | |
256 | out << " changeset INTEGER,\n"; | |
257 | } | |
258 | ||
259 | if (!options().uid.empty()) { | |
260 | out << " uid INTEGER,\n"; | |
261 | } | |
262 | ||
263 | if (!options().user.empty()) { | |
264 | out << " user VARCHAR,\n"; | |
265 | } | |
266 | ||
267 | if (!options().timestamp.empty()) { | |
268 | out << " timestamp TIMESTAMP (0) WITH TIME ZONE,\n"; | |
269 | } | |
270 | ||
271 | if (!options().way_nodes.empty()) { | |
272 | out << " way_nodes BIGINT[],\n"; | |
273 | } | |
274 | ||
275 | out << " tags JSON -- or JSONB\n"; | |
276 | out << ");\n"; | |
277 | out << "Then load data with something like this:\n"; | |
278 | out << "\\copy osmdata FROM '" << filename << "'\n"; | |
279 | out << '\n'; | |
280 | } | |
281 |
0 | #ifndef EXPORT_EXPORT_FORMAT_PG_HPP | |
1 | #define EXPORT_EXPORT_FORMAT_PG_HPP | |
2 | ||
3 | /* | |
4 | ||
5 | Osmium -- OpenStreetMap data manipulation command line tool | |
6 | http://osmcode.org/osmium-tool/ | |
7 | ||
8 | Copyright (C) 2013-2018 Jochen Topf <jochen@topf.org> | |
9 | ||
10 | This program is free software: you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation, either version 3 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program. If not, see <https://www.gnu.org/licenses/>. | |
22 | ||
23 | */ | |
24 | ||
25 | #include "export_format.hpp" | |
26 | ||
27 | #include <osmium/fwd.hpp> | |
28 | #include <osmium/geom/wkb.hpp> | |
29 | #include <osmium/io/writer_options.hpp> | |
30 | ||
31 | #include <string> | |
32 | ||
33 | class ExportFormatPg : public ExportFormat { | |
34 | ||
35 | osmium::geom::WKBFactory<> m_factory{osmium::geom::wkb_type::ewkb, osmium::geom::out_type::hex}; | |
36 | std::string m_buffer; | |
37 | std::size_t m_commit_size = 0; | |
38 | int m_fd; | |
39 | osmium::io::fsync m_fsync; | |
40 | ||
41 | void flush_to_output(); | |
42 | ||
43 | void start_feature(char type, osmium::object_id_type id); | |
44 | void add_attributes(const osmium::OSMObject& object); | |
45 | bool add_tags(const osmium::OSMObject& object); | |
46 | void finish_feature(const osmium::OSMObject& object); | |
47 | void append_pg_escaped(const char* str, std::size_t size); | |
48 | ||
49 | public: | |
50 | ||
51 | ExportFormatPg(const std::string& output_format, | |
52 | const std::string& output_filename, | |
53 | osmium::io::overwrite overwrite, | |
54 | osmium::io::fsync fsync, | |
55 | const options_type& options); | |
56 | ||
57 | ~ExportFormatPg() override { | |
58 | try { | |
59 | close(); | |
60 | } catch(...) { | |
61 | } | |
62 | } | |
63 | ||
64 | void node(const osmium::Node& node) override; | |
65 | ||
66 | void way(const osmium::Way& way) override; | |
67 | ||
68 | void area(const osmium::Area& area) override; | |
69 | ||
70 | void close() override; | |
71 | ||
72 | void debug_output(osmium::VerboseOutput& out, const std::string& filename) override; | |
73 | ||
74 | }; // class ExportFormatPg | |
75 | ||
76 | #endif // EXPORT_EXPORT_FORMAT_PG_HPP |
23 | 23 | #include "../util.hpp" |
24 | 24 | |
25 | 25 | #include <osmium/handler/check_order.hpp> |
26 | #include <osmium/util/misc.hpp> | |
26 | 27 | #include <osmium/util/string.hpp> |
27 | 28 | |
28 | 29 | namespace strategy_smart { |
29 | 30 | |
30 | void Data::add_relation(const osmium::Relation& relation) { | |
31 | void Data::add_relation_members(const osmium::Relation& relation) { | |
31 | 32 | for (const auto& member : relation.members()) { |
32 | 33 | const auto ref = member.positive_ref(); |
33 | 34 | switch (member.type()) { |
59 | 60 | m_extracts.emplace_back(*extract); |
60 | 61 | } |
61 | 62 | |
63 | m_types = {"multipolygon"}; | |
62 | 64 | for (const auto& option : options) { |
63 | if (std::string{"types"} != option.first) { | |
65 | if (option.first == "types") { | |
66 | if (option.second.empty() || option.second == "any" || option.second == "true") { | |
67 | m_types.clear(); | |
68 | } else { | |
69 | m_types = osmium::split_string(option.second, ',', true); | |
70 | } | |
71 | } else if (option.first == "complete-partial-relations") { | |
72 | if (!option.second.empty()) { | |
73 | m_complete_partial_relations_percentage = osmium::detail::str_to_int<std::size_t>(option.second.c_str()); | |
74 | if (m_complete_partial_relations_percentage <= 0 || | |
75 | m_complete_partial_relations_percentage > 100) { | |
76 | m_complete_partial_relations_percentage = 100; | |
77 | } | |
78 | } | |
79 | } else { | |
64 | 80 | warning(std::string{"Ignoring unknown option '"} + option.first + "' for 'smart' strategy.\n"); |
65 | 81 | } |
66 | } | |
67 | ||
68 | const auto types = options.get("types"); | |
69 | if (types.empty()) { | |
70 | m_types = {"multipolygon"}; | |
71 | } else if (types != "any") { | |
72 | m_types = osmium::split_string(types, ',', true); | |
73 | 82 | } |
74 | 83 | } |
75 | 84 | |
76 | 85 | const char* Strategy::name() const noexcept { |
77 | 86 | return "smart"; |
87 | } | |
88 | ||
89 | bool Strategy::check_members_count(const std::size_t size, const std::size_t wanted_members) const noexcept { | |
90 | return wanted_members * 100 >= size * m_complete_partial_relations_percentage; | |
78 | 91 | } |
79 | 92 | |
80 | 93 | bool Strategy::check_type(const osmium::Relation& relation) const noexcept { |
93 | 106 | void Strategy::show_arguments(osmium::VerboseOutput& vout) { |
94 | 107 | vout << "Additional strategy options:\n"; |
95 | 108 | if (m_types.empty()) { |
96 | vout << " types: any\n"; | |
109 | vout << " - [types] relation types: any\n"; | |
97 | 110 | } else { |
98 | vout << " types:\n"; | |
111 | std::string typelist; | |
99 | 112 | for (const auto& type : m_types) { |
100 | vout << " " << type << '\n'; | |
101 | } | |
113 | if (!typelist.empty()) { | |
114 | typelist += ", "; | |
115 | } | |
116 | typelist += type; | |
117 | } | |
118 | vout << " - [types] relation types: " << typelist << '\n'; | |
119 | } | |
120 | if (m_complete_partial_relations_percentage == 100) { | |
121 | vout << " - [complete-partial-relations] do not complete partial relations\n"; | |
122 | } else { | |
123 | vout << " - [complete-partial-relations] complete partial relations when " << m_complete_partial_relations_percentage << "% or more members are in extract\n"; | |
102 | 124 | } |
103 | 125 | vout << '\n'; |
104 | 126 | } |
143 | 165 | } |
144 | 166 | |
145 | 167 | void erelation(extract_data& e, const osmium::Relation& relation) { |
168 | std::size_t wanted_members = 0; | |
146 | 169 | for (const auto& member : relation.members()) { |
147 | 170 | switch (member.type()) { |
148 | 171 | case osmium::item_type::node: |
149 | 172 | if (e.node_ids.get(member.positive_ref())) { |
150 | e.relation_ids.set(relation.positive_id()); | |
151 | if (strategy().check_type(relation)) { | |
152 | e.add_relation(relation); | |
173 | if (wanted_members == 0) { | |
174 | e.relation_ids.set(relation.positive_id()); | |
175 | if (strategy().check_type(relation)) { | |
176 | e.add_relation_members(relation); | |
177 | return; | |
178 | } | |
153 | 179 | } |
154 | return; | |
180 | ++wanted_members; | |
155 | 181 | } |
156 | 182 | break; |
157 | 183 | case osmium::item_type::way: |
158 | 184 | if (e.way_ids.get(member.positive_ref())) { |
159 | e.relation_ids.set(relation.positive_id()); | |
160 | if (strategy().check_type(relation)) { | |
161 | e.add_relation(relation); | |
185 | if (wanted_members == 0) { | |
186 | e.relation_ids.set(relation.positive_id()); | |
187 | if (strategy().check_type(relation)) { | |
188 | e.add_relation_members(relation); | |
189 | return; | |
190 | } | |
162 | 191 | } |
163 | return; | |
192 | ++wanted_members; | |
164 | 193 | } |
165 | 194 | break; |
166 | 195 | default: |
167 | 196 | break; |
168 | 197 | } |
198 | } | |
199 | ||
200 | if (strategy().check_members_count(relation.members().size(), wanted_members)) { | |
201 | e.add_relation_members(relation); | |
169 | 202 | } |
170 | 203 | } |
171 | 204 |
41 | 41 | osmium::index::IdSetDense<osmium::unsigned_object_id_type> relation_ids; |
42 | 42 | osmium::index::IdSetDense<osmium::unsigned_object_id_type> extra_relation_ids; |
43 | 43 | |
44 | void add_relation(const osmium::Relation& relation); | |
44 | void add_relation_members(const osmium::Relation& relation); | |
45 | 45 | void add_relation_parents(osmium::unsigned_object_id_type id, const osmium::index::RelationsMapIndex& map); |
46 | 46 | }; |
47 | 47 | |
55 | 55 | |
56 | 56 | std::vector<std::string> m_types; |
57 | 57 | |
58 | std::size_t m_complete_partial_relations_percentage = 100; | |
59 | ||
60 | bool check_members_count(const std::size_t size, const std::size_t wanted_members) const noexcept; | |
58 | 61 | bool check_type(const osmium::Relation& relation) const noexcept; |
59 | 62 | |
60 | 63 | public: |
39 | 39 | if (p.second < 0) { |
40 | 40 | throw std::runtime_error{"This command does not work with negative IDs"}; |
41 | 41 | } |
42 | ids(p.first).set(p.second); | |
42 | ids(p.first).set(static_cast<osmium::unsigned_object_id_type>(p.second)); | |
43 | 43 | } |
44 | 44 | |
45 | 45 | void read_id_file(std::istream& stream, ids_type& ids, osmium::item_type default_item_type) { |
175 | 175 | } |
176 | 176 | |
177 | 177 | po::options_description with_osm_output::add_output_options() { |
178 | po::options_description options("OUTPUT OPTIONS"); | |
178 | po::options_description options{"OUTPUT OPTIONS"}; | |
179 | 179 | |
180 | 180 | options.add_options() |
181 | 181 | ("output-format,f", po::value<std::string>(), "Format of output file") |
22 | 22 | |
23 | 23 | */ |
24 | 24 | |
25 | #include <osmium/io/file.hpp> | |
25 | 26 | #include <osmium/osm/box.hpp> |
26 | 27 | #include <osmium/osm/entity_bits.hpp> |
27 | 28 | #include <osmium/tags/matcher.hpp> |
29 | #include <osmium/tags/tags_filter.hpp> | |
28 | 30 | #include <osmium/util/string_matcher.hpp> |
29 | 31 | |
30 | 32 | #include <string> |
31 | 33 | #include <utility> |
32 | 34 | #include <vector> |
33 | ||
34 | namespace osmium { | |
35 | ||
36 | class TagsFilter; | |
37 | ||
38 | namespace io { | |
39 | class File; | |
40 | } // namespace io | |
41 | ||
42 | } // namespace osmium | |
43 | 35 | |
44 | 36 | std::string get_filename_suffix(const std::string& file_name); |
45 | 37 | const char* yes_no(bool choice) noexcept; |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | 8 | function(check_add_locations_to_ways _name _options _input _output) |
9 | check_output(add-locations-to-ways ${_name} "add-locations-to-ways ${_options} --generator=test --output-format=xml add-locations-to-ways/${_input}" "add-locations-to-ways/${_output}") | |
9 | check_output(add-locations-to-ways ${_name} "add-locations-to-ways ${_options} --generator=test --output-header=xml_josm_upload=false --output-format=xml add-locations-to-ways/${_input}" "add-locations-to-ways/${_output}") | |
10 | 10 | endfunction() |
11 | 11 | |
12 | 12 | check_add_locations_to_ways(taggednodes "" input.osm output.osm) |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
4 | 4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"> |
3 | 3 | <tag k="some" v="tag"/> |
4 | 4 | </node> |
19 | 19 | check_cat(cat12 input1.osm input2.osm output-cat12.osm) |
20 | 20 | check_cat(cat21 input2.osm input1.osm output-cat21.osm) |
21 | 21 | |
22 | check_convert(osm2opl input1.osm output1.osm.opl opl) | |
22 | check_convert(osm input1.osm output1.osm.opl opl) | |
23 | check_convert(gzip input1.osm.gz output1.osm.opl opl) | |
24 | check_convert(bzip2 input1.osm.bz2 output1.osm.opl opl) | |
25 | check_convert(pbf input1.osm.pbf output1.osm.opl opl) | |
26 | check_convert(opl output1.osm.opl output1.osm.opl opl) | |
23 | 27 | |
24 | 28 | |
25 | 29 | #----------------------------------------------------------------------------- |
Binary diff not shown
Binary diff not shown
Binary diff not shown
5 | 5 | # |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | function(check_fileinfo _name _options _input _output) | |
9 | check_output(fileinfo ${_name} "fileinfo ${_options} fileinfo/${_input}" "fileinfo/${_output}") | |
10 | endfunction() | |
8 | if(NOT WIN32) | |
9 | function(check_fileinfo _name _options _input _output) | |
10 | check_output(fileinfo ${_name} "fileinfo ${_options} fileinfo/${_input}" "fileinfo/${_output}") | |
11 | endfunction() | |
12 | ||
13 | check_fileinfo(fi1-extended "--extended --crc" fi1.osm fi1-result.txt) | |
14 | endif() | |
11 | 15 | |
12 | 16 | #----------------------------------------------------------------------------- |
13 | ||
14 | check_fileinfo(fi1-extended "--extended --crc" fi1.osm fi1-result.txt) | |
15 | 17 | |
16 | 18 | add_test(NAME fileinfo-g-generator COMMAND osmium fileinfo ${CMAKE_SOURCE_DIR}/test/fileinfo/fi1.osm -g header.option.generator) |
17 | 19 | set_tests_properties(fileinfo-g-generator PROPERTIES PASS_REGULAR_EXPRESSION "^testdata\n$") |
8 | 8 | Options: |
9 | 9 | generator=testdata |
10 | 10 | version=0.6 |
11 | xml_josm_upload=false | |
11 | 12 | Data: |
12 | 13 | Bounding box: (1,1,1,3) |
13 | 14 | Timestamps: |
30 | 31 | Largest relation ID: 0 |
31 | 32 | All objects have following metadata attributes: all |
32 | 33 | Some objects have following metadata attributes: all |
34 | Number of buffers: 1 (avg 5 objects per buffer) | |
35 | Sum of buffer sizes: 224 (0 GB) | |
36 | Sum of buffer capacities: 1048576 (0.001 GB, 0% full) |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | 8 | function(check_getid _name _input _output) |
9 | check_output(getid ${_name} "getid --generator=test -f osm getid/${_input} n11,n12 w21" "getid/${_output}") | |
9 | check_output(getid ${_name} "getid --generator=test --output-header=xml_josm_upload=false -f osm getid/${_input} n11,n12 w21" "getid/${_output}") | |
10 | 10 | endfunction() |
11 | 11 | |
12 | 12 | function(check_getid_file _name _file _input _output) |
13 | check_output(getid ${_name} "getid --generator=test -i getid/${_file} -f osm getid/${_input}" "getid/${_output}") | |
13 | check_output(getid ${_name} "getid --generator=test --output-header=xml_josm_upload=false -i getid/${_file} -f osm getid/${_input}" "getid/${_output}") | |
14 | 14 | endfunction() |
15 | 15 | |
16 | 16 | check_getid(n input.osm output.osm) |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | </osm> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
3 | 3 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
4 | 4 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
4 | 4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
4 | 4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> |
3 | 3 | <relation id="32" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
4 | 4 | <member type="node" ref="13" role=""/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
4 | 4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
3 | 3 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
4 | 4 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 3 | <member type="relation" ref="31" role=""/> |
4 | 4 | </relation> |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | 8 | function(check_getparents _name _input _ids _output) |
9 | check_output(getparents ${_name} "getparents --generator=test -f osm getparents/${_input} ${_ids}" "getparents/${_output}") | |
9 | check_output(getparents ${_name} "getparents --generator=test --output-header=xml_josm_upload=false -f osm getparents/${_input} ${_ids}" "getparents/${_output}") | |
10 | 10 | endfunction() |
11 | 11 | |
12 | 12 | function(check_getparents_r _name _input _ids _output) |
13 | check_output(getparents ${_name}-s "getparents --generator=test -f osm --add-self getparents/${_input} ${_ids}" "getparents/${_output}") | |
13 | check_output(getparents ${_name}-s "getparents --generator=test --output-header=xml_josm_upload=false -f osm --add-self getparents/${_input} ${_ids}" "getparents/${_output}") | |
14 | 14 | endfunction() |
15 | 15 | |
16 | 16 | #----------------------------------------------------------------------------- |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
4 | 4 | <nd ref="10"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 3 | <nd ref="10"/> |
4 | 4 | <nd ref="11"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
3 | 3 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
4 | 4 | <nd ref="10"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 3 | <nd ref="10"/> |
4 | 4 | <nd ref="11"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 3 | <nd ref="10"/> |
4 | 4 | <nd ref="11"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 3 | <member type="node" ref="12" role="m1"/> |
4 | 4 | <member type="way" ref="20" role="m2"/> |
7 | 7 | |
8 | 8 | function(check_sort2 _name _in1 _in2 _output) |
9 | 9 | check_output(sort ${_name} "sort --generator=test -f osm sort/${_in1} sort/${_in2}" "sort/${_output}") |
10 | check_output(sort ${_name}_mp "sort --generator=test -f osm -s multipass sort/${_in1} sort/${_in2}" "sort/${_output}") | |
10 | 11 | endfunction() |
11 | 12 | |
12 | 13 | function(check_sort1 _name _input _output _format) |
13 | 14 | check_output(sort ${_name} "sort --generator=test -f ${_format} sort/${_input}" "sort/${_output}") |
15 | check_output(sort ${_name}_mp "sort --generator=test -f ${_format} -s multipass sort/${_input}" "sort/${_output}") | |
14 | 16 | endfunction() |
15 | 17 | |
16 | 18 |
5 | 5 | # |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | function(check_tags_filter_R _name _input _expressions _output) | |
9 | check_output(tags-filter ${_name} "tags-filter --generator=test -f osm -R tags-filter/${_input} ${_expressions}" "tags-filter/${_output}") | |
8 | function(check_tags_filter _name _flags _input _expressions _output) | |
9 | check_output(tags-filter ${_name} "tags-filter --generator=test --output-header=xml_josm_upload=false -f osm ${_flags} tags-filter/${_input} ${_expressions}" "tags-filter/${_output}") | |
10 | 10 | endfunction() |
11 | 11 | |
12 | function(check_tags_filter_i _name _input _expressions _output) | |
13 | check_output(tags-filter ${_name} "tags-filter --generator=test -f osm -i -R tags-filter/${_input} ${_expressions}" "tags-filter/${_output}") | |
14 | endfunction() | |
12 | check_tags_filter(node "" input.osm n/amenity output-amenity.osm) | |
13 | check_tags_filter(node-R "-R" input.osm n/amenity output-amenity.osm) | |
15 | 14 | |
16 | function(check_tags_filter _name _input _expressions _output) | |
17 | check_output(tags-filter ${_name} "tags-filter --generator=test -f osm tags-filter/${_input} ${_expressions}" "tags-filter/${_output}") | |
18 | endfunction() | |
15 | check_tags_filter(highway-R "-R" input.osm w/highway output-highway-R.osm) | |
16 | check_tags_filter(note-R "-R" input.osm note output-note-R.osm) | |
19 | 17 | |
20 | check_tags_filter_R(node input.osm n/amenity output-amenity.osm) | |
21 | check_tags_filter_R(highway input.osm w/highway output-highway.osm) | |
22 | check_tags_filter_R(note input.osm note output-note.osm) | |
18 | check_tags_filter(note-iR "-i -R" input.osm note output-note-iR.osm) | |
23 | 19 | |
24 | check_tags_filter_i(note-i input.osm note output-no-note.osm) | |
20 | check_tags_filter(highway "" input.osm w/highway output-highway.osm) | |
25 | 21 | |
26 | check_tags_filter(highway-r input.osm w/highway output-highway-r.osm) | |
22 | check_tags_filter(highway-i "-i" input.osm w/highway output-highway-i.osm) | |
27 | 23 | |
24 | check_tags_filter(highway-n-i "-i" input-nodes.osm w/highway output-nodes-highway-i.osm) | |
25 | ||
26 | check_tags_filter(note-rel "" input.osm r/note output-note-rel.osm) | |
27 | ||
28 | check_tags_filter(highway-t "-t" input.osm w/highway output-highway-t.osm) | |
29 | check_tags_filter(highway-it "-i -t" input.osm w/highway output-highway-it.osm) | |
30 | check_tags_filter(note-rel-t "-t" input.osm r/note output-note-rel-t.osm) | |
28 | 31 | |
29 | 32 | #----------------------------------------------------------------------------- |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="testdata"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
9 | <tag k="amenity" v="post_box"/> | |
10 | </node> | |
11 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
12 | <tag k="highway" v="traffic_signals"/> | |
13 | </node> | |
14 | </osm> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | 1 | <osm version="0.6" upload="false" generator="testdata"> |
2 | 2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
4 | 6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
5 | 7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> |
6 | 8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> |
3 | 3 | <tag k="amenity" v="post_box"/> |
4 | 4 | </node> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
3 | <nd ref="10"/> | |
4 | <nd ref="11"/> | |
5 | <nd ref="12"/> | |
6 | <tag k="highway" v="primary"/> | |
7 | </way> | |
8 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
9 | <nd ref="12"/> | |
10 | <nd ref="13"/> | |
11 | <tag k="highway" v="residential"/> | |
12 | <tag k="note" v="test"/> | |
13 | </way> | |
14 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
9 | <tag k="amenity" v="post_box"/> | |
10 | </node> | |
11 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
12 | <tag k="highway" v="traffic_signals"/> | |
13 | </node> | |
14 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
15 | <nd ref="10"/> | |
16 | <nd ref="11"/> | |
17 | <nd ref="12"/> | |
18 | <tag k="highway" v="primary"/> | |
19 | </way> | |
20 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
21 | <member type="node" ref="12" role="m1"/> | |
22 | <member type="way" ref="20" role="m2"/> | |
23 | <tag k="note" v="test"/> | |
24 | </relation> | |
25 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
9 | <tag k="amenity" v="post_box"/> | |
10 | </node> | |
11 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
12 | <tag k="highway" v="traffic_signals"/> | |
13 | </node> | |
14 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
15 | <nd ref="10"/> | |
16 | <nd ref="11"/> | |
17 | <nd ref="12"/> | |
18 | </way> | |
19 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
20 | <member type="node" ref="12" role="m1"/> | |
21 | <member type="way" ref="20" role="m2"/> | |
22 | <tag k="note" v="test"/> | |
23 | </relation> | |
24 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> | |
4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
5 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
6 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
7 | <nd ref="10"/> | |
8 | <nd ref="11"/> | |
9 | <nd ref="12"/> | |
10 | <tag k="highway" v="primary"/> | |
11 | </way> | |
12 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
13 | <nd ref="12"/> | |
14 | <nd ref="13"/> | |
15 | <tag k="highway" v="residential"/> | |
16 | <tag k="note" v="test"/> | |
17 | </way> | |
18 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> | |
4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
5 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
6 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
7 | <nd ref="10"/> | |
8 | <nd ref="11"/> | |
9 | <nd ref="12"/> | |
10 | <tag k="highway" v="primary"/> | |
11 | </way> | |
12 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
13 | <nd ref="12"/> | |
14 | <nd ref="13"/> | |
15 | <tag k="highway" v="residential"/> | |
16 | <tag k="note" v="test"/> | |
17 | </way> | |
18 | </osm> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
2 | 8 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> |
3 | 9 | <nd ref="10"/> |
4 | 10 | <nd ref="11"/> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> | |
4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
5 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
6 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
7 | <tag k="amenity" v="post_box"/> | |
8 | </node> | |
9 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
10 | <tag k="highway" v="traffic_signals"/> | |
11 | </node> | |
12 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
13 | <nd ref="10"/> | |
14 | <nd ref="11"/> | |
15 | <nd ref="12"/> | |
16 | <tag k="highway" v="primary"/> | |
17 | </way> | |
18 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
9 | <tag k="amenity" v="post_box"/> | |
10 | </node> | |
11 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
12 | <tag k="highway" v="traffic_signals"/> | |
13 | </node> | |
14 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
3 | <nd ref="12"/> | |
4 | <nd ref="13"/> | |
5 | <tag k="highway" v="residential"/> | |
6 | <tag k="note" v="test"/> | |
7 | </way> | |
8 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
9 | <member type="node" ref="12" role="m1"/> | |
10 | <member type="way" ref="20" role="m2"/> | |
11 | <tag k="note" v="test"/> | |
12 | </relation> | |
13 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/> | |
8 | <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1"> | |
9 | <tag k="amenity" v="post_box"/> | |
10 | </node> | |
11 | <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1"> | |
12 | <tag k="highway" v="traffic_signals"/> | |
13 | </node> | |
14 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
15 | <nd ref="10"/> | |
16 | <nd ref="11"/> | |
17 | <nd ref="12"/> | |
18 | <tag k="highway" v="primary"/> | |
19 | </way> | |
20 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> | |
4 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
5 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
6 | <nd ref="10"/> | |
7 | <nd ref="11"/> | |
8 | <nd ref="12"/> | |
9 | </way> | |
10 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
11 | <member type="node" ref="12" role="m1"/> | |
12 | <member type="way" ref="20" role="m2"/> | |
13 | <tag k="note" v="test"/> | |
14 | </relation> | |
15 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> | |
3 | <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"> | |
4 | <tag k="barrier" v="gate"/> | |
5 | </node> | |
6 | <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> | |
7 | <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
8 | <nd ref="10"/> | |
9 | <nd ref="11"/> | |
10 | <nd ref="12"/> | |
11 | <tag k="highway" v="primary"/> | |
12 | </way> | |
13 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
14 | <member type="node" ref="12" role="m1"/> | |
15 | <member type="way" ref="20" role="m2"/> | |
16 | <tag k="note" v="test"/> | |
17 | </relation> | |
18 | </osm> |
0 | <?xml version='1.0' encoding='UTF-8'?> | |
1 | <osm version="0.6" generator="test"> | |
2 | <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
3 | <nd ref="12"/> | |
4 | <nd ref="13"/> | |
5 | <tag k="highway" v="residential"/> | |
6 | <tag k="note" v="test"/> | |
7 | </way> | |
8 | <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1"> | |
9 | <member type="node" ref="12" role="m1"/> | |
10 | <member type="way" ref="20" role="m2"/> | |
11 | <tag k="note" v="test"/> | |
12 | </relation> | |
13 | </osm> |
6 | 6 | #----------------------------------------------------------------------------- |
7 | 7 | |
8 | 8 | function(check_time_filter _name _type _from _to _output) |
9 | check_output(time-filter ${_name} "time-filter --generator=test -f ${_type} time-filter/input.osh ${_from} ${_to}" "time-filter/output-${_output}.${_type}") | |
9 | check_output(time-filter ${_name} "time-filter --generator=test --output-header=xml_josm_upload=false -f ${_type} time-filter/input.osh ${_from} ${_to}" "time-filter/output-${_output}.${_type}") | |
10 | 10 | endfunction() |
11 | 11 | |
12 | 12 | #----------------------------------------------------------------------------- |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/> |
3 | 3 | <node id="3" version="4" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="3" lon="3"/> |
4 | 4 | </osm> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/> |
3 | 3 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/> |
4 | 4 | <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/> |
3 | 3 | <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="2" lon="1"/> |
4 | 4 | <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/> |
3 | 3 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/> |
4 | 4 | <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="2" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/> |
3 | 3 | <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/> |
4 | 4 | <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="2" lon="3"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/> |
3 | 3 | <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/> |
4 | 4 | <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/> |
3 | 3 | <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/> |
4 | 4 | <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/> |
3 | 3 | <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/> |
4 | 4 | <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" lat="1" lon="2"/> |
3 | 3 | <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/> |
4 | 4 | <node id="3" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" lat="3" lon="2"/> |
0 | 0 | <?xml version='1.0' encoding='UTF-8'?> |
1 | <osm version="0.6" generator="test"> | |
1 | <osm version="0.6" upload="false" generator="test"> | |
2 | 2 | <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="1" lon="3"/> |
3 | 3 | <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/> |
4 | 4 | <node id="3" version="4" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="3" lon="3"/> |