1#![cfg(not(target_family = "wasm"))]
4#![warn(rustdoc::broken_intra_doc_links, rust_2018_idioms, clippy::all, missing_docs)]
5#![allow(incomplete_features)]
6
7pub fn main() {
10 #[cfg(feature = "self-contained")]
11 generate_self_contained_bincodes();
12}
13
14#[cfg(feature = "self-contained")]
15fn generate_self_contained_bincodes() {
16 #[cfg(feature = "tz-ned")]
17 generate_ned_tz_bincodes();
18 #[cfg(feature = "tz-osm")]
19 generate_osm_tz_bincodes();
20 #[cfg(feature = "admin-osm")]
21 generate_osm_admin_bincodes();
22}
23
24#[cfg(all(feature = "tz-ned", feature = "self-contained"))]
25fn generate_ned_tz_bincodes() {
26 use rtz_core::geo::{
27 shared::generate_bincodes,
28 tz::ned::{get_geojson_features_from_source, NedTimezone, LOOKUP_BINCODE_DESTINATION_NAME, TIMEZONE_BINCODE_DESTINATION_NAME},
29 };
30
31 let timezone_bincode_destination = &format!("../assets/{}", TIMEZONE_BINCODE_DESTINATION_NAME);
32 let lookup_bincode_destination = &format!("../assets/{}", LOOKUP_BINCODE_DESTINATION_NAME);
33
34 #[cfg(not(feature = "force-rebuild"))]
35 if std::path::Path::new(timezone_bincode_destination).exists() && std::path::Path::new(lookup_bincode_destination).exists() {
36 return;
37 }
38
39 std::fs::create_dir_all("../assets").unwrap();
40
41 let features = get_geojson_features_from_source();
42 generate_bincodes::<NedTimezone>(features, timezone_bincode_destination, lookup_bincode_destination);
43}
44
45#[cfg(all(feature = "tz-osm", feature = "self-contained"))]
46fn generate_osm_tz_bincodes() {
47 use rtz_core::geo::{
48 shared::generate_bincodes,
49 tz::osm::{get_geojson_features_from_source, OsmTimezone, LOOKUP_BINCODE_DESTINATION_NAME, TIMEZONE_BINCODE_DESTINATION_NAME},
50 };
51
52 let timezone_bincode_destination = &format!("../assets/{}", TIMEZONE_BINCODE_DESTINATION_NAME);
53 let lookup_bincode_destination = &format!("../assets/{}", LOOKUP_BINCODE_DESTINATION_NAME);
54
55 #[cfg(not(feature = "force-rebuild"))]
56 if std::path::Path::new(timezone_bincode_destination).exists() && std::path::Path::new(lookup_bincode_destination).exists() {
57 return;
58 }
59
60 std::fs::create_dir_all("../assets").unwrap();
61
62 let features = get_geojson_features_from_source();
63 generate_bincodes::<OsmTimezone>(features, timezone_bincode_destination, lookup_bincode_destination);
64}
65
66#[cfg(all(feature = "admin-osm", feature = "self-contained"))]
67fn generate_osm_admin_bincodes() {
68 use rtz_core::geo::{
69 admin::osm::{get_geojson_features_from_source, OsmAdmin, ADMIN_BINCODE_DESTINATION_NAME, LOOKUP_BINCODE_DESTINATION_NAME},
70 shared::generate_bincodes,
71 };
72
73 let admin_bincode_destination = &format!("../assets/{}", ADMIN_BINCODE_DESTINATION_NAME);
74 let lookup_bincode_destination = &format!("../assets/{}", LOOKUP_BINCODE_DESTINATION_NAME);
75
76 #[cfg(not(feature = "force-rebuild"))]
77 if std::path::Path::new(admin_bincode_destination).exists() && std::path::Path::new(lookup_bincode_destination).exists() {
78 return;
79 }
80
81 std::fs::create_dir_all("../assets").unwrap();
82
83 let features = get_geojson_features_from_source();
84 generate_bincodes::<OsmAdmin>(features, admin_bincode_destination, lookup_bincode_destination);
85}