- This example shows the most simple customization of the process_tags function.
- It simply adds some additional processing before running the original code.
- To do that, first save the original function and then overwrite process_tags
- from the module. In this example all highways which are not accessible
- by anyone will be ignored.
-
-
-#### The `Place` class
-
-The `process_tags` function receives a Lua object of `Place` type which comes
-with some handy functions to collect the data necessary for geocoding and
-writing it into the place table. Always use this object to fill the table.
-
-The Place class has some attributes which you may access read-only:
-
-* __object__ is the original OSM object data handed in by osm2pgsql
-* __admin_level__ is the content of the admin_level tag, parsed into an
- integer and normalized to a value between 0 and 15
-* __has_name__ is a boolean indicating if the object has a full name
-* __names__ is a table with the collected list of name tags
-* __address__ is a table with the collected list of address tags
-* __extratags__ is a table with the collected list of additional tags to save
-
-There are a number of functions to fill these fields. All functions expect
-a table parameter with fields as indicated in the description.
-Many of these functions expect match functions which are described in detail
-further below.
-
-* __delete{match=...}__ removes all tags that match the match function given
- in _match_.
-* __grab_extratags{match=...}__ moves all tags that match the match function
- given in _match_ into extratags. Returns the number of tags moved.
-* __clean{delete=..., extra=...}__ deletes all tags that match _delete_ and
- moves the ones that match _extra_ into extratags
-* __grab_address_parts{groups=...}__ moves matching tags into the address table.
- _groups_ must be a group match function. Tags of the group `main` and
- `extra` are added to the address table as is but with `addr:` and `is_in:`
- prefixes removed from the tag key. All other groups are added with the
- group name as key and the value from the tag. Multiple values of the same
- group overwrite each other. The function returns the number of tags saved
- from the main group.
-* __grab_main_parts{groups=...}__ moves matching tags into the name table.
- _groups_ must be a group match function. If a tags of the group `main` is
- present, the object will be marked as having a name. Tags of group `house`
- produce a fallback to `place=house`. This fallback is return by the function
- if present.
-
-There are two functions to write a row into the place table. Both functions
-expect the main tag (key and value) for the row and then use the collected
-information from the name, address, extratags etc. fields to complete the row.
-They also have a boolean parameter `save_extra_mains` which defines how any
-unprocessed tags are handled: when True, the tags will be saved as extratags,
-when False, they will be simply discarded.
-
-* __write_row(key, value, save_extra_mains)__ creates a new table row from
- the current state of the Place object.
-* __write_place(key, value, mtype, save_extra_mains)__ creates a new row
- conditionally. When value is nil, the function will attempt to look up the
- value in the object tags. If value is still nil or mtype is nil, the row
- is ignored. An mtype of `always` will then always write out the row,
- a mtype of `named` only, when the object has a full name. When mtype
- is `named_with_key`, the function checks for a domain name, i.e. a name
- tag prefixed with the name of the main key. Only if at least one is found,
- the row will be written. The names are replaced with the domain names found.
-
-#### Match functions
-
-The Place functions usually expect either a _match function_ or a
-_group match function_ to find the tags to apply their function to.
-
-The __match function__ is a Lua function which takes two parameters,
-key and value, and returns a boolean to indicate that a tag matches. The
-flex-base module has a convenience function `tag_match()` to create such a
-function. It takes a table with two optional fields: `keys` takes a key match
-list (see above), `tags` takes a table with keys that point to a list of
-possible values, thus defining key/value matches.
-
-The __group match function__ is a Lua function which also takes two parameters,
-key and value, and returns a string indicating to which group or type they
-belong to. The `tag_group()` can be used to create such a function. It expects
-a table where the group names are the keys and the values are a key match list.
-
-
-
-### Using the gazetteer output of osm2pgsql