Skip to main content

Maritime route geometry: GeoRoute, RouteLine, GeoCalc (Rust core)

Project description

georoutelib

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

PyPI georoutelib 0.1.0
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
uv run pytest

Package layout

src/georoutelib/
├── __init__.py          # public exports + __version__
├── route_point.py       # RoutePoint, round_lon/lat, COORD_PRECISION
├── geo_calc.py          # GeoCalc — bearing, distance, interpolation, ±180° split
├── route_line.py        # RouteLine — flat RoutePoint polyline
└── geo_route.py         # GeoRoute — GeoMultiLine storage (cross-dateline)

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 via pyturf + shapely (rhumb vs great-circle selectable).

Planning API reference (Chinese): docs/route-planning.md.

Dependencies

Package Role
pyturf Rhumb / great-circle bearing, distance, destination, line intersect, center/bbox
shapely Great-circle polyline × dateline intersection

Publish

Build wheel from source (maturin,仅 wheel,无 sdist 源码包):

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

Upload to PyPI:

uv publish dist/*

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.0-cp312-cp312-win_amd64.whl (294.1 kB view details)

Uploaded CPython 3.12Windows x86-64

georoutelib-0.1.0-cp312-cp312-manylinux_2_35_x86_64.whl (369.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.35+ x86-64

georoutelib-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (349.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

georoutelib-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (673.1 kB 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.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: georoutelib-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 294.1 kB
  • 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9ff282e25927b49c3d74ddf9d259a7a586b258d1796d93000b33050aeb63faf3
MD5 9fe563d513a4574d21e58e081b5ff7dc
BLAKE2b-256 bbe7604dae6b0da6dff6a0e08b2d53f6f1f936e80047342d4c06a4ebd19ed148

See more details on using hashes here.

File details

Details for the file georoutelib-0.1.0-cp312-cp312-manylinux_2_35_x86_64.whl.

File metadata

  • Download URL: georoutelib-0.1.0-cp312-cp312-manylinux_2_35_x86_64.whl
  • Upload date:
  • Size: 369.0 kB
  • Tags: CPython 3.12, manylinux: glibc 2.35+ 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.0-cp312-cp312-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 763312d2ae6dbd8a842830a74496d7cf88cde5b3e1bc9610557c82ac771ff9ec
MD5 7242296da21dfaabc8d82167d419ae5a
BLAKE2b-256 30e46b80a86a7fe20f574d7b4726d09dae70e4ad3be229f047f8b48c0d887667

See more details on using hashes here.

File details

Details for the file georoutelib-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: georoutelib-0.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
  • Upload date:
  • Size: 349.5 kB
  • Tags: CPython 3.12, manylinux: glibc 2.17+ 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.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 96d44561bab18bb696c66cde1fe19700fa6d4fbf486c31f9ca8839c366f7b43e
MD5 ac37dc54f1555471c4cbe47d54d88582
BLAKE2b-256 7f34cc22f1f7878c007bdfde1e46b196aab5ad17fec8611e0b1dcef12a0ae086

See more details on using hashes here.

File details

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

File metadata

  • Download URL: georoutelib-0.1.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
  • Upload date:
  • Size: 673.1 kB
  • 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.0-cp312-cp312-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 b1b49da7728c78e7ab47d25acd6f44abdc9a4bbc515dfbde74808d0a33a96fca
MD5 a2abfaf9370cc7f3f5608fe00fd95cef
BLAKE2b-256 2695129fa1e430e216a8b16a29f091717e2d6f2883324979b125b545a8ec1ae9

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