Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unified value tags #217

Closed
mnameghi opened this issue Dec 11, 2019 · 1 comment
Closed

Unified value tags #217

mnameghi opened this issue Dec 11, 2019 · 1 comment

Comments

@mnameghi
Copy link

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?

@ImreSamu
Copy link
Contributor

ImreSamu commented Dec 12, 2019

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants