Files
osm2pgsql/flex-config
Jochen Topf 24ce38f232 New feature: Check location of OSM objects against list of regions
This commit introduces a new feature: Locators. A locator is initialized
with one or more regions, each region has a name and a polygon or
bounding box. A geometry of an OSM object can then be checked against
this region list to figure out in which region(s) it is located.
This check is much faster than it would be to do this inside the
database after import.

Locators can be used for all sorts of interesting features:
* Read larger OSM file but import only data inside some area.
* Annotate each OSM object with the country (or other region) it
  is in. This can then, for instance, be used to show special
  highway shields for each country.
* Use the information which region the data is in for further
  processing, for instance setting of default values for the
  speed limit or using special language transliterations rules
  based on country.

Locators are created in Lua with `define_locator()`. Bounding boxes can
be added with `add_bbox()`. Polygons can be added from the database by
calling `add_from_db()` and specifiying an SQL query which can return
any number of rows each defining a region with the name and the
(multi)polygon as columns.

A locator can then be queried using `all_intersecting()` returning a
list of names of all regions that intersect the specified OSM object
geometry. Or the `first_intersecting()` function can be used which only
returns a single region for those cases where there can be no
overlapping data or where the details of objects straddling region
boundaries don't matter.

Several example config files are provided in the flex-config/locator
directory.
2025-05-30 14:47:12 +02:00
..
2022-09-29 21:58:44 +02:00

Flex Output Configuration

See the Flex Output chapter in the manual for all the details.

Example config files

This directory contains example config files for the flex output. All config files are documented extensively with inline comments.

If you are learning about the flex output, read the config files in the following order (from easiest to understand to the more complex ones):

  1. simple.lua -- Introduction to config file format
  2. geometries.lua -- Geometry column options
  3. data-types.lua -- Data types and how to handle them

After that you can dive into more advanced topics:

The "generic" configuration is a full-featured but simple configuration that is a good starting point for your own real-world configuration:

The following config file tries to be more or less compatible with the old pgsql (C transform) output:

The other files demonstrate some specific functionality, look at these if and when you need that functionality.

  • addresses.lua -- Get all objects with addresses and store as point objects in the database
  • bbox.lua -- Use of the get_bbox() function to get the bounding boxes of features
  • expire.lua -- Tile expiry configuration
  • indexes.lua -- Various options around index creation
  • labelpoint.lua -- How to get good labelling points using the centroid() and pole_of_inaccessibility() functions.
  • untagged -- How to access untagged objects.

The subdirectory gen contains example configurations for generalization support.

Public Domain

All the example config files in this directory are released into the Public Domain. You may use them in any way you like.