pbfcut 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pbfcut-0.1.0/.github/workflows/ci.yml +65 -0
- pbfcut-0.1.0/.github/workflows/pages.yml +58 -0
- pbfcut-0.1.0/.github/workflows/python.yml +84 -0
- pbfcut-0.1.0/.gitignore +7 -0
- pbfcut-0.1.0/CLAUDE.md +81 -0
- pbfcut-0.1.0/Cargo.lock +245 -0
- pbfcut-0.1.0/Cargo.toml +27 -0
- pbfcut-0.1.0/LICENSE +21 -0
- pbfcut-0.1.0/PKG-INFO +27 -0
- pbfcut-0.1.0/README.md +79 -0
- pbfcut-0.1.0/docs/assets/extra.css +61 -0
- pbfcut-0.1.0/docs/design.md +245 -0
- pbfcut-0.1.0/docs/explanation/comparison.md +86 -0
- pbfcut-0.1.0/docs/explanation/rules.md +125 -0
- pbfcut-0.1.0/docs/explanation/speed-and-memory.md +84 -0
- pbfcut-0.1.0/docs/index.md +20 -0
- pbfcut-0.1.0/docs/reference/boundaries.md +58 -0
- pbfcut-0.1.0/docs/reference/cli.md +94 -0
- pbfcut-0.1.0/docs/reference/python.md +102 -0
- pbfcut-0.1.0/docs/tutorials/cut-to-areas.md +85 -0
- pbfcut-0.1.0/docs/tutorials/cut-to-h3-cells.md +65 -0
- pbfcut-0.1.0/docs/tutorials/cut-to-tiles.md +79 -0
- pbfcut-0.1.0/docs/tutorials/online-page.md +63 -0
- pbfcut-0.1.0/mkdocs.yml +65 -0
- pbfcut-0.1.0/pyproject.toml +24 -0
- pbfcut-0.1.0/python/Cargo.lock +341 -0
- pbfcut-0.1.0/python/Cargo.toml +23 -0
- pbfcut-0.1.0/python/README.md +13 -0
- pbfcut-0.1.0/python/pbfcut.pyi +86 -0
- pbfcut-0.1.0/python/src/lib.rs +210 -0
- pbfcut-0.1.0/python/tests/test_pbfcut.py +82 -0
- pbfcut-0.1.0/src/areas.rs +176 -0
- pbfcut-0.1.0/src/boundary.rs +564 -0
- pbfcut-0.1.0/src/cells.rs +126 -0
- pbfcut-0.1.0/src/decode.rs +478 -0
- pbfcut-0.1.0/src/elements.rs +53 -0
- pbfcut-0.1.0/src/extract.rs +574 -0
- pbfcut-0.1.0/src/job.rs +231 -0
- pbfcut-0.1.0/src/lib.rs +16 -0
- pbfcut-0.1.0/src/main.rs +195 -0
- pbfcut-0.1.0/src/store.rs +687 -0
- pbfcut-0.1.0/src/tilecut/write.rs +494 -0
- pbfcut-0.1.0/src/tilecut.rs +1957 -0
- pbfcut-0.1.0/src/tiles.rs +90 -0
- pbfcut-0.1.0/src/util.rs +69 -0
- pbfcut-0.1.0/src/write.rs +379 -0
- pbfcut-0.1.0/tests/cells.rs +105 -0
- pbfcut-0.1.0/tests/data/monaco-areas-overlap.json +6 -0
- pbfcut-0.1.0/tests/data/monaco-areas.json +7 -0
- pbfcut-0.1.0/tests/data/monaco-east.poly +16 -0
- pbfcut-0.1.0/tests/data/monaco.geojson +1 -0
- pbfcut-0.1.0/tests/data/monaco.osm.pbf +0 -0
- pbfcut-0.1.0/tests/golden/monaco.txt +30 -0
- pbfcut-0.1.0/tests/golden/monaco_cells.txt +85 -0
- pbfcut-0.1.0/tests/golden.rs +145 -0
- pbfcut-0.1.0/tests/memory.rs +125 -0
- pbfcut-0.1.0/tests/peak_heap.json +1 -0
- pbfcut-0.1.0/tools/measure.sh +40 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
14
|
+
with:
|
|
15
|
+
targets: wasm32-unknown-unknown
|
|
16
|
+
- uses: Swatinem/rust-cache@v2
|
|
17
|
+
- name: Tests (unit tests and the golden tests)
|
|
18
|
+
run: cargo test --release
|
|
19
|
+
- name: Build for WebAssembly
|
|
20
|
+
run: cargo build --release --lib --target wasm32-unknown-unknown
|
|
21
|
+
- name: The command line on Monaco
|
|
22
|
+
run: |
|
|
23
|
+
cargo run --release -- tiles tests/data/monaco.osm.pbf --zoom 14 --boundary tests/data/monaco.geojson -o out1 > out1.json
|
|
24
|
+
cargo run --release -- tiles tests/data/monaco.osm.pbf --zoom 14 --boundary tests/data/monaco.geojson -o out2 > out2.json
|
|
25
|
+
cargo run --release -- compare out1 out2
|
|
26
|
+
|
|
27
|
+
page:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
steps:
|
|
30
|
+
- uses: actions/checkout@v4
|
|
31
|
+
# nightly first: the last toolchain is the default, and stable must be the default
|
|
32
|
+
- uses: dtolnay/rust-toolchain@master
|
|
33
|
+
with:
|
|
34
|
+
toolchain: nightly-2026-10-15
|
|
35
|
+
targets: wasm32-unknown-unknown
|
|
36
|
+
components: rust-src
|
|
37
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
38
|
+
with:
|
|
39
|
+
targets: wasm32-unknown-unknown
|
|
40
|
+
- uses: taiki-e/install-action@v2
|
|
41
|
+
with:
|
|
42
|
+
tool: wasm-bindgen@0.2.129
|
|
43
|
+
- uses: Swatinem/rust-cache@v2
|
|
44
|
+
- name: The WebAssembly modules and the command line
|
|
45
|
+
run: |
|
|
46
|
+
./web/build.sh
|
|
47
|
+
cargo build --release
|
|
48
|
+
- uses: actions/setup-python@v5
|
|
49
|
+
with:
|
|
50
|
+
python-version: "3.12"
|
|
51
|
+
- name: The end-to-end test of the online page (desktop and phone, on Monaco)
|
|
52
|
+
run: |
|
|
53
|
+
pip install playwright
|
|
54
|
+
playwright install --with-deps chromium
|
|
55
|
+
python web/e2e.py
|
|
56
|
+
|
|
57
|
+
manual:
|
|
58
|
+
runs-on: ubuntu-latest
|
|
59
|
+
steps:
|
|
60
|
+
- uses: actions/checkout@v4
|
|
61
|
+
- uses: actions/setup-python@v5
|
|
62
|
+
with:
|
|
63
|
+
python-version: "3.12"
|
|
64
|
+
- run: pip install "mkdocs==1.6.*" "mkdocs-material==9.*"
|
|
65
|
+
- run: mkdocs build --strict
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
name: Pages
|
|
2
|
+
|
|
3
|
+
# The online page at https://khoshkhah.github.io/pbfcut/ (web/), and the manual at /pbfcut/manual/.
|
|
4
|
+
on:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
pages: write
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
concurrency:
|
|
15
|
+
group: pages
|
|
16
|
+
cancel-in-progress: true
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
build:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
# nightly first: the last toolchain is the default, and stable must be the default
|
|
24
|
+
- uses: dtolnay/rust-toolchain@master
|
|
25
|
+
with:
|
|
26
|
+
toolchain: nightly-2026-10-15
|
|
27
|
+
targets: wasm32-unknown-unknown
|
|
28
|
+
components: rust-src
|
|
29
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
30
|
+
with:
|
|
31
|
+
targets: wasm32-unknown-unknown
|
|
32
|
+
- uses: taiki-e/install-action@v2
|
|
33
|
+
with:
|
|
34
|
+
tool: wasm-bindgen@0.2.129
|
|
35
|
+
- uses: Swatinem/rust-cache@v2
|
|
36
|
+
- name: The online page (the WebAssembly modules, and the regions of Geofabrik)
|
|
37
|
+
run: REGIONS=1 ./web/build.sh
|
|
38
|
+
- uses: actions/setup-python@v5
|
|
39
|
+
with:
|
|
40
|
+
python-version: "3.12"
|
|
41
|
+
- run: pip install "mkdocs==1.6.*" "mkdocs-material==9.*"
|
|
42
|
+
- run: mkdocs build --strict --site-dir site/manual
|
|
43
|
+
- name: The page at the root; ?v=<commit> on its references, because Pages keeps files in its cache for 10 minutes
|
|
44
|
+
run: |
|
|
45
|
+
cp -r web/www/. site/
|
|
46
|
+
sed -i "s/?v=dev/?v=${GITHUB_SHA::7}/g" site/index.html site/app.js site/worker.js
|
|
47
|
+
- uses: actions/upload-pages-artifact@v3
|
|
48
|
+
with:
|
|
49
|
+
path: site
|
|
50
|
+
deploy:
|
|
51
|
+
needs: build
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
environment:
|
|
54
|
+
name: github-pages
|
|
55
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
56
|
+
steps:
|
|
57
|
+
- id: deployment
|
|
58
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
name: Python
|
|
2
|
+
|
|
3
|
+
# The wheels of the Python binding (python/): build them, test them with pytest against the command line, and publish
|
|
4
|
+
# them to PyPI on a version tag (v0.1.0) with trusted publishing (the environment "pypi").
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
branches: [main]
|
|
8
|
+
tags: ["v*"]
|
|
9
|
+
pull_request:
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
wheel:
|
|
16
|
+
name: wheel ${{ matrix.name }}
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
include:
|
|
22
|
+
# Python 3.9 on one runner: the lowest version of the abi3 wheel (Ubuntu 26.04 has no Python 3.9)
|
|
23
|
+
- { name: linux-x86_64, os: ubuntu-24.04, python: "3.9" }
|
|
24
|
+
- { name: linux-aarch64, os: ubuntu-24.04-arm, python: "3.x" }
|
|
25
|
+
- { name: macos-arm64, os: macos-15, python: "3.x" }
|
|
26
|
+
- { name: macos-x86_64, os: macos-15-intel, python: "3.x" }
|
|
27
|
+
- { name: windows-x86_64, os: windows-latest, python: "3.x" }
|
|
28
|
+
defaults:
|
|
29
|
+
run:
|
|
30
|
+
shell: bash
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: ${{ matrix.python }}
|
|
36
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
37
|
+
- uses: PyO3/maturin-action@v1
|
|
38
|
+
with:
|
|
39
|
+
command: build
|
|
40
|
+
args: --release -m python/Cargo.toml -o dist
|
|
41
|
+
manylinux: auto
|
|
42
|
+
- name: The command line (the tests compare with it)
|
|
43
|
+
run: cargo build --release
|
|
44
|
+
- name: Install the wheel and run the tests
|
|
45
|
+
run: |
|
|
46
|
+
python -m pip install pytest
|
|
47
|
+
python -m pip install --no-index --find-links dist pbfcut
|
|
48
|
+
PBFCUT_BIN="$PWD/target/release/pbfcut" python -m pytest -v python/tests
|
|
49
|
+
- uses: actions/upload-artifact@v4
|
|
50
|
+
with:
|
|
51
|
+
name: wheel-${{ matrix.name }}
|
|
52
|
+
path: dist/*.whl
|
|
53
|
+
|
|
54
|
+
sdist:
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
- uses: PyO3/maturin-action@v1
|
|
59
|
+
with:
|
|
60
|
+
command: sdist
|
|
61
|
+
args: -m python/Cargo.toml -o dist
|
|
62
|
+
- uses: actions/upload-artifact@v4
|
|
63
|
+
with:
|
|
64
|
+
name: sdist
|
|
65
|
+
path: dist/*.tar.gz
|
|
66
|
+
|
|
67
|
+
publish:
|
|
68
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
69
|
+
needs: [wheel, sdist]
|
|
70
|
+
runs-on: ubuntu-latest
|
|
71
|
+
environment: pypi
|
|
72
|
+
permissions:
|
|
73
|
+
id-token: write
|
|
74
|
+
steps:
|
|
75
|
+
- uses: actions/checkout@v4
|
|
76
|
+
- name: The tag equals the version of python/Cargo.toml
|
|
77
|
+
run: |
|
|
78
|
+
v=$(sed -n 's/^version = "\(.*\)"/\1/p' python/Cargo.toml | head -1)
|
|
79
|
+
test "${GITHUB_REF_NAME}" = "v$v" || { echo "tag ${GITHUB_REF_NAME}, version $v"; exit 1; }
|
|
80
|
+
- uses: actions/download-artifact@v4
|
|
81
|
+
with:
|
|
82
|
+
path: dist
|
|
83
|
+
merge-multiple: true
|
|
84
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
pbfcut-0.1.0/.gitignore
ADDED
pbfcut-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`pbfcut` is a Rust library and command. It cuts an OpenStreetMap `.osm.pbf` file into map tiles or areas. One read of the input gives all outputs. Each output is a complete `.osm.pbf` file: the nodes in the area, each way with a node there (with all its nodes), and the relations with a member there.
|
|
8
|
+
|
|
9
|
+
pbfcut is an independent project. Do not mention the other projects of the owner in the code, the tests, the README or the manual.
|
|
10
|
+
|
|
11
|
+
`docs/design.md` is the source of truth for scope and decisions. Status: the commands `tiles`, `h3` (H3 cells of one resolution), `areas` (a list of areas that do not overlap, as `osmium extract -c`) and `compare` exist. A list of H3 cells of mixed resolutions is planned and not in the code. `docs/design.md` is for developers: `mkdocs.yml` keeps it out of the published manual.
|
|
12
|
+
|
|
13
|
+
## Commands
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
cargo build --release
|
|
17
|
+
cargo test --release # unit tests and the golden tests
|
|
18
|
+
cargo test --release --test golden tile_files_equal_the_reference # one test
|
|
19
|
+
cargo clippy --release
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Run the command:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cargo run --release -- tiles tests/data/monaco.osm.pbf --zoom 14 --boundary tests/data/monaco.geojson -o out/
|
|
26
|
+
cargo run --release -- h3 tests/data/monaco.osm.pbf --res 9 --boundary tests/data/monaco.geojson -o out/
|
|
27
|
+
cargo run --release -- areas tests/data/monaco.osm.pbf --areas tests/data/monaco-areas.json -o out/
|
|
28
|
+
cargo run --release -- compare DIR_A DIR_B # exit 1 if the elements of the .osm.pbf files differ
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`tiles` takes `--zoom Z` or `--tiles LIST.txt` (one `z/x/y` on each line, no tile inside another tile of the list). `--complete` sets the relation types that the cut keeps whole (default `multipolygon,boundary`). `--steps` prints the time of each step to standard error.
|
|
32
|
+
|
|
33
|
+
The online page is in `web/` (a crate `pbfcut-web` with wasm-bindgen, and the page in `web/www/`). The worker owns the
|
|
34
|
+
browser objects (the input file, a pool of 160 OPFS sync access handles for the temporary files, one OPFS file for the
|
|
35
|
+
tile files). The module calls them only from the thread of the cut.
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
CARGO_BUILD_JOBS=4 ./web/build.sh # web/www/pkg (stable), web/www/pkg-threads (nightly), regions.json
|
|
39
|
+
python3 web/serve.py 8800 # no COOP/COEP headers, as Pages; ?relay=relay gets Geofabrik files
|
|
40
|
+
python3 web/e2e.py [--relay] # Playwright, desktop and phone, on Monaco (needs cargo build --release)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Python binding
|
|
44
|
+
|
|
45
|
+
`python/` is the crate `pbfcut-py` (PyO3, maturin, abi3 for Python 3.9 and later). It only converts arguments and results; all logic stays in `pbfcut::job`. Build and test:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
maturin build --release -m python/Cargo.toml -o dist && pip install dist/pbfcut-*.whl
|
|
49
|
+
PBFCUT_BIN=target/release/pbfcut pytest python/tests # the Python results equal the command line
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`.github/workflows/python.yml` builds and tests the wheels, and publishes them to PyPI on a tag `v*` (trusted publishing). The tag must equal the version in `python/Cargo.toml`.
|
|
53
|
+
|
|
54
|
+
## Golden tests
|
|
55
|
+
|
|
56
|
+
`tests/golden.rs` compares the output with the hashes of the reference files (`tests/golden/monaco.txt`, from pbfcut 11276bc). `tests/cells.rs` does the same for the H3 cells (`tests/golden/monaco_cells.txt`). The input is `tests/data/monaco.osm.pbf`. The hash covers the blocks after the header block, because the header names the program.
|
|
57
|
+
|
|
58
|
+
If a golden test fails, a change altered the result. Find the cause. **Never edit the golden file to make a test pass.**
|
|
59
|
+
|
|
60
|
+
## Architecture
|
|
61
|
+
|
|
62
|
+
The library (`src/lib.rs`) has one module for each job. The command in `src/main.rs` is thin: it parses arguments and calls the library.
|
|
63
|
+
|
|
64
|
+
- `decode`: reads the data blocks of a `.osm.pbf` file in place, with no owned objects. It gives the elements to a `RawSink` (`elements`). `read_block` and `decode_block` are the entry points.
|
|
65
|
+
- `write`: `PbfWriter` writes the output. Blocks have 8000 elements, with no metadata, and the header says `Sort.Type_then_ID`.
|
|
66
|
+
- `boundary`: GeoJSON, `.poly`, WKT or a box (`Boundary::parse` finds the format from the text), with point-in-area tests by latitude band. `WORLD` is a boundary that holds every point.
|
|
67
|
+
- `areas`: the list of areas of `pbfcut areas` (GeoJSON FeatureCollection or osmium config), with a grid of their boxes.
|
|
68
|
+
- `tiles`: the Web Mercator tile grid and `tiles(boundary, z)`. Change the tile rule in this one function.
|
|
69
|
+
- `cells`: the H3 cells (`h3o`, no `std` feature, so `libm` math): `cell_of`, `cells(boundary, res)`, `near_cell`.
|
|
70
|
+
- `extract`: the cut of one area (`cut_to_pbf`, `cut_where`) in four passes. The input must be sorted by type, then id (as the files of Geofabrik).
|
|
71
|
+
- `tilecut` (and `tilecut/write.rs`): the cut to many tiles. It is the largest module. It reads the file two times. Read 1 only makes a plan. Read 2 writes each element straight into the files of its tiles. The cut keeps the tile of each node in memory as compressed runs of ids (`Book`). `Grid` is the only part that knows tiles from cells (the area of a point, the border, the file name). `cut_to_tiles`, `cut_to_cells` and `cut_to_areas` write files to a folder. For an area list, the number of a node in the book can be a set of areas (`Grid::Areas`, `Grid::each`). `cut_to_store` and `cut_to_sink` keep the tile files in a temporary store.
|
|
72
|
+
- `job`: the jobs of the command: `cut` (one cut to a folder, with the file names and the counts) and `compare`. The command and the Python binding call it.
|
|
73
|
+
- `store`: rows in temporary files, with an external sort that has a memory budget. The large lists of the cut live here, so they do not stay in memory.
|
|
74
|
+
|
|
75
|
+
## Rules that are easy to break
|
|
76
|
+
|
|
77
|
+
- **The output bytes must not depend on the target.** zlib output uses `miniz_oxide` (pure Rust). zlib input uses `flate2` with `zlib-rs`. Do not change these for a faster native library. The native build and the WebAssembly build must write the same file.
|
|
78
|
+
- **The code runs natively and on `wasm32`.** The paths with `#[cfg(target_arch = "wasm32")]` use a `Store` of the page (OPFS) and not temporary folders. Keep both paths working.
|
|
79
|
+
- **Memory is the main limit.** The cut keeps lists of ids, never the elements. A change that holds elements in memory can make large inputs (France, Sweden) fail.
|
|
80
|
+
- **Behavior must equal the reference files.** One known difference from `osmium extract`: a node exactly on a tile border goes to one tile, not two.
|
|
81
|
+
- Code comments and docs use ASD-STE100 Simplified Technical English (see the global instructions).
|
pbfcut-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "adler2"
|
|
7
|
+
version = "2.0.1"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "autocfg"
|
|
13
|
+
version = "1.5.1"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "crossbeam-deque"
|
|
19
|
+
version = "0.8.8"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
|
22
|
+
dependencies = [
|
|
23
|
+
"crossbeam-epoch",
|
|
24
|
+
"crossbeam-utils",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[[package]]
|
|
28
|
+
name = "crossbeam-epoch"
|
|
29
|
+
version = "0.9.21"
|
|
30
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
31
|
+
checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"crossbeam-utils",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "crossbeam-utils"
|
|
38
|
+
version = "0.8.23"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
|
|
41
|
+
|
|
42
|
+
[[package]]
|
|
43
|
+
name = "either"
|
|
44
|
+
version = "1.19.0"
|
|
45
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
46
|
+
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
|
47
|
+
|
|
48
|
+
[[package]]
|
|
49
|
+
name = "flate2"
|
|
50
|
+
version = "1.1.11"
|
|
51
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
52
|
+
checksum = "626d4928326b646e70f65ed36fc7cf9f206bdb68a0019ee7c6b4709da4e084c4"
|
|
53
|
+
dependencies = [
|
|
54
|
+
"zlib-rs",
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
[[package]]
|
|
58
|
+
name = "float_eq"
|
|
59
|
+
version = "1.0.1"
|
|
60
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
61
|
+
checksum = "28a80e3145d8ad11ba0995949bbcf48b9df2be62772b3d351ef017dff6ecb853"
|
|
62
|
+
|
|
63
|
+
[[package]]
|
|
64
|
+
name = "h3o"
|
|
65
|
+
version = "0.11.1"
|
|
66
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
67
|
+
checksum = "e09e90732a210d62fb37ce0452cac2b999aeff4ebd1998b53cf45290175b39b5"
|
|
68
|
+
dependencies = [
|
|
69
|
+
"either",
|
|
70
|
+
"float_eq",
|
|
71
|
+
"h3o-bit",
|
|
72
|
+
"libm",
|
|
73
|
+
"ordered-float",
|
|
74
|
+
]
|
|
75
|
+
|
|
76
|
+
[[package]]
|
|
77
|
+
name = "h3o-bit"
|
|
78
|
+
version = "0.1.2"
|
|
79
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
80
|
+
checksum = "3b42eb4efef1f96510ae1a33b2682562a677d504641e9903a77bf5c666b9013e"
|
|
81
|
+
|
|
82
|
+
[[package]]
|
|
83
|
+
name = "itoa"
|
|
84
|
+
version = "1.0.19"
|
|
85
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
86
|
+
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|
87
|
+
|
|
88
|
+
[[package]]
|
|
89
|
+
name = "libm"
|
|
90
|
+
version = "0.2.16"
|
|
91
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
92
|
+
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
|
|
93
|
+
|
|
94
|
+
[[package]]
|
|
95
|
+
name = "memchr"
|
|
96
|
+
version = "2.8.3"
|
|
97
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
98
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
99
|
+
|
|
100
|
+
[[package]]
|
|
101
|
+
name = "miniz_oxide"
|
|
102
|
+
version = "0.8.9"
|
|
103
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
104
|
+
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
|
105
|
+
dependencies = [
|
|
106
|
+
"adler2",
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[[package]]
|
|
110
|
+
name = "num-traits"
|
|
111
|
+
version = "0.2.19"
|
|
112
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
113
|
+
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
|
114
|
+
dependencies = [
|
|
115
|
+
"autocfg",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "ordered-float"
|
|
120
|
+
version = "5.5.1"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"num-traits",
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
[[package]]
|
|
128
|
+
name = "pbfcut"
|
|
129
|
+
version = "0.1.0"
|
|
130
|
+
dependencies = [
|
|
131
|
+
"flate2",
|
|
132
|
+
"h3o",
|
|
133
|
+
"miniz_oxide",
|
|
134
|
+
"rayon",
|
|
135
|
+
"serde_json",
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
[[package]]
|
|
139
|
+
name = "proc-macro2"
|
|
140
|
+
version = "1.0.107"
|
|
141
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
142
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
143
|
+
dependencies = [
|
|
144
|
+
"unicode-ident",
|
|
145
|
+
]
|
|
146
|
+
|
|
147
|
+
[[package]]
|
|
148
|
+
name = "quote"
|
|
149
|
+
version = "1.0.47"
|
|
150
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
151
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
152
|
+
dependencies = [
|
|
153
|
+
"proc-macro2",
|
|
154
|
+
]
|
|
155
|
+
|
|
156
|
+
[[package]]
|
|
157
|
+
name = "rayon"
|
|
158
|
+
version = "1.12.0"
|
|
159
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
160
|
+
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
|
|
161
|
+
dependencies = [
|
|
162
|
+
"either",
|
|
163
|
+
"rayon-core",
|
|
164
|
+
]
|
|
165
|
+
|
|
166
|
+
[[package]]
|
|
167
|
+
name = "rayon-core"
|
|
168
|
+
version = "1.13.0"
|
|
169
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
170
|
+
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
|
171
|
+
dependencies = [
|
|
172
|
+
"crossbeam-deque",
|
|
173
|
+
"crossbeam-utils",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
[[package]]
|
|
177
|
+
name = "serde"
|
|
178
|
+
version = "1.0.229"
|
|
179
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
180
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
181
|
+
dependencies = [
|
|
182
|
+
"serde_core",
|
|
183
|
+
]
|
|
184
|
+
|
|
185
|
+
[[package]]
|
|
186
|
+
name = "serde_core"
|
|
187
|
+
version = "1.0.229"
|
|
188
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
189
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
190
|
+
dependencies = [
|
|
191
|
+
"serde_derive",
|
|
192
|
+
]
|
|
193
|
+
|
|
194
|
+
[[package]]
|
|
195
|
+
name = "serde_derive"
|
|
196
|
+
version = "1.0.229"
|
|
197
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
198
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
199
|
+
dependencies = [
|
|
200
|
+
"proc-macro2",
|
|
201
|
+
"quote",
|
|
202
|
+
"syn",
|
|
203
|
+
]
|
|
204
|
+
|
|
205
|
+
[[package]]
|
|
206
|
+
name = "serde_json"
|
|
207
|
+
version = "1.0.154"
|
|
208
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
209
|
+
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
|
210
|
+
dependencies = [
|
|
211
|
+
"itoa",
|
|
212
|
+
"memchr",
|
|
213
|
+
"serde",
|
|
214
|
+
"serde_core",
|
|
215
|
+
"zmij",
|
|
216
|
+
]
|
|
217
|
+
|
|
218
|
+
[[package]]
|
|
219
|
+
name = "syn"
|
|
220
|
+
version = "3.0.10"
|
|
221
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
222
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
223
|
+
dependencies = [
|
|
224
|
+
"proc-macro2",
|
|
225
|
+
"quote",
|
|
226
|
+
"unicode-ident",
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
[[package]]
|
|
230
|
+
name = "unicode-ident"
|
|
231
|
+
version = "1.0.27"
|
|
232
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
233
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
234
|
+
|
|
235
|
+
[[package]]
|
|
236
|
+
name = "zlib-rs"
|
|
237
|
+
version = "0.6.8"
|
|
238
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
239
|
+
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
|
|
240
|
+
|
|
241
|
+
[[package]]
|
|
242
|
+
name = "zmij"
|
|
243
|
+
version = "1.0.23"
|
|
244
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
245
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
pbfcut-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "pbfcut"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
license = "MIT"
|
|
6
|
+
authors = ["Kaveh Khoshkhah"]
|
|
7
|
+
description = "Cut an OpenStreetMap .osm.pbf file into map tiles or areas, with one read for all outputs"
|
|
8
|
+
repository = "https://github.com/Khoshkhah/pbfcut"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
|
|
11
|
+
[dependencies]
|
|
12
|
+
# the zlib blobs of the input: zlib-rs is a pure-Rust zlib that also builds for WebAssembly
|
|
13
|
+
flate2 = { version = "1.1", default-features = false, features = ["zlib-rs"] }
|
|
14
|
+
# the zlib blobs of the output: pure Rust, so every target writes the same bytes
|
|
15
|
+
miniz_oxide = "0.8"
|
|
16
|
+
# the blocks are decoded on all threads
|
|
17
|
+
rayon = "1.12"
|
|
18
|
+
# the boundary (GeoJSON)
|
|
19
|
+
serde_json = "1"
|
|
20
|
+
# the H3 cells: pure Rust, the cell ids of the H3 library 4; with no `std` feature its math is `libm`, so a point has
|
|
21
|
+
# the same cell on every target
|
|
22
|
+
h3o = { version = "0.11", default-features = false }
|
|
23
|
+
|
|
24
|
+
[profile.release]
|
|
25
|
+
opt-level = 3
|
|
26
|
+
lto = "thin"
|
|
27
|
+
codegen-units = 16
|
pbfcut-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kaveh Khoshkhah
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pbfcut-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pbfcut
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
7
|
+
Summary: Cut an OpenStreetMap .osm.pbf file into map tiles, H3 cells or areas
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
11
|
+
Project-URL: Documentation, https://khoshkhah.github.io/pbfcut/manual/reference/python/
|
|
12
|
+
Project-URL: Homepage, https://github.com/Khoshkhah/pbfcut
|
|
13
|
+
|
|
14
|
+
# pbfcut
|
|
15
|
+
|
|
16
|
+
Cut an OpenStreetMap `.osm.pbf` file into map tiles, H3 cells or a list of areas. Each output is a complete `.osm.pbf`
|
|
17
|
+
file. The cut is the Rust library of pbfcut: this package only converts the arguments and the results.
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import pbfcut
|
|
21
|
+
|
|
22
|
+
r = pbfcut.cut_tiles("monaco.osm.pbf", "tiles", zoom=14, memory="1G")
|
|
23
|
+
print(r["tiles"], [f["file"] for f in r["files"]])
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Manual: https://khoshkhah.github.io/pbfcut/manual/reference/python/
|
|
27
|
+
|