File: delete-callbacks.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 (112 lines) | stat: -rw-r--r-- 3,966 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
Feature: Test for delete callbacks

    Background:
        Given the input file 'liechtenstein-2013-08-03.osm.pbf'
        And the lua style
            """
            local change = osm2pgsql.define_table{
                name = 'change',
                ids = {type = 'any', id_column = 'osm_id', type_column = 'osm_type'},
                columns = {
                    { column = 'extra', type = 'int' }
                }}

            local function process_delete(object)
                change:insert{extra = object.version}
            end

            osm2pgsql.process_deleted_node = process_delete
            osm2pgsql.process_deleted_way = process_delete
            osm2pgsql.process_deleted_relation = process_delete
            """
        When running osm2pgsql flex with parameters
            | --slim |

        Then table change contains exactly
            | osm_type | osm_id |

        Given the input file '008-ch.osc.gz'

    Scenario: Delete callbacks are called
        When running osm2pgsql flex with parameters
            | --slim | -a |

        Then SELECT osm_type, count(*), sum(extra) FROM change GROUP BY osm_type
            | osm_type | count | sum |
            | N        | 16773 | 16779 |
            | W        | 4     | 9 |
            | R        | 1     | 3 |

        When running osm2pgsql flex with parameters
            | --slim | -a |

        Then SELECT osm_type, count(*), sum(osm_id) FROM change GROUP BY osm_type
            | osm_type | count | sum |
            | N        | 16773 | 37856781001834 |
            | W        | 4     | 350933407 |
            | R        | 1     | 2871571 |

    Scenario: No object payload is available
        Given the lua style
            """
            local change = osm2pgsql.define_table{
                name = 'change',
                ids = {type = 'any', id_column = 'osm_id', type_column = 'osm_type'},
                columns = {
                    { column = 'extra', type = 'int' }
                }}

            function osm2pgsql.process_deleted_node(object)
                change:insert{extra = object.tags == nil and 1 or 0}
            end

            function osm2pgsql.process_deleted_way(object)
                change:insert{extra = object.nodes == nil and 1 or 0}
            end

            function osm2pgsql.process_deleted_relation(object)
                change:insert{extra = object.members == nil and 1 or 0}
            end


            """
        When running osm2pgsql flex with parameters
            | --slim | -a |
        Then SELECT osm_type, count(*), sum(extra) FROM change GROUP BY osm_type
            | osm_type | count | sum |
            | N        | 16773 | 16773 |
            | W        | 4     | 4 |
            | R        | 1     | 1 |


    Scenario: Geometries are not valid for deleted objects
        Given the lua style
            """
            change = osm2pgsql.define_table{
                name = 'change',
                ids = {type = 'any', id_column = 'osm_id', type_column = 'osm_type'},
                columns = {
                    { column = 'extra', sql_type = 'int' }
                }}

            function osm2pgsql.process_deleted_node(object)
                change:insert{extra = object.as_point == nil and 1 or 0}
            end

            function osm2pgsql.process_deleted_way(object)
                change:insert{extra = object.as_linestring == nil and 1 or 0}
            end

            function osm2pgsql.process_deleted_relation(object)
                change:insert{extra = object.as_geometrycollection == nil and 1 or 0}
            end


            """
        When running osm2pgsql flex with parameters
            | --slim | -a |
        Then SELECT osm_type, count(*), sum(extra) FROM change GROUP BY osm_type
            | osm_type | count | sum |
            | N        | 16773 | 16773|
            | W        | 4     | 4|
            | R        | 1     | 1|