kml
Rust support for reading and writing KML with a focus on conversion to geo-types
primitives.
Examples
Reading
use Path;
use ;
let kml_str = r#"
<Polygon>
<outerBoundaryIs>
<LinearRing>
<tessellate>1</tessellate>
<coordinates>
-1,2,0
-1.5,3,0
-1.5,2,0
-1,2,0
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
"#;
// Parse from a string
let kml: Kml = kml_str.parse.unwrap;
// Read from a file path
let kml_path = new
.join
.join
.join;
let mut kml_reader = from_path.unwrap;
let kml_data = kml_reader.read.unwrap;
// Read KMZ files with the `zip` feature or default features enabled
let kmz_path = new
.join
.join
.join;
let mut kmz_reader = from_kmz_path.unwrap;
let kmz_data = kmz_reader.read.unwrap;
Writing
use ;
let kml = Point;
let mut buf = Vec new;
let mut writer = from_writer;
writer.write.unwrap;
Conversion
use ;
use ;
let kml_point = new;
// Convert into geo_types primitives
let geo_point = from;
// Convert back into kml::types structs
let kml_point = from;
let kml_folder_str = r#"
<Folder>
<Point>
<coordinates>1,1,1</coordinates>
<altitudeMode>relativeToGround</altitudeMode>
</Point>
<LineString>
<coordinates>1,1 2,1 3,1</coordinates>
<altitudeMode>relativeToGround</altitudeMode>
</LineString>
</Folder>"#;
let kml_folder: = kml_folder_str.parse.unwrap;
// Use the quick_collection helper to convert Kml to a geo_types::GeometryCollection
let geom_coll: = quick_collection.unwrap;
Code of Conduct
All contributors are expected to follow the GeoRust Code of Conduct
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.