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 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 prek install  # pre-commit hooks
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.10.2.tar.gz (37.9 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.10.2-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ohsome_filter_to_sql-0.10.2.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ohsome_filter_to_sql-0.10.2.tar.gz
Algorithm Hash digest
SHA256 fa80ac8790419a13075ed35859a33ee854b22f27fad7320c952f87f12bf1c30a
MD5 441535a8502716866af53e90dab8b283
BLAKE2b-256 0e027cb6780625881911b7a6526e0ea67385aa0acba0b73b36d78f6e481da5d4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ohsome_filter_to_sql-0.10.2-py3-none-any.whl
  • Upload date:
  • Size: 39.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ohsome_filter_to_sql-0.10.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3223acc7bb4eb5cbb69826df4f76ce7006b8a864f027b4dc12dc1ce945aab8eb
MD5 e7d178cd40a466a04ed6093e9a47a369
BLAKE2b-256 7948e5ccd04e2410aede7adbf8478c66ef27e5e895f4fc6343a3a3abd53172ab

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