|
| 1 | +Feature: Creating point features from way |
| 2 | + |
| 3 | + Scenario: |
| 4 | + Given the grid |
| 5 | + | 1 | 2 | | |
| 6 | + | 4 | | 3 | |
| 7 | + | | 5 | | |
| 8 | + And the OSM data |
| 9 | + """ |
| 10 | + w20 Thighway=motorway Nn1,n2,n3 |
| 11 | + w21 Thighway=motorway Nn4,n5 |
| 12 | + """ |
| 13 | + And the lua style |
| 14 | + """ |
| 15 | + local points = osm2pgsql.define_way_table('osm2pgsql_test_points', { |
| 16 | + { column = 'n', type = 'int' }, |
| 17 | + { column = 'geom', type = 'point', projection = 4326, not_null = false }, |
| 18 | + }) |
| 19 | +
|
| 20 | + function osm2pgsql.process_way(object) |
| 21 | + if object.tags.highway == 'motorway' then |
| 22 | + points:insert({ n = nil, geom = object:as_point() }) |
| 23 | + points:insert({ n = 0, geom = object:as_point(0) }) |
| 24 | + points:insert({ n = 1, geom = object:as_point(1) }) |
| 25 | + points:insert({ n = 2, geom = object:as_point(2) }) |
| 26 | + points:insert({ n = 3, geom = object:as_point(3) }) |
| 27 | + points:insert({ n = 4, geom = object:as_point(4) }) |
| 28 | + points:insert({ n = -1, geom = object:as_point(-1) }) |
| 29 | + points:insert({ n = -2, geom = object:as_point(-2) }) |
| 30 | + points:insert({ n = -3, geom = object:as_point(-3) }) |
| 31 | + end |
| 32 | + end |
| 33 | + """ |
| 34 | + When running osm2pgsql flex |
| 35 | + |
| 36 | + Then table osm2pgsql_test_points contains exactly |
| 37 | + | way_id | n | ST_AsText(geom) | |
| 38 | + | 20 | NULL | 1 | |
| 39 | + | 20 | 0 | 1 | |
| 40 | + | 20 | 1 | 1 | |
| 41 | + | 20 | 2 | 2 | |
| 42 | + | 20 | 3 | 3 | |
| 43 | + | 20 | 4 | NULL | |
| 44 | + | 20 | -1 | 3 | |
| 45 | + | 20 | -2 | 2 | |
| 46 | + | 20 | -3 | 1 | |
| 47 | + | 21 | NULL | 4 | |
| 48 | + | 21 | 0 | 4 | |
| 49 | + | 21 | 1 | 4 | |
| 50 | + | 21 | 2 | 5 | |
| 51 | + | 21 | 3 | NULL | |
| 52 | + | 21 | 4 | NULL | |
| 53 | + | 21 | -1 | 5 | |
| 54 | + | 21 | -2 | 4 | |
| 55 | + | 21 | -3 | NULL | |
| 56 | + |
| 57 | + Scenario: |
| 58 | + Given the grid |
| 59 | + | 1 | 2 | |
| 60 | + And the OSM data |
| 61 | + """ |
| 62 | + w20 Thighway=motorway Nn1,n2 |
| 63 | + """ |
| 64 | + And the lua style |
| 65 | + """ |
| 66 | + function osm2pgsql.process_way(object) |
| 67 | + local geom = object:as_point('foo') |
| 68 | + end |
| 69 | + """ |
| 70 | + Then running osm2pgsql flex fails |
| 71 | + |
| 72 | + And the error output contains |
| 73 | + """ |
| 74 | + Argument #1 to 'as_point()' must be an integer. |
| 75 | + """ |
| 76 | + |
| 77 | + Scenario: |
| 78 | + Given the grid |
| 79 | + | 1 | 2 | |
| 80 | + And the OSM data |
| 81 | + """ |
| 82 | + w20 Thighway=motorway Nn1,n2 |
| 83 | + """ |
| 84 | + And the lua style |
| 85 | + """ |
| 86 | + function osm2pgsql.process_way(object) |
| 87 | + local geom = object:as_point(1, 'foo') |
| 88 | + end |
| 89 | + """ |
| 90 | + Then running osm2pgsql flex fails |
| 91 | + |
| 92 | + And the error output contains |
| 93 | + """ |
| 94 | + Too many arguments for function as_point() |
| 95 | + """ |
0 commit comments