Skip to content

Commit c24278f

Browse files
committed
initial commit
0 parents  commit c24278f

8 files changed

+362
-0
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Cargo.lock
2+
/coverage
3+
/target
4+
lcov.info
5+
lcov_correct.info
6+
*.swp
7+
.DS_Store

.rustfmt.toml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
max_width = 80
2+
hard_tabs = false
3+
tab_spaces = 4
4+
newline_style = "Auto"
5+
use_small_heuristics = "Default"
6+
indent_style = "Block"
7+
wrap_comments = false
8+
comment_width = 100
9+
normalize_comments = false
10+
normalize_doc_attributes = false
11+
format_strings = false
12+
format_macro_matchers = false
13+
format_macro_bodies = true
14+
empty_item_single_line = true
15+
struct_lit_single_line = true
16+
fn_single_line = false
17+
where_single_line = false
18+
imports_indent = "Block"
19+
imports_layout = "Mixed"
20+
imports_granularity = "Crate"
21+
reorder_imports = true
22+
reorder_modules = true
23+
reorder_impl_items = true
24+
type_punctuation_density = "Wide"
25+
space_before_colon = false
26+
space_after_colon = true
27+
spaces_around_ranges = false
28+
binop_separator = "Front"
29+
remove_nested_parens = true
30+
combine_control_expr = true
31+
overflow_delimited_expr = false
32+
struct_field_align_threshold = 0
33+
enum_discrim_align_threshold = 0
34+
match_arm_blocks = true
35+
force_multiline_blocks = false
36+
brace_style = "SameLineWhere"
37+
control_brace_style = "AlwaysSameLine"
38+
trailing_semicolon = true
39+
trailing_comma = "Vertical"
40+
match_block_trailing_comma = false
41+
blank_lines_upper_bound = 1
42+
blank_lines_lower_bound = 0
43+
edition = "2021"
44+
version = "One"
45+
merge_derives = true
46+
use_try_shorthand = false
47+
use_field_init_shorthand = false
48+
force_explicit_abi = true
49+
condense_wildcard_suffixes = false
50+
color = "Auto"
51+
unstable_features = true
52+
disable_all_formatting = false
53+
skip_children = false
54+
hide_parse_errors = false
55+
error_on_line_overflow = false
56+
error_on_unformatted = false
57+
ignore = []
58+
emit_mode = "Files"
59+
make_backup = false

