[−][src]Module vadeen_osm::osm_io
IO functionality for OSM maps.
Reading to and from files are easiest done with the read
and write
functions.
Readers and writers are easies created with the create_reader
and create_writer
functions.
Error handling is defined in the error
module.
Examples
Read from .osm file and write to .o5m file:
use vadeen_osm::osm_io::{read, write}; let osm = read("map.osm")?; write("map.o5m", &osm)?;
Read from arbitrary reader and write to arbitrary writer:
// Read from file in this example, you can read from anything that implements the Read trait. let path = Path::new("map.osm"); let input = File::open(path)?; // Get format from path. This can also be specified as FileFormat::Xml or any other FileFormat. let format = path.try_into()?; // Create reader and read. let mut reader = create_reader(BufReader::new(input), format); let osm = reader.read()?; // ... do som stuff with the map. // Write to a Vec in this example, you can write to anything that implements the Write trait. let output = Vec::new(); // Create writer and write. let mut writer = create_writer(output, FileFormat::O5m); writer.write(&osm);
Modules
error |
Enums
FileFormat | Represent a osm file format. |
Traits
OsmReader | Reader for the osm formats. |
OsmWriter | Writer for the osm formats. |
Functions
create_reader | Creates an |
create_writer | Creates an |
read | Convenience function for easily reading osm files. Format is determined from file ending. |
write | Convenience function for easily writing osm files. Format is determined from file ending. |