From 6b7c4a81ba844c58eb6f48e301ec16754dc10633 Mon Sep 17 00:00:00 2001 From: Abdul Razak Khatib <78922825+Abdumbo99@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:43:05 +0300 Subject: [PATCH] fixed off-by-one length assignment to ensure (RFC 7946) compliance and fix inconsistency in calculations --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4aba334..f663863 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,7 @@ function polygonArea(coords) { function ringArea(coords) { var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i, area = 0, - coordsLength = coords.length; + coordsLength = coords.length - 1; if (coordsLength > 2) { for (i = 0; i < coordsLength; i++) { @@ -86,4 +86,4 @@ function ringArea(coords) { function rad(_) { return _ * Math.PI / 180; -} \ No newline at end of file +}