mainlandBounds関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The box around a region as anyone would picture it: its largest outline, and whatever else is close enough to belong in the same glance.
A region's own bounds are its whole reach, which is the wrong frame for a picture of it. Kagoshima's run from the foot of Kyushu to the Amami islands, three hundred kilometres south, so the prefecture drew at a quarter of the size it could with two specks under it.
reach is how far a ring may sit from the mainland and still be framed with
it, as a share of the mainland's own longer side - so a near island comes
along and a far one is left out of the picture, which is where the map itself
now draws it anyway.
インポート
import { mainlandBounds } from "@johnmorrisdotca/chizu";
定義
function mainlandBounds(rings: readonly MapRing[], reach?: number): [number, number, number, number] | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
rings | readonly MapRing[] | Closed outline rings in native map units. |
reach (省略可) | number | The maximum native map-unit search distance. |
戻り値
[number, number, number, number] | null
Bounds around the mainland and nearby pieces, or null when no ring exists.
例
import WORLD from "@johnmorrisdotca/chizu/world";
import { mainlandBounds, mapOutlines } from "@johnmorrisdotca/chizu";
const index = WORLD.regions.findIndex((region) => region.code === "FR");
// France on the world reaches French Guiana; its mainland does not.
const mainland = mainlandBounds(mapOutlines(WORLD)[index]!.rings)!;
console.log(mainland[3] - mainland[1] < WORLD.regions[index]!.bbox[3] - WORLD.regions[index]!.bbox[1]);
// truetrue出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。