Compare commits
8 Commits
0ed672efde
...
lts
| Author | SHA1 | Date | |
|---|---|---|---|
| efd0d53852 | |||
| 590a5f442a | |||
| 3ea1d726cf | |||
| a4af35fbee | |||
| a9c41a9aa0 | |||
| baa57a08e7 | |||
| e627698b0c | |||
| c5d280163e |
795
Cargo.lock
generated
795
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -22,13 +22,15 @@ include = ["Cargo.toml", "README.md", "LICENSE", "ACKNOWLEDGEMENTS", "src/**/*.r
|
||||
lto = true
|
||||
|
||||
[dependencies]
|
||||
measure_time = "^0.6"
|
||||
structopt = "^0.3"
|
||||
mercator_db = "^0.1"
|
||||
measure_time = "0.8"
|
||||
mercator_db = "0.1"
|
||||
|
||||
# Online help & argument parsing
|
||||
clap = {version = "4.5", features = ["derive","wrap_help"]}
|
||||
|
||||
# Logging macros API
|
||||
log = { version = "^0.4", features = ["max_level_trace", "release_max_level_trace"] }
|
||||
pretty_env_logger = "^0.3" # Logger implementation
|
||||
log = { version = "0.4", features = ["max_level_trace", "release_max_level_trace"] }
|
||||
pretty_env_logger = "0.5" # Logger implementation
|
||||
|
||||
[workspace]
|
||||
|
||||
|
||||
33
README.md
33
README.md
@@ -1,6 +1,6 @@
|
||||
# Mercator Indexer
|
||||
|
||||
Tool to generate indexes for the Mercator Spatial Index service.
|
||||
Tool to generate indices for the Mercator, a spatial index.
|
||||
|
||||
## Mercator: Spatial Index
|
||||
|
||||
@@ -22,16 +22,14 @@ This enables the index implementations to be agnostic from the underlying data s
|
||||
|
||||
* Rust: https://www.rust-lang.org
|
||||
|
||||
## Quick start
|
||||
|
||||
Checkout the dependencies in the parent folder:
|
||||
* mercator_db
|
||||
* ironsea_index
|
||||
* ironsea_store
|
||||
* ironsea_table
|
||||
* ironsea_index_hashmap
|
||||
* ironsea_index_sfc_dbc
|
||||
* ironsea_table_vector
|
||||
|
||||
* mercator_db – https://github.com/epfl-dias/mercator_db
|
||||
* ironsea_index – https://github.com/epfl-dias/ironsea_index
|
||||
* ironsea_index_hashmap – https://github.com/epfl-dias/ironsea_index_hashmap
|
||||
* ironsea_index_sfc_dbc – https://github.com/epfl-dias/ironsea_index_sfc_dbc
|
||||
|
||||
## Quick start
|
||||
|
||||
For 3 datasets, `setA`, `setB`, `setC`, the following files are expected to be in the current folder:
|
||||
* setA:
|
||||
@@ -78,6 +76,21 @@ For more options, please refer to the online help:
|
||||
cargo run --release -- --help
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
To install the software on the system, after checking out the
|
||||
dependencies you can use:
|
||||
|
||||
```sh
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
Then in any folder you can then use:
|
||||
|
||||
```sh
|
||||
mercator_indexer -f json setA:v0.1 setB setC:MyAwesomeVersion
|
||||
```
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
This open source software code was developed in part or in whole in the
|
||||
|
||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
[toolchain]
|
||||
channel = "1.80.0"
|
||||
75
src/main.rs
75
src/main.rs
@@ -5,37 +5,62 @@ extern crate measure_time;
|
||||
|
||||
use std::io::Error;
|
||||
|
||||
use clap::Parser;
|
||||
use mercator_db::storage;
|
||||
use mercator_db::storage::model;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(StructOpt, Debug)]
|
||||
/// Tool to generate indices for Mercator, a spatial index.
|
||||
#[derive(Parser, 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)]
|
||||
/// List of scale factors.
|
||||
///
|
||||
/// This is applied to generate coarser indices on top of the
|
||||
/// full-resolution index.
|
||||
///
|
||||
/// The factors are power of 2, which defines the number of bits to
|
||||
/// mask in order to reduce the precision of the volumetric
|
||||
/// positions within an index.
|
||||
#[arg(short, long)]
|
||||
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.
|
||||
/// Threshold to stop generating extra, coarser indices.
|
||||
///
|
||||
/// This threshold defines the minimum number of elements contained
|
||||
/// in the index. Indices will be build for all the precision
|
||||
/// reductions which half the number of data point in the index,
|
||||
/// compared to the previous one, until we reached this threshold,
|
||||
/// or the number of data point equals the number of distinct IDs
|
||||
/// registered in the index.
|
||||
///
|
||||
/// Without a value, the limit will be the number od distinct IDs in
|
||||
/// the index.
|
||||
///
|
||||
/// This argument is ignored when `scales` is also provided.
|
||||
#[allow(clippy::option_option)]
|
||||
#[structopt(long, short)]
|
||||
#[arg(short, long)]
|
||||
max_elements: Option<Option<usize>>,
|
||||
|
||||
/// Storage format of the input data. Either `xyz` or `json`.
|
||||
#[structopt(long, short)]
|
||||
#[arg(short, long)]
|
||||
format: String,
|
||||
|
||||
/// 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
|
||||
/// List of datasets to index
|
||||
///
|
||||
/// The data files are expected to be found in the current directory.
|
||||
///
|
||||
/// Syntax per dataset:
|
||||
///
|
||||
/// name[:version]
|
||||
///
|
||||
/// where `name` is the basename of the input files, and `version` a
|
||||
/// string to add to the dataset description.
|
||||
datasets: Vec<String>,
|
||||
}
|
||||
|
||||
enum StorageFormat {
|
||||
Json,
|
||||
XYZ,
|
||||
Xyz,
|
||||
}
|
||||
|
||||
impl StorageFormat {
|
||||
@@ -48,7 +73,7 @@ impl StorageFormat {
|
||||
title
|
||||
))?;
|
||||
}
|
||||
StorageFormat::XYZ => {
|
||||
StorageFormat::Xyz => {
|
||||
storage::json::from::<Vec<model::Space>>(&format!("{}.spaces", title))?;
|
||||
storage::xyz::from(&format!("{}.objects", title))?;
|
||||
}
|
||||
@@ -62,7 +87,7 @@ impl From<&str> for StorageFormat {
|
||||
fn from(name: &str) -> Self {
|
||||
match name {
|
||||
"json" => StorageFormat::Json,
|
||||
"xyz" => StorageFormat::XYZ,
|
||||
"xyz" => StorageFormat::Xyz,
|
||||
_ => panic!("Unknown input format: {}", name),
|
||||
}
|
||||
}
|
||||
@@ -75,7 +100,7 @@ fn main() {
|
||||
}
|
||||
pretty_env_logger::init();
|
||||
|
||||
let opt = Opt::from_args();
|
||||
let opt = Opt::parse();
|
||||
|
||||
let format = StorageFormat::from(opt.format.as_str());
|
||||
|
||||
@@ -117,24 +142,18 @@ fn main() {
|
||||
// Convert to binary the JSON data:
|
||||
{
|
||||
info_time!("Converting to binary data");
|
||||
match format.convert(title) {
|
||||
Err(e) => {
|
||||
warn!("Error converting input files: {:?}, skipping.", e);
|
||||
continue;
|
||||
}
|
||||
Ok(()) => (),
|
||||
if let Err(e) = format.convert(title) {
|
||||
warn!("Error converting input files: {:?}, skipping.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Build a Database Index:
|
||||
{
|
||||
info_time!("Building database index");
|
||||
match storage::bincode::build(&title, version, scales.clone(), max_elements) {
|
||||
Err(e) => {
|
||||
warn!("Error building index: {:?}, skipping.", e);
|
||||
continue;
|
||||
}
|
||||
Ok(()) => (),
|
||||
if let Err(e) = storage::bincode::build(title, version, scales.clone(), max_elements) {
|
||||
warn!("Error building index: {:?}, skipping.", e);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user