@@ -57,8 +57,14 @@ local themepark = {
5757 node = {},
5858 way = {},
5959 relation = {},
60+ untagged_node = {},
61+ untagged_way = {},
62+ untagged_relation = {},
6063 area = {},
6164 select_relation_members = {},
65+ after_nodes = {},
66+ after_ways = {},
67+ after_relations = {},
6268 gen = {}
6369 },
6470 tables = {},
484490
485491-- ---------------------------------------------------------------------------
486492
487- local process_area = function (object , data )
488- for _ , func in ipairs (themepark .process .area ) do
489- if func (object , data ) == ' stop' then
490- return
491- end
492- end
493- end
494-
495- function osm2pgsql .process_node (object )
496- local data = {}
497-
498- for _ , func in ipairs (themepark .process .node ) do
499- if func (object , data ) == ' stop' then
493+ local call_each = function (funcs , ...)
494+ for _ , func in ipairs (funcs ) do
495+ if func (... ) == ' stop' then
500496 return
501497 end
502498 end
@@ -505,30 +501,22 @@ end
505501function osm2pgsql .process_way (object )
506502 local data = {}
507503
508- for _ , func in ipairs (themepark .process .way ) do
509- if func (object , data ) == ' stop' then
510- return
511- end
512- end
504+ call_each (themepark .process .way , object , data )
513505
514506 if themepark :way_is_area (object ) then
515507 object .as_area = object .as_polygon
516- process_area ( object , data )
508+ call_each ( themepark . process . area , object , data )
517509 end
518510end
519511
520512function osm2pgsql .process_relation (object )
521513 local data = {}
522514
523- for _ , func in ipairs (themepark .process .relation ) do
524- if func (object , data ) == ' stop' then
525- return
526- end
527- end
515+ call_each (themepark .process .relation , object , data )
528516
529517 if themepark :relation_is_area (object ) then
530518 object .as_area = object .as_multipolygon
531- process_area ( object , data )
519+ call_each ( themepark . process . area , object , data )
532520 end
533521end
534522
@@ -551,16 +539,32 @@ function osm2pgsql.select_relation_members(relation)
551539 return members
552540end
553541
554- function osm2pgsql .process_gen ()
555- local data = {}
542+ local function gen_process_func_with_object (type )
543+ local funcs = themepark .process [type ]
544+ return function (object )
545+ local data = {}
546+ call_each (funcs , object , data )
547+ end
548+ end
556549
557- for _ , func in ipairs (themepark .process .gen ) do
558- if func (data ) == ' stop' then
559- return
560- end
550+ local function gen_process_func (type )
551+ local funcs = themepark .process [type ]
552+ return function ()
553+ local data = {}
554+ call_each (funcs , data )
561555 end
562556end
563557
558+ osm2pgsql .process_node = gen_process_func_with_object (' node' )
559+ osm2pgsql .process_untagged_node = gen_process_func_with_object (' untagged_node' )
560+ osm2pgsql .process_untagged_way = gen_process_func_with_object (' untagged_way' )
561+ osm2pgsql .process_untagged_relation = gen_process_func_with_object (' untagged_relation' )
562+
563+ osm2pgsql .after_nodes = gen_process_func (' after_nodes' )
564+ osm2pgsql .after_ways = gen_process_func (' after_ways' )
565+ osm2pgsql .after_relations = gen_process_func (' after_relations' )
566+ osm2pgsql .process_gen = gen_process_func (' gen' )
567+
564568-- ---------------------------------------------------------------------------
565569
566570return themepark
0 commit comments