import { type Frame, type SurfaceSize } from "./frames.ts"; import type { SceneItem, SceneOptions, SceneSource } from "./scene.types.ts"; /** A position, a ring of them and so on, as GeoJSON has them. */ export type Position = [number, number]; export type Geometry = { type: "Point"; coordinates: Position; } | { type: "LineString"; coordinates: Position[]; } | { type: "MultiLineString"; coordinates: Position[][]; } | { type: "Polygon"; coordinates: Position[][]; } | { type: "MultiPolygon"; coordinates: Position[][][]; }; /** A shape of the drawing, with how it is painted. */ export interface Feature { type: "Feature"; geometry: Geometry; properties: { /** The shape's place in the paint order, from 0. */ order: number; kind: SceneItem["kind"]; class: string; fill?: string; stroke?: string; strokeWidth?: number; opacity?: number; label?: string; text?: string; fontSize?: number; href?: string; data?: Record; }; } /** The drawing: every shape, and what the numbers are. */ export interface FeatureCollection { type: "FeatureCollection"; features: Feature[]; /** `[west, south, east, north]` of the numbers, which for this collection are `x` and `y`. */ bbox?: [number, number, number, number]; /** A foreign member (RFC 7946, 6.1): what the numbers are. */ kyogijo: { sport?: string; frame: string; unit: string; note: string; }; } /** What `sceneToGeoJSON` takes besides the drawing. */ export interface GeoJsonOptions extends SceneOptions { /** A provider's coordinate frame (`"nhl-api"`, `"opta"`, a `Frame` of your own) to write the numbers in. Without one, the surface's own: feet from its left end and its top. */ frame?: string | Frame; /** The surface's size, for a frame that is for a surface of any size (the soccer providers). */ size?: SurfaceSize; /** Leave out the shapes this returns false for (the apron, the teams' names). All by default. */ filter?: (item: SceneItem) => boolean; /** Decimals in a coordinate. 4. */ precision?: number; } /** * A scene as a GeoJSON FeatureCollection (RFC 7946): a filled shape is a Polygon or MultiPolygon (a ring inside another is its hole, the winding as the * RFC has it), a line a LineString, a label a Point with its `text`. The numbers are the drawing's own, feet from the surface's left end and its top (a tall * drawing is turned back), or those of a provider's `frame`; this is a flat plane and not longitude and latitude, so give it to a tool that takes one (Leaflet's * `CRS.Simple`, d3's `geoIdentity`, deck.gl's Cartesian coordinates). The painting of each shape is in its properties. * @example * ```ts * import { sceneToGeoJSON } from "@johnmorrisdotca/kyogijo-stadiums/geojson"; * const rink = sceneToGeoJSON({ sport: "nhl", id: "rink" }, { filter: (item) => item.class.includes("ky-surface") }); * console.log(rink.type, rink.features.length, rink.features[0].geometry.type, rink.bbox); * // FeatureCollection 1 Polygon [ 0, 0, 200, 85 ] * ``` */ export declare function sceneToGeoJSON(source: SceneSource, options?: GeoJsonOptions): FeatureCollection;