File: geometry-collection.feature

package info (click to toggle)
osm2pgsql 2.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,772 kB
  • sloc: cpp: 60,940; python: 1,115; ansic: 763; sh: 25; makefile: 14
file content (110 lines) | stat: -rw-r--r-- 3,984 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Feature: Create geometry collections from relations

    Background:
        Given the lua style
            """
            local dtable = osm2pgsql.define_table{
                name = 'osm2pgsql_test_collection',
                ids = { type = 'relation', id_column = 'osm_id' },
                columns = {
                    { column = 'name', type = 'text' },
                    { column = 'geom', type = 'geometrycollection', projection = 4326 }
                }
            }

            function osm2pgsql.process_relation(object)
                dtable:insert({
                    name = object.tags.name,
                    geom = object.as_geometrycollection()
                })
            end
            """

    Scenario Outline: Create geometry collection from different relations
        Given the 1.0 grid
            | 13 | 12 | 17 |    | 16 |
            | 10 | 11 |    | 14 | 15 |
        And the OSM data
            """
            w20 Nn10,n11,n12,n13,n10
            w21 Nn14,n15,n16
            r30 Tname=single Mw20@
            r31 Tname=multi Mw20@,w21@
            r32 Tname=mixed Mn17@,w21@
            r33 Tname=node Mn17@
            """
        When running osm2pgsql flex with parameters
            | -c      |
            | <param> |

        Then table osm2pgsql_test_collection contains exactly
            | osm_id | name   | ST_GeometryType(geom) | ST_NumGeometries(geom) | ST_GeometryType(ST_GeometryN(geom, 1)) |
            | 30     | single | ST_GeometryCollection | 1                      | ST_LineString                          |
            | 31     | multi  | ST_GeometryCollection | 2                      | ST_LineString                          |
            | 32     | mixed  | ST_GeometryCollection | 2                      | ST_Point                               |
            | 33     | node   | ST_GeometryCollection | 1                      | ST_Point                               |

        And table osm2pgsql_test_collection contains exactly
            | osm_id | ST_AsText(geom)                    |
            | 30     | { 10, 11, 12, 13, 10 }             |
            | 31     | { 10, 11, 12, 13, 10; 14, 15, 16 } |
            | 32     | { 17; 14, 15, 16 }                 |
            | 33     | { 17 }                             |

        Examples:
            | param  |
            |        |
            | --slim |

    Scenario: NULL entry generated for broken geometries
        Given the grid
            | 10 |
        And the OSM data
            """
            w20 Nn10
            r30 Tname=foo Mn11@
            r31 Tname=bar Mw20@
            r32 Tname=baz Mw21@
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_collection contains exactly
            | osm_id | name   | geom |
            | 30     | foo    | NULL |
            | 31     | bar    | NULL |
            | 32     | baz    | NULL |

    Scenario: Null geometry generated for broken way lines
        Given the grid
            | 10 |
        And the OSM data
            """
            w20 Nn10
            w21 Nn10,n10
            r30 Tname=w20 Mw20@
            r31 Tname=w21 Mw21@
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_collection contains exactly
            | osm_id | name  | geom |
            | 30     | w20   | NULL |
            | 31     | w21   | NULL |

    Scenario: No geometry generated for broken way lines, others are there
        Given the grid
            | 10 | 11 |
            | 13 | 12 |
        And the OSM data
            """
            w20 Nn10,n11,n12,n13,n10
            w21 Nn10
            w22 Nn10,n11,n13
            r30 Tname=three Mw20@,w21@,w22@
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_collection contains exactly
            | osm_id | name  | ST_AsText(geom)                    |
            | 30     | three | { 10, 11, 12, 13, 10; 10, 11, 13 } |