diff --git a/README.md b/README.md index 4927b3e..e7d3189 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ ![](https://github.com/ringsaturn/tzf/blob/gh-pages/docs/tzf-social-media.png?raw=true) +**NOTE**: this package use a simplified shape data so not so accurate around +border. + ## Build options By default, the binary is built as well. If you don't want/need it, then build @@ -56,8 +59,8 @@ Here is what has been done to improve performance: 1. Using pre-indexing to handle most queries takes approximately 1000 nanoseconds. 2. Using a finely-tuned Ray Casting algorithm package - to verify whether a polygon - contains a point. + [`ringsaturn/geometry-rs`](https://github.com/ringsaturn/geometry-rs) to + verify whether a polygon contains a point. That's all. There are no black magic tricks inside the tzf-rs. @@ -68,10 +71,10 @@ ns per query: test benches_default::bench_default_finder_random_city ... bench: 2,870 ns/iter (+/- 182) ``` -| Criterion result | Pic | -| ---------------- | -------------------------------- | -| PDF | ![](assets/pdf_small.svg) | -| Regression | ![](assets/regression_small.svg) | +| Criterion result | Pic | +| ---------------- | ----------------------------------------------------------------------------------------- | +| PDF | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/pdf_small.svg) | +| Regression | ![](https://raw.githubusercontent.com/ringsaturn/tzf-rs/main/assets/regression_small.svg) | You can view more details from latest benchmark from [GitHub Actions logs](https://github.com/ringsaturn/tzf-rs/actions/workflows/rust.yml). diff --git a/src/lib.rs b/src/lib.rs index 3ad8bfb..013b1ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,27 +1,5 @@ -//! Fast timezone finder for Rust. -//! -//! It's designed for high performance geo queries related services like -//! weather forecast API. And most queries could return in very limited time, -//! averagely like 2000 nanoseconds. -//! -//! Please note that this package use a simplified shape data so not so accurate -//! around border. -//! -//! There are there finders implements: -//! - [Finder]: works anywhere. -//! - [FuzzyFinder]: blazing fast for most places on earth, use a preindex data. -//! Not work for places around borders. -//! - [DefaultFinder]: combine both, if [FuzzyFinder] got no data, then use [Finder]. -//! -//! Preprocessed timezone data is distributed via [tzf-rel]. -//! -//! It's Rust port of [tzf] and also the foundation of -//! [tzfpy] since `v0.11.0`.... -//! -//! [tzf]: https://github.com/ringsaturn/tzf -//! [tzf-rel]: https://github.com/ringsaturn/tzf-rel -//! [tzfpy]: https://github.com/ringsaturn/tzfpy -// +#![doc = include_str!("../README.md")] + use geometry_rs::{Point, Polygon}; use std::collections::HashMap; use std::f64::consts::PI; @@ -45,6 +23,8 @@ impl Item { } } +/// Finder works anywhere. +/// /// Finder use a fine tuned Ray casting algorithm implement [geometry-rs] /// which is Rust port of [geometry] by [Josh Baker]. /// @@ -203,6 +183,9 @@ pub fn deg2num(lng: f64, lat: f64, zoom: i64) -> (i64, i64) { return (xtile as i64, ytile as i64); } +/// FuzzyFinder blazing fast for most places on earth, use a preindex data. +/// Not work for places around borders. +/// /// FuzzyFinder store all preindex's tiles data in a HashMap, /// It iterate all zoom levels for input's longitude and latitude to build /// map key to to check if in map. @@ -281,7 +264,8 @@ impl FuzzyFinder { } } -/// It's most recommend to use, combine both [Finder] and [FuzzyFinder]. +/// It's most recommend to use, combine both [Finder] and [FuzzyFinder], +/// if [FuzzyFinder] got no data, then use [Finder]. pub struct DefaultFinder { finder: Finder, fuzzy_finder: FuzzyFinder,