pub struct Finder { /* private fields */ }Expand description
Finder works anywhere.
Finder use a fine tuned Ray casting algorithm implement geometry-rs which is Rust port of geometry by Josh Baker.
Implementations§
Source§impl Finder
impl Finder
Sourcepub fn from_compressed_topo(tzs: CompressedTopoTimezones) -> Self
pub fn from_compressed_topo(tzs: CompressedTopoTimezones) -> Self
Create a Finder from CompressedTopoTimezones protobuf data.
This is the preferred constructor when using tzf-dist data.
Sourcepub fn from_compressed_topo_with_options(
tzs: CompressedTopoTimezones,
options: FinderOptions,
) -> Self
pub fn from_compressed_topo_with_options( tzs: CompressedTopoTimezones, options: FinderOptions, ) -> Self
Create a Finder from CompressedTopoTimezones with explicit polygon build options.
Sourcepub fn from_pb_with_options(tzs: Timezones, options: FinderOptions) -> Self
pub fn from_pb_with_options(tzs: Timezones, options: FinderOptions) -> Self
Create a finder from protobuf data with explicit polygon build options.
Sourcepub fn get_tz_name(&self, lng: f64, lat: f64) -> &str
pub fn get_tz_name(&self, lng: f64, lat: f64) -> &str
Example:
use tzf_rs::Finder;
let finder = Finder::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>
use tzf_rs::Finder;
let finder = Finder::new();
println!("{:?}", finder.get_tz_names(116.3883, 39.9289));Sourcepub fn timezonenames(&self) -> Vec<&str>
pub fn timezonenames(&self) -> Vec<&str>
Example:
use tzf_rs::Finder;
let finder = Finder::new();
println!("{:?}", finder.timezonenames());Sourcepub fn data_version(&self) -> &str
pub fn data_version(&self) -> &str
Example:
use tzf_rs::Finder;
let finder = Finder::new();
println!("{:?}", finder.data_version());Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new, empty Finder.
Example:
use tzf_rs::Finder;
let finder = Finder::new();Sourcepub fn to_geojson(&self) -> BoundaryFile
pub fn to_geojson(&self) -> BoundaryFile
Convert the Finder’s data to GeoJSON format.
Returns a BoundaryFile (FeatureCollection) containing all timezone polygons.
§Example
use tzf_rs::Finder;
let finder = Finder::new();
let geojson = finder.to_geojson();
let json_string = geojson.to_string();Sourcepub fn get_tz_geojson(&self, timezone_name: &str) -> Option<BoundaryFile>
pub fn get_tz_geojson(&self, timezone_name: &str) -> Option<BoundaryFile>
Convert a specific timezone to GeoJSON format.
Returns Some(BoundaryFile) containing a FeatureCollection with all features
for the timezone if found, None otherwise. The returned FeatureCollection
may contain multiple features if the timezone has multiple geographic boundaries.
§Arguments
timezone_name- The timezone name to export (e.g., “Asia/Tokyo”)
§Example
use tzf_rs::Finder;
let finder = Finder::new();
if let Some(collection) = finder.get_tz_geojson("Asia/Tokyo") {
let json_string = collection.to_string();
println!("Found {} feature(s)", collection.features.len());
if let Some(first_feature) = collection.features.first() {
println!("Timezone ID: {}", first_feature.properties.tzid);
}
}