Thanks to visit codestin.com
Credit goes to pypi.org

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 LICENSE status: active

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


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.1.0.tar.gz (37.1 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.1.0-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for ohsome_filter_to_sql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 652d7fe4ae9d47711a3c38159d78a6fc7062890aa170bfff009f1c2eab9dc4ac
MD5 be6eacb14e43114f5d29517bf330c6b8
BLAKE2b-256 aea08e0fe168fc3c56fc4dc8e6f5a685a4c87ea826e149449e52eeeea8c41058

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ohsome_filter_to_sql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 524c1498066c6a15666bb400856376f637e56069d09573491dcd02aafe70bcf4
MD5 f2c9d70bcb3c17a95da0844239cb25e7
BLAKE2b-256 ef15b4fe8473351d8f4c414b4355eb29ca9441cab03f99f35ad545d687139f73

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