Skip to content

Commit e190e3a

Browse files
committed
Fix missing edgecase inside Karney algorithm. Fixes #72
1 parent 9cc25f3 commit e190e3a

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

33
## [Unreleased]
4+
5+
## [5.10.3] - 2025-01-31
46
### Changed
57
- Updates to data for Canada and Germany
8+
### Fixed
9+
- Calculation of small distances along a meridian
610

711
## [5.10.2] - 2024-10-06
812
### Fixed
@@ -355,8 +359,9 @@ Initial release of this fork (based off of v2.3 of original)
355359
- 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.
356360
- When calculating surface distances, a more accurate mean radius is now used rather than that derived from historical definitions of a nautical mile
357361

358-
[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.10.2..master
362+
[Unreleased]: https://github.com/dvdoug/PHPCoord/compare/v5.10.3..master
359363

364+
[5.10.3]: https://github.com/dvdoug/PHPCoord/compare/v5.10.2..v5.10.3
360365
[5.10.2]: https://github.com/dvdoug/PHPCoord/compare/v5.10.1..v5.10.2
361366
[5.10.1]: https://github.com/dvdoug/PHPCoord/compare/v5.10.0..v5.10.1
362367
[5.10.0]: https://github.com/dvdoug/PHPCoord/compare/v5.9.2..v5.10.0

src/Geometry/Geodesic.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ public function distance(GeographicValue $from, GeographicValue $to): Length
385385
$csig2,
386386
$dn2,
387387
);
388+
389+
if ($sig12 < 1) {
390+
$s12x *= $this->b;
391+
}
388392
} elseif ($sbet1 == 0 && $lon12s >= $this->f * 180) {
389393
$s12x = $this->a * $lam12;
390394
} else {

tests/Point/GeographicPointTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,14 @@ public function testDistanceIssue64(): void
298298
self::assertEqualsWithDelta(13917773.830057, $from->calculateDistance($to)->getValue(), 0.001);
299299
}
300300

301+
#[Group('distance')]
302+
public function testIssue72(): void
303+
{
304+
$from = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84), new Degree(49.200221), new Degree(16.607841));
305+
$to = GeographicPoint::create(Geographic2D::fromSRID(Geographic2D::EPSG_WGS_84), new Degree(49.204719), new Degree(16.607841));
306+
self::assertEqualsWithDelta(500.239, $from->calculateDistance($to)->getValue(), 0.001);
307+
}
308+
301309
public function testGeographicGeocentric(): void
302310
{
303311
$from = GeographicPoint::create(Geographic3D::fromSRID(Geographic3D::EPSG_WGS_84), new Degree(53.80939444), new Degree(2.12955000), new Metre(73.0));

0 commit comments

Comments
 (0)