locat 0.1.0

A zero-copy ISO 6709 geographic coordinate parser in Rust.
Documentation

A blazing fast, zero-copy ISO 6709 geographic coordinate parser and writer in Rust.

Features

  • Zero-copy: CRS identifiers borrow directly from the input string
  • no_std compatible: works without the standard library
  • All ISO 6709 notation forms: decimal degrees, degrees+minutes, DMS
  • Altitude & CRS: optional altitude (meters) and coordinate reference system identifier
  • Round-trip: Display impls produce valid ISO 6709 output
  • DFA-powered lexer: logos-based tokenizer classifies components in a single pass

Installation

[dependencies]
locat = "0.1"

Quick Start

use locat::parse;

// Decimal degrees (New York City)
let coord = parse("+40.7128-074.0060/").unwrap();
let (lat, lon): (f64, f64) = coord.to_decimal_degrees();
assert!((lat - 40.7128).abs() < 1e-10);
assert!((lon - (-74.006)).abs() < 1e-10);

// Degrees, minutes, seconds
let coord = parse("+404243-0740002/").unwrap();

// With altitude and CRS (Mount Everest)
let coord = parse("+27.5916+086.5640+8848CRSepsg4326/").unwrap();
assert!(coord.altitude().is_some());
assert_eq!(coord.crs().unwrap().as_str(), "epsg4326");

// Round-trip
let input = "+40.7128-074.0060/";
let coord = parse(input).unwrap();
assert_eq!(coord.to_string(), input);

Supported Formats

Form Latitude Longitude Example
Degrees ±DD[.D+] ±DDD[.D+] +40.7128-074.0060/
Deg+Min ±DDMM[.M+] ±DDDMM[.M+] +4042.77-07400.36/
DMS ±DDMMSS[.S+] ±DDDMMSS[.S+] +404243.0-0740002.0/

Optional trailing components: [±Altitude][CRS<id>]/

Benchmarks

Measured on Apple Silicon with cargo bench (Criterion). All times are per-operation.

Parse (single coordinate)

Format Time Throughput
Minimal (+00+000/) ~18 ns 424 MiB/s
DMS integer (+404243-0740002/) ~22 ns 704 MiB/s
Decimal degrees (+40.7128-074.0060/) ~27 ns 634 MiB/s
Deg+Min (+4042.7700-07400.3600/) ~30 ns 708 MiB/s
DMS decimal (+404243.123000-0740002.456000/) ~34 ns 840 MiB/s
With altitude (+27.5916+086.5640+8848/) ~32 ns 680 MiB/s
With altitude+CRS (+27.5916+086.5640+8848CRSepsg4326/) ~37 ns 884 MiB/s

Round-trip (parse + Display)

Format Time
DMS integer ~184 ns
Minimal ~180 ns
DMS decimal ~339 ns
Decimal degrees ~489 ns
Deg+Min ~497 ns
With altitude ~556 ns
With altitude+CRS ~622 ns

Conversion

to_decimal_degrees() completes in ~1 ns regardless of input format.

Batch throughput

Parsing 1,000 mixed-format coordinates: ~48 µs (~430 MiB/s).

Run benchmarks yourself:

cargo bench

License

locat is under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2026 Al Liu.