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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.1.tar.gz
Algorithm Hash digest
SHA256 7a0f477288d6b90f6701250663ccbcbf209fa5c8cdf01b79c2570283e7b38ca7
MD5 9d04b5d9fbb4469900b9fc9db260bcc2
BLAKE2b-256 831379e86f95617c3f08b985e9aca29d8d31fbd10d951e61c14a24a2f66bed76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for trilateration_coordfinder-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc5eab5b79eb9154cd9eeff9bda065441094833219130edd76903bfbdf488aad
MD5 57833ddcecc7d903fd9eddac6d891f52
BLAKE2b-256 7750989ae96b1e756cca4cb13691bf75f3f0a31ad58b4e0138edaa46809b2fd2

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