Skip to main content

High-precision geospatial trilateration solver using multiple optimization methods

Project description

Trilateration Coordinate Finder

High-precision geospatial trilateration solver using multiple optimization methods to determine unknown coordinates from known reference points and distances.

Features

  • Multiple Optimization Methods: Uses differential evolution, L-BFGS-B, Nelder-Mead, Powell, CG, and BFGS algorithms
  • Two-Phase Refinement: Initial optimization followed by iterative precision refinement
  • High Precision: Sub-meter accuracy in optimal conditions
  • Vincenty Distance Calculations: Uses WGS-84 ellipsoid for accurate geodesic distances
  • Professional CLI: Clean, apt-style progress indicators and status updates
  • TTY-Aware: Adapts output based on terminal capabilities

Installation

From PyPI (when published)

pip install trilateration-coordfinder

From Source

git clone https://github.com/yourusername/trilateration-coordfinder.git
cd trilateration-coordfinder
pip install -e .

Usage

Command Line Interface

Run the interactive CLI:

trilateration

You'll be prompted to enter:

  1. Three reference points (latitude, longitude)
  2. Distance from each reference point to the unknown location (in meters)

As a Python Library

from trilateration import (
    multi_stage_optimization,
    refine_position,
    verify_solution
)

# Define reference points and distances
reference_points = {
    "lat": [50.8561306, 49.8109078, 48.5883175],
    "lon": [14.7763778, 18.6925036, 12.4846475]
}
measured_distances = [91070, 304700, 218100]  # in meters

# Phase 1: Initial optimization
solution = multi_stage_optimization(reference_points, measured_distances)

# Phase 2: Precision refinement
final_point, errors, iterations, total_checked, total_error = refine_position(
    solution,
    reference_points,
    measured_distances
)

print(f"Final position: {final_point[0]:.8f}, {final_point[1]:.8f}")

How It Works

Phase 1: Global Optimization

The solver tries three different optimization approaches:

  1. Multi-stage optimization: Combines differential evolution (global search) with L-BFGS-B (local refinement)
  2. Alternative optimization: Tests multiple methods from different starting points, including antipodal positions
  3. Geometric approach: Uses grid search to find candidates, then refines with local optimization

The best solution from these methods is selected and further refined.

Phase 2: Iterative Refinement

Starting from the Phase 1 solution, the solver:

  • Generates surrounding points at multiple radii (from nanometers to kilometers)
  • Tests 8 directions (N, NE, E, SE, S, SW, W, NW) at each radius
  • Iteratively moves toward the point with minimum total distance error
  • Converges when no improvement is found or tolerance is met

Output Interpretation

The solver provides residuals (distance errors) for each reference point:

  • < 1m: Optimal - High precision result
  • 100-5000m: Sub-optimal - Good approximation
  • 5000-10000m: Non-optimal - Rough estimate
  • > 10000m: Failed - Poor solution quality

Requirements

  • Python >= 3.7
  • numpy >= 1.21.0
  • scipy >= 1.7.0
  • geopy >= 2.2.0

Development

Setup Development Environment

git clone https://github.com/yourusername/trilateration-coordfinder.git
cd trilateration-coordfinder
pip install -e ".[dev]"

Run Tests

pytest

License

MIT License - see LICENSE file for details

Author

LOKAI77

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgments

  • Uses Vincenty's formula via geopy for accurate geodesic calculations
  • Optimization algorithms provided by scipy
  • Inspired by real-world GPS trilateration challenges

Project details


Download files

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

Source Distribution

trilateration_coordfinder-1.0.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

trilateration_coordfinder-1.0.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file trilateration_coordfinder-1.0.0.tar.gz.

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a7454a3ea6caf428c65b7674129fc41eb6fc9855d856fbf61189e0c9aec39f2b
MD5 0d1b6b8465661fb2bcb154d9e922d781
BLAKE2b-256 e7bbcbe0dcc804903f83f36fb8173e9aa9c2a31711eafc572c55d0c5c2ed482c

See more details on using hashes here.

File details

Details for the file trilateration_coordfinder-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5350b5617962c80f74fa4f90577bddc5329ccfa6599ce926e360449309d2854
MD5 f9dd232f8e761f648e3cfdb9abcfd587
BLAKE2b-256 0233f6d700e31e05e28b1066c5bed0b2af278e248839357c138f8f74e385fe7d

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