CONTRIBUTING.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Contribution guidelines
2+
3+
First off, thank you for considering contributing to h3o.
4+
5+
If your contribution is not straightforward, please first discuss the change you
6+
wish to make by creating a new issue before making the change.
7+
8+
## Reporting issues
9+
10+
Before reporting an issue on the
11+
[issue tracker](https://github.com/HydroniumLabs/h3o/issues),
12+
please check that it has not already been reported by searching for some related
13+
keywords.
14+
15+
## Pull requests
16+
17+
Try to do one pull request per change.
18+
19+
### Updating the changelog
20+
21+
Update the changes you have made in
22+
[CHANGELOG](https://github.com/HydroniumLabs/h3o/blob/main/CHANGELOG.md)
23+
file under the **Unreleased** section.
24+
25+
Add the changes of your pull request to one of the following subsections,
26+
depending on the types of changes defined by
27+
[Keep a changelog](https://keepachangelog.com/en/1.0.0/):
28+
29+
- `Added` for new features.
30+
- `Changed` for changes in existing functionality.
31+
- `Deprecated` for soon-to-be removed features.
32+
- `Removed` for now removed features.
33+
- `Fixed` for any bug fixes.
34+
- `Security` in case of vulnerabilities.
35+
36+
If the required subsection does not exist yet under **Unreleased**, create it!
37+
38+
## Developing
39+
40+
### Set up
41+
42+
This is no different than other Rust projects.
43+
44+
```shell
45+
git clone https://github.com/HydroniumLabs/h3o
46+
cd h3o
47+
cargo test
48+
```
49+
50+
### Useful Commands
51+
52+
- Run Clippy:
53+
54+
```shell
55+
cargo clippy --all-targets --all-features
56+
```
57+
58+
- Run all tests:
59+
60+
```shell
61+
cargo test --all-features
62+
```
63+
64+
- Check to see if there are code formatting issues
65+
66+
```shell
67+
cargo +nightly fmt --all -- --check
68+
```
69+
70+
- Format the code in the project
71+
72+
```shell
73+
cargo +nightly fmt --all
74+
```

Cargo.toml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "h3o"
3+
version = "0.1.0"
4+
authors = ["Sylvain Laperche <[email protected]>"]
5+
edition = "2021"
6+
description = "A Rust implementation of the H3 geospatial indexing system."
7+
documentation = "https://docs.rs/h3o/"
8+
readme = "README.md"
9+
homepage = "https://docs.rs/h3o"
10+
repository = "https://github.com/HydroniumLabs/h3o"
11+
license = "BSD-3-Clause"
12+
keywords = ["geography", "geospatial", "gis", "h3", "spatial-index"]
13+
categories = ["science"]
14+
15+
[package.metadata.docs.rs]
16+
all-features = true
17+
18+
[dependencies]
19+
20+
[dev-dependencies]
21+
22+
[lib]
23+
# doctests are good for docs, but unfortunately they are slow.
24+
# Cf. https://matklad.github.io/2021/02/27/delete-cargo-integration-tests.html
25+
doctest = false

LICENSE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Redistribution and use in source and binary forms, with or without modification,
2+
are permitted provided that the following conditions are met:
3+
4+
1. Redistributions of source code must retain the above copyright notice, this
5+
list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice,
8+
this list of conditions and the following disclaimer in the documentation
9+
and/or other materials provided with the distribution.
10+
11+
3. Neither the name of the copyright holder nor the names of its contributors
12+
may be used to endorse or promote products derived from this software without
13+
specific prior written permission.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
19+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
22+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# h3o
2+
3+
[![Crates.io](https://img.shields.io/crates/v/h3o.svg)](https://crates.io/crates/h3o)
4+
[![Docs.rs](https://docs.rs/h3o/badge.svg)](https://docs.rs/h3o)
5+
[![Build Status](https://img.shields.io/github/workflow/status/HydroniumLabs/h3o/Build)](https://github.com/HydroniumLabs/h3o/actions)
6+
[![License](https://img.shields.io/badge/license-BSD-green)](https://opensource.org/licenses/BSD-3-Clause)
7+
8+
[Rust](https://rustlang.org) implementation of the [H3](https://h3geo.org)
9+
geospatial indexing system.
10+
11+
## Design
12+
13+
This is not a binding of the reference implementation, but a reimplementation
14+
from scratch.
15+
16+
The goals are:
17+
- To be safer/harder to misuse by leveraging the strong typing of Rust.
18+
- To be 100% Rust (no C deps): painless compilation to WASM, easier LTO, …
19+
- To be as fast (or even faster when possible) than the reference library.
20+
21+
## Installation
22+
23+
### Cargo
24+
25+
* Install the rust toolchain in order to have cargo installed by following
26+
[this](https://www.rust-lang.org/tools/install) guide.
27+
* run `cargo install h3o`
28+
29+
## Usage
30+
31+
```rust
32+
use h3o::{LatLng, Resolution};
33+
34+
let coord = LatLng::from_degrees(37.769377, -122.388903).expect("valid coord");
35+
let cell = coord.to_cell(Resolution::Nine);
36+
```
37+
38+
## Why this name?
39+
40+
Rust is an iron oxide.
41+
A Rust version of H3 is an H3 oxide, in other word $$H_3O$$ (a.k.a hydronium).
42+
Chemically speaking this is wrong ($$H_3O$$ is produced by protonation of
43+
$$H_2O$$, not oxidation of $$H_3$$), but ¯\_(ツ)_
44+
45+
## License
46+
47+
[BSD 3-Clause](./LICENSE)

clippy.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Furthermore, Rust types that are larger than 128 bytes are copied with memcpy
2+
# rather than inline code. [...] Shrinking these types to 128 bytes or less can
3+
# make the code faster by avoiding memcpy calls and reducing memory traffic.
4+
#
5+
# See https://nnethercote.github.io/perf-book/type-sizes.html
6+
enum-variant-size-threshold = 128

src/lib.rs

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
//! The `h3o` library implements the H3 geospatial indexing system.
2+
//!
3+
//! H3 is a geospatial indexing system using a hexagonal grid that can be
4+
//! (approximately) subdivided into finer and finer hexagonal grids, combining
5+
//! the benefits of a hexagonal grid with S2's hierarchical subdivisions.
6+
7+
// Lints {{{
8+
9+
#![deny(
10+
nonstandard_style,
11+
rust_2018_idioms,
12+
rust_2021_compatibility,
13+
future_incompatible,
14+
rustdoc::all,
15+
rustdoc::missing_crate_level_docs,
16+
missing_docs,
17+
unsafe_code,
18+
unused,
19+
unused_import_braces,
20+
unused_lifetimes,
21+
unused_qualifications,
22+
variant_size_differences,
23+
warnings,
24+
clippy::all,
25+
clippy::cargo,
26+
clippy::pedantic,
27+
clippy::allow_attributes_without_reason,
28+
clippy::as_underscore,
29+
clippy::branches_sharing_code,
30+
clippy::clone_on_ref_ptr,
31+
clippy::cognitive_complexity,
32+
clippy::create_dir,
33+
clippy::dbg_macro,
34+
clippy::debug_assert_with_mut_call,
35+
clippy::decimal_literal_representation,
36+
clippy::default_union_representation,
37+
clippy::derive_partial_eq_without_eq,
38+
clippy::empty_drop,
39+
clippy::empty_line_after_outer_attr,
40+
clippy::empty_structs_with_brackets,
41+
clippy::equatable_if_let,
42+
clippy::exhaustive_enums,
43+
clippy::exit,
44+
clippy::filetype_is_file,
45+
clippy::float_cmp_const,
46+
clippy::fn_to_numeric_cast_any,
47+
clippy::format_push_string,
48+
clippy::future_not_send,
49+
clippy::get_unwrap,
50+
clippy::if_then_some_else_none,
51+
clippy::imprecise_flops,
52+
clippy::integer_division,
53+
clippy::iter_on_empty_collections,
54+
clippy::iter_on_single_items,
55+
clippy::iter_with_drain,
56+
clippy::large_include_file,
57+
clippy::let_underscore_must_use,
58+
clippy::lossy_float_literal,
59+
clippy::mem_forget,
60+
clippy::missing_const_for_fn,
61+
clippy::mixed_read_write_in_expression,
62+
clippy::multiple_inherent_impl,
63+
clippy::mutex_atomic,
64+
clippy::mutex_integer,
65+
clippy::needless_collect,
66+
clippy::non_send_fields_in_send_ty,
67+
clippy::nonstandard_macro_braces,
68+
clippy::option_if_let_else,
69+
clippy::or_fun_call,
70+
clippy::panic,
71+
clippy::path_buf_push_overwrite,
72+
clippy::pattern_type_mismatch,
73+
clippy::print_stderr,
74+
clippy::print_stdout,
75+
clippy::rc_buffer,
76+
clippy::rc_mutex,
77+
clippy::redundant_pub_crate,
78+
clippy::rest_pat_in_fully_bound_structs,
79+
clippy::same_name_method,
80+
clippy::self_named_module_files,
81+
clippy::significant_drop_in_scrutinee,
82+
clippy::str_to_string,
83+
clippy::string_add,
84+
clippy::string_lit_as_bytes,
85+
clippy::string_slice,
86+
clippy::string_to_string,
87+
clippy::suboptimal_flops,
88+
clippy::suspicious_operation_groupings,
89+
clippy::todo,
90+
clippy::trailing_empty_array,
91+
clippy::trait_duplication_in_bounds,
92+
clippy::transmute_undefined_repr,
93+
clippy::trivial_regex,
94+
clippy::try_err,
95+
clippy::type_repetition_in_bounds,
96+
clippy::undocumented_unsafe_blocks,
97+
clippy::unimplemented,
98+
clippy::unnecessary_self_imports,
99+
clippy::unneeded_field_pattern,
100+
clippy::unseparated_literal_suffix,
101+
clippy::unused_peekable,
102+
clippy::unused_rounding,
103+
clippy::unwrap_used,
104+
clippy::use_debug,
105+
clippy::use_self,
106+
clippy::useless_let_if_seq,
107+
clippy::verbose_file_reads
108+
)]
109+
#![allow(
110+
// The 90’s called and wanted their charset back :p
111+
clippy::non_ascii_literal,
112+
// "It requires the user to type the module name twice."
113+
// => not true here since internal modules are hidden from the users.
114+
clippy::module_name_repetitions,
115+
// External visibility is controlled through mod reexport.
116+
// Sprinkling `pub(crate)` and friends everywhere is noisy and a pain for refactoring...
117+
unreachable_pub,
118+
)]
119+
120+
// }}}

0 commit comments

Comments
 (0)