The shared namespace: projections, spherical geometry, datasets. Both the
map and the globe are built on it, and the drawable elements measure with
it.
- Source:
Methods
(static) angle(a, b) → {number}
Angular distance between two positions.
Parameters:
| Name | Type | Description |
|---|---|---|
a |
Array.<number> | Position as [lon, lat] in degrees. |
b |
Array.<number> | Position as [lon, lat] in degrees. |
- Source:
Returns:
Angular distance in degrees, 0 to 180.
- Type
- number
(static) area(ring) → {number}
Area of a spherical polygon in steradians.
Sum of dLambda * mean(sin phi) integrates the band between the ring and
the equator. A ring that encircles a pole therefore measures that band,
not the cap, and the cap is its complement in the hemisphere. Densified
edges make the trapezoid rule accurate enough; the difference to true
great-circle edges vanishes below the segment length.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
Steradians, always positive. Multiply by R squared for
an area on a sphere of that radius.
- Type
- number
(static) asLayer(ds, name) → (nullable) {Object}
The existing groups, presented as layers without copying their geometry.
`countries` and the rest keep the shape they have had since the first
build. This is an adapter, not a migration: both readings work on the same
arrays, so nothing has to be converted and nothing can drift apart.
Parameters:
| Name | Type | Description |
|---|---|---|
ds |
Object | A dataset, as registered with `registerDataset`. |
name |
string | A group in the dataset, such as "countries". |
- Source:
Returns:
A layer, or null with a warning if there is no such
group. The features are the dataset's own arrays, not copies.
- Type
- Object
(static) bandIndex(features, sizeopt) → {Object}
Lat-band buckets, so a lookup need not walk every feature.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
features |
Array.<Object> | Features carrying a `bbox`. | ||
size |
number |
<optional> |
10 | Height of a band, in degrees. |
- Source:
Returns:
Feature ids per band.
- Type
- Object
(static) bboxOf(rings) → (nullable) {Array.<Array.<number>>}
Bounding box of a group of rings, as [[lonW, latS], [lonE, latN]].
Longitudes are unwrapped against the first point, so a shape straddling
the antimeridian yields a west edge east of its east edge — Fiji comes out
2.9 degrees wide rather than as the whole world, and Russia keeps running
past 180. A viewport needs that; a label would need the fold back.
Parameters:
| Name | Type | Description |
|---|---|---|
rings |
Array.<Array.<Array.<number>>> | Rings of [lon, lat] in degrees. |
- Source:
Returns:
[[lonW, latS], [lonE, latN]] in degrees,
or null for an empty group. The east edge may exceed 180.
- Type
- Array.<Array.<number>>
(static) boxLL(box, nopt) → {Array.<Array.<number>>}
The outline of a lon/lat box, sampled along its edges.
Corners alone will not do: every projection bends a straight edge, so a
box fitted from its four corners comes out too small.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
box |
Array.<Array.<number>> | [[lonW, latS], [lonE, latN]] in degrees. | ||
n |
number |
<optional> |
60 | Samples per edge. |
- Source:
Returns:
The outline as [lon, lat], closed.
- Type
- Array.<Array.<number>>
(static) centreFromMatrix(m) → {Array.<number>}
Map centre from a camera rotation matrix.
lon = atan2(cam_y, cam_x) collapses at the poles: both components go to
zero and the arctangent swings over its whole range on the slightest
pointer move. Row 2 of the matrix is exactly the preimage of the screen
up-axis, (-sin p cos l, -sin p sin l, cos p), and carries the longitude
well-conditioned wherever the eye vector loses it. With zero roll both
routes agree, so the switch at |lat| = 45° introduces no jump.
Parameters:
| Name | Type | Description |
|---|---|---|
m |
Array.<Array.<number>> | A 3×3 rotation matrix. |
- Source:
Returns:
The centre it carries, as [lon, lat].
- Type
- Array.<number>
(static) clamp(v, a, b) → {number}
Clamp a number into a closed interval.
Parameters:
| Name | Type | Description |
|---|---|---|
v |
number | The value. |
a |
number | Lower bound. |
b |
number | Upper bound. |
- Source:
Returns:
v, or the bound it exceeded.
- Type
- number
(static) clipLineCircle(pts, rot, rhoMax) → {Array.<Array.<Array.<number>>>}
Open polyline clipped to the disc; no rim arcs, just the pieces inside.
Parameters:
| Name | Type | Description |
|---|---|---|
pts |
Array.<Array.<number>> | Open polyline of [lon, lat] in degrees. |
rot |
function | Carries a position into the frame the cut is made in. |
rhoMax |
number | Angular radius of the disc, in degrees. |
- Source:
Returns:
The pieces inside the disc.
- Type
- Array.<Array.<Array.<number>>>
(static) clipRing(ring, rot, maxStep) → {Array.<Array.<Array.<number>>>}
Filled ring clipped to a sheet, split where it crosses the antimeridian.
The ring is unwrapped, cut against ±180 in each turn it spans, and closed
along the pole line where it circles a pole. The orientation is imposed
afterwards, on the densified result: the winding is read from steps
normalised to ±180, and a single step longer than that normalises the
other way round, so measuring before the split and shipping after it gave
the wrong answer for every ring reaching a pole.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
rot |
function | Carries a position into the frame the cut is made in. |
maxStep |
number | Longest segment to leave undivided, in degrees. |
- Source:
Returns:
The pieces, each an open ring.
- Type
- Array.<Array.<Array.<number>>>
(static) clipRingCircle(ring, rot, rhoMax, arcStepopt) → {Array.<Array.<Array.<number>>>}
Filled ring clipped to a disc of angular radius rhoMax about the centre.
Works in pole-rotated coordinates, where the disc is everything above the
parallel φ′ = 90 − rhoMax. Runs of points inside are kept; where a run
leaves and the next one enters, the two are joined along that parallel, in
the direction the ring is wound. That join is the same idea as the
terminator rejoin on the globe, and it is what makes a coastline running
off the edge close against the rim instead of across the middle.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. | |
rot |
function | Carries a position into the frame the cut is made in. | |
rhoMax |
number | Angular radius of the disc, in degrees. | |
arcStep |
number |
<optional> |
Step along the rim when joining, in degrees. |
- Source:
Returns:
The pieces inside the disc.
- Type
- Array.<Array.<Array.<number>>>
(static) clipSphereRing(pts, r1, r2, cam, side, arcStepopt, orientopt) → {Array.<Array.<Array.<number>>>}
Terminator clipping for a filled ring on the sphere.
Returns the parts of `pts` on the hemisphere `side` faces, each closed
over arcs of the silhouette circle. Where a ring crosses the terminator
more than twice the pieces must be chained along that circle: closing
each piece on its own produces the complement of the intended area.
r1, r2 are the screen axes in world coordinates (rows 1 and 2 of the
camera rotation), cam is the eye vector (row 3). Points are unit vectors;
the caller scales and projects.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pts |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. | ||
r1 |
Array.<number> | First row of the view rotation. | ||
r2 |
Array.<number> | Second row of the view rotation. | ||
cam |
Array.<number> | Camera direction as a unit vector. | ||
side |
number | +1 keeps the hemisphere facing the camera, -1 the one behind it. It is the sign the dot product with `cam` must have for a point to count as visible. | ||
arcStep |
number |
<optional> |
Step along the limb when rejoining. | |
orient |
number |
<optional> |
1 | Winding of the ring, +1 or -1. Stated by the caller rather than derived, because a great circle spans every longitude and no measure can read its orientation. |
- Source:
Returns:
The visible pieces.
- Type
- Array.<Array.<Array.<number>>>
(static) countryAt(ds, lon, lat) → (nullable) {string}
Point in polygon over the latitude-band index instead of every country.
Parameters:
| Name | Type | Description |
|---|---|---|
ds |
Object | A dataset, as registered with `registerDataset`. |
lon |
number | Longitude in degrees. |
lat |
number | Latitude in degrees. |
- Source:
Returns:
The country id, or null for open water.
- Type
- string
(static) countryRings(country, smallRadius, showSmall) → {Array.<Array.<Array.<number>>>}
A country is either polygons or a point below the resolution.
Parameters:
| Name | Type | Description |
|---|---|---|
country |
Object | A country from the dataset. |
smallRadius |
number | Radius of the stand-in circle, in degrees. |
showSmall |
boolean | Whether to draw stand-ins at all. A circle is a symbol at the wrong size, not the country's shape, so a map meant to be measured from should leave them out. |
- Source:
Returns:
Rings ready to draw.
- Type
- Array.<Array.<Array.<number>>>
(static) destination(lon, lat, r, b) → {Array.<number>}
Position at distance r (degrees) from a point on course b (degrees).
Computed in vectors rather than from the spherical law of cosines: the
closed form degenerates to atan2(0, 0) exactly at the poles, which
collapses a polar small circle into a single point. Here the tangent
frame is built explicitly, and where it is undefined -- only at the two
poles -- the reference direction is fixed to match the limit of the
closed form, so nothing shifts away from the poles.
Parameters:
| Name | Type | Description |
|---|---|---|
lon |
number | Start longitude in degrees. |
lat |
number | Start latitude in degrees. |
r |
number | Angular distance in degrees. |
b |
number | Initial bearing in degrees, clockwise from north. |
- Source:
Returns:
The arrival point as [lon, lat] in degrees.
- Type
- Array.<number>
(static) devicePixels()
Device pixels per CSS pixel.
Board coordinates are in CSS pixels, but a corner is visible at the
resolution the screen actually has: half a CSS pixel is a whole device
pixel on a retina display, which is exactly where the remaining kinks
came from. Sampling therefore works in device pixels.
- Source:
(static) featureAt(layer, lon, lat) → (nullable) {Object}
Which feature of this layer contains the point, or null.
Parameters:
| Name | Type | Description |
|---|---|---|
layer |
Object | A feature layer. |
lon |
number | Longitude in degrees. |
lat |
number | Latitude in degrees. |
- Source:
Returns:
The feature containing the position, or null. A
position in a hole counts as outside.
- Type
- Object
(static) featuresIn(layer, boxnullable, minRankopt) → {Array.<Object>}
The features of this layer worth drawing in `box`, at or above `minRank`.
Culling by bounding box is what makes a detailed dataset affordable: at
country scale nothing outside the view is clipped, projected or drawn.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
layer |
Object | A feature layer. | |
box |
Array.<Array.<number>> |
<nullable> |
[[lonW, latS], [lonE, latN]], or null for no culling. May straddle the antimeridian. |
minRank |
number |
<optional> |
Keep features at or below this rank. One without a rank is always kept. |
- Source:
Returns:
The features that survive.
- Type
- Array.<Object>
(static) frameLL(P, n) → {Array.<Array.<number>>}
The outline of the sheet, in the coordinates the projection reads.
For a cylindrical map that is the rectangle bounded by the meridians
±180 and the parallels ±latMax. For an azimuthal one it is the rim of the
disc: a single parallel at φ′ = 90 − rhoMax, which is what the projection
turns into a circle.
Parameters:
| Name | Type | Description |
|---|---|---|
P |
Object | A registered projection. |
n |
number | Samples per edge, or around the rim for a disc. |
- Source:
Returns:
The outline as [lon, lat] in degrees.
- Type
- Array.<Array.<number>>
(static) inRing(ring, lon, lat) → {boolean}
Is the position inside this ring?
Ray casting in longitude and latitude, so the ring must not straddle the
antimeridian — the dataset guarantees that, and `validate` checks it.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
lon |
number | Longitude in degrees. |
lat |
number | Latitude in degrees. |
- Source:
Returns:
True when the position lies inside.
- Type
- boolean
(static) invert(P, x, y, seedopt, tolopt) → {Object}
Generic inverse: coarse grid start, damped Newton with a numerical
Jacobian and backtracking, then a derivative-free pattern search as a
fallback. Projections need only supply forward(); a closed-form inverse
is an optimisation, not a requirement.
`tol` is the residual, in projected units, below which the point counts
as being on the map. Callers derive it from a pixel tolerance and their
own scale — a fixed number would mean different things on a small phone
and a large screen, and different things again for projections whose
extents range from 5.1 to 6.9.
Returns {lon, lat, ok}. ok is false when the point lies outside the map.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
P |
Object | A registered projection. | |
x |
number | Projected x. | |
y |
number | Projected y. | |
seed |
Array.<number> |
<optional> |
Starting guess as [lon, lat]; ignored when the projection has an exact inverse of its own. |
tol |
number |
<optional> |
Tolerance in projected units. |
- Source:
Returns:
ok is false when
the point lies outside the sheet.
- Type
- Object
(static) localTime(offsetHours, whenopt, ruleopt) → {Date}
Local time in a nominal zone, with an optional summer-time rule.
`rule` is 'eu', 'us' or 'none'. Both rules are stated in local time and
differ by more than their dates: the European change happens at the same
instant everywhere, the American one at 2 a.m. in each zone separately.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
offsetHours |
number | Standard offset from UTC, in hours. | |
when |
Date |
<optional> |
The moment; defaults to now. |
rule |
string |
<optional> |
Summer-time rule: "eu", "us" or "none". |
- Source:
Returns:
Local time, summer time included where the rule says.
- Type
- Date
(static) maskLine(pts, cam, side, radius, X, Y, Z, occludeopt) → {void}
`occlude` is the distance of the points from the centre in Earth radii.
On the surface it is 1 and the half-space test is right. Further out a
point is only hidden when it is behind the plane *and* inside the Earth's
silhouette — otherwise it is seen past the limb, which is exactly what
makes a satellite visible above the far side.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
pts |
Array.<Array.<number>> | Points as [lon, lat] in degrees. | |
cam |
Array.<number> | Camera direction as a unit vector. | |
side |
number | +1 for the near hemisphere, -1 for the far one. | |
radius |
number | Sphere radius in world units. | |
X |
Array.<number> | Output array for x, NaN between pieces. | |
Y |
Array.<number> | Output array for y. | |
Z |
Array.<number> | Output array for z. | |
occlude |
number |
<optional> |
Radius factor a point must clear to be seen past the limb; 1 is the surface itself. |
- Source:
Returns:
The three arrays are filled in place.
- Type
- void
(static) maskedLayer(el, opts) → {Object}
Visibility mask for a polyline drawn on the globe: the parts behind the
sphere are cut away and the piece boundaries marked with NaN.
Parameters:
| Name | Type | Description |
|---|---|---|
el |
Object | A JSXGraph curve3d to drive. |
opts |
Object | How to read the scene: `segments()` yields the polylines as [lon, lat]; `camera()` the view direction as a unit vector; `project(lon, lat, r)` places a point in world coordinates; `radius()` the sphere radius, default 1; `side` +1 for the near hemisphere, -1 for the far one, default +1; `occlude` the radius factor a point must clear to be seen past the limb, default 1; `active` false leaves the element empty. |
- Source:
Returns:
The element, for chaining.
- Type
- Object
(static) maskedRings(el, opts) → {Object}
Filled counterpart to `maskedLayer`: rings clipped against the terminator
and rejoined along the limb, so a coastline running off the edge closes
against the silhouette instead of across the middle.
Parameters:
| Name | Type | Description |
|---|---|---|
el |
Object | A JSXGraph curve3d to drive. |
opts |
Object | As `maskedLayer`, plus `orients()` giving each ring's winding — stated rather than derived, because a great circle spans every longitude and no measure can read its orientation. |
- Source:
Returns:
The element, for chaining.
- Type
- Object
(static) meridianLL(lon, nopt) → {Array.<Array.<number>>}
A meridian, pole to pole.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
lon |
number | Longitude in degrees. | |
n |
number |
<optional> |
Number of samples. |
- Source:
Returns:
Points as [lon, lat] in degrees.
- Type
- Array.<Array.<number>>
(static) nearest(ds, lon, lat, layeropt, lon, lat, layeropt) → (nullable) {Object}
The nearest point of a dataset group to a position.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
ds |
Object | A dataset. | ||
lon |
number | Longitude in degrees. | ||
lat |
number | Latitude in degrees. | ||
layer |
string |
<optional> |
"capitals" | * @param {Object} ds A dataset. |
lon |
number | Longitude in degrees. | ||
lat |
number | Latitude in degrees. | ||
layer |
string |
<optional> |
"capitals" | Which group of points to search. |
- Source:
Returns:
The nearest entry, with `km` added, or null when
the group is empty.
- Type
- Object
(static) orientationOf(ring) → {number}
Which way a ring runs: +1 counter-clockwise seen from outside, -1 the
other way.
A ring that circles a pole needs a different reading from one that does
not. The trapezoid integral measures the complement in that case and its
sign flips with it, so the winding decides instead — and the winding is
unambiguous exactly when the integral is not.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
+1 or -1. Meaningless where `readableOrientation` is
false; such rings keep the orientation they were given.
- Type
- number
(static) parallelLL(lat, nopt) → {Array.<Array.<number>>}
A parallel, right around the sphere.
The ring is open and runs eastward, so it circles the north pole
counter-clockwise seen from outside — which is what `orientationOf`
reports for it.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
lat |
number | Latitude in degrees. | |
n |
number |
<optional> |
Number of samples. |
- Source:
Returns:
Points as [lon, lat] in degrees.
- Type
- Array.<Array.<number>>
(static) poleRotator(lon0, lat0) → {function}
Rotation that carries the map centre to the **north pole**.
The cylindrical and pseudocylindrical projections put the centre on the
equator, where the map edge is the meridian λ′ = ±180 — a straight cut.
An azimuthal projection is built around a point instead: everything is
expressed as an angular distance ρ from the centre and an azimuth θ. With
the centre at the pole, ρ = 90° − φ′ and θ = λ′, so the map edge becomes
the parallel φ′ = 90° − ρmax: a circle, and the reason this needs its own
clipping.
Parameters:
| Name | Type | Description |
|---|---|---|
lon0 |
number | Longitude of the new centre, in degrees. |
lat0 |
number | Latitude of the new centre, in degrees. |
- Source:
Returns:
lon, lat in
degrees to the rotated [lon, lat], also in degrees.
- Type
- function
(static) projection(p) → (nullable) {Object}
Look up a projection by name, or pass one through.
Parameters:
| Name | Type | Description |
|---|---|---|
p |
string | Object | A registered name, or a projection itself. |
- Source:
Returns:
The projection, or null with a warning.
- Type
- Object
(static) readableOrientation(ring) → {boolean}
Can this ring's orientation be read at all?
Not for one that circles a pole — the winding says which pole, not which
way round — and not for one covering half the sphere, where the integral
comes out at zero. A 90-degree cap is both.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
True when `orientationOf` can answer for this ring.
- Type
- boolean
(static) refineSamples(make, n0, radiusPx, tolPx, maxNopt) → {Array}
Sampling count found by measuring the curve instead of assuming a circle.
What is measured here is how far the curve departs from a great circle:
for an evenly sampled great circle a point lies exactly on the bisector
of its neighbours, so the measure is zero. It therefore does not replace
samplesFor — which covers the chord error of the arc itself — but adds to
it wherever a curve bends more tightly than a circle of the same screen
size, as a ground track does at its turning latitudes.
`make(n)` must return an array of [lon, lat]. Called a handful of times
when the curve is built, never while drawing.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
make |
function | Builds the curve at n samples. | |
n0 |
number | Starting sample count. | |
radiusPx |
number | Drawn radius in device pixels. | |
tolPx |
number | Allowed chord error in device pixels. | |
maxN |
number |
<optional> |
Upper bound on samples. |
- Source:
Returns:
The curve, sampled finely enough.
- Type
- Array
(static) registerDataset(name, ds) → {Object}
Add a dataset under a name, so an element can ask for it by that name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The key it is looked up by. |
ds |
Object | The dataset. It is not validated here; run `G.validate` when building one. |
- Source:
Returns:
The dataset as registered.
- Type
- Object
(static) registerProjection(name, desc) → {Object}
Add a projection under a name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The key it is looked up by. |
desc |
Object | Needs `forward(lon, lat)`; may carry `inverse(x, y)`, `latMax`, `oblique`, `clip` and `rhoMax`. Without an inverse a click cannot be turned back into a position, so `G.invert` falls back to searching, which is slower and can fail near the edges. |
- Source:
Returns:
The projection as registered.
- Type
- Object
(static) resetWarnings() → {void}
Forget which messages have already been reported.
Only of use to a test that wants to see a warning it has provoked twice.
- Source:
Returns:
- Type
- void
(static) ringSign(ll) → {number}
Winding of a lon/lat ring: +1 counter-clockwise seen from outside the
sphere, -1 clockwise. Holes are stored clockwise so the nonzero fill rule
punches them out, and the terminator rejoin needs to know which it has.
This is a planar measure in lon/lat and only agrees with the spherical
one for rings that do not circle the sphere. A great circle spans every
longitude, and its shoelace then reports the area under a sine wave
rather than the side its interior lies on. Callers who know the winding
by construction — a small circle, for instance — should say so instead
of asking.
Parameters:
| Name | Type | Description |
|---|---|---|
ll |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
+1 or -1. Planar, and therefore wrong for rings near
a pole or across the antimeridian; `orientationOf` is the one to ask.
- Type
- number
(static) ringsOf(features) → {Array.<Array.<Array.<number>>>}
Every ring of a layer's features, ready for addGeoLayer.
Parameters:
| Name | Type | Description |
|---|---|---|
features |
Array.<Object> | Features with a `polys` member. |
- Source:
Returns:
Every ring, outer and hole
alike, in the order they appear.
- Type
- Array.<Array.<Array.<number>>>
(static) rotator(lon0, lat0) → {function}
Rotation that brings (lon0, lat0) to the map centre (0, 0).
For lat0 = 0 this collapses to a shift of the central meridian, which
every projection supports; lat0 != 0 needs an oblique-capable one.
Parameters:
| Name | Type | Description |
|---|---|---|
lon0 |
number | Longitude of the new centre, in degrees. |
lat0 |
number | Latitude of the new centre, in degrees. |
- Source:
Returns:
lon, lat in
degrees to the rotated [lon, lat], also in degrees.
- Type
- function
(static) samplesFor(spanRad, radiusPx, tolPx, minopt, maxopt) → {number}
How many segments an arc needs so its chord stays within `tol` pixels.
A chord across an angle d on a circle of screen radius R misses the arc
by the sagitta R(1 - cos(d/2)). Setting that below the tolerance and
solving for the number of segments gives
n >= (span / 2) * sqrt(R / (2 * tol))
so the count follows from how large the thing is drawn, not from a number
chosen because it looked about right.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
spanRad |
number | Angular span of the arc, in radians. | |
radiusPx |
number | Drawn radius in device pixels. | |
tolPx |
number | Allowed chord error in device pixels. | |
min |
number |
<optional> |
Never return fewer than this. |
max |
number |
<optional> |
Never return more than this. |
- Source:
Returns:
Number of samples.
- Type
- number
(static) shoelace(r) → {number}
Twice the signed planar area of a ring, in its own coordinates.
A planar measure on planar data. It is *not* a way to read the winding of
a geographic ring: for one near a pole or across the antimeridian it
answers confidently and wrongly. Use `orientationOf` for that.
Parameters:
| Name | Type | Description |
|---|---|---|
r |
Array.<Array.<number>> | Open ring of [x, y]. |
- Source:
Returns:
Twice the signed area; positive counter-clockwise.
- Type
- number
(static) signedArea(ring) → {number}
Signed spherical area: positive for a ring wound counter-clockwise seen
from outside, negative for a hole.
`area` returns the magnitude, which is what a measurement wants. Every
orientation question needs the sign, and taking it from the planar
shoelace fails for exactly the rings that matter — those near a pole or
across the antimeridian.
No complement correction, unlike `area`: that correction gives the
magnitude a pole-circling ring encloses but flips the sign with it, and
the sign is the whole point. A cap larger than a hemisphere still runs
counter-clockwise and is still an outer ring. The integral runs the other
way round from the winding convention, so it is negated.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
Steradians, signed. A pole-circling ring reports the
band it bounds rather than the cap.
- Type
- number
(static) smallCountries(ds) → {Array.<string>}
Countries represented by a symbol rather than an outline.
Parameters:
| Name | Type | Description |
|---|---|---|
ds |
Object | A dataset, as registered with `registerDataset`. |
- Source:
Returns:
Ids of the countries with no outline at this
resolution.
- Type
- Array.<string>
(static) stepFor(radiusPx, tolPx) → {number}
Largest step that keeps the chord within tolerance, for a full circle.
Parameters:
| Name | Type | Description |
|---|---|---|
radiusPx |
number | Drawn radius in device pixels. |
tolPx |
number | Allowed chord error in device pixels. |
- Source:
Returns:
Step in degrees.
- Type
- number
(static) subsolar(dateopt) → {Array.<number>}
Subsolar point for a date. Ignores the equation of time.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
date |
Date |
<optional> |
When; defaults to now. |
- Source:
Returns:
The point the sun is overhead, as [lon, lat]
in degrees. The equation of time is not applied, so the longitude
can be 4.1 degrees out — 457 km at the equator, around 31 October.
That is fine for a terminator on a world map and not fine for
anything that needs the sun's true position.
- Type
- Array.<number>
(static) summerTime(when, rule, offsetHours) → {boolean}
Whether summer time is in force. Northern-hemisphere rules only.
Parameters:
| Name | Type | Description |
|---|---|---|
when |
Date | The moment to test. |
rule |
string | "eu", "us" or "none". |
offsetHours |
number | Standard offset from UTC, in hours. |
- Source:
Returns:
True when summer time is in force.
- Type
- boolean
(static) timeZoneBand(offsetHours) → {Array.<Array.<number>>}
Nominal time zones: the 15-degree bands, and one of them singled out.
These are the meridian-based zones, not the legal ones — a country's real
zone follows its border and can be offset by 30 or 45 minutes. What can be
had from a formula is the nominal band; the legal boundaries need their
own dataset, and the two disagree by up to several hundred kilometres.
Parameters:
| Name | Type | Description |
|---|---|---|
offsetHours |
number | Offset from UTC, in hours. |
- Source:
Returns:
The band as a closed ring of
[lon, lat]. The nominal 15-degree slice, not the legal boundary.
- Type
- Array.<Array.<number>>
(static) tissot(optsopt) → {Array.<Array.<Array.<number>>>}
Tissot indicatrices: circles of equal angular radius on a lattice.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
opts |
Object |
<optional> |
`radius` in degrees, `lonStep` and `latStep` in degrees, `n` samples per circle. |
- Source:
Returns:
One ring per indicatrix.
- Type
- Array.<Array.<Array.<number>>>
(static) toVector(lon, lat) → {Array.<number>}
A position as a unit vector.
Parameters:
| Name | Type | Description |
|---|---|---|
lon |
number | Longitude in degrees. |
lat |
number | Latitude in degrees. |
- Source:
Returns:
Unit vector [x, y, z]; x towards 0°/0°,
z towards the north pole.
- Type
- Array.<number>
(static) unwrap(ring) → {Array.<Array.<number>>}
Longitudes made continuous, so a ring can be cut against a meridian.
Parameters:
| Name | Type | Description |
|---|---|---|
ring |
Array.<Array.<number>> | Open ring of [lon, lat] in degrees. |
- Source:
Returns:
A copy whose longitudes run
continuously, and may leave the range ±180.
- Type
- Array.<Array.<number>>
(static) validate(ds) → {Array.<string>}
The six guarantees the renderer relies on. See SPEC.md §7.
Parameters:
| Name | Type | Description |
|---|---|---|
ds |
Object | A dataset, as registered with `registerDataset`. |
- Source:
Returns:
One message per broken invariant; empty when
the dataset is sound.
- Type
- Array.<string>
(static) warn(msg) → {void}
Report a problem once per message.
Repeating the same complaint on every frame is what makes a console
useless, so each distinct message is passed on only the first time.
Parameters:
| Name | Type | Description |
|---|---|---|
msg |
string | What went wrong, in a form the caller can act on. |
- Source:
Returns:
- Type
- void