Skip to main content

Maritime route geometry and ECA intersect distance (Rust core)

Project description

georoutelib

Maritime route calculation: waypoints → route geometry → along-route analysis and editing.

PyPI georoutelib 0.1.1
import georoutelib

Requires Python 3.12+.

Shared references: RouteLine and GeoRoute do not copy the list you pass in. Edits (merge_point, remove_point, deduplicate, simplify, …) mutate that same list in place. To keep the original data, pass a copy: RouteLine(points.copy()) or copy.deepcopy(segments).

Install

pip install georoutelib

Development:

uv sync --extra dev
env -u CONDA_PREFIX maturin develop
.venv/bin/pytest

Package layout (Rust)

src/
├── lib.rs           # PyO3 module entry
├── route/           # GeoRoute, RouteLine, GeoCalc, …
└── eca/             # ECAProcessor — GeoJSON zones × route distance

Units

Quantity Unit
Distance nautical miles (nm)
Speed knots (kts)
Bearing degrees (0–360°)
Time hours (h) or timestamp (Unix s)

Quick start

Create points and measure distance

from georoutelib import RoutePoint, GeoCalc

a = RoutePoint(lon=-50.9, lat=12.6)
b = RoutePoint(lon=-52.3, lat=12.9)

rhumb_nm = GeoCalc.distance(a, b, rhumb=True)
gc_nm = GeoCalc.distance(a, b, rhumb=False)
bearing = GeoCalc.bearing(a, b, rhumb=True)

Build a route from points

from georoutelib import RoutePoint, GeoRoute

points = [
    RoutePoint(lon=103.8, lat=1.2, is_great_circle=True),
    RoutePoint(lon=104.5, lat=1.5, is_great_circle=True),
    RoutePoint(lon=105.0, lat=2.0),
]

route = GeoRoute.from_points(points, spacing=200.0)
print(route.segments)  # GeoRoute: List[List[List[float]]], split at ±180° if needed

Flat route operations

from georoutelib import RouteLine, RoutePoint

points = [RoutePoint(lon=0, lat=0), RoutePoint(lon=1, lat=1), RoutePoint(lon=2, lat=0)]
route = RouteLine(points).deduplicate().simplify()

total_nm = route.total_distance()
center = route.center()
bbox = route.bbox()  # [minLon, minLat, maxLon, maxLat]
segments = route.to_multi_line()

Advance along a route

from georoutelib import RoutePoint, GeoRoute

route = GeoRoute.from_points(points, spacing=200.0)
current = RoutePoint(lon=104.0, lat=1.3)
result = route.advance_along(current, dist=50.0)
next_pos = result["point"]
remaining = result["remaining"]   # segments ahead
traveled = result["traveled"]     # points already passed

Minimum distance to route

result = route.min_distance_to(RoutePoint(lon=104.2, lat=1.4))
# {"min_dist": float, "seg_index": int, "min_index": int}

Architecture

RoutePoint
    ↓
GeoCalc          ← bearing / distance / interpolate / dateline split
    ↓
RouteLine     ← flat List[RoutePoint], chainable edits, DR
    ↕
GeoRoute         ← List[List[List[float]]], dateline-safe storage, along-route ops
  • RouteLine: flat, undivided RoutePoint list (not a GeoRoute sub-segment); position_at / time_at, point queries.
  • GeoRoute: raw multi-segment coordinates split at the antimeridian; from_points, advance_along, min_distance_to, remaining_route, fill_point_distances.
  • GeoCalc: geodesic math in Rust (geo / Turf-aligned great-circle), rhumb vs great-circle selectable.
  • ECAProcessor: Emission Control Area intersect distance from GeoJSON (no Shapely).

ECA (Emission Control Area)

from georoutelib import ECAProcessor

processor = ECAProcessor("https://example.com/eca-zones.geojson")
# offline / tests: ECAProcessor.from_geojson(url, geojson_dict)

results = processor.calculate_eca_intersects([[120.0, 30.0], [122.0, 31.0]])
for item in results:
    print(item["eca"], item["distance"], "nm")

Supports GeoRoute, list[RoutePoint], and coordinate segments. Optional processor.geojson_loader overrides HTTP fetch (e.g. tests).

Native dependencies

Crate Role
geo Rhumb / haversine measures; ECA polygon predicates
geojson Parse ECA FeatureCollection
ureq Optional HTTP load for ECAProcessor(url)

Publish

uv sync --extra dev
maturin build --release -o dist
ls dist/
# georoutelib-0.1.1-cp312-cp312-*.whl

Upload to PyPI:

uv publish dist/*.whl

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

georoutelib-0.1.1-cp312-cp312-win_amd64.whl (1.4 MB view details)

Uploaded CPython 3.12Windows x86-64

georoutelib-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl (1.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

georoutelib-0.1.1-cp312-cp312-manylinux_2_28_aarch64.whl (1.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ ARM64

georoutelib-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file georoutelib-0.1.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: georoutelib-0.1.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for georoutelib-0.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f88e27b928040b4ae56f236d3ad98252e28936a069fddbe3f417c25e36d7f8e4
MD5 fd9aabd41500198f7d2a9b35c815d6f7
BLAKE2b-256 a723120b82ed6f595e7f49144d27a842a4e5036486f00dc9f2536d29390cddee

See more details on using hashes here.

File details

Details for the file georoutelib-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

  • Download URL: georoutelib-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for georoutelib-0.1.1-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b90ff22debbeecfecdb789dda94ac7716578bd73861b77ee4b41d7d25dfd59a0
MD5 ad2b7b954e24fe585043d568a1ac9f23
BLAKE2b-256 7f57388d66d1e207aaf2679131ba3f41d8a91b2bb383fdcbab3bc1ea5233d233

See more details on using hashes here.

File details

Details for the file georoutelib-0.1.1-cp312-cp312-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: georoutelib-0.1.1-cp312-cp312-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: CPython 3.12, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for georoutelib-0.1.1-cp312-cp312-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 aa0a0f414b458aa1f3758635c5752ff0d45bba5ee630d59b26751d7c969daf92
MD5 0191890e63070ee2c5a4b9d1e4c52312
BLAKE2b-256 1347455953930fc1b1b119905a538a869a89dd4c7efb83aa72b2a470d3329f84

See more details on using hashes here.

File details

Details for the file georoutelib-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

  • Download URL: georoutelib-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.12, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for georoutelib-0.1.1-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 df7b6c72c610a2340a0c61125adb70db0c01b0f52942ed8ce3e162812ef0bfae
MD5 f5539fc30834bbf63f4c10e7cbe514a9
BLAKE2b-256 73894b975e8326775246a8848585cf7b496297719863146b4c7c9b58190926da

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page