Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to calculate long distances with vicenty #64

Open
mmilet opened this issue May 7, 2024 · 1 comment
Open

Failure to calculate long distances with vicenty #64

mmilet opened this issue May 7, 2024 · 1 comment

Comments

@mmilet
Copy link

mmilet commented May 7, 2024

Hello,

I've been trying to calculate distances between many points pairs (decimal degrees) and WGS 84 CRS.
While most distances are properly calculated some are getting stuck in the Vicenty calculation, more specifically within the "Antipodal case" code block, where it loops over four $sinAlpha values over and over, indefinitely.

I've tried the following script:

<?php

use PHPCoord\CoordinateReferenceSystem\Geographic2D;
use PHPCoord\Point\GeographicPoint;
use PHPCoord\UnitOfMeasure\Angle\Degree;

require_once './vendor/autoload.php';

$lat1 = -33.81083333;
$lon1 = 19.91;
$lat2 = -18.2;
$lon2 = -178.8161111;

$crs = Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84);

$from = GeographicPoint::create($crs, new Degree($lat1), new Degree($lon1));
$to = GeographicPoint::create($crs, new Degree($lat2), new Degree($lon2));

// Hangs in here indefinitely.
$distance = $from->calculateDistance($to);

I also tried the above values in GeographicPointTest::testDistanceCalculationAntipodeWikiExample1(), the test hangs in the very same way

Thanks for all the work put in this library!

@dvdoug
Copy link
Owner

dvdoug commented May 7, 2024

I can reproduce :(

The Antipode case is taken from https://github.com/dvdoug/PHPCoord/blob/master/resources/papers/Vincenty%2075b.pdf which I think I've transcribed correctly, but perhaps not. I'll take a look, see if I can spot the error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants