omniscale / imposm3

Imposm imports OpenStreetMap data into PostGIS
http://imposm.org/docs/imposm3/latest/
Apache License 2.0
719 stars 157 forks source link

filter - reject/require #135

Closed ImreSamu closed 7 years ago

ImreSamu commented 7 years ago

Proposal ....

current syntax :

    filter:
        reject:
          key1: [ val1, val2, ... valn ]
          key2: [ val1, val2, ... valn ]
          key3: [ __any__ ]
          .... 
        require:
          key1: [ val1, val2, ... valn ]
          key2: [ val1, val2, ... valn ]
          key3: [ __any__ ]
          ....
        reject_regexp:
          key1: 'regexp'
          key2: 'regexp'
          ....
        require_regexp:
          key1: 'regexp'
          key2: 'regexp'
          ....

golang struct

type Filters struct {
    ExcludeTags   *[][]string    `yaml:"exclude_tags"`
    Reject        KeyValues      `yaml:"reject"`
    Require       KeyValues      `yaml:"require"`
    RejectRegexp  KeyRegexpValue `yaml:"reject_regexp"`
    RequireRegexp KeyRegexpValue `yaml:"require_regexp"`
}
type KeyRegexpValue map[Key]string
      ## housenumber cleaning ... 
      require_regexp:
        'addr:housenumber': '^\d+[a-zA-Z,]*$'
      ## filtering extreme tagging
      require_regexp:
        building: '^[a-z_]+$'

example mapping:

  config_test_t3_highway_with_name:
    fields:
    - name: id
      type: id
    - key: highway
      name: highway
      type: string
    - key: name
      name: name
      type: string
    filters:
      require:
        name: ["__any__"]
      reject:
        highway: ["no","none"]
    mapping:
      highway:
      - __any__
    type: linestring

// Allowed to modify, refactor, optimalize as you like

=== Edited:

ImreSamu commented 7 years ago

@olt : I'd appreciate any feedback you can give me on the new syntax.

If accepted :

olt commented 7 years ago

Sorry, the first notification slipped through... Yes, the syntax looks good. Haven't reviewed the code though.

I would deprecate the old exclude_tags syntax: Print a warning (see pseudoarea) and convert it to a reject filter.

Thanks!

ImreSamu commented 7 years ago

Yes, the syntax looks good.

Thank you !

if I will finished, I will ping you ...

ImreSamu commented 7 years ago

@olt: ready for review !

I would deprecate the old exclude_tags syntax: Print a warning (see pseudoarea) and convert it to a reject filter.

I have refactored ( According to my best knowledge )

some experience:

// Allowed to modify, refactor, optimalize as you like

ImreSamu commented 7 years ago

ping @olt

olt commented 7 years ago

I've updated the docs, moved the test mapping inside the tests and merged your changes.

Thanks a lot for working on the patch and your patience! 👍