New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/area

Package Overview
Dependencies
Maintainers
4
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/area - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

index.d.ts

40

index.js

@@ -26,2 +26,3 @@ "use strict";

}
exports.default = area;
/**

@@ -35,28 +36,29 @@ * Calculate Area

function calculateArea(geom) {
var area = 0;
var total = 0;
var i;
switch (geom.type) {
case 'Polygon':
case "Polygon":
return polygonArea(geom.coordinates);
case 'MultiPolygon':
case "MultiPolygon":
for (i = 0; i < geom.coordinates.length; i++) {
area += polygonArea(geom.coordinates[i]);
total += polygonArea(geom.coordinates[i]);
}
return area;
case 'Point':
case 'MultiPoint':
case 'LineString':
case 'MultiLineString':
return total;
case "Point":
case "MultiPoint":
case "LineString":
case "MultiLineString":
return 0;
}
return 0;
}
function polygonArea(coords) {
var area = 0;
var total = 0;
if (coords && coords.length > 0) {
area += Math.abs(ringArea(coords[0]));
total += Math.abs(ringArea(coords[0]));
for (var i = 1; i < coords.length; i++) {
area -= Math.abs(ringArea(coords[i]));
total -= Math.abs(ringArea(coords[i]));
}
}
return area;
return total;
}

@@ -69,3 +71,4 @@ /**

* Reference:
* Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
* Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for Polygons on a Sphere",
* JPL Publication 07-03, Jet Propulsion
* Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409

@@ -84,3 +87,3 @@ *

var i;
var area = 0;
var total = 0;
var coordsLength = coords.length;

@@ -107,7 +110,7 @@ if (coordsLength > 2) {

p3 = coords[upperIndex];
area += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
total += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
}
area = area * RADIUS * RADIUS / 2;
total = total * RADIUS * RADIUS / 2;
}
return area;
return total;
}

@@ -117,2 +120,1 @@ function rad(num) {

}
exports.default = area;
{
"name": "@turf/area",
"version": "6.0.0",
"version": "6.0.1",
"description": "turf area module",
"main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.ts"
"index.d.ts"
],

@@ -38,3 +39,5 @@ "scripts": {

"tape": "*",
"write-json-file": "*"
"write-json-file": "*",
"tslint": "*",
"@types/tape": "*"
},

@@ -41,0 +44,0 @@ "dependencies": {

@@ -11,3 +11,3 @@ # @turf/area

- `geojson` **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** input GeoJSON feature(s)
- `geojson` **[GeoJSON][1]** input GeoJSON feature(s)

@@ -26,4 +26,8 @@ **Examples**

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** area in square meters
Returns **[number][2]** area in square meters
[1]: https://tools.ietf.org/html/rfc7946#section-3
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
<!-- This file is automatically generated. Please don't edit it directly:

@@ -30,0 +34,0 @@ if you find an error, edit the source file (likely index.js), and re-run

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