Allmaps TypeScript types
npm install @allmaps/typesAllmaps TypeScript types
The following Geometries are used by default Allmaps packages.
``ts
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
| MultiPolygon
`
To 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):
`js
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
| SvgRect
`
Bbox ([number, number, number, number]). Defined as \[xMin, yMin, xMax, yMax]
###### Fields
* clipLngLat (boolean)clipWebMercator
* (boolean)
###### Type
`ts`
[number, number, number]
###### Fields
* color ([number, number, number])count
* (number)
###### Type
`ts`
[number, number, number, number]
###### Type
`ts`
(
input: Request | string | URL,
init?: RequestInit
) => Promise
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
* geo ([number, number])resource
* ([number, number])
###### Fields
* geometry ( | GeojsonPoint
| GeojsonLineString
| GeojsonPolygon
| GeojsonMultiPoint
| GeojsonMultiLineString
| GeojsonMultiPolygon)properties
* (unknown)type
* ('Feature')
###### Fields
* features (Array)type
* ('FeatureCollection')
###### Type
`ts`
| GeojsonPoint
| GeojsonLineString
| GeojsonPolygon
| GeojsonMultiPoint
| GeojsonMultiLineString
| GeojsonMultiPolygon
###### Type
`ts`
| 'Point'
| 'LineString'
| 'Polygon'
| 'MultiPoint'
| 'MultiLineString'
| 'MultiPolygon'
###### Fields
* coordinates (Array)type
* ('LineString')
###### Type
`ts`
GeojsonMultiPoint | GeojsonMultiLineString | GeojsonMultiPolygon
###### Fields
* coordinates (Array)type
* ('MultiLineString')
###### Fields
* coordinates (Array)type
* ('MultiPoint')
###### Fields
* coordinates (Array)type
* ('MultiPolygon')
###### Fields
* coordinates (Array)type
* ('Point')
###### Fields
* coordinates (Array)type
* ('Polygon')
###### Type
`ts`
| Point
| LineString
| Polygon
| MultiPoint
| MultiLineString
| MultiPolygon
###### Fields
* [bin: string] ({count: number; color: Color})
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 CSS matrix() function.
* WebGL 2D transform matrices.
* OpenLayers' transform class.
See:
See:
Note: The weights array of a Polynomial1 Transformation has a different order. See the corresponding conversion functions.
###### Type
`ts`
[number, number, number, number, number, number]
###### Fields
* region? ({x: number; y: number; width: number; height: number})size?
* ({width: number; height: number})
###### Type
`ts`
[Point, Point]
###### Type
`ts`
Array
###### Type
`ts`
[
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number,
number
]
###### Fields
* isMultiGeometry (boolean)
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
[number, number]
###### Type
`ts`
Array
Rectangle (or possibly quadrilateral) ([Point, Point, Point, Point]). Winding order of points is free.
###### Fields
* height (number)width
* (number)x
* (number)y
* (number)
Ring as [[number, number], ...] (Array).
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!)
###### Fields
* height (number)width
* (number)
###### Type
`ts`
{[x: string]: string | number}
###### Fields
* attributes? ({[x: string]: string | number})coordinates
* ([number, number])type
* ('circle')
###### Type
`ts`
SvgCircle | SvgLine | SvgPolyLine | SvgPolygon | SvgRect
###### Fields
* attributes? ({[x: string]: string | number})coordinates
* ([Point, Point])type
* ('line')
###### Fields
* attributes? ({[x: string]: string | number})coordinates
* (Array)type
* ('polyline')
###### Fields
* attributes? ({[x: string]: string | number})coordinates
* (Array)type
* ('polygon')
###### Fields
* attributes? ({[x: string]: string | number})coordinates
* (Array)type
* ('rect')
###### Fields
* column (number)imageSize
* ([number, number])row
* (number)tileZoomLevel
* ({
scaleFactor: number
width: number
height: number
originalWidth: number
originalHeight: number
columns: number
rows: number
})
###### Fields
* [key: number] ([number, number])
###### Fields
* columns (number)height
* (number)originalHeight
* (number)originalWidth
* (number)rows
* (number)scaleFactor
* (number)width
* (number)
Triangle
As [[x0, y0], [x1, y1], [x2, y2]] ([Point, Point, Point]).
Winding order of points is free.
###### Type
` | TypedPolygon | TypedMultiPoint | TypedMultiLineString | TypedMultiPolygon<...>ts`
P | TypedLineString
###### Type
`ts`
[P, P]
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
Array
###### Type
`ts`
[P, P, P, P]
###### Type
`ts`
Array
###### Type
`ts``
[P, P, P]