wip
This commit is contained in:
		
							parent
							
								
									725381c07c
								
							
						
					
					
						commit
						d8ff878491
					
				
					 4 changed files with 29 additions and 30 deletions
				
			
		
							
								
								
									
										15
									
								
								src/app.rs
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								src/app.rs
									
										
									
									
									
								
							|  | @ -22,11 +22,7 @@ impl Component for App { | ||||||
|                 <p> |                 <p> | ||||||
|                     {"This client-side tool is for merging "} |                     {"This client-side tool is for merging "} | ||||||
|                     <a href="https://www.topografix.com/gpx.asp">{"GPX files"}</a> |                     <a href="https://www.topografix.com/gpx.asp">{"GPX files"}</a> | ||||||
|               {". Please note, this has only been tested on GPX files produced by "} |                     {". "} | ||||||
|               <a href="https://www.garmin.com">{"Garmin"}</a> |  | ||||||
|               {" and "} |  | ||||||
|               <a href="https://www.strava.com">{"Strava"}</a> |  | ||||||
|               {" - your mileage may vary."} |  | ||||||
|                 </p> |                 </p> | ||||||
| 
 | 
 | ||||||
|                 <Loader /> |                 <Loader /> | ||||||
|  | @ -34,10 +30,13 @@ impl Component for App { | ||||||
|                 <hr/> |                 <hr/> | ||||||
| 
 | 
 | ||||||
|                 <p> |                 <p> | ||||||
|  |                     <small>{"source (public access): git://pingo.thermokar.st/gpx-web-utils"}</small> | ||||||
|                     <small> |                     <small> | ||||||
|                 <a href="https://github.com/thermokarst/gpx-web-utils"> |                         {"Please note, this has only been tested on GPX files produced by "} | ||||||
|                   {"https://github.com/thermokarst/gpx-web-utils"} |                         <a href="https://www.garmin.com">{"Garmin"}</a> | ||||||
|                 </a> |                         {" and "} | ||||||
|  |                         <a href="https://www.strava.com">{"Strava"}</a> | ||||||
|  |                         {" - your mileage may vary."} | ||||||
|                     </small> |                     </small> | ||||||
|                 </p> |                 </p> | ||||||
|             </> |             </> | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ use std::error::Error; | ||||||
| use wasm_bindgen::prelude::*; | use wasm_bindgen::prelude::*; | ||||||
| use web_sys::Blob; | use web_sys::Blob; | ||||||
| 
 | 
 | ||||||
| fn join_gpx_files(files: &Vec<String>) -> Result<gpx::Gpx, Box<dyn Error>> { | fn join_gpx_files(files: &[String]) -> Result<gpx::Gpx, Box<dyn Error>> { | ||||||
|     let mut merged_gpx: gpx::Gpx = Default::default(); |     let mut merged_gpx: gpx::Gpx = Default::default(); | ||||||
|     let mut merged_track: gpx::Track = gpx::Track::new(); |     let mut merged_track: gpx::Track = gpx::Track::new(); | ||||||
| 
 | 
 | ||||||
|  | @ -51,7 +51,7 @@ fn write_gpx_to_buffer(gpx: gpx::Gpx) -> Result<js_sys::Array, Box<dyn Error>> { | ||||||
|     Ok(array) |     Ok(array) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn merge(files: &Vec<String>) -> Result<Blob, Box<dyn Error>> { | pub fn merge(files: &[String]) -> Result<Blob, Box<dyn Error>> { | ||||||
|     let merged: gpx::Gpx = join_gpx_files(files)?; |     let merged: gpx::Gpx = join_gpx_files(files)?; | ||||||
|     let out_vec = write_gpx_to_buffer(merged)?; |     let out_vec = write_gpx_to_buffer(merged)?; | ||||||
|     let result = Blob::new_with_u8_array_sequence(&out_vec).map_err(|e| e.as_string().unwrap())?; |     let result = Blob::new_with_u8_array_sequence(&out_vec).map_err(|e| e.as_string().unwrap())?; | ||||||
|  | @ -5,7 +5,7 @@ use gloo_file::File; | ||||||
| use web_sys::{Event, HtmlInputElement, Url, MouseEvent}; | use web_sys::{Event, HtmlInputElement, Url, MouseEvent}; | ||||||
| use yew::{html, html::TargetCast, Component, Context, Html}; | use yew::{html, html::TargetCast, Component, Context, Html}; | ||||||
| 
 | 
 | ||||||
| use super::utils; | use super::gpx; | ||||||
| 
 | 
 | ||||||
| pub enum Msg { | pub enum Msg { | ||||||
|     FileLoaded(String, String), |     FileLoaded(String, String), | ||||||
|  | @ -52,7 +52,7 @@ impl Component for Loader { | ||||||
|             Msg::StartLoad(files) => { |             Msg::StartLoad(files) => { | ||||||
|                 self.count = files.len(); |                 self.count = files.len(); | ||||||
|                 if self.count < 2 { |                 if self.count < 2 { | ||||||
|                     utils::alert("must load two or more files"); |                     gpx::alert("must load two or more files"); | ||||||
|                     ctx.link().send_message(Msg::Reset); |                     ctx.link().send_message(Msg::Reset); | ||||||
|                     return true; |                     return true; | ||||||
|                 } |                 } | ||||||
|  | @ -78,10 +78,10 @@ impl Component for Loader { | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             Msg::FilesLoaded => { |             Msg::FilesLoaded => { | ||||||
|                 let merged = match utils::merge(&self.files) { |                 let merged = match gpx::merge(&self.files) { | ||||||
|                     Ok(result) => result, |                     Ok(result) => result, | ||||||
|                     Err(err) => { |                     Err(err) => { | ||||||
|                         utils::alert(&err.to_string()); |                         gpx::alert(&err.to_string()); | ||||||
|                         ctx.link().send_message(Msg::Reset); |                         ctx.link().send_message(Msg::Reset); | ||||||
|                         return true |                         return true | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ extern crate wee_alloc; | ||||||
| 
 | 
 | ||||||
| mod app; | mod app; | ||||||
| mod loader; | mod loader; | ||||||
| mod utils; | mod gpx; | ||||||
| 
 | 
 | ||||||
| // Use `wee_alloc` as the global allocator.
 | // Use `wee_alloc` as the global allocator.
 | ||||||
| #[global_allocator] | #[global_allocator] | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue