本文へ移動

Chizu地図

SVGの地図を描き、地域を表示範囲に収め、番号付きの注記や地理クイズを英語と日本語の名前で作れます。

「地図」は、土地や場所を図で表したものです。 名前について(英語)

目次

リファレンス · 表示範囲・形・クイズの道具

ChizuFeature型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

One named physical feature on a map's canvas: a sea, a lake, a river, a landform or a peak. It has the fields a region has that the engine reads (code, path, bbox, centroid, neighbors, group, the names), so featureMap makes a layer a map of its own and every function of the engine (framing, quizzes, pasted names, callouts) works on features as it works on regions.

インポート

import type { ChizuFeature } from "@johnmorrisdotca/chizu";

定義

interface ChizuFeature {
    code: string;
    kind: ChizuFeatureKind;
    group: ChizuFeatureGroup;
    name: string;
    nameJa?: string;
    reading?: string;
    rank: number;
    elevation?: number;
    path: string;
    bbox: [
        number,
        number,
        number,
        number
    ];
    centroid: [
        number,
        number
    ];
    angle?: number;
    neighbors: string[];
}

メンバー

名前型説明
codestring

Its stable id: its Wikidata item (Q200239, Lake Biwa) where it has one, else Natural Earth's own (ne-…, ne-river-…).

kindChizuFeatureKind
groupChizuFeatureGroup
namestring

Its English name: Natural Earth's for a sea, a landform or a peak, Wikidata's label for a lake or a river.

nameJa (省略可)string | undefined

Its Japanese name: Natural Earth's (name_ja) where it has one, else Wikidata's label. Absent where neither has one.

reading (省略可)string | undefined

How nameJa is read, in kana, where it is known: see docs/features.md in the repository for where each comes from.

ranknumber

Natural Earth's rank: 0 for an ocean, up to 10 for a small lake or a short river, for the scale it may be shown at.

elevation (省略可)number | undefined

A peak's height, in metres.

pathstring

Its shape on the map's canvas: closed rings (M x,y L … Z) for an area, open lines (M x,y L …) for a river, empty for a peak.

bbox[number, number, number, number]

The box round it on the canvas: left, top, right, bottom.

centroid[number, number]

Where its name goes: the point inside an area farthest from its edges, a point half way along a river, a peak itself.

angle (省略可)number | undefined

The angle a river's name is written at, in degrees clockwise, to run along it there; absent for 0.

neighborsstring[]

The codes of the water features it touches on this map: a sea's neighbouring seas, a river's tributaries and the lakes it runs through.

例

import { loadFeatures } from "@johnmorrisdotca/chizu/load";
import type { ChizuFeature } from "@johnmorrisdotca/chizu";

const layer = (await loadFeatures("divisions-jp"))!;
const biwa: ChizuFeature = layer.features.find((one) => one.nameJa === "琵琶湖")!;
console.log(biwa.code, biwa.kind, biwa.name, biwa.reading);
// Q200239 lake Lake Biwa びわこ
Q200239 lake Lake Biwa びわこ

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/chizu 1.5.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。