Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set mandate metadata to mbtiles #17

Merged
merged 8 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
pull_request:
branches: [master]

jobs:
Test:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install the latest version of rye
uses: eifinger/setup-rye@v3

- name: rye sync
run: rye sync

- name: Lint with ruff
run: rye run ruff --output-format=github .

- name: Format with ruff
run: rye run ruff format .
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__pycache__/
.DS_Store
.venv
dist
dist
.ruff_cache
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pip install tileget

## usage

```
```planetext
usage: __main__.py [-h] [-e OUTPUT_DIR] [-o OUTPUT_FILE] [--extent EXTENT EXTENT EXTENT EXTENT] [--geojson GEOJSON] [--minzoom MINZOOM] [--maxzoom MAXZOOM] [--interval INTERVAL] [--overwrite] [--timeout TIMEOUT] [--tms]
tileurl

Expand Down Expand Up @@ -39,6 +39,10 @@ options:
### examples

```sh
tileget https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg -e ./output_dir --extent 141.23 40.56 142.45 43.78 --maxzoom 12
tileget https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg -o ./output.mbtiles
```
# basic usage
tileget http://path/to/tile/{z}/{x}/{y}.jpg -e output_dir --extent 141.23 40.56 142.45 43.78
tileget http://path/to/tile/{z}/{x}/{y}.jpg -o output.mbtiles --geojson input.geojson

# optional arguments
tileget http://path/to/tile/{z}/{x}/{y}.jpg -e output_dir --extent 141.23 40.56 142.45 43.78 --minzoom 0 --maxzoom 16 --interval 500 --timeout 5000 --overwrite
```
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "tileget"
version = "0.4.1"
version = "0.4.2"
description = "Tile download utility - easily download xyz-tile data"
readme = "README.md"
requires-python = ">= 3.10"
Expand Down
24 changes: 24 additions & 0 deletions tileget/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,30 @@ def _download(tile):

conn = sqlite3.connect(params.output_path)

# write metadata
c = conn.cursor()
c.execute(
"INSERT INTO metadata (name, value) VALUES (?, ?)",
("name", os.path.basename(params.output_path)),
)
c.execute(
"INSERT INTO metadata (name, value) VALUES (?, ?)",
(
"format",
os.path.splitext(params.tileurl.split("?")[0])[-1].replace(".", ""),
),
)
c.execute(
"INSERT INTO metadata (name, value) VALUES (?, ?)",
("minzoom", params.minzoom),
)
c.execute(
"INSERT INTO metadata (name, value) VALUES (?, ?)",
("maxzoom", params.maxzoom),
)

conn.commit()

def _download(tile):
download_mbtiles(
conn, tile, params.tileurl, params.timeout, params.overwrite, params.tms
Expand Down