Split conversion of spaces and objects

This commit is contained in:
2020-01-10 13:01:54 +01:00
parent 97fefec1c9
commit 24e2e724e0
2 changed files with 10 additions and 12 deletions

View File

@@ -60,18 +60,15 @@ where
bincode::serialize_into(writer, &data).unwrap();
}
pub fn convert(name: &str) {
// Convert Reference Space definitions
let fn_in = format!("{}.spaces.json", name);
let fn_out = format!("{}.spaces.bin", name);
pub fn convert<T>(name: &str)
where
T: Serialize + DeserializeOwned,
{
// Convert definitions from json to bincode
let fn_in = format!("{}.json", name);
let fn_out = format!("{}.bin", name);
from_json::<Vec<model::Space>>(&fn_in, &fn_out);
// Convert Spatial Objects
let fn_in = format!("{}.objects.json", name);
let fn_out = format!("{}.objects.bin", name);
from_json::<Vec<model::SpatialObject>>(&fn_in, &fn_out);
from_json::<T>(&fn_in, &fn_out);
}
pub fn build(

View File

@@ -16,7 +16,8 @@ fn main() {
// Convert to binary the JSON data:
if true {
info_time!("Converting to binary JSON data");
storage::convert("10k");
storage::convert::<Vec<mercator_db::json::model::Space>>("10k.spaces");
storage::convert::<Vec<mercator_db::json::model::SpatialObject>>("10k.objects");
}
// Build a Database Index: