|
| 1 | +Feature: Creating (multi)linestring features from way and relations |
| 2 | + |
| 3 | + Scenario: |
| 4 | + Given the grid |
| 5 | + | 1 | 2 | | |
| 6 | + | 4 | | 3 | |
| 7 | + | | 5 | 6 | |
| 8 | + And the OSM data |
| 9 | + """ |
| 10 | + w20 Thighway=motorway Nn1,n2,n3 |
| 11 | + w21 Thighway=motorway Nn4,n5,n6 |
| 12 | + r30 Ttype=route,route=road Mw20@ |
| 13 | + r31 Ttype=route,route=road Mw20@,w21@ |
| 14 | + """ |
| 15 | + And the lua style |
| 16 | + """ |
| 17 | + local lines = osm2pgsql.define_table({ |
| 18 | + name = 'osm2pgsql_test_lines', |
| 19 | + ids = { type = 'any', id_column = 'osm_id', type_column = 'osm_type' }, |
| 20 | + columns = { |
| 21 | + { column = 'geom', type = 'geometry', projection = 4326 }, |
| 22 | + } |
| 23 | + }) |
| 24 | +
|
| 25 | + function osm2pgsql.process_way(object) |
| 26 | + if object.tags.highway == 'motorway' then |
| 27 | + lines:insert({ |
| 28 | + geom = object:as_multilinestring() |
| 29 | + }) |
| 30 | + end |
| 31 | + end |
| 32 | +
|
| 33 | + function osm2pgsql.process_relation(object) |
| 34 | + if object.tags.type == 'route' then |
| 35 | + lines:insert({ |
| 36 | + geom = object:as_multilinestring() |
| 37 | + }) |
| 38 | + end |
| 39 | + end |
| 40 | + """ |
| 41 | + When running osm2pgsql flex |
| 42 | + |
| 43 | + Then table osm2pgsql_test_lines contains exactly |
| 44 | + | osm_type | osm_id | ST_GeometryType(geom) | ST_AsText(ST_GeometryN(geom, 1)) | ST_AsText(ST_GeometryN(geom, 2)) | |
| 45 | + | W | 20 | ST_LineString | 1, 2, 3 | NULL | |
| 46 | + | W | 21 | ST_LineString | 4, 5, 6 | NULL | |
| 47 | + | R | 30 | ST_LineString | 1, 2, 3 | NULL | |
| 48 | + | R | 31 | ST_MultiLineString | 1, 2, 3 | 4, 5, 6 | |
| 49 | + |
0 commit comments