mirror of
https://github.com/CIMEngine/cimengine-build-tools.git
synced 2024-11-24 13:06:20 +03:00
feat: time display
This commit is contained in:
parent
817f117ac4
commit
a3ea2a093c
2 changed files with 56 additions and 30 deletions
40
src/build.rs
40
src/build.rs
|
@ -1,4 +1,4 @@
|
|||
use std::{fs, path::Path};
|
||||
use std::{fs, path::Path, time};
|
||||
|
||||
use geojson::{Feature, FeatureCollection};
|
||||
use serde_json::json;
|
||||
|
@ -12,8 +12,10 @@ use crate::{
|
|||
pub fn build() {
|
||||
let config = read_config();
|
||||
|
||||
let total_time = time::Instant::now();
|
||||
|
||||
for processing_item in config.processing {
|
||||
let features: Vec<Feature> = vec![];
|
||||
let processed_time = time::Instant::now();
|
||||
|
||||
let out_folder = Path::new(&processing_item.output_folder);
|
||||
|
||||
|
@ -22,12 +24,15 @@ pub fn build() {
|
|||
|
||||
let mut countries: Vec<CountryData> = vec![];
|
||||
|
||||
{
|
||||
let dissolved_time = time::Instant::now();
|
||||
|
||||
for country_id in &config.main.layers {
|
||||
let country = get_country(country_id.to_owned());
|
||||
|
||||
let mut matches = false;
|
||||
for glob in &globs {
|
||||
for tag in &country.config.tags.clone().unwrap_or(vec![]) {
|
||||
for tag in &country.config.tags.clone().unwrap_or(vec!["*".to_owned()]) {
|
||||
if glob.is_match(tag.as_str()) {
|
||||
matches = true;
|
||||
}
|
||||
|
@ -41,12 +46,24 @@ pub fn build() {
|
|||
countries.push(country);
|
||||
}
|
||||
|
||||
println!("Dissolved in {:?}", dissolved_time.elapsed());
|
||||
}
|
||||
|
||||
// TODO: Add country_rewrite support
|
||||
|
||||
let countries = {
|
||||
let diff_time = time::Instant::now();
|
||||
|
||||
let countries = diff_countries(countries);
|
||||
|
||||
// TODO: Add nature support
|
||||
println!("Diffed in {:?}", diff_time.elapsed());
|
||||
|
||||
countries
|
||||
};
|
||||
|
||||
// TODO: Add nature support
|
||||
{
|
||||
let generated_time = time::Instant::now();
|
||||
let countries_json = serde_json::to_string_pretty(&serde_json::Map::from_iter(
|
||||
countries
|
||||
.iter()
|
||||
|
@ -54,16 +71,25 @@ pub fn build() {
|
|||
))
|
||||
.unwrap();
|
||||
|
||||
let feature_collection = countries.to_collection().to_string();
|
||||
|
||||
fs::create_dir_all(out_folder).unwrap();
|
||||
|
||||
fs::write(out_folder.join("geo.geojson"), feature_collection).unwrap();
|
||||
fs::write(
|
||||
out_folder.join("geo.geojson"),
|
||||
countries.to_collection().to_string(),
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(out_folder.join("countries.json"), countries_json).unwrap();
|
||||
|
||||
if let Some(public) = processing_item.public {
|
||||
let public = serde_json::to_string(&public).unwrap();
|
||||
fs::write(out_folder.join("public.json"), public).unwrap();
|
||||
}
|
||||
|
||||
println!("Generated files in {:?}", generated_time.elapsed());
|
||||
}
|
||||
|
||||
println!("Processed in {:?}\n---\n", processed_time.elapsed());
|
||||
}
|
||||
|
||||
println!("Total time: {:?}", total_time.elapsed());
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ impl ToFeature for Marker {
|
|||
serde_json::Map::from_iter([
|
||||
("title".to_owned(), json!(self.title)),
|
||||
("description".to_owned(), json!(self.description)),
|
||||
("marker-type".to_owned(), json!(self.ty.to_str())),
|
||||
("type".to_owned(), json!(self.ty.to_str())),
|
||||
])
|
||||
.into(),
|
||||
),
|
||||
|
|
Loading…
Add table
Reference in a new issue