alexpechkarev / geometry-library

PHP Geometry Library provides utility functions for the computation of geometric data on the surface of the Earth. Code ported from Google Maps Android API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Call to undefined method GeometryLibrary\\PolyUtil::distanceToLine()

contreras2004 opened this issue · comments

I cant find the function inside the PolyUtil Class. Did you remove it?

Used composer to install this library. Awesome work by the way.

Thanks @contreras2004 !

The distanceToLine() method is still there.
Try with backslash (\) as per below:

/**
* no backslash -> GeometryLibrary\PolyUtil::distanceToLine 
* with backslash - > \GeometryLibrary\PolyUtil::distanceToLine
*/

$response =  \GeometryLibrary\PolyUtil::distanceToLine(
              ['lat' => 61.387002, 'lng' => 23.890636], // point array [lat, lng]
              ['lat' => 61.487002, 'lng' => 23.790636], // line startpoint array [lat, lng]
              ['lat' => 60.48047, 'lng' => 22.052754] // line endpoint array [lat, lng]
             );  
             
  echo $response; // 12325.124046196 in meters

Nop, its not there. Please try to install the library with composer. I had to download the library using the zip File and add it manually to the PolyUtil class

Thanks for checking!
I have updated the release version to 1.0.1 that should now include distanceToLine() method.
Regards