Allmaps TypeScript 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]
[number, number, number]color([number, number, number])count(number)
[number, number, number, number](
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
geo([number, number])resource([number, number])
geometry(| GeojsonPoint | GeojsonLineString | GeojsonPolygon | GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygon)properties(unknown)type('Feature')
features(Array<GeojsonFeature>)type('FeatureCollection')
| GeojsonPoint
| GeojsonLineString
| GeojsonPolygon
| GeojsonMultiPoint
| GeojsonMultiLineString
| GeojsonMultiPolygon | 'Point'
| 'LineString'
| 'Polygon'
| 'MultiPoint'
| 'MultiLineString'
| 'MultiPolygon'coordinates(Array<Array<number>>)type('LineString')
GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygoncoordinates(Array<Array<Array<number>>>)type('MultiLineString')
coordinates(Array<Array<number>>)type('MultiPoint')
coordinates(Array<Array<Array<Array<number>>>>)type('MultiPolygon')
coordinates(Array<number>)type('Point')
coordinates(Array<Array<Array<number>>>)type('Polygon')
| Point
| LineString
| Polygon
| MultiPoint
| MultiLineString
| MultiPolygon[bin: string]({count: number; color: Color})
Map<string, unknown>region?({x: number; y: number; width: number; height: number})size?({width: number; height: number})
[Point, Point]Array<Point>[
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number
]isMultiGeometry(false)
Array<Array<Point>>Array<Point>Array<Array<Array<Point>>>[number, number]Array<Array<Point>>Rectangle (or possibly quadrilateral) ([Point, Point, Point, Point]). Winding order of points is free.
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
height(number)width(number)
{[x: string]: string | number}attributes?({[x: string]: string | number})coordinates([number, number])type('circle')
SvgCircle | SvgLine | SvgPolyLine | SvgPolygon | SvgRectattributes?({[x: string]: string | number})coordinates([Point, Point])type('line')
attributes?({[x: string]: string | number})coordinates(Array<Point>)type('polyline')
attributes?({[x: string]: string | number})coordinates(Array<Point>)type('polygon')
attributes?({[x: string]: string | number})coordinates(Array<Point>)type('rect')
column(number)imageSize([number, number])row(number)tileZoomLevel({ scaleFactor: number width: number height: number originalWidth: number originalHeight: number columns: number rows: number })
[key: number]([number, number])
columns(number)height(number)originalHeight(number)originalWidth(number)rows(number)scaleFactor(number)width(number)
[number, number, number, number, number, number]Triangle
As [[x0, y0], [x1, y1], [x2, y2]] ([Point, Point, Point]).
Winding order of points is free.
P | TypedLineString<P> | TypedPolygon<P> | TypedMultiPoint<P> | TypedMultiLineString<P> | TypedMultiPolygon<...>[P, P]Array<P>Array<Array<P>>Array<P>Array<Array<Array<P>>>Array<Array<P>>[P, P, P, P]Array<P>[P, P, P]