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

@turf/square-grid

Package Overview
Dependencies
Maintainers
4
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/square-grid - npm Package Compare versions

Comparing version 5.0.5 to 5.1.0

main.mjs

6

index.d.ts

@@ -6,3 +6,3 @@ import { Units, BBox, Polygon, Feature, MultiPolygon, Properties, FeatureCollection } from '@turf/helpers'

*/
export default function squareGrid(
export default function squareGrid<P = Properties>(
bbox: BBox,

@@ -12,5 +12,5 @@ cellSide: number,

units?: Units,
properties?: Properties,
properties?: P,
mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon
}
): FeatureCollection<Polygon>;
): FeatureCollection<Polygon, P>;

@@ -34,3 +34,3 @@ 'use strict';

options = options || {};
if (!helpers.isObject(options)) throw new Error('options is invalid');
if (!helpers.isObject(options)) { throw new Error('options is invalid'); }
// var units = options.units;

@@ -44,8 +44,8 @@ var properties = options.properties;

// Input Validation
if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');
if (!helpers.isNumber(cellSide)) throw new Error('cellSide is invalid');
if (!bbox) throw new Error('bbox is required');
if (!Array.isArray(bbox)) throw new Error('bbox must be array');
if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');
if (mask && ['Polygon', 'MultiPolygon'].indexOf(invariant.getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');
if (cellSide === null || cellSide === undefined) { throw new Error('cellSide is required'); }
if (!helpers.isNumber(cellSide)) { throw new Error('cellSide is invalid'); }
if (!bbox) { throw new Error('bbox is required'); }
if (!Array.isArray(bbox)) { throw new Error('bbox must be array'); }
if (bbox.length !== 4) { throw new Error('bbox must contain 4 numbers'); }
if (mask && ['Polygon', 'MultiPolygon'].indexOf(invariant.getType(mask)) === -1) { throw new Error('options.mask must be a (Multi)Polygon'); }

@@ -85,3 +85,3 @@ var west = bbox[0];

if (mask) {
if (intersect(mask, cellPoly)) results.push(cellPoly);
if (intersect(mask, cellPoly)) { results.push(cellPoly); }
} else {

@@ -88,0 +88,0 @@ results.push(cellPoly);

{
"name": "@turf/square-grid",
"version": "5.0.5",
"version": "5.1.0",
"description": "turf square-grid module",
"main": "main",
"module": "index",
"jsnext:main": "index",
"main": "main.js",
"module": "main.mjs",
"types": "index.d.ts",

@@ -12,3 +11,4 @@ "files": [

"index.d.ts",
"main.js"
"main.js",
"main.mjs"
],

@@ -40,6 +40,7 @@ "scripts": {

"@std/esm": "*",
"@turf/bbox-polygon": "*",
"@turf/truncate": "*",
"@turf/bbox-polygon": "^5.1.0",
"@turf/truncate": "^5.1.0",
"benchmark": "*",
"rollup": "*",
"rollup-plugin-buble": "*",
"tape": "*",

@@ -49,8 +50,8 @@ "write-json-file": "*"

"dependencies": {
"@turf/boolean-contains": "^5.0.4",
"@turf/boolean-overlap": "^5.0.4",
"@turf/distance": "^5.0.4",
"@turf/helpers": "^5.0.4",
"@turf/intersect": "*",
"@turf/invariant": "^5.0.4"
"@turf/boolean-contains": "^5.1.0",
"@turf/boolean-overlap": "^5.1.0",
"@turf/distance": "^5.1.0",
"@turf/helpers": "^5.1.0",
"@turf/intersect": "^5.1.0",
"@turf/invariant": "^5.1.0"
},

@@ -57,0 +58,0 @@ "@std/esm": {

@@ -7,3 +7,3 @@ # @turf/square-grid

Creates a square grid from a bounding box, [Feature](http://geojson.org/geojson-spec.html#feature-objects) or [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects).
Creates a square grid from a bounding box, [Feature](https://tools.ietf.org/html/rfc7946#section-3.2) or [FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3).

@@ -16,3 +16,3 @@ **Parameters**

- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** used in calculating cellSide, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
- `options.mask` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
- `options.mask` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)&lt;([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) \| [MultiPolygon](https://tools.ietf.org/html/rfc7946#section-3.1.7))>?** if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
- `options.properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** passed to each point of the grid (optional, default `{}`)

@@ -33,3 +33,3 @@

Returns **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)&lt;[Polygon](http://geojson.org/geojson-spec.html#polygon)>** grid a grid of polygons
Returns **[FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3)&lt;[Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6)>** grid a grid of polygons

@@ -36,0 +36,0 @@ <!-- This file is automatically generated. Please don't edit it directly:

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