Calculation of polygon area in WGS'84 coordinates. Port of the Python algorithm to PHP and JS.
In the project root folder:
.../geo-area-calculator$ composer install
If js tests needed:
.../geo-area-calculator$ npm install
.../geo-area-calculator$ phpunit
.../geo-area-calculator$ npm test
alert( ffGeo.getGeoPolygonArea(
[
[ -10.812317, 18 ],
[ 10.812317, -18 ],
[ 26.565051, 18 ],
[ 52.622632, -18 ],
[ 52.622632, 54 ],
[ 10.812317, 54 ],
[ -10.812317, 18 ],
]
) );
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)