How to use the @turf/random.randomPoint function in @turf/random

To help you get started, we’ve selected a few @turf/random examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DenisCarriere / geojson-rbush / bench.js View on Github external
const Benchmark = require('benchmark');
const {randomPoint, randomPolygon} = require('@turf/random');
const geojsonRbush = require('./').default;

// Fixtures
const points = randomPoint(3);
const point = points.features[0];
const polygons = randomPolygon(3);
const polygon = polygons.features[0];

// Load trees before (used to benchmark search)
const pointsTree = geojsonRbush();
pointsTree.load(points);
const polygonsTree = geojsonRbush();
polygonsTree.load(polygons);

/**
 * Benchmark Results
 *
 * rbush.points x 313,979 ops/sec ±10.60% (67 runs sampled)
 * rbush.polygons x 428,333 ops/sec ±1.69% (70 runs sampled)
 * search.points x 5,986,675 ops/sec ±7.95% (77 runs sampled)
github Turfjs / turf / packages / turf-center-median / bench.js View on Github external
    .add('turf-center-median - 500 points', () => centerMedian(randomPoint(500)))
    .on('cycle', e => console.log(String(e.target)))
github Turfjs / turf / packages / turf-quadrat-analysis / bench.js View on Github external
const bbox = require('@turf/bbox').default;
const nearestNeighborAnalysis = require('@turf/nearest-neighbor-analysis').default;
const quadratAnalysis = require('.').default;

/**
 * Benchmark Results
 * quadrat: 1383.768ms
 * nearest: 12259.498ms
 * quadrat x 0.76 ops/sec ±1.24% (6 runs sampled)
 * nearest x 0.08 ops/sec ±0.97% (5 runs sampled)
 */
const suite = new Benchmark.Suite('turf-quadrat-analysis');


const smallBbox = [-10, -10, 10, 10];
const dataset = randomPoint(10000, { bbox: smallBbox });


var nameQ = 'quadrat';
var nameN = 'nearest'
console.time(nameQ);
quadratAnalysis(dataset, {
    studyBbox: smallBbox,
    confidenceLevel: 20
});
console.timeEnd(nameQ);

console.time(nameN);
nearestNeighborAnalysis(dataset);
console.timeEnd(nameN);

suite.add(nameQ, () => quadratAnalysis(dataset, {
github Turfjs / turf / packages / turf-meta / bench.js View on Github external
const Benchmark = require('benchmark');
const random = require('@turf/random');
const meta = require('./');

const fixtures = {
    point: random.randomPoint(),
    points: random.randomPoint(1000),
    polygon: random.randomPolygon(),
    polygons: random.randomPolygon(1000)
};

const suite = new Benchmark.Suite('turf-meta');

/**
 * Benchmark Results
 * segmentEach   - point x 3,541,484 ops/sec ±6.03% (88 runs sampled)
 * segmentReduce - point x 3,245,821 ops/sec ±0.95% (86 runs sampled)
 * flattenEach   - point x 6,447,234 ops/sec ±5.56% (79 runs sampled)
 * flattenReduce - point x 5,415,555 ops/sec ±1.28% (85 runs sampled)
 * coordEach     - point x 19,941,547 ops/sec ±0.64% (84 runs sampled)
 * coordReduce   - point x 11,959,189 ops/sec ±1.53% (85 runs sampled)
 * propEach      - point x 29,317,809 ops/sec ±1.38% (85 runs sampled)
 * propReduce    - point x 14,552,839 ops/sec ±1.06% (90 runs sampled)
github Turfjs / turf / packages / turf-center-median / bench.js View on Github external
    .add('turf-center-median - 100 points', () => centerMedian(randomPoint(100)))
    .add('turf-center-median - 200 points', () => centerMedian(randomPoint(200)))
github Turfjs / turf / packages / turf-center-median / bench.js View on Github external
    .add('turf-center-median - 200 points', () => centerMedian(randomPoint(200)))
    .add('turf-center-median - 500 points', () => centerMedian(randomPoint(500)))
github Turfjs / turf / packages / turf-meta / bench.js View on Github external
const Benchmark = require('benchmark');
const random = require('@turf/random');
const meta = require('./');

const fixtures = {
    point: random.randomPoint(),
    points: random.randomPoint(1000),
    polygon: random.randomPolygon(),
    polygons: random.randomPolygon(1000)
};

const suite = new Benchmark.Suite('turf-meta');

/**
 * Benchmark Results
 * segmentEach   - point x 3,541,484 ops/sec ±6.03% (88 runs sampled)
 * segmentReduce - point x 3,245,821 ops/sec ±0.95% (86 runs sampled)
 * flattenEach   - point x 6,447,234 ops/sec ±5.56% (79 runs sampled)
 * flattenReduce - point x 5,415,555 ops/sec ±1.28% (85 runs sampled)
 * coordEach     - point x 19,941,547 ops/sec ±0.64% (84 runs sampled)
 * coordReduce   - point x 11,959,189 ops/sec ±1.53% (85 runs sampled)
 * propEach      - point x 29,317,809 ops/sec ±1.38% (85 runs sampled)
github sharedstreets / sharedstreets-road-closure-ui / src / utils / street-builder.ts View on Github external
export const createTwoWayStreetToIntersection = (intersectionId: string) : { forward: SharedStreetsMatchGeomPath, backward: SharedStreetsMatchGeomPath} => {
    const points = randomPoint(2);
    const geometryId = uuid();
    const fromIntersectionId = uuid();
    const toIntersectionId = intersectionId;
    
    const forwardReferenceId = uuid();

    const forwardPathProperties: ISharedStreetsMatchGeomPathProperties = {
        direction: "forward",
        fromIntersectionId,
        fromStreetnames: ['street-'+forwardReferenceId],
        geometryId,
        originalFeature: {
            geometry: {
                coordinates: coordAll(points),
                type: "LineString",
            },

@turf/random

turf random module

MIT
Latest version published 4 months ago

Package Health Score

94 / 100
Full package analysis