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

@turf/hex-grid

Package Overview
Dependencies
Maintainers
4
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/hex-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, MultiPolygon, Feature, FeatureCollection, Point, Properties } from '@turf/helpers';

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

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

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

@@ -12,3 +12,3 @@ import distance from '@turf/distance';

* @name hexGrid
* @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
* @param {number} cellSide length of the side of the the hexagons or triangles, in units. It will also coincide with the

@@ -15,0 +15,0 @@ * radius of the circumcircle of the hexagons.

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

* @name hexGrid
* @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
* @param {number} cellSide length of the side of the the hexagons or triangles, in units. It will also coincide with the

@@ -39,3 +39,3 @@ * radius of the circumcircle of the hexagons.

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;

@@ -47,8 +47,8 @@ var properties = options.properties || {};

// 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'); }

@@ -108,4 +108,4 @@ var west = bbox[0];

var isOdd = x % 2 === 1;
if (y === 0 && isOdd) continue;
if (y === 0 && hasOffsetY) continue;
if (y === 0 && isOdd) { continue; }
if (y === 0 && hasOffsetY) { continue; }

@@ -128,3 +128,3 @@ var center_x = x * x_interval + west - x_adjust;

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

@@ -144,3 +144,3 @@ results.push(triangle);

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

@@ -147,0 +147,0 @@ results.push(hex);

{
"name": "@turf/hex-grid",
"version": "5.0.5",
"version": "5.1.0",
"description": "turf hex-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"
],

@@ -49,7 +49,8 @@ "scripts": {

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

@@ -59,6 +60,6 @@ "write-json-file": "*"

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

@@ -65,0 +66,0 @@ "@std/esm": {

@@ -7,4 +7,4 @@ # @turf/hex-grid

Takes a bounding box and the diameter of the cell and returns a [FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) of flat-topped
hexagons or triangles ([Polygon](http://geojson.org/geojson-spec.html#polygon) features) aligned in an "odd-q" vertical grid as
Takes a bounding box and the diameter of the cell and returns a [FeatureCollection](https://tools.ietf.org/html/rfc7946#section-3.3) of flat-topped
hexagons or triangles ([Polygon](https://tools.ietf.org/html/rfc7946#section-3.1.6) features) aligned in an "odd-q" vertical grid as
described in [Hexagonal Grids](http://www.redblobgames.com/grids/hexagons/).

@@ -14,3 +14,3 @@

- `bbox` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** extent in [minX, minY, maxX, maxY] order
- `bbox` **[BBox](https://tools.ietf.org/html/rfc7946#section-5)** extent in [minX, minY, maxX, maxY] order
- `cellSide` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** length of the side of the the hexagons or triangles, in units. It will also coincide with the

@@ -21,3 +21,3 @@ radius of the circumcircle of the hexagons.

- `options.properties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** passed to each hexagon or triangle of the grid (optional, default `{}`)
- `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.triangles` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether to return as triangles instead of hexagons (optional, default `false`)

@@ -38,3 +38,3 @@

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

@@ -41,0 +41,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