Skip to content

Translate ohsome API filter to SQL WHERE clause ready to be used with ohsomeDB

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING
Notifications You must be signed in to change notification settings

GIScience/ohsome-filter-to-sql

Repository files navigation

README

Try it out

$ uvx --from git+https://github.com/GIScience/ohsome-filter-to-sql.git ohsome-filter-to-sql
natural = tree and leaftype = broadleaf  # type in ohsome filter and hit enter
tags @> '{"natural": "tree"}' AND tags @> '{"leaftype": "broadleaf"}'  # result

Installation

uv add git+https://github.com/GIScience/ohsome-filter-to-sql.git

Usage as Python library

from ohsome_filter_to_sql.main import ohsome_filter_to_sql

sql_query = ohsome_filter_to_sql("natural = tree")

Development Setup

uv run pytest

To install pre-commit hooks run:

uv run pre-commit install

To develop new features you will need a local instance of the ohsomeDB.

How to play around with the grammar?

Execute antlr4-parse, type in an ohsome filter and press ctlr+d.

antlr4-parse OFL.g4 root -tree
buildings=yes
(root:1 (expression:8 (tagMatch:1 (string:1 buildings) = (string:1 yes))) <EOF>)

ANTLR Lab can also be used to try out the grammar.

How to generating parser code?

When the grammar file has change generate new Python code with antlr4 and move genrated files to ohsome_filter_to_sql/.

uv run antlr4 -Dlanguage=Python3 OFL.g4 && mv *.py ohsome_filter_to_sql/

Release

This project uses CalVer.

Format is: YYYY.MM.DD (E.g 2025.9.2).

In case of releasing twice on one day add a micro number starting with 1: YYYY.MM.DD.micro (E.g. 2025.9.2.1).

To make a new release run ./scripts/release.sh YYYY.MM.DD

Resources

About

Translate ohsome API filter to SQL WHERE clause ready to be used with ohsomeDB

Resources

License

LGPL-3.0, GPL-3.0 licenses found

Licenses found

LGPL-3.0
COPYING.LESSER
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •