Skip to main content

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

Project description

ohsome filter to SQL

Build Status Sonarcloud Status PyPI - Version LICENSE status: active

Try it out

# USAGE:
#   after running ohsome-filter-to-sql type in ohsome filter and hit enter
$ uvx ohsome-filter-to-sql
natural = tree and leaftype = broadleaf
('tags @> $1 AND tags @> $2', ('{"natural": "tree"}', '{"leaftype": "broadleaf"}'))

Installation

uv add ohsome-filter-to-sql

Usage

Python Library

from ohsome_filter_to_sql.main import ohsome_filter_to_sql

query, query_args = ohsome_filter_to_sql("natural = tree")

Command Line Interface (CLI)

uv run ohsome-filter-to-sql

Development Setup

uv run pre-commit install
uv run pytest

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ohsome_filter_to_sql-0.2.0.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ohsome_filter_to_sql-0.2.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file ohsome_filter_to_sql-0.2.0.tar.gz.

File metadata

File hashes

Hashes for ohsome_filter_to_sql-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9ea74de51de3018ed61bc8e56b7af66e7d13cea31ebeaf7229e0468b3a59ea61
MD5 e620a1625d2f21a8d2e74851ffde0435
BLAKE2b-256 a0cbbdeab6ff3b8bfbe6858a1ec786063dc1d261c5ce80fef8105d4deb722ab0

See more details on using hashes here.

File details

Details for the file ohsome_filter_to_sql-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ohsome_filter_to_sql-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6dc4fc1af3fd96c4535148fb8a1995d1940a7d80be96546d50a4da71619492a1
MD5 e48ca68500d32228661a7fb7990f23a3
BLAKE2b-256 6d3f54be03cc4eea728c61a2b6f07dd42f2b1d7dc34cc1aa4858e284b524c643

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page