悉达多 / geo-area
给定多边形的WGS84坐标下的地理区域
dev-master
2024-05-03 10:08 UTC
Requires
- php: >=5.4.0
- components/qunit: ^1.11
Requires (Dev)
- phpunit/phpunit: ^4
This package is not auto-updated.
Last update: 2024-09-18 19:12:40 UTC
README
在WGS'84坐标下计算多边形面积。将Python算法移植到PHP和JS。
安装
在项目根目录下
.../geo-area-calculator$ composer install
如果需要js测试
.../geo-area-calculator$ npm install
测试
PHP
.../geo-area-calculator$ phpunit
JavaScript
.../geo-area-calculator$ npm test
示例
JavaScript
alert( ffGeo.getGeoPolygonArea( [ [ -10.812317, 18 ], [ 10.812317, -18 ], [ 26.565051, 18 ], [ 52.622632, -18 ], [ 52.622632, 54 ], [ 10.812317, 54 ], [ -10.812317, 18 ], ] ) );
PHP
use siddthartha\geo\area\helpers\GeoAreaCalculator; echo GeoAreaCalculator::getArea( [ [ -10.812317, 18 ], [ 10.812317, -18 ], [ 26.565051, 18 ], [ 52.622632, -18 ], [ 52.622632, 54 ], [ 10.812317, 54 ], [ -10.812317, 18 ], ] ); // 33953235824742.51 (sq.meters)