Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn committed Jul 31, 2023
1 parent d4a7a38 commit b8db9b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
<https://github.com/ringsaturn/geometry-rs> 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.

Expand All @@ -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).
Expand Down
34 changes: 9 additions & 25 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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].
///
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b8db9b3

Please sign in to comment.