Skip to main content

DefaultFinder

Struct DefaultFinder 

Source
pub struct DefaultFinder { /* private fields */ }
Expand description

The recommended finder: FUZZY preindex fast path over materialized polygon geometry, loaded from a .tzb file.

get_tz_name answers from the preindex tile when one covers the point (the vast majority of queries) and falls back to exact point-in-polygon otherwise; get_tz_names always uses the polygon scan, as the polygon-exact escape hatch. Files without a FUZZY section get the plain polygon finder.

Implementations§

Source§

impl DefaultFinder

Source

pub fn new() -> Self

Creates the finder from the bundled tzf-dist lite .tzb data.

§Panics

Panics when the embedded dataset is malformed — the release pipeline validates it, so this only fires on a broken build.

use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
assert_eq!("Asia/Shanghai", finder.get_tz_name(116.3883, 39.9289));
Source

pub fn from_tzb(data: &[u8]) -> Result<Self, Error>

Builds a finder from TZF embedded binary (.tzb) bytes by expanding the geometry into the materialized polygon engine at load time. data is only read during loading. When the file carries a FUZZY section it becomes the get_tz_name fast path.

§Errors

Returns Error when the bytes are not a structurally valid E-profile (.tzb) file.

Source

pub fn get_tz_name(&self, lng: f64, lat: f64) -> &str

Returns the first matching timezone name, or "" when no timezone covers the point.

use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
assert_eq!("Asia/Shanghai", finder.get_tz_name(116.3883, 39.9289));
Source

pub fn get_tz_names(&self, lng: f64, lat: f64) -> Vec<&str>

Returns all matching timezone names (overlapping areas produce more than one), sorted lexicographically. Always polygon-exact.

use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
println!("{:?}", finder.get_tz_names(116.3883, 39.9289));
Source

pub fn timezonenames(&self) -> Vec<&str>

Returns all timezone names in the dataset.

use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
println!("{:?}", finder.timezonenames());
Source

pub fn data_version(&self) -> &str

Returns the dataset release this finder was built from (e.g. 2026c).

use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
println!("{:?}", finder.data_version());
Source

pub fn to_geojson(&self) -> BoundaryFile

Converts all timezone boundaries to a GeoJSON FeatureCollection.

Source

pub fn get_tz_geojson(&self, timezone_name: &str) -> Option<BoundaryFile>

Converts one timezone’s boundaries to a GeoJSON FeatureCollection. Returns None when the dataset does not contain the name.

Source

pub fn get_tz_preindex_geojson( &self, timezone_name: &str, ) -> Option<BoundaryFile>

Converts one timezone’s FUZZY preindex tiles to a GeoJSON FeatureCollection: one Feature whose MultiPolygon holds each tile’s bounding rectangle — the area where get_tz_name answers from the preindex fast path instead of exact point-in-polygon. Tiles are ordered coarsest zoom first.

Returns None when the file carries no FUZZY section, the dataset does not contain the name, or no preindex tile names it.

Source

pub fn to_preindex_geojson(&self) -> Option<BoundaryFile>

Converts the whole FUZZY preindex to a GeoJSON FeatureCollection: one Feature per timezone that owns at least one tile, in dataset order; a boundary tile appears in every timezone it names. Returns None when the file carries no FUZZY section.

Trait Implementations§

Source§

impl Default for DefaultFinder

Available on crate features bundled or full only.
Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.