Skip to content

Commit 7ba6ea1

Browse files
committed
Add a test for hstore-match-only mode
This will also test the correct function of the hstore flag given in styles
1 parent d21c739 commit 7ba6ea1

5 files changed

Lines changed: 495 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ tests/test-output-multi-point-multi-table
5353
tests/test-output-multi-polygon
5454
tests/test-output-pgsql
5555
tests/test-expire-tiles
56+
tests/test-hstore-match-only
5657
tests/*.log
5758
tests/*.trs
5859
tests/test_output_pgsql_area_way.flat.nodes.bin

Makefile.am

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ check_PROGRAMS = \
9191
tests/test-output-pgsql \
9292
tests/test-pgsql-escape \
9393
tests/test-parse-options \
94-
tests/test-expire-tiles
94+
tests/test-expire-tiles \
95+
tests/test-hstore-match-only
9596

9697
tests_test_parse_xml2_SOURCES = tests/test-parse-xml2.cpp
9798
tests_test_parse_xml2_LDADD = libosm2pgsql.la
@@ -107,6 +108,8 @@ tests_test_output_multi_point_multi_table_SOURCES = tests/test-output-multi-poin
107108
tests_test_output_multi_point_multi_table_LDADD = libosm2pgsql.la
108109
tests_test_output_multi_polygon_SOURCES = tests/test-output-multi-polygon.cpp tests/common-pg.cpp
109110
tests_test_output_multi_polygon_LDADD = libosm2pgsql.la
111+
tests_test_hstore_match_only_SOURCES = tests/test-hstore-match-only.cpp tests/common-pg.cpp
112+
tests_test_hstore_match_only_LDADD = libosm2pgsql.la
110113
tests_test_output_pgsql_SOURCES = tests/test-output-pgsql.cpp tests/common-pg.cpp
111114
tests_test_output_pgsql_LDADD = libosm2pgsql.la
112115
tests_test_pgsql_escape_SOURCES = tests/test-pgsql-escape.cpp
@@ -166,6 +169,7 @@ tests_test_output_multi_line_LDADD += $(GLOBAL_LDFLAGS)
166169
tests_test_output_multi_point_LDADD += $(GLOBAL_LDFLAGS)
167170
tests_test_output_multi_point_multi_table_LDADD += $(GLOBAL_LDFLAGS)
168171
tests_test_output_multi_polygon_LDADD += $(GLOBAL_LDFLAGS)
172+
tests_test_hstore_match_only_LDADD += $(GLOBAL_LDFLAGS)
169173
tests_test_output_pgsql_LDADD += $(GLOBAL_LDFLAGS)
170174
tests_test_pgsql_escape_LDADD += $(GLOBAL_LDFLAGS)
171175
tests_test_parse_options_LDADD += $(GLOBAL_LDFLAGS)

tests/hstore-match-only.osm

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
3+
<!--
4+
test dataset for hstore-match-only function of osm2pgsql
5+
6+
This file contains 19 tagged ways and 7 tagged nodes
7+
8+
Using the provided hstore-match-only.style file and the hstore as well as
9+
hstore-match-only commandline option we end up with a database containing
10+
6 points, 7 polygons and 12 lines:
11+
12+
gis=> select count(*) from planet_osm_point;
13+
count
14+
6
15+
(1 row)
16+
gis=> select count(*) from planet_osm_polygon;
17+
count
18+
7
19+
(1 row)
20+
21+
gis=> select count(*) from planet_osm_line;
22+
count
23+
12
24+
(1 row)
25+
-->
26+
27+
<osm version='0.6' upload='false' generator='JOSM'>
28+
<node id='6' visible='true' version='1' lat='49.05153222821' lon='8.07892280714' />
29+
<node id='8' visible='true' version='1' lat='49.05160942246' lon='8.07685590746' />
30+
<node id='10' visible='true' version='1' lat='49.05266928632' lon='8.07991140766' />
31+
<node id='12' visible='true' version='1' lat='49.05305485258' lon='8.07803155655' />
32+
<node id='14' visible='true' version='1' lat='49.05260999334' lon='8.07646785276' />
33+
<node id='16' visible='true' version='1' lat='49.03515657968' lon='8.13942160317' />
34+
<node id='18' visible='true' version='1' lat='48.98613332441' lon='8.33058309563' />
35+
<node id='20' visible='true' version='1' lat='49.11989047093' lon='8.33058309563' />
36+
<node id='22' visible='true' version='1' lat='49.11518682447' lon='8.15523195217' />
37+
<node id='24' visible='true' version='1' lat='48.99509309991' lon='8.17679151899' />
38+
<node id='26' visible='true' version='1' lat='49.02337655032' lon='8.3772954904' />
39+
<node id='28' visible='true' version='1' lat='49.10671913679' lon='8.37370222926' />
40+
<node id='30' visible='true' version='1' lat='49.07565858296' lon='8.4089161884'>
41+
<tag k='historic' v='castle' />
42+
<tag k='ruined' v='yes' />
43+
</node>
44+
<node id='32' visible='true' version='1' lat='49.03138727373' lon='8.51024615245' />
45+
<node id='34' visible='true' version='1' lat='48.933757167' lon='8.44772340868' />
46+
<node id='36' visible='true' version='1' lat='48.92714725897' lon='8.10277033957' />
47+
<node id='38' visible='true' version='1' lat='48.96443456342' lon='8.03018646462' />
48+
<node id='40' visible='true' version='1' lat='49.15797356916' lon='8.09989573067' />
49+
<node id='42' visible='true' version='1' lat='49.03358637848' lon='7.99017805251' />
50+
<node id='44' visible='true' version='1' lat='48.92713658981' lon='8.20221643712' />
51+
<node id='46' visible='true' version='1' lat='49.12020833896' lon='8.4870044058' />
52+
<node id='48' visible='true' version='1' lat='49.09795155433' lon='8.01122065379' />
53+
<node id='50' visible='true' version='1' lat='49.06402712622' lon='8.06789282649' />
54+
<node id='52' visible='true' version='1' lat='49.06318018297' lon='8.06973971479' />
55+
<node id='54' visible='true' version='1' lat='49.0645445515' lon='8.07119709293' />
56+
<node id='56' visible='true' version='1' lat='49.0653914715' lon='8.06935020463' />
57+
<node id='58' visible='true' version='1' lat='49.06423960402' lon='8.06957831599'>
58+
<tag k='amenity' v='prison' />
59+
</node>
60+
<node id='60' visible='true' version='1' lat='49.0858769851' lon='8.19763560952' />
61+
<node id='62' visible='true' version='1' lat='49.08987054796' lon='8.35211742394' />
62+
<node id='64' visible='true' version='1' lat='49.03393143573' lon='8.41563790685' />
63+
<node id='66' visible='true' version='1' lat='49.09353103175' lon='8.36736233984' />
64+
<node id='68' visible='true' version='1' lat='49.02926700076' lon='8.344494966' />
65+
<node id='70' visible='true' version='1' lat='49.03059974109' lon='8.29266225195' />
66+
<node id='72' visible='true' version='1' lat='49.07988603855' lon='8.1813743659' />
67+
<node id='74' visible='true' version='1' lat='48.99860411956' lon='8.13411512662' />
68+
<node id='76' visible='true' version='1' lat='49.05910165734' lon='8.41044514247' />
69+
<node id='78' visible='true' version='1' lat='49.05910787132' lon='8.41060121724' />
70+
<node id='80' visible='true' version='1' lat='49.05918164083' lon='8.41059437718' />
71+
<node id='82' visible='true' version='1' lat='49.05917542687' lon='8.4104383024' />
72+
<node id='84' visible='true' version='1' lat='49.0571059179' lon='8.41070821764'>
73+
<tag k='addr:housenumber' v='42' />
74+
</node>
75+
<node id='86' visible='true' version='1' lat='49.00485239659' lon='8.10591725672' />
76+
<node id='88' visible='true' version='1' lat='49.08085222575' lon='8.08283939451' />
77+
<node id='90' visible='true' version='1' lat='48.98423743896' lon='8.11845937143' />
78+
<node id='92' visible='true' version='1' lat='49.10319099594' lon='8.11917802366' />
79+
<node id='94' visible='true' version='1' lat='49.05904839499' lon='8.41049417747' />
80+
<node id='96' visible='true' version='1' lat='49.05471933562' lon='8.06849989751' />
81+
<node id='117' visible='true' version='1' lat='49.16700513707' lon='8.12518444414' />
82+
<node id='118' visible='true' version='1' lat='49.13091446704' lon='8.08644347959' />
83+
<node id='120' visible='true' version='1' lat='49.11055388122' lon='8.05181140521' />
84+
<node id='122' visible='true' version='1' lat='49.08710965227' lon='8.04476759347' />
85+
<node id='124' visible='true' version='1' lat='49.04634415702' lon='8.0512244209' />
86+
<node id='126' visible='true' version='1' lat='49.02402435131' lon='8.05944220126' />
87+
<node id='128' visible='true' version='1' lat='49.0013094457' lon='8.06237712282' />
88+
<node id='130' visible='true' version='1' lat='48.93503056586' lon='8.05415934246' />
89+
<node id='214' visible='true' version='1' lat='49.11746633187' lon='8.24020952552' />
90+
<node id='216' visible='true' version='1' lat='49.05813441994' lon='8.14395837697' />
91+
<node id='218' visible='true' version='1' lat='49.06140528217' lon='8.37565665399' />
92+
<node id='221' visible='true' version='1' lat='49.05582697806' lon='8.37589712773' />
93+
<node id='224' visible='true' version='1' lat='49.05309372735' lon='8.14296295673' />
94+
<node id='284' visible='true' version='1' lat='49.04978920459' lon='8.07928222396' />
95+
<node id='285' visible='true' version='1' lat='49.04992522037' lon='8.08353659497' />
96+
<node id='287' visible='true' version='1' lat='49.04679676328' lon='8.08332906468' />
97+
<node id='289' visible='true' version='1' lat='49.04768091241' lon='8.0795935194' />
98+
<node id='304' visible='true' version='1' lat='49.01555628571' lon='8.07933310333'>
99+
<tag k='name' v='Nowhere' />
100+
<tag k='place' v='hamlet' />
101+
</node>
102+
<node id='317' visible='true' version='1' lat='49.01825104522' lon='8.40804431774'>
103+
<tag k='power' v='tower' />
104+
</node>
105+
<node id='328' visible='true' version='1' lat='49.10094761615' lon='8.03120038979' />
106+
<node id='329' visible='true' version='1' lat='49.06519342756' lon='8.0265045153' />
107+
<node id='331' visible='true' version='1' lat='49.02517975693' lon='8.03237435841' />
108+
<node id='333' visible='true' version='1' lat='48.99399295757' lon='8.03589626428' />
109+
<node id='335' visible='true' version='1' lat='48.98012588722' lon='8.03707023291' />
110+
<node id='337' visible='true' version='1' lat='48.94968184469' lon='8.03002642117' />
111+
<node id='339' visible='true' version='1' lat='49.13590798222' lon='8.03530927997' />
112+
<node id='361' visible='true' version='1' lat='49.0105513453' lon='8.42271892552' />
113+
<node id='363' visible='true' version='1' lat='48.99168204717' lon='8.4162620981' />
114+
<node id='365' visible='true' version='1' lat='48.99399295757' lon='8.44972020385' />
115+
<node id='367' visible='true' version='1' lat='48.9781996' lon='8.45500306265' />
116+
<node id='436' visible='true' version='1' lat='49.0371102771' lon='8.0728762759'>
117+
<tag k='shop' v='beverages' />
118+
</node>
119+
<node id='444' visible='true' version='1' lat='48.98608722574' lon='8.37533796274'>
120+
<tag k='foo' v='bar' />
121+
<tag k='name' v='senseless tag on node' />
122+
</node>
123+
<node id='445' visible='true' version='1' lat='48.98513388557' lon='8.41743606672' />
124+
<node id='447' visible='true' version='1' lat='48.97434680224' lon='8.41978400397' />
125+
<node id='449' visible='true' version='1' lat='48.96440559803' lon='8.38103588213' />
126+
<node id='1116' visible='true' version='1' lat='49.10432671853' lon='7.99302782947' />
127+
<node id='1117' visible='true' version='1' lat='49.14365414527' lon='8.06119495067' />
128+
<node id='1119' visible='true' version='1' lat='49.17122342967' lon='8.1015570619' />
129+
<node id='1121' visible='true' version='1' lat='49.17298265023' lon='8.15088853119' />
130+
<node id='1123' visible='true' version='1' lat='49.14834787313' lon='8.35090521576' />
131+
<node id='1125' visible='true' version='1' lat='49.13954676867' lon='8.48454865074' />
132+
<node id='1127' visible='true' version='1' lat='49.12428781794' lon='8.50517817426' />
133+
<node id='1129' visible='true' version='1' lat='49.08788213472' lon='8.52132301875' />
134+
<node id='1131' visible='true' version='1' lat='49.0102842774' lon='8.52849850519' />
135+
<node id='1133' visible='true' version='1' lat='48.9502393357' lon='8.48096090752' />
136+
<node id='1135' visible='true' version='1' lat='48.91842154869' lon='8.45674364077' />
137+
<node id='1137' visible='true' version='1' lat='48.91488498718' lon='8.289913581' />
138+
<node id='1139' visible='true' version='1' lat='48.91193766133' lon='8.10783561254' />
139+
<node id='1141' visible='true' version='1' lat='48.91783213916' lon='8.05760720744' />
140+
<node id='1143' visible='true' version='1' lat='48.95200639595' lon='8.00379105913' />
141+
<node id='1145' visible='true' version='1' lat='49.03381156891' lon='7.95894426887' />
142+
<node id='1147' visible='true' version='1' lat='49.0861198919' lon='7.97508911336' />
143+
<way id='107' visible='true' version='1'>
144+
<nd ref='46' />
145+
<nd ref='32' />
146+
<nd ref='34' />
147+
<nd ref='44' />
148+
<nd ref='36' />
149+
<tag k='admin_level' v='3' />
150+
<tag k='boundary' v='administrative' />
151+
</way>
152+
<way id='98' visible='true' version='1'>
153+
<nd ref='14' />
154+
<nd ref='12' />
155+
<nd ref='10' />
156+
<nd ref='6' />
157+
<nd ref='8' />
158+
<nd ref='14' />
159+
<tag k='leisure' v='playground' />
160+
</way>
161+
<way id='102' visible='true' version='1'>
162+
<nd ref='36' />
163+
<nd ref='38' />
164+
<nd ref='42' />
165+
<nd ref='48' />
166+
<nd ref='40' />
167+
<nd ref='46' />
168+
<tag k='admin_level' v='3' />
169+
<tag k='boundary' v='administrative' />
170+
</way>
171+
<way id='104' visible='true' version='1'>
172+
<nd ref='56' />
173+
<nd ref='54' />
174+
<nd ref='52' />
175+
<nd ref='50' />
176+
<nd ref='56' />
177+
<tag k='barrier' v='wall' />
178+
</way>
179+
<way id='106' visible='true' version='1'>
180+
<nd ref='82' />
181+
<nd ref='80' />
182+
<nd ref='78' />
183+
<nd ref='76' />
184+
<nd ref='82' />
185+
<tag k='addr:housenumber' v='23' />
186+
<tag k='building' v='yes' />
187+
</way>
188+
<way id='108' visible='true' version='1'>
189+
<nd ref='88' />
190+
<nd ref='86' />
191+
<nd ref='74' />
192+
<nd ref='72' />
193+
<nd ref='60' />
194+
<nd ref='70' />
195+
<nd ref='68' />
196+
<nd ref='62' />
197+
<nd ref='66' />
198+
<nd ref='64' />
199+
<tag k='highway' v='unclassified' />
200+
</way>
201+
<way id='110' visible='true' version='1'>
202+
<nd ref='92' />
203+
<nd ref='90' />
204+
<tag k='aeroway' v='runway' />
205+
</way>
206+
<way id='112' visible='true' version='1'>
207+
<nd ref='96' />
208+
<nd ref='94' />
209+
<tag k='aerialway' v='chair_lift' />
210+
</way>
211+
<way id='119' visible='true' version='1'>
212+
<nd ref='117' />
213+
<nd ref='118' />
214+
<nd ref='120' />
215+
<nd ref='122' />
216+
<nd ref='124' />
217+
<tag k='waterway' v='river' />
218+
<tag k='width' v='30' />
219+
</way>
220+
<way id='135' visible='true' version='1'>
221+
<nd ref='124' />
222+
<nd ref='126' />
223+
<tag k='lock' v='yes' />
224+
</way>
225+
<way id='136' visible='true' version='1'>
226+
<nd ref='126' />
227+
<nd ref='128' />
228+
<nd ref='130' />
229+
<tag k='waterway' v='river' />
230+
<tag k='width' v='30' />
231+
</way>
232+
<way id='219' visible='true' version='1'>
233+
<nd ref='216' />
234+
<nd ref='218' />
235+
<nd ref='221' />
236+
<nd ref='224' />
237+
<nd ref='216' />
238+
<tag k='man_made' v='cutline' />
239+
</way>
240+
<way id='228' visible='true' version='1'>
241+
<nd ref='221' />
242+
<nd ref='26' />
243+
<nd ref='18' />
244+
<nd ref='24' />
245+
<nd ref='16' />
246+
<nd ref='224' />
247+
<nd ref='221' />
248+
<tag k='landuse' v='forest' />
249+
</way>
250+
<way id='243' visible='true' version='1'>
251+
<nd ref='216' />
252+
<nd ref='22' />
253+
<nd ref='214' />
254+
<nd ref='20' />
255+
<nd ref='28' />
256+
<nd ref='218' />
257+
<nd ref='216' />
258+
<tag k='landuse' v='forest' />
259+
</way>
260+
<way id='286' visible='true' version='1'>
261+
<nd ref='284' />
262+
<nd ref='285' />
263+
<nd ref='287' />
264+
<nd ref='289' />
265+
<nd ref='284' />
266+
<tag k='military' v='barracks' />
267+
</way>
268+
<way id='330' visible='true' version='1'>
269+
<nd ref='339' />
270+
<nd ref='328' />
271+
<nd ref='329' />
272+
<nd ref='331' />
273+
<nd ref='333' />
274+
<nd ref='335' />
275+
<nd ref='337' />
276+
<tag k='railway' v='rail' />
277+
</way>
278+
<way id='369' visible='true' version='1'>
279+
<nd ref='64' />
280+
<nd ref='361' />
281+
<nd ref='363' />
282+
<nd ref='365' />
283+
<nd ref='367' />
284+
<tag k='highway' v='track' />
285+
</way>
286+
<way id='446' visible='true' version='1'>
287+
<nd ref='444' />
288+
<nd ref='445' />
289+
<nd ref='447' />
290+
<nd ref='449' />
291+
<nd ref='444' />
292+
<tag k='tourism' v='zoo' />
293+
</way>
294+
<way id='1118' visible='true' version='1'>
295+
<nd ref='1116' />
296+
<nd ref='1117' />
297+
<nd ref='1119' />
298+
<nd ref='1121' />
299+
<nd ref='1123' />
300+
<nd ref='1125' />
301+
<nd ref='1127' />
302+
<nd ref='1129' />
303+
<nd ref='1131' />
304+
<nd ref='1133' />
305+
<nd ref='1135' />
306+
<nd ref='1137' />
307+
<nd ref='1139' />
308+
<nd ref='1141' />
309+
<nd ref='1143' />
310+
<nd ref='1145' />
311+
<nd ref='1147' />
312+
<nd ref='1116' />
313+
<tag k='foo' v='bar' />
314+
<tag k='name' v='senseless way' />
315+
</way>
316+
<relation id='384' visible='true' version='1'>
317+
<member type='way' ref='369' role='' />
318+
<member type='way' ref='108' role='' />
319+
<tag k='name' v='my cycle route' />
320+
<tag k='route' v='bicycle' />
321+
<tag k='type' v='route' />
322+
</relation>
323+
</osm>

tests/hstore-match-only.style

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# hstore only Database schema which stores only objects
2+
# with one of the important tags defined here
3+
#
4+
# this does only make sence when --hstore-match-only ist used
5+
#
6+
# "important" are those tags which appear in the where clause of
7+
# select statements in the standard mapnik style
8+
#
9+
# import using the following command:
10+
# osm2pgsql -s -S <this-file> --hstore --hstore-match-only <osm-or-pbf-file>
11+
#
12+
node,way aerialway text linear,hstore
13+
node,way addr:housenumber text linear,hstore
14+
node,way aeroway text polygon,hstore
15+
node,way amenity text nocache,polygon,hstore
16+
node,way barrier text linear,hstore
17+
node,way boundary text linear,hstore
18+
node,way building text polygon,hstore
19+
node,way highway text linear,hstore
20+
node,way historic text polygon,hstore
21+
node,way landuse text polygon,hstore
22+
node,way leisure text polygon,hstore
23+
node,way lock text linear,hstore
24+
node,way man_made text polygon,hstore
25+
node,way military text polygon,hstore
26+
node,way place text polygon,hstore
27+
node,way power text polygon,hstore
28+
node,way railway text linear,hstore
29+
node,way route text linear,hstore
30+
node,way shop text polygon,hstore
31+
node,way tourism text polygon,hstore
32+
node,way waterway text polygon,hstore
33+
node,way natural text polygon,hstore
34+
35+
node,way z_order int4 linear # This is calculated during import
36+
way way_area real # This is calculated during import
37+

0 commit comments

Comments
 (0)