Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Setup Node
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24

- name: Install dependencies
run: npm install
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISC License

Copyright (c) 2024, Mapbox
Copyright (c) 2026, Mapbox

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ and usually much less for shorter distances.
## Usage

```js
var ruler = new CheapRuler(35.05, 'miles'); // calculations around latitude 35
...
var distance = ruler.distance([30.51, 50.32], [30.52, 50.312]);
var lineLength = ruler.lineDistance(line.geometry.coordinates);
var bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
const ruler = new CheapRuler(35.05, 'miles'); // calculations around latitude 35
// ...
const distance = ruler.distance([30.51, 50.32], [30.52, 50.312]);
const lineLength = ruler.lineDistance(line.geometry.coordinates);
const bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
```

**Note**: to get the full performance benefit,
Expand All @@ -29,7 +29,7 @@ Don't create a new ruler for every calculation.
#### new CheapRuler(latitude[, units])

Creates a ruler object that will approximate measurements around the given latitude.
Units are one of: `kilometers` (default), `miles`, `nauticalmiles`, `meters`, `yards`, `feet`, `inches`.
Units are one of: `kilometers` (default), `miles`, `nauticalmiles`, `meters`, `metres`, `yards`, `feet`, `inches`.

```js
const ruler = new CheapRuler(50.5, 'meters');
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class CheapRuler {
* Creates a ruler instance for very fast approximations to common geodesic measurements around a certain latitude.
*
* @param {number} lat latitude
* @param {keyof typeof factors} [units='kilometers']
* @param {keyof typeof factors} [units='kilometers'] one of: kilometers, miles, nauticalmiles, meters, metres, yards, feet, inches
* @example
* const ruler = cheapRuler(35.05, 'miles');
* //=ruler
Expand Down Expand Up @@ -216,7 +216,6 @@ export default class CheapRuler {
/**
* Returns the distance from a point `p` to a line segment `a` to `b`.
*
* @pointToSegmentDistance
* @param {[number, number]} p point [longitude, latitude]
* @param {[number, number]} a segment point 1 [longitude, latitude]
* @param {[number, number]} b segment point 2 [longitude, latitude]
Expand Down Expand Up @@ -350,6 +349,7 @@ export default class CheapRuler {

/**
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
* Returns an empty array if start is beyond the total line length.
*
* @param {number} start start distance
* @param {number} stop stop distance
Expand Down Expand Up @@ -437,7 +437,7 @@ export default class CheapRuler {
* const inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
* //=inside
*/
insideBBox(p, bbox) { // eslint-disable-line
insideBBox(p, bbox) {
return wrap(p[0] - bbox[0]) >= 0 &&
wrap(p[0] - bbox[2]) <= 0 &&
p[1] >= bbox[1] &&
Expand Down
Loading
Loading