Skip to the content

Chizu地図

Draw SVG maps, frame regions, place numbered callouts and build geography quizzes with English and Japanese names.

Chizu is the Japanese word 地図 for map. About the name

Contents

Reference · Framing, geometry and quiz tools

ChizuFeaturetype

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 it

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

Definition

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[];
}

Members

NameTypeDescription
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 (optional)string | undefined

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

reading (optional)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 (optional)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 (optional)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.

Examples

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 びわこ

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/chizu 1.5.0.