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
impl DefaultFinder
Sourcepub fn new() -> Self
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));Sourcepub fn from_tzb(data: &[u8]) -> Result<Self, Error>
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.
Sourcepub fn get_tz_name(&self, lng: f64, lat: f64) -> &str
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));Sourcepub fn get_tz_names(&self, lng: f64, lat: f64) -> Vec<&str>
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));Sourcepub fn timezonenames(&self) -> Vec<&str>
pub fn timezonenames(&self) -> Vec<&str>
Returns all timezone names in the dataset.
use tzf_rs::DefaultFinder;
let finder = DefaultFinder::new();
println!("{:?}", finder.timezonenames());Sourcepub fn data_version(&self) -> &str
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());Sourcepub fn to_geojson(&self) -> BoundaryFile
pub fn to_geojson(&self) -> BoundaryFile
Converts all timezone boundaries to a GeoJSON FeatureCollection.
Sourcepub fn get_tz_geojson(&self, timezone_name: &str) -> Option<BoundaryFile>
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.
Sourcepub fn get_tz_preindex_geojson(
&self,
timezone_name: &str,
) -> Option<BoundaryFile>
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.
Sourcepub fn to_preindex_geojson(&self) -> Option<BoundaryFile>
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.