+ modified points.rs TODO:expected f64 but integer found

This commit is contained in:
dongho
2024-09-06 23:42:40 +09:00
parent 022d4249c4
commit fc8ce9bc28
3 changed files with 9 additions and 51 deletions

View File

@ -2,18 +2,20 @@ use wasm_bindgen::prelude::*;
use web_sys::{
WebGl2RenderingContext, WebGlBuffer, WebGlProgram, WebGlShader, WebGlVertexArrayObject,
};
mod points;
use points::points::get_points;
#[wasm_bindgen(start)]
pub fn start() -> Result<(), JsValue> {
let document = web_sys::window().unwrap().document().unwrap();
let canvas = document.get_element_by_id("glcanvas").unwrap();
let canvas: web_sys::HtmlCanvasElement = canvas.dyn_into::<web_sys::HtmlCanvasElement>()?;
let gl = canvas
.get_context("webgl2")?
.unwrap()
.dyn_into::<WebGl2RenderingContext>()?;
let points = get_points();
let vert_shader = compile_shader(
&gl,
WebGl2RenderingContext::VERTEX_SHADER,

View File

@ -10,25 +10,12 @@ fn main() {
let mut writer = BufWriter::new(file);
// Insert Macro_rules for gettign dynamic size of array
//
let mac_rules_and_init_file: &str = r#"macro_rules! array_size {
($array:expr) => {{
let mu size = 0;
for _ in $array {
size += 1;
}
size
}}
}
struct point {
lat: f64,
lon: f64,
}
pub const POINTS: [point; array_size!(POINTS)] = [
let mac_rules_and_init_file: &str = r#"pub mod points {
pub fn get_points() -> Vec<f64> {
vec![
"#;
let endian_file: &str = r#"];"#;
let endian_file: &str = r#"]}}"#;
let _ = writer.write_all(mac_rules_and_init_file.as_bytes());
let mut nodes = 0_u64;
let mut max_lat: f64 = 0.0;
@ -39,7 +26,7 @@ fn main() {
if let Element::DenseNode(node) = element {
let lat: f64 = node.lat();
let lon: f64 = node.lon();
let lat_lon_str: String = format!("points {{ lat: {}, lon: {} }}, \n", lat, lon);
let lat_lon_str: String = format!("\t\t\t{}, {}, \n", lat, lon);
let _ = writer.write_all(lat_lon_str.as_bytes());
max_lon = if lon > max_lon { lon } else { max_lon };
max_lat = if lat > max_lat { lat } else { max_lat };

View File

@ -1,31 +0,0 @@
use std::fmt::write;
use osmpbf::*;
fn main() {
let reader = ElementReader::from_path(
"/mnt/c/Users/dongho/Desktop/ekstrahMap/assets/south-korea-latest.osm.pbf",
);
println!("Counting...");
match reader.expect("REASON").par_map_reduce(
|element| match element {
Element::Node(_) | Element::DenseNode(_) => (1, 0, 0),
Element::Way(_) => (0, 1, 0),
Element::Relation(_) => (0, 0, 1),
},
|| (0u64, 0u64, 0u64),
|a, b| (a.0 + b.0, a.1 + b.1, a.2 + b.2),
) {
Ok((nodes, ways, relations)) => {
println!("Nodes: {nodes}");
println!("Ways: {ways}");
println!("Relations: {relations}");
}
Err(e) => {
println!("{e}");
std::process::exit(1);
}
}
}