File: bbox.feature

package info (click to toggle)
osm2pgsql 1.8.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,536 kB
  • sloc: cpp: 46,707; ansic: 1,804; python: 797; sh: 25; makefile: 14
file content (108 lines) | stat: -rw-r--r-- 4,518 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
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> },
            })

            function osm2pgsql.process_node(object)
                local row = {}
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                points:add_row(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> },
            })

            function osm2pgsql.process_way(object)
                local row = { geom = { create = 'line' } }
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                highways:add_row(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> },
            })

            function osm2pgsql.process_relation(object)
                local row = { geom = { create = 'line' } }
                row.min_x, row.min_y, row.max_x, row.max_y = object:get_bbox()
                rels:add_row(row)
            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 |