@turf/square-grid
Advanced tools
Comparing version 5.0.5 to 5.1.0
@@ -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>; |
16
main.js
@@ -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)<([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)<([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)<[Polygon](http://geojson.org/geojson-spec.html#polygon)>** grid a grid of polygons | ||
Returns **[FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3)<[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: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
16206
7
259
0
8
+ Added@turf/clean-coords@5.1.5(transitive)
+ Added@turf/intersect@5.1.6(transitive)
+ Added@turf/truncate@5.1.5(transitive)
+ Addedturf-jsts@1.2.3(transitive)
- Removed@turf/helpers@7.1.0(transitive)
- Removed@turf/intersect@7.1.0(transitive)
- Removed@turf/meta@7.1.0(transitive)
- Removed@types/geojson@7946.0.14(transitive)
- Removedpolygon-clipping@0.15.7(transitive)
- Removedrobust-predicates@3.0.2(transitive)
- Removedsplaytree@3.1.2(transitive)
- Removedtslib@2.8.1(transitive)
Updated@turf/boolean-overlap@^5.1.0
Updated@turf/distance@^5.1.0
Updated@turf/helpers@^5.1.0
Updated@turf/intersect@^5.1.0
Updated@turf/invariant@^5.1.0