File: bbox.feature

package info (click to toggle)
osm2pgsql 2.1.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,652 kB
  • sloc: cpp: 59,934; python: 1,039; ansic: 763; sh: 25; makefile: 14
file content (126 lines) | stat: -rw-r--r-- 5,482 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
Feature: Test get_bbox() function

    Scenario Outline: for nodes
        Given the OSM data
            """
            n10 v1 dV Tamenity=post_box x20.0 y10.1
            """
        And the lua style
            """
            local points = osm2pgsql.define_node_table('osm2pgsql_test_points', {
                { column = 'min_x', type = 'real' },
                { column = 'min_y', type = 'real' },
                { column = 'max_x', type = 'real' },
                { column = 'max_y', type = 'real' },
                { column = 'geom',  type = 'point', projection = <projection>, not_null = true },
            })

            function osm2pgsql.process_node(object)
                local row = { geom = object:as_point() }
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                local min_x, min_y, max_x, max_y = object:as_point():get_bbox()
                assert(row.min_x == min_x)
                assert(row.min_y == min_y)
                assert(row.max_x == max_x)
                assert(row.max_y == max_y)
                points:insert(row)
            end
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_points contains exactly
            | node_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
            | 10      | 20.0  | 20.0  | 10.1  | 10.1  | <geometry>      |

        Examples:
            | projection | geometry            |
            | 4326       | 20 10.1             |
            | 3857       | 2226389.8 1130195.4 |

    Scenario Outline: for ways
        Given the 0.1 grid with origin 20.0 10.1
            | 10 | 11 |
            |    | 12 |
        And the OSM data
            """
            w20 v1 dV Thighway=primary Nn10,n11,n12
            """
        And the lua style
            """
            local highways = osm2pgsql.define_way_table('osm2pgsql_test_highways', {
                { column = 'min_x', type = 'real' },
                { column = 'min_y', type = 'real' },
                { column = 'max_x', type = 'real' },
                { column = 'max_y', type = 'real' },
                { column = 'geom',  type = 'linestring', projection = <projection>, not_null = true },
            })

            function osm2pgsql.process_way(object)
                local row = { geom = object:as_linestring() }
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                local min_x, min_y, max_x, max_y = object:as_linestring():get_bbox()
                assert(row.min_x == min_x)
                assert(row.min_y == min_y)
                assert(row.max_x == max_x)
                assert(row.max_y == max_y)
                highways:insert(row)
            end
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_highways contains exactly
            | way_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
            | 20     | 20.0  | 20.1  | 10.0  | 10.1  | <geometry>      |

        Examples:
            | projection | geometry                                                    |
            | 4326       | 20 10.1,20.1 10.1,20.1 10                                   |
            | 3857       | 2226389.8 1130195.4,2237521.8 1130195.4,2237521.8 1118890.0 |

    Scenario Outline: for relations
        Given the 0.1 grid with origin 20.0 10.1
            | 10 | 11 |
            |    | 12 |
        And the OSM data
            """
            w20 v1 dV Nn10,n11
            w21 v1 dV Nn11,n12
            r30 v1 dV Ttype=route,route=bus Mw20@
            r31 v1 dV Ttype=route,route=bus Mw20@,w21@
            """
        And the lua style
            """
            local rels = osm2pgsql.define_relation_table('osm2pgsql_test_routes', {
                { column = 'min_x', type = 'real' },
                { column = 'min_y', type = 'real' },
                { column = 'max_x', type = 'real' },
                { column = 'max_y', type = 'real' },
                { column = 'geom',  type = 'linestring', projection = <projection>, not_null = true },
            })

            function osm2pgsql.process_relation(object)
                local row = {}
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                for sgeom in object:as_multilinestring():line_merge():geometries() do
                    row.geom = sgeom
                    local min_x, min_y, max_x, max_y = sgeom:get_bbox()
                    assert(row.min_x == min_x)
                    assert(row.min_y == min_y)
                    assert(row.max_x == max_x)
                    assert(row.max_y == max_y)
                    rels:insert(row)
                end
            end
            """
        When running osm2pgsql flex

        Then table osm2pgsql_test_routes contains exactly
            | relation_id | min_x | max_x | min_y | max_y | ST_AsText(geom) |
            | 30          | 20.0  | 20.1  | 10.1  | 10.1  | <geom30>        |
            | 31          | 20.0  | 20.1  | 10.0  | 10.1  | <geom31>        |

        Examples:
            | projection | geom30                                  | geom31                                                      |
            | 4326       | 10, 11                                  | 10, 11, 12                                                  |
            | 3857       | 2226389.8 1130195.4,2237521.8 1130195.4 | 2226389.8 1130195.4,2237521.8 1130195.4,2237521.8 1118890.0 |