Replace osmborder with imposm/SQL (#1213)

Fixes #1156
Fixes #810
Fixes #1228

This PR replaces `osmborder`, which is no longer maintained, with `imposm` mappings and SQL code to generate borders.  Key features that were moved into the imposm/SQL layer:
1. Grouping by `osm_id` and aggregating by lowest `admin_level` value so that there's only one copy of ways that are members of multiple relations.
2. Filtering out of point features in boundary relations (typically `admin_centre` and `label` roles).
3. Move disputed boundary detection logic into SQL.

This will increase the database size slightly because of the limits of what imposm can do, as some of the filtering is done in the SQL layer after importing, rather than being done in `osmborder`.
This commit is contained in:
Brian Sperlongano
2021-09-29 05:08:55 -04:00
committed by GitHub
parent bfdbd829dc
commit b4b897999d
9 changed files with 187 additions and 404 deletions

View File

@@ -1,107 +1,34 @@
generalized_tables:
# etldoc: osm_border_disp_linestring_gen_z2 -> osm_border_disp_linestring_gen_z1
border_disp_linestring_gen_z1:
source: border_disp_linestring_gen_z2
sql_filter: admin_level = 2
tolerance: ZRES2
# etldoc: osm_border_disp_linestring_gen_z3 -> osm_border_disp_linestring_gen_z2
border_disp_linestring_gen_z2:
source: border_disp_linestring_gen_z3
sql_filter: admin_level = 2
tolerance: ZRES3
# etldoc: osm_border_disp_linestring_gen_z4 -> osm_border_disp_linestring_gen_z3
border_disp_linestring_gen_z3:
source: border_disp_linestring_gen_z4
sql_filter: admin_level = 2
tolerance: ZRES4
# etldoc: osm_border_disp_linestring_gen_z5 -> osm_border_disp_linestring_gen_z4
border_disp_linestring_gen_z4:
source: border_disp_linestring_gen_z5
sql_filter: admin_level = 2
tolerance: ZRES5
# etldoc: osm_border_disp_linestring_gen_z6 -> osm_border_disp_linestring_gen_z5
border_disp_linestring_gen_z5:
source: border_disp_linestring_gen_z6
sql_filter: admin_level = 2
tolerance: ZRES6
# etldoc: osm_border_disp_linestring_gen_z7 -> osm_border_disp_linestring_gen_z6
border_disp_linestring_gen_z6:
source: border_disp_linestring_gen_z7
sql_filter: admin_level = 2
tolerance: ZRES7
# etldoc: osm_border_disp_linestring_gen_z8 -> osm_border_disp_linestring_gen_z7
border_disp_linestring_gen_z7:
source: border_disp_linestring_gen_z8
sql_filter: admin_level = 2
tolerance: ZRES8
# etldoc: osm_border_disp_linestring_gen_z9 -> osm_border_disp_linestring_gen_z8
border_disp_linestring_gen_z8:
source: border_disp_linestring_gen_z9
sql_filter: admin_level = 2
tolerance: ZRES9
# etldoc: osm_border_disp_linestring_gen_z10 -> osm_border_disp_linestring_gen_z9
border_disp_linestring_gen_z9:
source: border_disp_linestring_gen_z10
sql_filter: admin_level = 2
tolerance: ZRES10
# etldoc: osm_border_disp_linestring_gen_z11 -> osm_border_disp_linestring_gen_z10
border_disp_linestring_gen_z10:
source: border_disp_linestring_gen_z11
sql_filter: admin_level = 2
tolerance: ZRES11
# etldoc: osm_border_disp_linestring_gen_z12 -> osm_border_disp_linestring_gen_z11
border_disp_linestring_gen_z11:
source: border_disp_linestring_gen_z12
sql_filter: admin_level = 2
tolerance: ZRES12
# etldoc: osm_border_disp_linestring_gen_z13 -> osm_border_disp_linestring_gen_z12
border_disp_linestring_gen_z12:
source: border_disp_linestring_gen_z13
sql_filter: admin_level = 2
tolerance: ZRES13
# etldoc: osm_border_disp_linestring -> osm_border_disp_linestring_gen_z13
border_disp_linestring_gen_z13:
source: border_disp_linestring
sql_filter: admin_level = 2
tolerance: ZRES14
# etldoc: osm_border_disp_relation -> osm_border_disp_linestring
# etldoc: osm_border_linestring -> osm_border_disp_linestring
border_disp_linestring:
source: border_disp_relation
sql_filter: ST_GeometryType(geometry) = 'ST_LineString'
source: border_linestring
sql_filter: ST_GeometryType(geometry) = 'ST_LineString' AND (disputed OR dispute OR border_status = 'disputed' OR disputed_by <> '') AND admin_level = 2
tables:
# etldoc: imposm3 -> osm_border_disp_relation
border_disp_relation:
# etldoc: imposm3 -> osm_border_linestring
border_linestring:
type: relation_member
filters:
require:
admin_level: [__any__]
boundary: [administrative]
columns:
- name: relation_id
type: id
- name: osm_id
type: id
from_member: true
- name: member
type: member_id
- name: type
type: member_type
- name: geometry
type: geometry
- key: name
name: name
type: string
- key: boundary
name: boundary
type: string
# Used for disputed boundary, e.g. "Line of actual control"
from_member: true
- key: admin_level
name: admin_level
type: integer
@@ -111,14 +38,36 @@ tables:
- key: disputed_by
name: disputed_by
type: string
from_member: true
- key: dispute
name: dispute
type: bool
from_member: true
- key: disputed
name: disputed
type: bool
from_member: true
- key: border_status
name: border_status
type: string
from_member: true
- key: maritime
name: maritime
type: bool
from_member: true
- key: boundary_type
name: boundary_type
type: string
from_member: true
- key: natural
name: natural
type: string
from_member: true
relation_types: [boundary]
mapping:
type: [boundary]
filters:
require:
#admin_level: ['2']
admin_level: [__any__]
claimed_by: [__any__]
boundary:
- administrative
border_status:
- dispute
boundary_type:
- maritime