A .NET console application that generates PDF maps from KML territory files using OpenStreetMap data.
Smapshot is a mapping application that takes KML (Keyhole Markup Language) files as input and generates high-quality PDF maps. The application downloads OpenStreetMap data for the specified territories, renders them with customizable styling, and outputs professional PDF documents suitable for territory management and planning.
- KML File Processing: Parse KML files to extract territory boundaries and geographic data
- OpenStreetMap Integration: Automatically download and cache OSM data for specified regions
- Custom Map Rendering: Render maps with configurable road styles, labels, and visual elements
- PDF Generation: Create professional PDF documents with territory maps
- Configurable Styling: Customize road colors, widths, labels, and other visual elements
- Batch Processing: Process multiple KML files or entire directories
- .NET 9.0 or later
- Windows operating system
- Internet connection (for downloading OpenStreetMap data)
-
Clone or download the repository
-
Ensure you have .NET 9.0 SDK installed
-
Build the application:
dotnet build
You can just drag the .kml file you want to process on top of the executable file.
# Process a specific KML file
Smapshot.exe "file.kml"
# Process all KML files in a folder
Smapshot.exe "path_to_folder"The application will:
- Parse the KML file(s)
- Download required OpenStreetMap data
- Render the map with territories highlighted
- Generate a PDF file with the same name as the KML file
The application uses appSettings.json for styling and configuration. If the file doesn't exist, it will be created with default settings.
Configure different road types with custom colors, widths, and outline colors:
{
"roadStyles": {
"motorway": {
"color": "#FF4500",
"width": 16,
"outlineColor": "#B22222"
},
"primary": {
"color": "#FFFF00",
"width": 16,
"outlineColor": "#CCCC00"
}
}
}Customize text labels for roads, places, and water features:
{
"labelStyle": {
"fontSize": 28,
"color": "#000000"
},
"placeLabelStyle": {
"fontSize": 40,
"color": "#333333",
"backgroundColor": "#FFFFFF",
"backgroundOpacity": 150,
"fontStyle": "Italic"
}
}waterStyle: Configure water body appearancebuildingStyle: Configure building renderingbackgroundColor: Set the map background colorborderOffset: Adjust territory border rendering
For each processed KML file, the application generates:
- A PDF file with the same name as the input KML file
- Cached OSM data in the
cachedirectory
The application uses several key libraries:
- OsmSharp: OpenStreetMap data processing
- QuestPDF: PDF document generation
- SharpKml.Core: KML file parsing
- SixLabors.ImageSharp: Image processing and drawing
- SkiaSharp: Graphics rendering
- HtmlAgilityPack: HTML processing
Smapshot/
├── Models/ # Data models and configuration
│ ├── AppSettings.cs # Application settings model
│ ├── BoundingBoxGeo.cs # Geographic bounding box
│ └── CoordWithPixels.cs# Coordinate conversion
├── Services/ # Core application services
│ ├── KmlService.cs # KML file processing
│ ├── OsmDownloader.cs # OpenStreetMap data download
│ ├── OsmRenderEngine.cs# Map rendering engine
│ ├── PdfGenerator.cs # PDF document creation
│ ├── LabelUtilities.cs # Text label utilities
│ └── SmapshotManager.cs# Main workflow coordinator
├── cache/ # Cached OSM data
├── appSettings.json # Configuration file
└── Program.cs # Application entry point
The application includes error handling for:
- Missing or invalid KML files
- Network connectivity issues
- Invalid configuration files
- File system access problems
If appSettings.json is missing or invalid, the application will create a new file with default settings.
- OSM data is cached locally to avoid repeated downloads
- Batch processing is optimized for multiple files
Feel free to submit issues, feature requests, or pull requests to improve the application.