JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 530202
  • Score
    100M100P100Q194226F
  • License ISC

A collection of fast approximations to common geographic measurements.

Package Exports

  • cheap-ruler

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cheap-ruler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

cheap-ruler

A collection of fast approximations to common geographic measurements, along with some utility functions. Useful for speeding up analysis scripts when measuring things on a city scale by replacing expensive Turf calls in key places.

Usage

var ruler = cheapRuler(35.05, 'miles');
var distance = ruler.distance([30.51, 50.32], [30.52, 50.312]);

Creating a ruler object

cheapRuler(latitude[, units])

Creates a ruler object that will approximate measurements around the given latitude. Units are either kilometers (default) or miles.

cheapRuler.fromTile(y, z[, units])

Creates a ruler object from tile coordinates (y and z). Convenient in tile-reduce scripts.

var ruler = cheapRuler.fromTile(1567, 12);

Ruler methods

distance(a, b)

Given two points of the form [x, y], returns the distance. Typically within 0.1% of turf.distance values but 20–25 times faster.

lineDistance(points)

Given an array of points, returns the total line distance. Typically within 0.1% of turf.lineDistance values but 20–25 times faster.

bearing(a, b)

Returns the bearing between two points in angles. Typically within 0.001% of turf.bearing but 3–4 times faster.

bufferPoint(p, buffer)

Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.

var bbox = ruler.bufferPoint([30.5, 50.5], 0.01);

bufferBBox(bbox, buffer)

Given a bounding box, returns the box buffered by a given distance.

insideBBox(p, bbox)

Returns true if the given point is inside in the given bounding box, otherwise false.