omniscale/imposm3

Unified value tags

mnameghi opened this issue · 1 comments

Hi
I want to import data something like this.
All values from tags like garden,park,grass and ... replaced with a word. for example: "green"
Is this possible?

you can ask questions in the community mailing list: https://groups.google.com/forum/#!forum/imposm

All values from tags like garden,park,grass and ... replaced with a word. for example: "green"

my2c/imho:

  • Too much redundancy .. Just create a separated table for every colors.
    So you don't have to store the multiple copies of the same string "green" ( Less disk space, better i/o )

example mapping file for creating osm_green , osm_blue tables.

tables:
  # osm_green table definition:
  green:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: geometry
    mapping:
      landuse:
      - park
      - forest
      - grass
      - wood
      leisure:
      - park
      - nature_reserve
      natural:
      - wood
    type: polygon

  # osm_blue table definition:
  blue:
    columns:
    - name: osm_id
      type: id
    - name: geometry
      type: geometry
    mapping:
      natural:
      - water
      waterway:
      - riverbank
    type: polygon

and if you need a single view (osm_colors ) , just create ...

create view osm_colors as
          select 'green'::text as color , * from osm_green
union all select 'blue'::text  as color , * from osm_blue
;

test:

appx=# select color , count(*) as _cnt 
appx-# from osm_colors
appx-# group by 1;
 color | _cnt 
-------+------
 green | 2374
 blue  |  132
(2 rows)

appx=# \d+ osm_colors
                                   View "public.osm_colors"
  Column  |          Type           | Collation | Nullable | Default | Storage  | Description 
----------+-------------------------+-----------+----------+---------+----------+-------------
 color    | text                    |           |          |         | extended | 
 id       | integer                 |           |          |         | plain    | 
 osm_id   | bigint                  |           |          |         | plain    | 
 geometry | geometry(Geometry,4326) |           |          |         | main     | 
View definition:
 SELECT 'green'::text AS color,
    osm_green.id,
    osm_green.osm_id,
    osm_green.geometry
   FROM osm_green
UNION ALL
 SELECT 'blue'::text AS color,
    osm_blue.id,
    osm_blue.osm_id,
    osm_blue.geometry
   FROM osm_blue;