Skip to content

Commit 4362106

Browse files
committed
Cleanup and simplify uni test
1 parent 48b7d5c commit 4362106

File tree

2 files changed

+14
-76
lines changed

2 files changed

+14
-76
lines changed

tests/data/test_output_flex_uni.lua

Lines changed: 11 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ local test_table = osm2pgsql.define_table{
44
ids = { type = 'any', type_column = 'osm_type', id_column = 'osm_id' },
55
columns = {
66
{ column = 'tags', type = 'hstore' },
7-
{ column = 'name', type = 'text' },
87
{ column = 'geom', type = 'geometry' },
98
}
109
}
@@ -13,103 +12,42 @@ function is_empty(some_table)
1312
return next(some_table) == nil
1413
end
1514

16-
function clean_tags(tags)
17-
tags.odbl = nil
18-
tags.created_by = nil
19-
tags.source = nil
20-
tags['source:ref'] = nil
21-
tags['source:name'] = nil
22-
end
23-
24-
function is_polygon(tags)
25-
if tags.aeroway
26-
or tags.amenity
27-
or tags.area
28-
or tags.building
29-
or tags.harbour
30-
or tags.historic
31-
or tags.landuse
32-
or tags.leisure
33-
or tags.man_made
34-
or tags.military
35-
or tags.natural
36-
or tags.office
37-
or tags.place
38-
or tags.power
39-
or tags.public_transport
40-
or tags.shop
41-
or tags.sport
42-
or tags.tourism
43-
or tags.water
44-
or tags.waterway
45-
or tags.wetland
46-
or tags['abandoned:aeroway']
47-
or tags['abandoned:amenity']
48-
or tags['abandoned:building']
49-
or tags['abandoned:landuse']
50-
or tags['abandoned:power']
51-
or tags['area:highway']
52-
then
53-
return true
54-
else
55-
return false
56-
end
57-
end
58-
59-
function osm2pgsql.process_node(data)
60-
clean_tags(data.tags)
61-
if is_empty(data.tags) then
15+
function osm2pgsql.process_node(object)
16+
if is_empty(object.tags) then
6217
return
6318
end
6419

6520
test_table:add_row({
66-
tags = data.tags,
21+
tags = object.tags,
6722
geom = { create = 'point' }
6823
})
6924
end
7025

71-
function osm2pgsql.process_way(data)
72-
clean_tags(data.tags)
73-
if is_empty(data.tags) then
26+
function osm2pgsql.process_way(object)
27+
if is_empty(object.tags) then
7428
return
7529
end
7630

77-
if is_polygon(data.tags) then
31+
if object.tags.building then
7832
test_table:add_row({
79-
tags = data.tags,
80-
name = data.tags.name,
33+
tags = object.tags,
8134
geom = { create = 'area' }
8235
})
8336
else
8437
test_table:add_row({
85-
tags = data.tags,
86-
name = data.tags.name,
38+
tags = object.tags,
8739
geom = { create = 'line' }
8840
})
8941
end
9042
end
9143

92-
function osm2pgsql.process_relation(data)
93-
clean_tags(data.tags)
94-
if is_empty(data.tags) then
95-
return
96-
end
97-
98-
if data.tags.type == 'multipolygon' or data.tags.type == 'boundary' then
44+
function osm2pgsql.process_relation(object)
45+
if object.tags.type == 'multipolygon' then
9946
test_table:add_row({
100-
tags = data.tags,
101-
name = data.tags.name,
47+
tags = object.tags,
10248
geom = { create = 'area', multi = false }
10349
})
10450
return
10551
end
106-
107-
if data.tags.type == 'route' then
108-
test_table:add_row({
109-
tags = data.tags,
110-
name = data.tags.name,
111-
geom = { create = 'line' }
112-
})
113-
end
11452
end
11553

tests/test-output-flex-uni.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55

66
static testing::db::import_t db;
77

8+
static char const *const conf_file = "test_output_flex_uni.lua";
9+
810
struct options_slim_default
911
{
1012
static options_t options()
1113
{
12-
return testing::opt_t().slim().flex("test_output_flex_uni.lua");
14+
return testing::opt_t().slim().flex(conf_file);
1315
}
1416
};
1517

@@ -137,8 +139,6 @@ TEMPLATE_TEST_CASE("ways as linestrings and polygons", "", options_slim_default,
137139
auto conn = db.db().connect();
138140

139141
REQUIRE(0 == conn.get_count("osm2pgsql_test_data", "osm_type != 'W'"));
140-
// REQUIRE(0 == conn.get_count("osm2pgsql_test_line"));
141-
// REQUIRE(1 == conn.get_count("osm2pgsql_test_polygon"));
142142
REQUIRE(
143143
1 ==
144144
conn.get_count(

0 commit comments

Comments
 (0)