php distance
v1.0.1
PHP距離庫允許計算點之間多種類型的距離。
可以使用作曲家輕鬆安裝PHP距離。只需從項目的根部運行以下命令即可。
composer require divineomega/php-distance
如果您以前從未使用過Composer Dependency Manager,請前往Commater網站,以獲取有關如何開始的更多信息。
請參閱以下代碼片段,該代碼段是如何使用此庫。
$ a = new Point ( $ x1 , $ y1 );
$ b = new Point ( $ x2 , $ y2 );
$ c = new Point ( $ x3 , $ y3 , $ z3 ); # Infinite dimensions supported by some distance types
$ distanceType = new Euclidean ();
$ distanceType = new EuclideanSquare ();
$ distanceType = new Haversine (); # For GPS coordinates (latitude and longitude)
$ distance = ( new Distance ())
-> type ( new Euclidean ()) # Type is optional, and defaults to Euclidean distance
-> from ( $ a )
-> to ( $ b )
-> get ();