@@ -32,6 +32,7 @@ ZEND_BEGIN_ARG_INFO(haversine_args,ZEND_SEND_BY_VAL)
32
32
ZEND_ARG_INFO (0 ,fromLongitude )
33
33
ZEND_ARG_INFO (0 ,toLatitude )
34
34
ZEND_ARG_INFO (0 ,toLongitude )
35
+ ZEND_ARG_INFO (0 ,radius )
35
36
ZEND_END_ARG_INFO ()
36
37
37
38
/* {{{ geospatial_functions[]
@@ -100,8 +101,8 @@ PHP_MINFO_FUNCTION(geospatial)
100
101
PHP_FUNCTION (haversine )
101
102
{
102
103
double fromLat , fromLong , toLat , toLong , deltaLat , deltaLong ;
103
- double latH , longH , result ;
104
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "dddd" , & fromLat , & fromLong , & toLat , & toLong ) == FAILURE ) {
104
+ double radius = GEO_EARTH_RADIUS , latH , longH , result ;
105
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "dddd|d " , & fromLat , & fromLong , & toLat , & toLong , & radius ) == FAILURE ) {
105
106
return ;
106
107
}
107
108
@@ -114,7 +115,7 @@ PHP_FUNCTION(haversine)
114
115
longH *= longH ;
115
116
116
117
result = cos (fromLat * GEO_DEG_TO_RAD ) * cos (toLat * GEO_DEG_TO_RAD );
117
- result = GEO_EARTH_RADIUS_IN_METERS * 2.0 * asin (sqrt (latH + result * longH ));
118
+ result = radius * 2.0 * asin (sqrt (latH + result * longH ));
118
119
RETURN_DOUBLE (result );
119
120
}
120
121
0 commit comments