Skip to main content

lc_gpx_utils/
lib.rs

1pub mod course;
2
3#[allow(clippy::needless_doctest_main)]
4#[allow(clippy::empty_line_after_doc_comments)]
5/// # these are utilities to write a kml file from a rust data model
6///
7/// __warning__ : there is no capability to read a kml file...., the intent here is only to write kml files
8/// with a rust data model, no XML. Not all kml features are \[yet\] supported.
9///
10/// input information is taken from <https://developers.google.com/kml/documentation>
11///
12/// Simple usage is
13/// - Instanciate a [kml::model::Document] rust structure
14/// - write it to a kml file with [kml::write::write_kml],
15/// # example :
16/// ```
17/// use std::path::PathBuf ;
18/// use lc_gpx_utils::kml::model as M ;
19/// use lc_gpx_utils::kml::write::write_kml ;
20/// use lc_gpx_utils::kml::convert::lonlat_of_string ;
21///
22/// fn main() {
23///
24/// // a first kml placemark
25/// let eiffel_tower : M::Placemark = M::Placemark::new_point_on_ground(
26///                     "Eiffel Tower".to_string(),
27///                     "the Paris icon".to_string(),
28///                     // use style-1 for this placemark
29///                     Some("style-1".to_string()),
30///                     2.2944919,48.8582027
31///                 );
32/// // a second kml placemark
33/// let (lon,lat) = lonlat_of_string(r###"48°51'11"N 2°20'56"E"###).expect("get (lon,lat)") ;
34/// let notre_dame : M::Placemark = M::Placemark::new_point_on_ground(
35///                     "Notre Dame".to_string(),
36///                     "home of Quasimodo".to_string(),
37///                     Some("style-1".to_string()),
38///                     lon,lat
39///                 );
40/// // the kml document
41/// let doc = M::Document {
42///     name:"a name".to_string(),
43///     description:"a description".to_string(),
44///     styles:vec![
45///         // a user defined style
46///         M::Style {
47///             id: "style-1".to_string(),
48///             icon_url: "https://maps.google.com/mapfiles/kml/shapes/trail.png".to_string(),
49///             icon_style_scale: 1.0,
50///             line_style_width: 1.6,
51///             }
52///     ],
53///     // what is inside the document
54///     elements:vec![
55///         M::Folder{
56///             name:"Paris".to_string(),
57///             description:"".to_string(),
58///             elements:vec![
59///                 eiffel_tower.into(),
60///                 notre_dame.into()
61///             ]
62///         }.into(),
63///     ]
64/// } ;
65/// write_kml(&doc,&PathBuf::from("eiffel-tower.kml")).expect("write kml") ;
66/// }
67/// ```
68///
69/// if you load the kml file into google/mymaps, or in google earth, you should get
70///  ![Texte alternatif](x.png "Titre de l'image").
71pub mod kml;
72
73pub mod tcx;