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

pip install trilateration-coordfinder

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

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.4.tar.gz (10.3 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.4-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.4.tar.gz
Algorithm Hash digest
SHA256 1f926c23f983e0cf0dcfc67113e15a3a1ada57c3f3a1dca8fa4851ce053c3f05
MD5 c024596301883163a9451c4dd6e0d043
BLAKE2b-256 91cb9364158afe7884c1c7f1134b4a73bf0c6c253c3c153af4ec6874c0cca743

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 80fc080462a6c7fd7c36d0f225cd9ebaf54ef6886013dc9a16838c105be29f6c
MD5 b20ee1a317561466a7ab36fe036f052e
BLAKE2b-256 ca68934f1b90695d6beab7256cd162c516449685948ea6f11b67577770de04a8

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