php distance
v1.0.1
PHP距離ライブラリを使用すると、ポイント間の多くのタイプの距離を計算できます。
PHP距離は、Composerを使用して簡単にインストールできます。プロジェクトのルートから次のコマンドを実行するだけです。
composer require divineomega/php-distance
以前にComposer Dependency Managerを使用したことがない場合は、Composer Webサイトにアクセスして、開始方法の詳細をご覧ください。
このライブラリの使用方法をデモンテートする次のコードスニペットを参照してください。
$ 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 ();