@turf/square-grid 7.1.0-alpha.7 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,16 +4,18 @@
4
4
 
5
5
  ## squareGrid
6
6
 
7
- Creates a square grid from a bounding box.
7
+ Creates a grid of square polygons with cell length consistent in degrees
8
8
 
9
9
  ### Parameters
10
10
 
11
- * `bbox` **[Array][1]<[number][2]>** extent in \[minX, minY, maxX, maxY] order
12
- * `cellSide` **[number][2]** of each cell, in units
11
+ * `bbox` **[BBox][1]** extent of grid in \[minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.
12
+ * `cellSide` **[number][2]** length of each cell side.
13
13
  * `options` **[Object][3]** Optional parameters (optional, default `{}`)
14
14
 
15
- * `options.units` **[string][4]** used in calculating cellSide, can be degrees,
16
- radians, miles, or kilometers (optional, default `'kilometers'`)
15
+ * `options.units` **Units** the units of the cellSide value.
16
+ Supports all valid Turf [Units][4].
17
+ If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.
18
+ The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees. (optional, default `'kilometers'`)
17
19
  * `options.mask` **[Feature][5]<([Polygon][6] | [MultiPolygon][7])>?** if passed a Polygon or MultiPolygon,
18
20
  the grid Points will be created only inside it
19
21
  * `options.properties` **[Object][3]** passed to each point of the grid (optional, default `{}`)
@@ -31,15 +33,15 @@ var squareGrid = turf.squareGrid(bbox, cellSide, options);
31
33
  var addToMap = [squareGrid]
32
34
  ```
33
35
 
34
- Returns **[FeatureCollection][8]<[Polygon][6]>** grid a grid of polygons
36
+ Returns **[FeatureCollection][8]<[Polygon][6]>** a grid of polygons with equal width and height in degrees.
35
37
 
36
- [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
38
+ [1]: https://tools.ietf.org/html/rfc7946#section-5
37
39
 
38
40
  [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
39
41
 
40
42
  [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
41
43
 
42
- [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
44
+ [4]: https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md
43
45
 
44
46
  [5]: https://tools.ietf.org/html/rfc7946#section-3.2
45
47
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AASA,SAAS,qBAAqB;AA0B9B,SAAS,WACP,MACA,UACA,UAII,CAAC,GAC0B;AAC/B,SAAO,cAAc,MAAM,UAAU,UAAU,OAAO;AACxD;AAGA,IAAO,2BAAQ","sourcesContent":["import {\n FeatureCollection,\n Polygon,\n BBox,\n Feature,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Units } from \"@turf/helpers\";\nimport { rectangleGrid } from \"@turf/rectangle-grid\";\n\n/**\n * Creates a square grid from a bounding box.\n *\n * @name squareGrid\n * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order\n * @param {number} cellSide of each cell, in units\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,\n * radians, miles, or kilometers\n * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,\n * the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} grid a grid of polygons\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var squareGrid = turf.squareGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [squareGrid]\n */\n\nfunction squareGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;\n } = {}\n): FeatureCollection<Polygon, P> {\n return rectangleGrid(bbox, cellSide, cellSide, options);\n}\n\nexport { squareGrid };\nexport default squareGrid;\n"]}
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AASA,SAAS,qBAAqB;AA4B9B,SAAS,WACP,MACA,UACA,UAII,CAAC,GAC0B;AAC/B,SAAO,cAAc,MAAM,UAAU,UAAU,OAAO;AACxD;AAGA,IAAO,2BAAQ","sourcesContent":["import {\n FeatureCollection,\n Polygon,\n BBox,\n Feature,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Units } from \"@turf/helpers\";\nimport { rectangleGrid } from \"@turf/rectangle-grid\";\n\n/**\n * Creates a grid of square polygons with cell length consistent in degrees\n *\n * @name squareGrid\n * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.\n * @param {number} cellSide length of each cell side.\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] the units of the cellSide value.\n * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.\n * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.\n * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees.\n * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,\n * the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} a grid of polygons with equal width and height in degrees.\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var squareGrid = turf.squareGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [squareGrid]\n */\n\nfunction squareGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;\n } = {}\n): FeatureCollection<Polygon, P> {\n return rectangleGrid(bbox, cellSide, cellSide, options);\n}\n\nexport { squareGrid };\nexport default squareGrid;\n"]}
@@ -2,18 +2,20 @@ import { GeoJsonProperties, BBox, Feature, Polygon, MultiPolygon, FeatureCollect
2
2
  import { Units } from '@turf/helpers';
3
3
 
4
4
  /**
5
- * Creates a square grid from a bounding box.
5
+ * Creates a grid of square polygons with cell length consistent in degrees
6
6
  *
7
7
  * @name squareGrid
8
- * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
9
- * @param {number} cellSide of each cell, in units
8
+ * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.
9
+ * @param {number} cellSide length of each cell side.
10
10
  * @param {Object} [options={}] Optional parameters
11
- * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,
12
- * radians, miles, or kilometers
11
+ * @param {Units} [options.units='kilometers'] the units of the cellSide value.
12
+ * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.
13
+ * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.
14
+ * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees.
13
15
  * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
14
16
  * the grid Points will be created only inside it
15
17
  * @param {Object} [options.properties={}] passed to each point of the grid
16
- * @returns {FeatureCollection<Polygon>} grid a grid of polygons
18
+ * @returns {FeatureCollection<Polygon>} a grid of polygons with equal width and height in degrees.
17
19
  * @example
18
20
  * var bbox = [-95, 30 ,-85, 40];
19
21
  * var cellSide = 50;
@@ -2,18 +2,20 @@ import { GeoJsonProperties, BBox, Feature, Polygon, MultiPolygon, FeatureCollect
2
2
  import { Units } from '@turf/helpers';
3
3
 
4
4
  /**
5
- * Creates a square grid from a bounding box.
5
+ * Creates a grid of square polygons with cell length consistent in degrees
6
6
  *
7
7
  * @name squareGrid
8
- * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
9
- * @param {number} cellSide of each cell, in units
8
+ * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.
9
+ * @param {number} cellSide length of each cell side.
10
10
  * @param {Object} [options={}] Optional parameters
11
- * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,
12
- * radians, miles, or kilometers
11
+ * @param {Units} [options.units='kilometers'] the units of the cellSide value.
12
+ * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.
13
+ * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.
14
+ * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees.
13
15
  * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
14
16
  * the grid Points will be created only inside it
15
17
  * @param {Object} [options.properties={}] passed to each point of the grid
16
- * @returns {FeatureCollection<Polygon>} grid a grid of polygons
18
+ * @returns {FeatureCollection<Polygon>} a grid of polygons with equal width and height in degrees.
17
19
  * @example
18
20
  * var bbox = [-95, 30 ,-85, 40];
19
21
  * var cellSide = 50;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n FeatureCollection,\n Polygon,\n BBox,\n Feature,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Units } from \"@turf/helpers\";\nimport { rectangleGrid } from \"@turf/rectangle-grid\";\n\n/**\n * Creates a square grid from a bounding box.\n *\n * @name squareGrid\n * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order\n * @param {number} cellSide of each cell, in units\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,\n * radians, miles, or kilometers\n * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,\n * the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} grid a grid of polygons\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var squareGrid = turf.squareGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [squareGrid]\n */\n\nfunction squareGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;\n } = {}\n): FeatureCollection<Polygon, P> {\n return rectangleGrid(bbox, cellSide, cellSide, options);\n}\n\nexport { squareGrid };\nexport default squareGrid;\n"],"mappings":";AASA,SAAS,qBAAqB;AA0B9B,SAAS,WACP,MACA,UACA,UAII,CAAC,GAC0B;AAC/B,SAAO,cAAc,MAAM,UAAU,UAAU,OAAO;AACxD;AAGA,IAAO,2BAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n FeatureCollection,\n Polygon,\n BBox,\n Feature,\n MultiPolygon,\n GeoJsonProperties,\n} from \"geojson\";\nimport { Units } from \"@turf/helpers\";\nimport { rectangleGrid } from \"@turf/rectangle-grid\";\n\n/**\n * Creates a grid of square polygons with cell length consistent in degrees\n *\n * @name squareGrid\n * @param {BBox} bbox extent of grid in [minX, minY, maxX, maxY] order. If the grid does not fill the bbox perfectly, it is centered.\n * @param {number} cellSide length of each cell side.\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] the units of the cellSide value.\n * Supports all valid Turf {@link https://github.com/Turfjs/turf/blob/master/packages/turf-helpers/README_UNITS.md Units}.\n * If you are looking for squares with sides of equal lengths in linear units (e.g. kilometers) this is not the module for you.\n * The cellSide is converted from units provided to degrees internally, so the width and height of resulting polygons will be consistent only in degrees.\n * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,\n * the grid Points will be created only inside it\n * @param {Object} [options.properties={}] passed to each point of the grid\n * @returns {FeatureCollection<Polygon>} a grid of polygons with equal width and height in degrees.\n * @example\n * var bbox = [-95, 30 ,-85, 40];\n * var cellSide = 50;\n * var options = {units: 'miles'};\n *\n * var squareGrid = turf.squareGrid(bbox, cellSide, options);\n *\n * //addToMap\n * var addToMap = [squareGrid]\n */\n\nfunction squareGrid<P extends GeoJsonProperties = GeoJsonProperties>(\n bbox: BBox,\n cellSide: number,\n options: {\n units?: Units;\n properties?: P;\n mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;\n } = {}\n): FeatureCollection<Polygon, P> {\n return rectangleGrid(bbox, cellSide, cellSide, options);\n}\n\nexport { squareGrid };\nexport default squareGrid;\n"],"mappings":";AASA,SAAS,qBAAqB;AA4B9B,SAAS,WACP,MACA,UACA,UAII,CAAC,GAC0B;AAC/B,SAAO,cAAc,MAAM,UAAU,UAAU,OAAO;AACxD;AAGA,IAAO,2BAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/square-grid",
3
- "version": "7.1.0-alpha.7+0ce6ecca0",
3
+ "version": "7.1.0",
4
4
  "description": "turf square-grid module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -52,8 +52,8 @@
52
52
  "test:tape": "tsx test.ts"
53
53
  },
54
54
  "devDependencies": {
55
- "@turf/bbox-polygon": "^7.1.0-alpha.7+0ce6ecca0",
56
- "@turf/truncate": "^7.1.0-alpha.7+0ce6ecca0",
55
+ "@turf/bbox-polygon": "^7.1.0",
56
+ "@turf/truncate": "^7.1.0",
57
57
  "@types/benchmark": "^2.1.5",
58
58
  "@types/tape": "^4.2.32",
59
59
  "benchmark": "^2.1.4",
@@ -65,9 +65,10 @@
65
65
  "write-json-file": "^5.0.0"
66
66
  },
67
67
  "dependencies": {
68
- "@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
69
- "@turf/rectangle-grid": "^7.1.0-alpha.7+0ce6ecca0",
68
+ "@turf/helpers": "^7.1.0",
69
+ "@turf/rectangle-grid": "^7.1.0",
70
+ "@types/geojson": "^7946.0.10",
70
71
  "tslib": "^2.6.2"
71
72
  },
72
- "gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
73
+ "gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
73
74
  }