@@ -531,7 +531,7 @@ PHP_FUNCTION(transform_datum)
531
531
/* }}} */
532
532
533
533
/* {{{ proto double haversine(GeoJSONPoint from, GeoJSONPoint to [, double radius ])
534
- * Calculates the greater circle distance between the two lattitude/longitude pairs */
534
+ * Calculates the greater circle distance between two points */
535
535
PHP_FUNCTION (haversine )
536
536
{
537
537
double radius = GEO_EARTH_RADIUS ;
@@ -549,18 +549,25 @@ PHP_FUNCTION(haversine)
549
549
}
550
550
/* }}} */
551
551
552
+ /* {{{ proto double vincenty(GeoJSONPoint from, GeoJSONPoint to [, long reference_ellipsoid ])
553
+ * Calculates the distance between two points */
552
554
PHP_FUNCTION (vincenty )
553
555
{
556
+ zval * from_geojson , * to_geojson ;
554
557
double from_lat , from_long , to_lat , to_long ;
555
- double radius = GEO_EARTH_RADIUS ;
556
- long reference_ellipsoid ;
558
+ long reference_ellipsoid = GEO_WGS84 ;
557
559
558
- if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "dddd |l" , & from_lat , & from_long , & to_lat , & to_long , & reference_ellipsoid ) == FAILURE ) {
560
+ if (zend_parse_parameters (ZEND_NUM_ARGS () TSRMLS_CC , "aa |l" , & from_geojson , & to_geojson , & reference_ellipsoid ) == FAILURE ) {
559
561
return ;
560
562
}
563
+
564
+ geojson_point_to_lon_lat (from_geojson , & from_long , & from_lat );
565
+ geojson_point_to_lon_lat (to_geojson , & to_long , & to_lat );
566
+
561
567
geo_ellipsoid eli = get_ellipsoid (reference_ellipsoid );
562
568
RETURN_DOUBLE (php_geo_vincenty (from_lat * GEO_DEG_TO_RAD , from_long * GEO_DEG_TO_RAD , to_lat * GEO_DEG_TO_RAD , to_long * GEO_DEG_TO_RAD , eli ));
563
569
}
570
+ /* }}} */
564
571
565
572
void php_geo_fraction_along_gc_line (double from_lat , double from_long , double to_lat , double to_long , double fraction , double radius , double * res_lat , double * res_long )
566
573
{
0 commit comments