import type * as L from "leaflet"; import type { Feature, FeatureCollection, Geometry } from "geojson"; export type DatasetName = "prefectures" | "municipalities" | "electoral-districts" | "municipality-district-intersections"; export type DataScope = "national" | "prefecture"; /** 色計算に使う値域 */ export type Range = { /** 最小値 */ min: number; /** 最大値 */ max: number; }; /** 凡例と値表示の設定 */ export type LegendOptions = { /** 凡例と吹き出しに表示する項目名 */ title?: string; /** 値の後ろに付ける単位 */ unit?: string; /** 小数点以下の表示桁数 */ digits?: number; /** 凡例を表示する位置 */ position?: L.ControlPosition; /** 凡例に表示する代表値 */ values?: number[]; /** 値を文字列に変換する関数 */ format?: (value: number) => string; }; /** Leafletのタイルレイヤー設定 */ export type TileLayerOptions = L.TileLayerOptions & { /** 背景地図のタイルURL */ url: string; }; /** コロプレス地図の表示設定 */ export type ChoroplethOptions = { /** 都道府県別TopoJSONを読む場合の2桁都道府県コード */ prefCode?: string; /** 色計算に使う最小値 */ min?: number; /** 色計算に使う最大値 */ max?: number; /** 最小値の色 */ startColor?: string; /** 最大値の色 */ endColor?: string; /** 値から塗り色を返す関数 */ color?: (value: number, range: Range) => string; /** 凡例を表示するか、または凡例設定 */ legend?: boolean | LegendOptions; /** 背景地図の設定、falseで背景地図を追加しない */ tileLayer?: false | TileLayerOptions; /** Leafletのクレジット表示を有効にするか */ attributionControl?: boolean; /** 吹き出しの設定、falseで吹き出しを表示しない */ popup?: false | ((feature: ChoroplethFeature, value: number | undefined) => string); /** 入力行から値を取り出す関数、既定は row.value */ getValue?: (row: Row) => number; /** 入力行からTopoJSON featureのidに対応するキーを取り出す関数、既定は row.code */ getKey?: (row: Row) => string; /** 作成後に地図をポリゴン範囲へ合わせるか */ fitBounds?: boolean; /** 同梱TopoJSONを置いたベースURL */ topoJsonBaseUrl?: string; /** 読み込むTopoJSONのURLを直接指定する場合のURL */ topoJsonUrl?: string; }; /** コロプレス地図で使うGeoJSON feature */ export type ChoroplethFeature = Feature; /** コロプレス地図で使うGeoJSON feature collection */ export type ChoroplethFeatureCollection = FeatureCollection; /** 都道府県ポリゴンの属性 */ export type PrefectureProperties = { /** 都道府県名 */ name: string; }; /** 市区町村ポリゴンの属性 */ export type MunicipalityProperties = { /** 都道府県名 */ prefecture: string; /** 支庁・振興局名 */ subPrefecture: string | null; /** 郡名 */ county: string | null; /** 市区町村名 */ municipality: string; /** 政令市の行政区名 */ ward: string | null; /** 表示用の市区町村名 */ displayName: string; }; /** 小選挙区ポリゴンの属性 */ export type ElectoralDistrictProperties = { /** 都道府県コード */ prefectureCode: string; /** 都道府県内の選挙区番号 */ districtNumber: string; /** 選挙区名 */ name: string; }; /** 市区町村と小選挙区の重なりポリゴンの属性 */ export type MunicipalityDistrictProperties = { /** 市区町村コード */ municipalityCode: string; /** 表示用の市区町村名 */ municipalityName: string; /** 都道府県名 */ prefecture: string; /** 支庁・振興局名 */ subPrefecture: string | null; /** 郡名 */ county: string | null; /** 市区町村名 */ municipality: string; /** 政令市の行政区名 */ ward: string | null; /** 小選挙区コード */ districtCode: string; /** 小選挙区名 */ districtName: string; /** 小選挙区の都道府県コード */ districtPrefectureCode: string; /** 都道府県内の選挙区番号 */ districtNumber: string; }; /** 公開APIで使う塗り分けデータ */ export type CodeValueRow = { /** ポリゴンの識別コード、TopoJSON featureのidと対応 */ code: string; /** 塗り分けに使う数値 */ value: number; }; export type BoundaryOverlay = { weightMultiplier: number; getBoundaryKey: (properties: Properties) => string; getGroupKey?: (properties: Properties) => string; }; export type DatasetConfig = { dataset: DatasetName; objectName: string; nationalPath: string; prefecturePath?: (prefCode: string) => string; strokeWeightMultiplier?: number; boundaryOverlay?: BoundaryOverlay; boundaryOverlays?: readonly BoundaryOverlay[]; getRowKey: (row: Row) => string; getFeatureKey: (feature: ChoroplethFeature) => string; getPopupTitle: (properties: Properties) => string; };