Skip to content

Commit 3984965

Browse files
committed
osm2pgsql-expire: Expire type=boundary relations as multipolygons
You can always use --mode=boundary_only to switch back to boundary only interepretation. So type=boundary is now treated exactly like type=multipolygon. Also adds more information to man page.
1 parent 4a85d1b commit 3984965

File tree

3 files changed

+71
-28
lines changed

3 files changed

+71
-28
lines changed

man/osm2pgsql-expire.1

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,102 @@
11
.TH "OSM2PGSQL" "1" "2.2.0" "" ""
22
.SH NAME
3-
osm2pgsql\-expire \- Visualize expire output
3+
.PP
4+
osm2pgsql-expire - Visualize expire output
45
.SH SYNOPSIS
5-
\f[B]osm2pgsql\-expire\f[R] [\f[I]OPTIONS\f[R]] \f[I]OSM\-FILE\f[R] (1)
6-
\f[B]osm2pgsql\-expire\f[R] \f[I]TILES\-FILE\f[R] (2)
6+
.PP
7+
\f[B]osm2pgsql-expire\f[R] [\f[I]OPTIONS\f[R]] \f[I]OSM-FILE\f[R] (1)
8+
\f[B]osm2pgsql-expire\f[R] \f[I]TILES-FILE\f[R] (2)
79
.SH DESCRIPTION
10+
.PP
811
\f[B]This command is currently experimental.\f[R]
912
.PP
1013
The expire command can be used for two things:
1114
.IP "1." 3
1215
\f[B]To check what tiles some OSM data is in.\f[R] If an
13-
\f[I]OSM\-FILE\f[R] is specified osm2pgsql\-expire will calculate the
16+
\f[I]OSM-FILE\f[R] is specified osm2pgsql-expire will calculate the
1417
tiles covering the objects in that file.
1518
Note that the file must not be a change file but a regular OSM data
1619
file!
1720
Output is, by default, a tile file, but GeoJSON is also possible.
21+
Covering tiles are only calculated for tagged objects.
1822
.IP "2." 3
19-
\f[B]Visualize tile list.\f[R] If a \f[I]TILE\-FILE\f[R] (presumably
23+
\f[B]Visualize tile list.\f[R] If a \f[I]TILE-FILE\f[R] (presumably
2024
generated by osm2pgsql) is specified, a GeoJSON file is generated
2125
showing all mentioned tiles.
2226
In this mode all command line options are ignored.
2327
.PP
2428
Read the \f[I]Expire\f[R] chapter of the osm2pgsql manual
2529
(https://osm2pgsql.org/doc/manual.html#expire) for details on how to
26-
interpret the \f[CR]\-m, \[rs]\-\-mode\f[R] and
27-
\f[CR]\[rs]\-\-full\-area\-limit\f[R] options.
30+
interpret the \f[V]-m, \[rs]--mode\f[R] and
31+
\f[V]\[rs]--full-area-limit\f[R] options.
32+
.SH GEOMETRY GENERATION
33+
.PP
34+
To calculate the tiles covering the specified OSM data in mode (1), a
35+
geometry has to be generated first for each object.
36+
This works as follow:
37+
.IP \[bu] 2
38+
For nodes a point geometry will be generated.
39+
.IP \[bu] 2
40+
For closed ways a polygon geometry will be generated, for non-closed
41+
ways a linestring geometry.
42+
If a generated polygon is not valid, the program will fall back to a
43+
linestring.
44+
If neither a valid polygon nor a valid linestring can be generated the
45+
object is ignored.
46+
.IP \[bu] 2
47+
For relations a geometry is generated based on the \f[V]type\f[R] tag.
48+
For types \f[V]multipolygon\f[R] and \f[V]boundary\f[R], a multipolygon
49+
geometry is created, for types \f[V]route\f[R] and
50+
\f[V]multilinestring\f[R] a multilinestring geometry is created, for all
51+
other types a geometry collection is created.
52+
.PP
53+
Note that for (multi)polygons it depends on the command line options
54+
--mode and --full-area-limit whether the tiles calculation is based on
55+
the area or the boundary of the (multi)polygons.
2856
.SH OPTIONS
57+
.PP
2958
This program follows the usual GNU command line syntax, with long
30-
options starting with two dashes (\f[CR]\-\-\f[R]).
59+
options starting with two dashes (\f[V]--\f[R]).
3160
Mandatory arguments to long options are mandatory for short options too.
3261
.SH MAIN OPTIONS
3362
.TP
34-
\-b, \-\-buffer=VALUE
63+
-b, --buffer=VALUE
3564
Set buffer size around geometry relative to tile size.
3665
Example: Set to 0.1 for a buffer that\[cq]s 10% of the tile size.
3766
.TP
38-
\-f, \-\-format=FORMAT
67+
-f, --format=FORMAT
3968
Output format.
4069
Options are `tiles' (default) or `geojson'.
4170
The GeoJSON output uses the Web Mercator projection (EPSG:3857) which is
4271
supported by many programs although, strictly speaking, it is not
4372
allowed by the GeoJSON spec.
4473
.TP
45-
\-\-full\-area\-limit=VALUE
74+
--full-area-limit=VALUE
4675
Set full area limit.
4776
.TP
48-
\-m, \-\-mode=MODE
77+
-m, --mode=MODE
4978
Set expire mode.
50-
One of \f[CR]boundary_only\f[R], \f[CR]full_area\f[R] (default), and
51-
\f[CR]hybrid\f[R].
79+
One of \f[V]boundary_only\f[R], \f[V]full_area\f[R] (default), and
80+
\f[V]hybrid\f[R].
5281
.TP
53-
\-z, \-\-zoom=ZOOM
82+
-z, --zoom=ZOOM
5483
Zoom level on which to calculate tiles.
5584
.SH HELP/VERSION OPTIONS
5685
.TP
57-
\-h, \-\-help
86+
-h, --help
5887
Print help.
5988
.TP
60-
\-V, \-\-version
89+
-V, --version
6190
Print osm2pgsql version.
6291
.SH LOGGING OPTIONS
6392
.TP
64-
\-\-log\-level=LEVEL
93+
--log-level=LEVEL
6594
Set log level (`debug', `info' (default), `warn', or `error').
6695
.SH SEE ALSO
6796
.IP \[bu] 2
68-
\c
69-
.UR https://osm2pgsql.org
70-
osm2pgsql website
71-
.UE \c
97+
osm2pgsql website (https://osm2pgsql.org)
7298
.IP \[bu] 2
73-
\c
74-
.UR https://osm2pgsql.org/doc/manual.html
75-
osm2pgsql manual
76-
.UE \c
99+
osm2pgsql manual (https://osm2pgsql.org/doc/manual.html)
77100
.IP \[bu] 2
78101
\f[B]osm2pgsql\f[R](1)
79102
.IP \[bu] 2

man/osm2pgsql-expire.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ The expire command can be used for two things:
1616
1. **To check what tiles some OSM data is in.** If an *OSM-FILE* is specified
1717
osm2pgsql-expire will calculate the tiles covering the objects in that file.
1818
Note that the file must not be a change file but a regular OSM data file!
19-
Output is, by default, a tile file, but GeoJSON is also possible.
19+
Output is, by default, a tile file, but GeoJSON is also possible. Covering
20+
tiles are only calculated for tagged objects.
2021
2. **Visualize tile list.** If a *TILE-FILE* (presumably generated by osm2pgsql)
2122
is specified, a GeoJSON file is generated showing all mentioned tiles. In
2223
this mode all command line options are ignored.
@@ -25,6 +26,25 @@ Read the *Expire* chapter of the osm2pgsql manual
2526
(https://osm2pgsql.org/doc/manual.html#expire) for details on how to
2627
interpret the `-m, \--mode` and `\--full-area-limit` options.
2728

29+
# GEOMETRY GENERATION
30+
31+
To calculate the tiles covering the specified OSM data in mode (1), a geometry
32+
has to be generated first for each object. This works as follow:
33+
34+
* For nodes a point geometry will be generated.
35+
* For closed ways a polygon geometry will be generated, for non-closed ways
36+
a linestring geometry. If a generated polygon is not valid, the program
37+
will fall back to a linestring. If neither a valid polygon nor a valid
38+
linestring can be generated the object is ignored.
39+
* For relations a geometry is generated based on the `type` tag. For types
40+
`multipolygon` and `boundary`, a multipolygon geometry is created, for types
41+
`route` and `multilinestring` a multilinestring geometry is created, for
42+
all other types a geometry collection is created.
43+
44+
Note that for (multi)polygons it depends on the command line options \--mode
45+
and \--full-area-limit whether the tiles calculation is based on the area or
46+
the boundary of the (multi)polygons.
47+
2848
# OPTIONS
2949

3050
This program follows the usual GNU command line syntax, with long options

src/osm2pgsql-expire.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void output_expire_t::relation_add(osmium::Relation const &relation)
189189
osmium::memory::Buffer tmp_buffer{1024,
190190
osmium::memory::Buffer::auto_grow::yes};
191191
geom::geometry_t geom;
192-
if (type == "multipolygon") {
192+
if (type == "multipolygon" || type == "boundary") {
193193
log_debug("Creating multipolygon from relation {}...", relation.id());
194194
geom::create_multipolygon(&geom, relation, buffer, &tmp_buffer);
195195
} else if (type == "route" || type == "multilinestring") {

0 commit comments

Comments
 (0)