Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojson-area

Package Overview
Dependencies
Maintainers
31
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-area - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

31

index.js

@@ -56,10 +56,25 @@ var wgs84 = require('wgs84');

function ringArea(coords) {
var area = 0;
var p1, p2, p3, lowerIndex, middleIndex, upperIndex,
area = 0,
coordsLength = coords.length;
if (coords.length > 2) {
var p1, p2;
for (var i = 0; i < coords.length - 1; i++) {
p1 = coords[i];
p2 = coords[i + 1];
area += rad(p2[0] - p1[0]) * (2 + Math.sin(rad(p1[1])) + Math.sin(rad(p2[1])));
if (coordsLength > 2) {
for (i = 0; i < coordsLength; i++) {
if (i === coordsLength - 2) {// i = N-2
lowerIndex = coordsLength - 2;
middleIndex = coordsLength -1;
upperIndex = 0;
} else if (i === coordsLength - 1) {// i = N-1
lowerIndex = coordsLength - 1;
middleIndex = 0;
upperIndex = 1;
} else { // i = 0 to N-3
lowerIndex = i;
middleIndex = i+1;
upperIndex = i+2;
}
p1 = coords[lowerIndex];
p2 = coords[middleIndex];
p3 = coords[upperIndex];
area += ( rad(p3[0]) - rad(p1[0]) ) * Math.sin( rad(p2[1]));
}

@@ -75,2 +90,2 @@

return _ * Math.PI / 180;
}
}
{
"name": "geojson-area",
"version": "0.2.0",
"version": "0.2.1",
"description": "calculate the physical area of a geojson geometry",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -5,3 +5,3 @@ [![Build Status](https://travis-ci.org/mapbox/geojson-area.png)](https://travis-ci.org/mapbox/geojson-area)

Calculate the area inside of a [GeoJSON](http://geojson.org/) Polygon.
Calculate the area inside of any [GeoJSON](http://geojson.org/) geometry.

@@ -24,5 +24,5 @@ ## usage

Given a Geometry object of type Polygon or MultiPolygon, return contained
Given a Geometry object, return contained
area as square meters. Invalid input will return `null`.
Adapted from [OpenLayers](http://openlayers.org/)

@@ -8,3 +8,3 @@ var gjArea = require('../'),

t.test('computes the area of illinois', function(t) {
t.equal(gjArea.geometry(ill), 145978332359.37125);
t.equal(gjArea.geometry(ill), 145978332359.36746);
t.end();

@@ -11,0 +11,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc