Add support for multi-scale Index generation

This commit is contained in:
2019-10-15 19:35:49 +02:00
parent 818c19859f
commit 3272590d24
2 changed files with 40 additions and 1 deletions

View File

@@ -64,6 +64,7 @@ This will produce the following files:
- setC.spaces.bin
- setC.index
By default, each dataset will have a version set to the empty string, if you want to specify the dataset version you can like this:
```sh
@@ -72,6 +73,14 @@ cargo run --release -- setA:v0.1 setB setC:MyAwesomeVersion
With the above, `setA` will have its version set to `v0.1`, `setB` to the empty string and `setC` to `MyAwesomeVersion`.
For more options, please refer to the online help:
```sh
cargo run --release -- --help
```
## Acknowledgements
This open source software code was developed in part or in whole in the

View File

@@ -5,7 +5,18 @@ use mercator_db::json::storage;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(rename_all = "kebab-case")]
struct Opt {
/// Optional list of scale factors to be applied to generate coarser indices
/// as well as the full-resolution index.
#[structopt(long, short)]
scales: Option<Vec<u32>>,
/// Optional hint to be used when you wish to generate extra, coarser
/// indices. This argument is ignored when `scales` is also provided.
#[structopt(long, short)]
max_elements: Option<Option<usize>>,
/// List of datasets to index, with the following syntax per dataset:
/// name[:version]: where name is the basename of the input files, and
/// `version` a string to add to the dataset description
@@ -20,6 +31,25 @@ fn main() {
pretty_env_logger::init();
let opt = Opt::from_args();
let scales = match opt.scales {
None => None,
Some(v) => {
if v.is_empty() {
None
} else {
let v = v.iter().map(|x| vec![*x, *x, *x]).collect();
Some(v)
}
}
};
let max_elements = match opt.max_elements {
None => None,
Some(e) => match e {
None => Some(0),
s @ Some(_) => s,
},
};
for dataset in opt.datasets {
println!();
@@ -45,7 +75,7 @@ fn main() {
// Build a Database Index:
{
info_time!("Building database index");
storage::build(&title, version);
storage::build(&title, version, scales.clone(), max_elements);
}
}
}