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

[FEATURE] Avoid zero value for direction type in custom schema #1146

Open
zstadler opened this issue Jan 14, 2025 · 3 comments
Open

[FEATURE] Avoid zero value for direction type in custom schema #1146

zstadler opened this issue Jan 14, 2025 · 3 comments

Comments

@zstadler
Copy link
Contributor

zstadler commented Jan 14, 2025

Is your feature request related to a problem? Please describe.
The custom YAML schema defines the direction type as

  • direction - Maps "-1" to -1, "1" "yes" or "true" to 1, and everything else to 0. See Key:oneway.

As a result, the default value 0 is set for the vast majority of highway features resulting in an unnecessary increase in tile size.

Describe the solution you'd like
Limit the possible values for the direction to 1 and -1 leaving the attribute undefined otherwise:

  • direction - Maps "-1" to -1, "1" "yes" or "true" to 1, and everything else leaves the attribute unset (null) . See Key:oneway.

Describe alternatives you've considered
Calculate this attribute using an expression of type int

    - key: oneway
      # type: direction # would add 0 elsewhere
      type: int
      value:
        1:
          oneway: ['yes', '1', 'true']
        -1:
          oneway: '-1'

Additional context
OMT and planetiler-openmaptiles also avoid adding oneway: 0 attributes

@msbarry
Copy link
Contributor

msbarry commented Jan 16, 2025

@phanecak-maptiler do you know if direction=0 is strictly necessary for openmaptiles schema? I'd be up for changing the default behavior of direction conversion from -1/0/1 to -1/null/1 but that would affect openmaptiles as well.

@zstadler
Copy link
Contributor Author

OMT emits only oneway <> 0:

CASE WHEN is_oneway <> 0 THEN is_oneway::int END AS oneway,

@zstadler
Copy link
Contributor Author

Another option to address this issue in a more general way is to add a nullif: option to attributes. If the calculated/final value of the attribute is equal to any of the nullif values, the attribute would be omitted from the tile feature. For example:

- key: oneway
  type: direction
  nullif: 0                    # Avoid oneway=0
- key: bridge
  nullif: ['no', 'No', 0]      # Avoid several flavors of non-bridges
- key: is_bridge
  tag_value: bridge
  type: boolean
  nullif: false                # Avoid is_bridge=false

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