#parser #osm #maps #mapsforge

mapsforge-rs

A Rust parser for Mapsforge binary map files

1 unstable release

0.1.0 Nov 13, 2024

#1005 in Parser implementations

Download history 86/week @ 2024-11-08 30/week @ 2024-11-15 4/week @ 2024-11-22 9/week @ 2024-12-06

79 downloads per month

MIT license

9KB
132 lines

mapsforge-rs

A Rust parser for Mapsforge binary map files. This library provides functionality to read and parse Mapsforge map files (.map), which are commonly used for offline mapping applications.

Features

  • Map header parsing
    • Magic bytes validation
    • Version checking
    • Bounding box parsing
  • Map tile parsing (Coming soon)
  • POI data structure (Coming soon)
  • Sub-file structure parsing (Coming soon)

Installation

Add this to your Cargo.toml:

[dependencies]
mapsforge-rs = "0.1.0"

Usage

Reading Map Header

use std::fs::File;
use std::io::BufReader;
use mapsforge_rs::MapHeader;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Open and read the map file
    let file = File::open("path/to/map.map")?;
    let mut reader = BufReader::new(file);
    
    // Parse the header
    let header = MapHeader::read_from_file(&mut reader)?;
    
    // Access header information
    println!("Map bounds: {:?}", header.bounding_box);
    println!("File version: {}", header.file_version);
    println!("Tile size: {}", header.tile_size);
    
    Ok(())
}

Requirements

  • Rust 1.56 or higher
  • byteorder crate for handling endianness
  • No other external dependencies required

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Development Status

This project is in active development. Current focus is on implementing basic file parsing capabilities.

Dependencies

~0.4–0.9MB
~20K SLoC