Skip to content

Commit

Permalink
Fix missing edgecase inside Karney algorithm. Fixes #72
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdoug committed Jan 31, 2025
1 parent 9cc25f3 commit e190e3a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## [Unreleased]

## [5.10.3] - 2025-01-31
### Changed
- Updates to data for Canada and Germany
### Fixed
- Calculation of small distances along a meridian

## [5.10.2] - 2024-10-06
### Fixed
Expand Down Expand Up @@ -355,8 +359,9 @@ Initial release of this fork (based off of v2.3 of original)
- Eastings and northings are rounded to 1m, and lat/long to 5dp (approx 1m) to avoid any misconceptions that precision is the same thing as accuracy.
- When calculating surface distances, a more accurate mean radius is now used rather than that derived from historical definitions of a nautical mile

[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.10.2..master
[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.10.3..master

[5.10.3]: https://github.com/dvdoug/PHPCoord/compare/v5.10.2..v5.10.3
[5.10.2]: https://github.com/dvdoug/PHPCoord/compare/v5.10.1..v5.10.2
[5.10.1]: https://github.com/dvdoug/PHPCoord/compare/v5.10.0..v5.10.1
[5.10.0]: https://github.com/dvdoug/PHPCoord/compare/v5.9.2..v5.10.0
Expand Down
4 changes: 4 additions & 0 deletions src/Geometry/Geodesic.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,10 @@ public function distance(GeographicValue $from, GeographicValue $to): Length
$csig2,
$dn2,
);

if ($sig12 < 1) {
$s12x *= $this->b;
}
} elseif ($sbet1 == 0 && $lon12s >= $this->f * 180) {
$s12x = $this->a * $lam12;
} else {
Expand Down
8 changes: 8 additions & 0 deletions tests/Point/GeographicPointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,14 @@ public function testDistanceIssue64(): void
self::assertEqualsWithDelta(13917773.830057, $from->calculateDistance($to)->getValue(), 0.001);
}

#[Group('distance')]
public function testIssue72(): void
{
$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84), new Degree(49.200221), new Degree(16.607841));
$to = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84), new Degree(49.204719), new Degree(16.607841));
self::assertEqualsWithDelta(500.239, $from->calculateDistance($to)->getValue(), 0.001);
}

public function testGeographicGeocentric(): void
{
$from = GeographicPoint::create(Geographic3D::fromSRID(Geographic3D::EPSG_WGS_84), new Degree(53.80939444), new Degree(2.12955000), new Metre(73.0));
Expand Down

0 comments on commit e190e3a

Please sign in to comment.