Translate ohsome API filter to SQL WHERE clause ready to be used with ohsomeDB
Project description
ohsome filter to SQL
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
Python Library
from ohsome_filter_to_sql.main import ohsome_filter_to_sql
sql_query = ohsome_filter_to_sql("natural = tree")
Command Line Interface (CLI)
uv run ohsome-filter-to-sql
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 SemVer.
To make a new release run ./scripts/release.sh <version number>.
Resources
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ohsome_filter_to_sql-0.1.0.tar.gz.
File metadata
- Download URL: ohsome_filter_to_sql-0.1.0.tar.gz
- Upload date:
- Size: 37.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
652d7fe4ae9d47711a3c38159d78a6fc7062890aa170bfff009f1c2eab9dc4ac
|
|
| MD5 |
be6eacb14e43114f5d29517bf330c6b8
|
|
| BLAKE2b-256 |
aea08e0fe168fc3c56fc4dc8e6f5a685a4c87ea826e149449e52eeeea8c41058
|
File details
Details for the file ohsome_filter_to_sql-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ohsome_filter_to_sql-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
524c1498066c6a15666bb400856376f637e56069d09573491dcd02aafe70bcf4
|
|
| MD5 |
f2c9d70bcb3c17a95da0844239cb25e7
|
|
| BLAKE2b-256 |
ef15b4fe8473351d8f4c414b4355eb29ca9441cab03f99f35ad545d687139f73
|