OPENER-next / OpenStop

App for collecting OpenStreetMap-compliant accessibility data in public transport
https://openstop.app
GNU General Public License v3.0
63 stars 13 forks source link

Rework question catalog scheme #247

Open Robbendebiene opened 4 months ago

Robbendebiene commented 4 months ago

The question catalogue was originally focused on serving a good balance between readability and versatility. However over time it gained more complexity and especially with the introduction of multi language keys it has become less readable. Additionally the structure sometimes requires duplicating tags or conditions (see crossing:markings questions) which ultimately makes it less readable, understandable and maintainable.

The duplication is mainly needed because AND + OR operators cannot be defined explicitly. They are always implicitly defined by the JSON structure. Usually arrays [] are disjunctions (OR) while the object notation {} defines conjunctions (AND).

Idea:

Reuse the expression system from the constructor and supplement it with more conditional expressions for matching elements similar to mapbox filter expressions.

Example:


["ALL"
  ["EQUALS", $type, "bar"]
  ["CONTAINS", $tag, "foo", "bla"]
]

["ANY"
  ["EQUALS", $type, "foo"]
  ["CONTAINS", $tag, "foo", "bla"]
]

---------------------------------------

"conditions": [
  "ALL",
  ["==", [GET, $tags, "highway"], "footway"],
  ["==", [GET, $tags, "conveying"], "yes"],
  ["HAS", $tags, "bus"],
  ["WITHOUT", $tags, "train"]
]

---------------------------------------

"conditions": [
  "ANY",
  [
    "ALL",
    ["==", [GET, $tags, "highway"], "footway"],
    ["==", [GET, $tags, "conveying"], "yes"],
    ["HAS", $tags, "bus"],
    ["WITHOUT", $tags, "train"]
  ],
  [
    "ALL",
    ["HAS", $tags, "railway"],
    ["WITHOUT", $tags, "train"]
  ]
]

Other goals:

rugk commented 3 months ago

FYI StreetComplete also once used Overpass-query simple syntax, but switched to their own, more information here. If you could embed Kotlin, you could of course just use theirs, but that may or may not be useful given your syntax seems to be quite different.