@allmaps/types
Allmaps TypeScript types
Geometry types
Section titled “Geometry types”The following Geometries are used by default Allmaps packages.
type Point = [number, number]
type LineString = Point[]
type Polygon = Point[][]// A Polygon is an array of rings of at least three points// Rings are not closed: the first point is not repeated at the end.// There is no requirement on winding order.
type MultiPoint = Point[]// Notice that this is equivalent to the LineString type, hence the `isMultiGeometry` option
type MultiLineString = Point[][]// Notice that this is equivalent to the Polygon type, hence the `isMultiGeometry` option
type MultiPolygon = Point[][][]
type Geometry = | Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygonTo interact with external data, the following types are used as well:
GeoJSON Geometries follow the GeoJSON specification.
SVG Geometries are expressed using the following types (but note that some functions allow svg’s to be passed as a string):
export type SvgCircle = { type: 'circle' attributes?: SvgAttributes coordinates: Point}
export type SvgLine = { type: 'line' attributes?: SvgAttributes coordinates: [Point, Point]}
export type SvgPolyLine = { type: 'polyline' attributes?: SvgAttributes coordinates: Point[]}
export type SvgPolygon = { type: 'polygon' attributes?: SvgAttributes coordinates: Point[]}
export type SvgRect = { type: 'rect' attributes?: SvgAttributes coordinates: Point[]}
export type SvgGeometry = | SvgCircle | SvgLine | SvgPolyLine | SvgPolygon | SvgRectBbox ([number, number, number, number]). Defined as [xMin, yMin, xMax, yMax]
BboxOptions
Section titled “BboxOptions”Fields
Section titled “Fields”clipLngLat(boolean)clipWebMercator(boolean)
[number, number, number]ColorCount
Section titled “ColorCount”Fields
Section titled “Fields”color([number, number, number])count(number)
ColorWithTransparancy
Section titled “ColorWithTransparancy”[number, number, number, number]FetchFn
Section titled “FetchFn”( input: Request | string | URL, init?: RequestInit) => Promise<Response>Two ways two rectangles (or shapes in general) can overlap: ('cover' | 'contain').
- ‘contain’: The first contains the second
- ‘cover’: The first is covered by the second
Fields
Section titled “Fields”geo([number, number])resource([number, number])
GeojsonFeature
Section titled “GeojsonFeature”Fields
Section titled “Fields”geometry(| GeojsonPoint | GeojsonLineString | GeojsonPolygon | GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygon)properties(unknown)type('Feature')
GeojsonFeatureCollection
Section titled “GeojsonFeatureCollection”Fields
Section titled “Fields”features(Array<GeojsonFeature>)type('FeatureCollection')
GeojsonGeometry
Section titled “GeojsonGeometry” | GeojsonPoint | GeojsonLineString | GeojsonPolygon | GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygonGeojsonGeometryType
Section titled “GeojsonGeometryType” | 'Point' | 'LineString' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon'GeojsonLineString
Section titled “GeojsonLineString”Fields
Section titled “Fields”coordinates(Array<Array<number>>)type('LineString')
GeojsonMultiGeometry
Section titled “GeojsonMultiGeometry”GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygonGeojsonMultiLineString
Section titled “GeojsonMultiLineString”Fields
Section titled “Fields”coordinates(Array<Array<Array<number>>>)type('MultiLineString')
GeojsonMultiPoint
Section titled “GeojsonMultiPoint”Fields
Section titled “Fields”coordinates(Array<Array<number>>)type('MultiPoint')
GeojsonMultiPolygon
Section titled “GeojsonMultiPolygon”Fields
Section titled “Fields”coordinates(Array<Array<Array<Array<number>>>>)type('MultiPolygon')
GeojsonPoint
Section titled “GeojsonPoint”Fields
Section titled “Fields”coordinates(Array<number>)type('Point')
GeojsonPolygon
Section titled “GeojsonPolygon”Fields
Section titled “Fields”coordinates(Array<Array<Array<number>>>)type('Polygon')
Geometry
Section titled “Geometry” | Point | LineString | Polygon | MultiPoint | MultiLineString | MultiPolygonHistogram
Section titled “Histogram”Fields
Section titled “Fields”[bin: string]({count: number; color: Color})
HomogeneousTransform
Section titled “HomogeneousTransform”Weights array of a 2D Homogeneous Transform Matrix
These coefficients are used in the same order in multiple places
- CSS Transform defined by a 2D matrix. Use
toString()before using this as input for a CSSmatrix()function. - WebGL 2D transform matrices.
- OpenLayers’ transform class.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix See: https://openlayers.org/en/latest/apidoc/module-ol_transform.html
Note: The weights array of a Polynomial1 Transformation has a different order. See the corresponding conversion functions.
[number, number, number, number, number, number]ImageRequest
Section titled “ImageRequest”Fields
Section titled “Fields”region?({x: number; y: number; width: number; height: number})size?({width: number; height: number})
[Point, Point]LineString
Section titled “LineString”Array<Point>Matrix4
Section titled “Matrix4”[ number, number, number, number, number, number, number, number, number, number, number, number, number, number, number, number]MultiGeometryOptions
Section titled “MultiGeometryOptions”Fields
Section titled “Fields”isMultiGeometry(boolean)
MultiLineString
Section titled “MultiLineString”Array<Array<Point>>MultiPoint
Section titled “MultiPoint”Array<Point>MultiPolygon
Section titled “MultiPolygon”Array<Array<Array<Point>>>[number, number]Polygon
Section titled “Polygon”Array<Array<Point>>Rectangle
Section titled “Rectangle”Rectangle (or possibly quadrilateral) ([Point, Point, Point, Point]). Winding order of points is free.
Region
Section titled “Region”Fields
Section titled “Fields”height(number)width(number)x(number)y(number)
Ring as [[number, number], ...] (Array<Point>).
Must contain at least 3 points May not contain duplicate points Must be unclosed: last element is not a repetition of the first May not be self-intersecting So far no requirement on self-intersection although that may be useful in future So far no requirement on winding order. This is only applied when exporting to GeoJSON
Two numbers indicating the size of a Bbox as [width, height] or [xSize, ySize] ([number, number]).
Alternatively, two numbers indicating the minimum and maximum of, for example, an array of numbers
Alternatively, two numbers indicating the dimensions of a matrix: rows, cols (which is a different handedness!)
SizeObject
Section titled “SizeObject”Fields
Section titled “Fields”height(number)width(number)
SvgAttributes
Section titled “SvgAttributes”{[x: string]: string | number}SvgCircle
Section titled “SvgCircle”Fields
Section titled “Fields”attributes?({[x: string]: string | number})coordinates([number, number])type('circle')
SvgGeometry
Section titled “SvgGeometry”SvgCircle | SvgLine | SvgPolyLine | SvgPolygon | SvgRectSvgLine
Section titled “SvgLine”Fields
Section titled “Fields”attributes?({[x: string]: string | number})coordinates([Point, Point])type('line')
SvgPolyLine
Section titled “SvgPolyLine”Fields
Section titled “Fields”attributes?({[x: string]: string | number})coordinates(Array<Point>)type('polyline')
SvgPolygon
Section titled “SvgPolygon”Fields
Section titled “Fields”attributes?({[x: string]: string | number})coordinates(Array<Point>)type('polygon')
SvgRect
Section titled “SvgRect”Fields
Section titled “Fields”attributes?({[x: string]: string | number})coordinates(Array<Point>)type('rect')
Fields
Section titled “Fields”column(number)imageSize([number, number])row(number)tileZoomLevel({ scaleFactor: number width: number height: number originalWidth: number originalHeight: number columns: number rows: number })
TileByColumn
Section titled “TileByColumn”Fields
Section titled “Fields”[key: number]([number, number])
TileZoomLevel
Section titled “TileZoomLevel”Fields
Section titled “Fields”columns(number)height(number)originalHeight(number)originalWidth(number)rows(number)scaleFactor(number)width(number)
Triangle
Section titled “Triangle”Triangle
As [[x0, y0], [x1, y1], [x2, y2]] ([Point, Point, Point]).
Winding order of points is free.
TypedGeometry
Section titled “TypedGeometry”P | TypedLineString<P> | TypedPolygon<P> | TypedMultiPoint<P> | TypedMultiLineString<P> | TypedMultiPolygon<...>TypedLine
Section titled “TypedLine”[P, P]TypedLineString
Section titled “TypedLineString”Array<P>TypedMultiLineString
Section titled “TypedMultiLineString”Array<Array<P>>TypedMultiPoint
Section titled “TypedMultiPoint”Array<P>TypedMultiPolygon
Section titled “TypedMultiPolygon”Array<Array<Array<P>>>TypedPolygon
Section titled “TypedPolygon”Array<Array<P>>TypedRectangle
Section titled “TypedRectangle”[P, P, P, P]TypedRing
Section titled “TypedRing”Array<P>TypedTriangle
Section titled “TypedTriangle”[P, P, P]