-
Notifications
You must be signed in to change notification settings - Fork 953
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #791 from Turfjs/grid-mask
Adds mask option to `@turf/point-grid`
- Loading branch information
Showing
16 changed files
with
14,596 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
var grid = require('./'); | ||
var polygon = require('@turf/helpers').polygon; | ||
var Benchmark = require('benchmark'); | ||
|
||
var bbox = [-95, 30, -85, 40]; | ||
var mask = polygon([[[6.5, 44.6 ], [ 9.2, 44.8 ], [ 8.3, 46.4 ], [ 6.5, 44.6 ]]]); | ||
|
||
var highres = grid(bbox, 100, 'miles').features.length; | ||
var midres = grid(bbox, 10, 'miles').features.length; | ||
var lowres = grid(bbox, 1, 'miles').features.length; | ||
var masked = grid(mask, 1, 'miles', true, true).features.length; | ||
var suite = new Benchmark.Suite('turf-square-grid'); | ||
|
||
/** | ||
* Benchmark Results | ||
* | ||
* highres -- 42 cells x 274,666 ops/sec ±1.96% (77 runs sampled) | ||
* midres -- 4200 cells x 2,725 ops/sec ±3.86% (73 runs sampled) | ||
* lowres -- 414508 cells x 2.09 ops/sec ±21.02% (10 runs sampled) | ||
* masked -- 7658 cells x 9,794 ops/sec ±2.08% (75 runs sampled) | ||
*/ | ||
suite | ||
.add('highres -- ' + highres + ' cells', () => grid(bbox, 100, 'miles')) | ||
.add('midres -- ' + midres + ' cells', () => grid(bbox, 10, 'miles')) | ||
.add('lowres -- ' + lowres + ' cells', () => grid(bbox, 1, 'miles')) | ||
.add('masked -- ' + masked + ' cells', () => grid(mask, 10, 'miles', true, true)) | ||
.on('cycle', e => console.log(String(e.target))) | ||
.on('complete', () => {}) | ||
.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.