Skip to content

Commit ffdf2ab

Browse files
committed
Update function description
1 parent 680abd2 commit ffdf2ab

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/lib/geo_location_utils.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,19 @@ function getFitboundsLonRange(lons) {
445445
}
446446

447447
/**
448-
* Return a monotonic version of a `[lon0, lon1]` longitude range so its
449-
* midpoint and span can be computed as if longitude were a regular linear
450-
* coordinate. When the range crosses the antimeridian (`lon0 > 0`, `lon1 < 0`)
451-
* `lon1` is shifted by +360°; otherwise the input pair is returned unchanged.
448+
* Return an unwrapped version of a `[lon0, lon1]` longitude range.
449+
* When the range crosses the antimeridian (`lon0 > 0`, `lon1 < 0`),
450+
* 360 is added to `lon1` to produce a continuous range;
451+
* otherwise the input pair is returned unchanged. Function assumes
452+
* `lon0` is west of `lon1`.
452453
*
453-
* @param {[number, number]} lonRange - `[lon0, lon1]`, each in [-180, 180]
454-
* @return {[number, number]} the unwrapped range
454+
* @example
455+
* unwrapLonRange([170, -170]) // → [170, 190] (span = 20°, midpoint = 180°)
456+
* unwrapLonRange([-10, 20]) // → [-10, 20] (no crossing, passthrough)
457+
*
458+
* @param {[number, number]} lonRange - `[lon0, lon1]`, each in the range [-180, 180]
459+
* @return {[number, number]} The unwrapped range; when the input contract is
460+
* respected, `lon1` falls in the range `[lon0, lon0 + 360)`.
455461
*/
456462
function unwrapLonRange([lon0, lon1]) {
457463
return [lon0, lon0 > 0 && lon1 < 0 ? lon1 + ANTIMERIDIAN_LON_SHIFT : lon1];

0 commit comments

Comments
 (0)