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 ();