Skip to content
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
67 changes: 67 additions & 0 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Rust CI

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

env:
CARGO_TERM_COLOR: always
PKG_CONFIG_PATH: /usr/lib/pkgconfig

jobs:
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
arch: [x64, arm64]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose -- --test-threads=2

clippy:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Check the lints
run: cargo clippy --tests --verbose -- -D warnings


rustfmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check the formatting
run: cargo fmt -- --check --verbose

lychee:
name: Links
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Check the links
uses: lycheeverse/lychee-action@v2
with:
args: -v *.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 changes: 0 additions & 27 deletions .github/workflows/rust.yml

This file was deleted.

25 changes: 24 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qbin"
version = "0.1.0"
version = "0.1.1"
authors = ["Anatoly Tsyplenkov <atsyplenkov@fastmail.com>"]
edition = "2024"
license = "MIT"
Expand All @@ -17,6 +17,7 @@ categories = ["data-structures", "science::geo"]
[dev-dependencies]
approx = "0.5.1"
criterion = "0.5.1"
geohash = "0.13.1"
h3o = "0.8.0"

[[bench]]
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
# Quadbin

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/atsyplenkov/qbin/blob/main/LICENSE)
[![crates.io](https://img.shields.io/crates/v/qbin.svg?logo=rust)](https://crates.io/crates/qbin)
[![Docs.rs](https://img.shields.io/docsrs/qbin?label=docs.rs&logo=rust)](https://docs.rs/qbin)
[![Build & Test](https://github.com/atsyplenkov/qbin/actions/workflows/rust.yml/badge.svg)](https://github.com/atsyplenkov/qbin/actions/workflows/rust.yml)
[![codecov](https://codecov.io/gh/atsyplenkov/qbin/graph/badge.svg?token=4SZ4RI3ILS)](https://codecov.io/gh/atsyplenkov/qbin)
<p align="center">
<a href="https://github.com/atsyplenkov/qbin/releases">
<img src="https://img.shields.io/github/v/release/atsyplenkov/qbin?style=flat&labelColor=1C2C2E&color=dea584&logo=GitHub&logoColor=white"></a>
<a href="https://crates.io/crates/qbin/">
<img src="https://img.shields.io/crates/v/qbin?style=flat&labelColor=1C2C2E&color=dea584&logo=Rust&logoColor=white"></a>
<a href="https://codecov.io/gh/atsyplenkov/qbin">
<img src="https://img.shields.io/codecov/c/gh/atsyplenkov/qbin?style=flat&labelColor=1C2C2E&color=dea584&logo=Codecov&logoColor=white"></a>
<br>
<a href="https://github.com/atsyplenkov/qbin/actions/workflows/rust.yml">
<img src="https://img.shields.io/github/actions/workflow/status/atsyplenkov/qbin/rust.yml?style=flat&labelColor=1C2C2E&color=dea584&logo=GitHub%20Actions&logoColor=white"></a>
<a href="https://docs.rs/qbin/">
<img src="https://img.shields.io/docsrs/qbin?style=flat&labelColor=1C2C2E&color=dea584&logo=Rust&logoColor=white"></a>
<br>
</p>

<h4 align="center">
<a href="https://docs.rs/qbin/">Documentation</a> |
<a href="https://crates.io/crates/qbin/">Website</a>
</h4>


A Rust implementation of Quadbin, a hierarchical geospatial index tiling approach developed by [CARTO](https://github.com/CartoDB). Like the [Microsoft's Bing Maps Tile System](https://docs.microsoft.com/en-us/bingmaps/articles/bing-maps-tile-system) (aka Quadkey), Quadbin uniformly subdivides a map in Mercator projection into four squares at different resolution levels, from 0 to 26 (less than 1 m² at the equator). However, unlike Quadkey, Quadbin stores the grid cell index in a 64-bit integer.

Expand Down
28 changes: 28 additions & 0 deletions benches/encode_point.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use criterion::{Criterion, black_box};
use h3o::{LatLng, Resolution};
use qbin::Cell;

const LAT: f64 = -41.28303675124842;
const LNG: f64 = 174.77727344223067;

pub fn bench(c: &mut Criterion) {
let mut group = c.benchmark_group("encodePoint");

group.bench_function("geohash", |b| {
let coord = geohash::Coord { x: LNG, y: LAT };
let index = geohash::encode(coord, 12).expect("Invalid coordinate");
b.iter(|| black_box(&index))
});
group.bench_function("qbin", |b| {
let index = Cell::from_point(LAT, LNG, 12);
b.iter(|| black_box(&index))
});

group.bench_function("h3o", |b| {
let latlng = LatLng::new(LAT, LNG).expect("Invalid coordinate");
let index = latlng.to_cell(Resolution::Twelve);
b.iter(|| black_box(&index))
});

group.finish();
}
8 changes: 7 additions & 1 deletion benches/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use criterion::{criterion_group, criterion_main};

mod encode_point;
mod get_cell_area;
mod get_resolution;

criterion_group!(benches, get_resolution::bench, get_cell_area::bench);
criterion_group!(
benches,
get_resolution::bench,
get_cell_area::bench,
encode_point::bench
);

criterion_main!(benches);
84 changes: 84 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.

[changelog]
# template for the changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits %}
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
{% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing s
trim = true
# postprocessors
postprocessors = [
# { pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" }, # replace repository URL
]
# render body even when there are no releases to process
# render_always = true
# output file path
# output = "test.md"

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
# regex for preprocessing the commit messages
commit_preprocessors = [
# Replace issue numbers
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
# Check spelling of the commit with https://github.com/crate-ci/typos
# If the spelling is incorrect, it will be automatically fixed.
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 3 -->📚 Documentation", skip = true},
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor", skip = true},
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing", skip = true},
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps.*\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" , skip = true},
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
{ message = ".*", group = "<!-- 10 -->💼 Other" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = true
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
Loading