66 lines
2.5 KiB
Rust
66 lines
2.5 KiB
Rust
mod common;
|
|
mod download;
|
|
mod preprocess;
|
|
mod route;
|
|
use std::collections::HashMap;
|
|
use pyo3::prelude::*;
|
|
use pyo3::types::PyDict;
|
|
use std::path::PathBuf;
|
|
|
|
#[pymodule]
|
|
pub fn _ed_lrr(py: Python, m: &PyModule) -> PyResult<()> {
|
|
/// Test
|
|
#[pyfn(m,"test")]
|
|
fn test(py:Python,o:PyObject) -> PyResult<()> {
|
|
println!("OBJ: {:?}",o);
|
|
return Ok(());
|
|
}
|
|
|
|
/// download(systems_url,systems_file, bodies_url, bodies_file, callback)
|
|
/// --
|
|
///
|
|
/// Download bodies.json and systemsWithCoordinates.json
|
|
#[pyfn(m, "download")]
|
|
fn download(py: Python, systems_url: String, systems_file: String, bodies_url:String,bodies_file:String,callback: PyObject) -> PyResult<PyObject> {
|
|
let state = PyDict::new(py);
|
|
state.set_item("systems_url", systems_url)?;
|
|
state.set_item("systems_file", systems_file)?;
|
|
state.set_item("bodies_url", bodies_url)?;
|
|
state.set_item("bodies_file", bodies_file)?;
|
|
state.set_item("callback", callback)?;
|
|
return Ok(state.to_object(py));
|
|
}
|
|
|
|
/// preprocess(infile_systems, infile_bodies, outfile, callback)
|
|
/// --
|
|
///
|
|
/// Preprocess bodies.json and systemsWithCoordinates.json into stars.csv
|
|
#[pyfn(m, "preprocess")]
|
|
fn preprocess(py: Python, infile_systems: String, infile_bodies: String, outfile:String,callback: PyObject) -> PyResult<PyObject> {
|
|
let state = PyDict::new(py);
|
|
state.set_item("infile_systems", infile_systems)?;
|
|
state.set_item("infile_bodies", infile_bodies)?;
|
|
state.set_item("outfile", outfile)?;
|
|
state.set_item("callback", callback)?;
|
|
return Ok(state.to_object(py));
|
|
}
|
|
|
|
/// route(infile, source, dest, range, mode, greedyness, precomp, callback)
|
|
/// --
|
|
///
|
|
/// Compute a Route using the suplied parameters
|
|
#[pyfn(m, "route")]
|
|
fn route(py: Python, infile: String, source: String, dest:String, range: f32, mode: String,greedyness: Option<f32>, precomp: Option<String>,callback: PyObject) -> PyResult<PyObject> {
|
|
let state = PyDict::new(py);
|
|
state.set_item("infile", infile)?;
|
|
state.set_item("source", source)?;
|
|
state.set_item("dest", dest)?;
|
|
state.set_item("range", range)?;
|
|
state.set_item("mode", mode)?;
|
|
state.set_item("greedyness", greedyness)?;
|
|
state.set_item("precomp", precomp)?;
|
|
state.set_item("callback", callback)?;
|
|
return Ok(state.to_object(py));
|
|
}
|
|
Ok(())
|
|
} |