landAnchor関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A point on the region's own land, for a leader to end at.
region.map.centroid is the average of a whole outline, so it falls in open
water whenever a place is a chain or a crescent: measured on 2026-09-18, 15
of the world's 173 countries - Indonesia, Japan, Malaysia, the Philippines,
Vietnam, Israel, France, Croatia among them - and a leader drawn to it ends
in the sea between the islands it is naming.
The biggest ring is the region as anyone would point at it, and inside it the chosen point is the one furthest from its coast: the pole of inaccessibility, found by quartering the ring's box and keeping the best square, which is a few hundred steps and exact enough for a circle's leader. A ring so thin that no sample lands inside it - a sandbar - falls back to the ring's own middle.
インポート
import { landAnchor } from "@johnmorrisdotca/chizu";
定義
function landAnchor(rings: readonly MapRing[]): [number, number] | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
rings | readonly MapRing[] | Closed outline rings in native map units. |
戻り値
[number, number] | null
A point on the widest ring’s land, or null when no ring exists.
例
import { landAnchor, parseMapRings } from "@johnmorrisdotca/chizu";
// The point deepest in the land of the widest ring.
console.log(landAnchor(parseMapRings("M0,0L20,0L20,10L0,10Z")));
// [ 5, 5 ][ 5, 5 ]出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。