Skip to content

nathan-casabieille/Native-UTM-Parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Native UTM Parser 🌍

A lightweight, zero-dependency C++ tool designed to parse binary ESRI Shapefiles and project them using the Universal Transverse Mercator (UTM) projection system.

About the Project

This project explores the complexities of localized map projections. Unlike the global Mercator projection, UTM is a grid-based system that divides the Earth into 60 zones to minimize distortion. Built from scratch without GIS libraries like GDAL or PROJ, this tool focuses on:

  1. Binary Data Parsing: Directly reading .shp files, handling Big/Little Endian conversions, and navigating record headers.
  2. Ellipsoidal Mathematics: Implementing the Krüger series for the Transverse Mercator projection, transforming Lat/Long into metric Easting and Northing coordinates based on the WGS84 ellipsoid.
  3. Dynamic Vector Rendering: Generating SVGs with an automated viewBox and fixed-point precision to handle large-scale metric coordinates (meters).

Features

  • Dependency-Free: Pure C++17 using only standard headers (<cmath>, <vector>, <fstream>).
  • WGS84 Compliant: Uses standard ellipsoidal constants for high-accuracy local mapping.
  • Automatic Zone Detection: Determines the optimal UTM zone based on the first geometry's longitude.
  • Robust Parser: Manually handles the ESRI Shapefile technical specification (Type 5: Polygon).
  • Smart Filtering: Automatically handles points far from the central meridian to prevent mathematical instability.

Getting Started

Prerequisites

  • A C++17 compatible compiler (GCC, Clang, or MSVC).
  • CMake (version 3.10 or higher).

Compilation

mkdir build && cd build
cmake ..
make

Usage

# Auto-detect zone
./utm_parser region.shp map.svg

# Force a specific zone (e.g., Zone 32 for Europe)
./utm_parser region.shp map.svg 32

How it Works (The Math)

The UTM system uses a Transverse Mercator projection. Unlike the standard Mercator, the "cylinder" is transverse to the Earth's axis.

  • Units: The output coordinates are in meters.
  • False Easting: A constant of 500,000m is added to X coordinates to ensure all values within a zone remain positive.
  • ViewBox: The SVG generator calculates the min/max X and Y of the projected data to create a tight, high-resolution viewport.

Note: For best results, use regional shapefiles. UTM is designed for high accuracy within 6-degree longitudinal strips.

Sample Output

Mercator Projection Result

About

Dependency-free C++ parser for ESRI Shapefiles that performs UTM projection and renders geographic vector data into SVG format.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors