Skip to content

Commit

Permalink
Merge pull request #17 from Kanahiro/feat/mbtiles-metadata
Browse files Browse the repository at this point in the history
fix: set mandate metadata to mbtiles
  • Loading branch information
Kanahiro authored Jun 11, 2024
2 parents 7300956 + e8b5f0d commit 7fd2de9
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 6 deletions.
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

0 comments on commit 7fd2de9

Please sign in to comment.