-
Notifications
You must be signed in to change notification settings - Fork 954
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace custom lineIntersects function with @turf/line-intersects, resolves #344 * Fixing missing semi-colon * Add dynamic outputs for expectedLocation * Update benchmark * Add dynamic geojson tests in/out * Truncate dynamic geojson test/out * Round precision & dist * Add test case for #344 * Add between line (helps visualize line between both points)
- Loading branch information
1 parent
d103758
commit 2263a80
Showing
19 changed files
with
68,760 additions
and
34,460 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
var pointOnLine = require('./'); | ||
var Benchmark = require('benchmark'); | ||
var fs = require('fs'); | ||
var point = require('@turf/helpers').point; | ||
const Benchmark = require('benchmark'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const load = require('load-json-file'); | ||
const pointOnLine = require('./'); | ||
|
||
var route1 = JSON.parse(fs.readFileSync(__dirname + '/test/in/route1.geojson')); | ||
var route2 = JSON.parse(fs.readFileSync(__dirname + '/test/in/route2.geojson')); | ||
var line1 = JSON.parse(fs.readFileSync(__dirname + '/test/in/line1.geojson')); | ||
const directory = path.join(__dirname, 'test', 'in') + path.sep; | ||
const fixtures = fs.readdirSync(directory).map(filename => { | ||
return { | ||
filename, | ||
name: path.parse(filename).name, | ||
geojson: load.sync(directory + filename) | ||
}; | ||
}); | ||
|
||
var pt1 = point([-97.79617309570312,22.254624939561698]); | ||
var pt2 = point([-79.0850830078125,37.60117623656667]); | ||
var pt3 = point([-112.60660171508789,45.96021963947196]); | ||
/** | ||
* Benchmark Results | ||
* | ||
* ==after (@turf/line-intersect)== | ||
* line1 x 234,231 ops/sec ±1.78% (88 runs sampled) | ||
* route1 x 161 ops/sec ±1.53% (80 runs sampled) | ||
* route2 x 184 ops/sec ±1.96% (80 runs sampled) | ||
* | ||
* ==before (original)== | ||
* line1 x 272,785 ops/sec ±1.29% (87 runs sampled) | ||
* route1 x 195 ops/sec ±2.23% (80 runs sampled) | ||
* route2 x 218 ops/sec ±2.42% (78 runs sampled) | ||
*/ | ||
const suite = new Benchmark.Suite('turf-linestring-to-polygon'); | ||
for (const {name, geojson} of fixtures) { | ||
const [line, point] = geojson.features; | ||
suite.add(name, () => pointOnLine(line, point)); | ||
} | ||
|
||
var suite = new Benchmark.Suite('turf-point-on-line'); | ||
suite | ||
.add('turf-point-on-line#simple',function () { | ||
pointOnLine(line1, pt1); | ||
}) | ||
.add('turf-point-on-line#route1',function () { | ||
pointOnLine(route1, pt2); | ||
}) | ||
.add('turf-point-on-line#route2',function () { | ||
pointOnLine(route2, pt3); | ||
}) | ||
.on('cycle', function (event) { | ||
console.log(String(event.target)); | ||
}) | ||
.on('complete', function () { | ||
|
||
}) | ||
.run(); | ||
.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
Oops, something went wrong.