Skip to content

Commit 31fe8f4

Browse files
committed
We can't have one in km, and one in meters. Use the SI unit "meter" everywhere.
1 parent 9e484dd commit 31fe8f4

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

geospatial.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ PHP_FUNCTION(transform_datum)
535535
/* }}} */
536536

537537
/* {{{ proto double haversine(GeoJSONPoint from, GeoJSONPoint to [, double radius ])
538-
* Calculates the greater circle distance between two points */
538+
* Calculates the greater circle distance between two points in m */
539539
PHP_FUNCTION(haversine)
540540
{
541541
double radius = GEO_EARTH_RADIUS;
@@ -554,7 +554,7 @@ PHP_FUNCTION(haversine)
554554
/* }}} */
555555

556556
/* {{{ proto double vincenty(GeoJSONPoint from, GeoJSONPoint to [, long reference_ellipsoid ])
557-
* Calculates the distance between two points */
557+
* Calculates the distance between two points in m */
558558
PHP_FUNCTION(vincenty)
559559
{
560560
zval *from_geojson, *to_geojson;

php_geospatial.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ const geo_helmert_constants osgb36_wgs84 = {
114114
#define GEO_DEG_TO_RAD 0.017453292519943295769236907684886
115115
/**
116116
* Calculate the radius using WGS-84's equatorial radius of
117-
* 6,378,1370m
117+
* 6,378,137.0m
118118
*/
119-
#define GEO_EARTH_RADIUS 6378.137
119+
#define GEO_EARTH_RADIUS 6378137.0
120120
#define GEO_SEC_IN_DEG 3600
121121

122122
#define GEO_WGS84 0x0001

tests/Greenwich.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ $diferenceAiry = haversine(
2222
//lat long of merdian in Airy 1830 ideally long of 0
2323
var_dump($polar);
2424
//distance in m of difference from lat long and meridian
25-
echo round($diferenceWGS84 * 1000, 8),PHP_EOL;
26-
echo round($diferenceAiry * 1000, 8),PHP_EOL;
25+
echo round($diferenceWGS84, 8),PHP_EOL;
26+
echo round($diferenceAiry, 8),PHP_EOL;
2727
?>
2828
--EXPECT--
2929
array(2) {

tests/geospatial_haversine_london_edinburgh.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ echo haversine($from, $to);
4545
*/
4646
?>
4747
--EXPECT--
48-
534.23703599421
48+
534237.03599421
4949

tests/haversine.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ $to = array(
1515
var_dump(haversine($to, $from));
1616
?>
1717
--EXPECTF--
18-
float(7.384698392931%d)
18+
float(7384.698392931%d)

0 commit comments

Comments
 (0)