Skip to content

Commit 2708888

Browse files
committed
WIP Add osm2pgsql-expire command
**work in progress** New osm2pgsql-expire command that helps with debugging/visualizing expire tiles issues. See man/osm2pgsql-expire.md for details.
1 parent 88e973f commit 2708888

File tree

8 files changed

+622
-1
lines changed

8 files changed

+622
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ else()
271271
target_link_libraries(osm2pgsql-gen osm2pgsql_lib ${LIBS} ${POTRACE_LIBRARY} ${OpenCV_LIBS})
272272
endif()
273273

274+
add_executable(osm2pgsql-expire src/osm2pgsql-expire.cpp)
275+
target_link_libraries(osm2pgsql-expire osm2pgsql_lib ${LIBS})
276+
274277
#############################################################
275278
# Optional "clang-tidy" target
276279
#############################################################

man/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ if(PANDOC)
2626

2727
list(APPEND MANPAGE_TARGETS osm2pgsql.1)
2828

29+
add_custom_command(OUTPUT osm2pgsql-expire.1
30+
COMMAND ${PANDOC} ${PANDOC_MAN_OPTIONS} -o osm2pgsql-expire.1
31+
${CMAKE_CURRENT_SOURCE_DIR}/osm2pgsql-expire.md
32+
DEPENDS osm2pgsql-expire.md manpage.template
33+
COMMENT "Building manpage osm2pgsql-expire.1"
34+
VERBATIM)
35+
list(APPEND MANPAGE_TARGETS osm2pgsql-expire.1)
36+
2937
if(BUILD_GEN)
3038
add_custom_command(OUTPUT osm2pgsql-gen.1
3139
COMMAND ${PANDOC} ${PANDOC_MAN_OPTIONS} -o osm2pgsql-gen.1

man/osm2pgsql-expire.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# NAME
2+
3+
osm2pgsql-expire - Visualize expire output
4+
5+
# SYNOPSIS
6+
7+
**osm2pgsql-expire** \[*OPTIONS*\] *OSM-FILE* (1)
8+
**osm2pgsql-expire** \[*OPTIONS*\] *OSM-FILE* (1)
9+
**osm2pgsql-expire** *TILES-FILE* (2)
10+
11+
# DESCRIPTION
12+
13+
The expire command can be used for two things:
14+
15+
1. **To check what tiles some OSM data is in.** If an *OSM-FILE* is specified
16+
that file is read and the tiles calculated in which the objects in that file
17+
are. Note that the file must not be a change file but a regular OSM data
18+
file!
19+
2. **Visualize tile list.** If a *TILE-FILE* (presumably generated by osm2pgsql)
20+
is specified, a GeoJSON file is generated showing all mentioned tiles. In
21+
this mode all command line options are ignored.
22+
23+
Read the *Expire* chapter of the osm2pgsql manual
24+
(https://osm2pgsql.org/doc/manual.html#expire) for details on how to
25+
interpret the `-m, \--mode` and `\--full-area-limit` options.
26+
27+
# OPTIONS
28+
29+
This program follows the usual GNU command line syntax, with long options
30+
starting with two dashes (`--`). Mandatory arguments to long options are
31+
mandatory for short options too.
32+
33+
# MAIN OPTIONS
34+
35+
-b, \--buffer=VALUE
36+
: Set buffer size around geometry relative to tile size.
37+
38+
-f, \--format=FORMAT
39+
: Output format. Options are 'tiles' (default) or 'geojson'. The GeoJSON output
40+
uses the Web Mercator projection (EPSG:3857) which is supported by many
41+
programs although, strictly speaking, it is not allowed by the GeoJSON spec.
42+
43+
\--full-area-limit=VALUE
44+
: Set full area limit.
45+
46+
-m, \--mode=MODE
47+
: Set expire mode. One of `boundary_only`, `full_area` (default), and `hybrid`.
48+
49+
-z, \--zoom=ZOOM
50+
: Zoom level on which to calculate tiles.
51+
52+
# HELP/VERSION OPTIONS
53+
54+
-h, \--help
55+
: Print help.
56+
57+
-V, \--version
58+
: Print osm2pgsql version.
59+
60+
# LOGGING OPTIONS
61+
62+
\--log-level=LEVEL
63+
: Set log level ('debug', 'info' (default), 'warn', or 'error').
64+
65+
\--log-progress=VALUE
66+
: Enable (`true`) or disable (`false`) progress logging. Setting this to
67+
`auto` will enable progress logging on the console and disable it
68+
if the output is redirected to a file. Default: true.
69+
70+
\--log-sql
71+
: Enable logging of SQL commands for debugging.
72+
73+
\--log-sql-data
74+
: Enable logging of all data added to the database. This will write out
75+
a huge amount of data! For debugging.
76+
77+
-v, \--verbose
78+
: Same as `--log-level=debug`.
79+
80+
# DATABASE OPTIONS
81+
82+
-d, \--database=NAME
83+
: The name of the PostgreSQL database to connect to. If this parameter
84+
contains an `=` sign or starts with a valid URI prefix (`postgresql://` or
85+
`postgres://`), it is treated as a conninfo string. See the PostgreSQL
86+
manual for details.
87+
88+
-U, \--username=NAME, \--user=NAME
89+
: Postgresql user name.
90+
91+
-W, \--password
92+
: Force password prompt.
93+
94+
-H, \--host=HOSTNAME
95+
: Database server hostname or unix domain socket location.
96+
97+
-P, \--port=PORT
98+
: Database server port.
99+
100+
\--schema=SCHEMA
101+
: Default for various schema settings throughout osm2pgsql (default: `public`).
102+
The schema must exist in the database and be writable by the database user.
103+
104+
# SEE ALSO
105+
106+
* [osm2pgsql website](https://osm2pgsql.org)
107+
* [osm2pgsql manual](https://osm2pgsql.org/doc/manual.html)
108+
* **osm2pgsql**(1)
109+
* **postgres**(1)
110+
* **osmcoastline**(1)
111+

src/expire-output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ std::size_t expire_output_t::output_tiles_to_file(
4545

4646
auto const count = for_each_tile(
4747
tiles_at_maxzoom, m_minzoom, m_maxzoom, [&](tile_t const &tile) {
48-
fmt::print(outfile, "{}/{}/{}\n", tile.zoom(), tile.x(), tile.y());
48+
fmt::print(outfile, "{}\n", tile.to_zxy());
4949
});
5050

5151
(void)std::fclose(outfile);

0 commit comments

Comments
 (0)