Projection package cartesian-projection
Class: Cartesian
Creates a projection of a rectangular coordinate area into world coordinates.
The area size in pixels is always 2*2.
Name
Cartesian
Param
An array of two points -
coordinates of the lower left and upper right corners of the rectangular coordinate area.
Param
false]] An array of signs of map looping by x and y.
Example
mappable.ready(async () => {
    const {MMaps} = mappable;
    // Calculate the size of all tiles at the maximum zoom.
    const worldSize = Math.pow(2, MAX_ZOOM) * 256;
    const PIC_WIDTH = 2526;
    const PIC_HEIGHT = 1642;
    const {Cartesian} = await mappable.import('@mappable-world/mappable-cartesian-projection@0.0.1');
    // We set as a projection Cartesian. With this calculation, the center of the image will lie in the coordinates [0, 0].
    const projection = new Cartesian([
        [-PIC_WIDTH / 2, PIC_HEIGHT / 2 - worldSize],
        [worldSize - PIC_WIDTH / 2, PIC_HEIGHT / 2],
    ]);
    const map = new MMaps({
        //...,
        projection: projection
    });
});
Implements
Constructors
constructor
new Cartesian(bounds, cycled?)
Parameters
| Name | Type | 
|---|---|
bounds | 
[LngLat, LngLat] | 
cycled? | 
[boolean, boolean] | 
Properties
type
readonly type: "cartesian"
Implementation of
Projection.type
Methods
fromWorldCoordinates
fromWorldCoordinates(point): LngLat
Parameters
| Name | Type | 
|---|---|
point | 
WorldCoordinates | 
Returns
Implementation of
Projection.fromWorldCoordinates
toWorldCoordinates
toWorldCoordinates(point): WorldCoordinates
Parameters
| Name | Type | 
|---|---|
point | 
LngLat | 
Returns
Implementation of
Projection.toWorldCoordinates
Interface: GenericProjection<TSource>
Type parameters
| Name | 
|---|
TSource | 
Properties
type
optional readonly type: string
Projection identity type. It may be:
- EPSG-code (e.g. EPSG:3857)
 - any other string to identify (e.g. 'cartesian')
 
Methods
fromWorldCoordinates
fromWorldCoordinates(coordinates): TSource
Parameters
| Name | Type | 
|---|---|
coordinates | 
WorldCoordinates | 
Returns
TSource
toWorldCoordinates
toWorldCoordinates(point): WorldCoordinates
Parameters
| Name | Type | 
|---|---|
point | 
TSource | 
Returns
Interface: Vec2
Properties
x
x: number
y
y: number
Interface: WorldCoordinates
Coordinates in [-1 ... +1].
Left bottom is (-1; -1).
Right top is (+1; +1).
Center is (0; 0).
Properties
type
optional readonly type: "world"
x
x: number
Inherited from
y
y: number
Inherited from
z
optional z: number
Module: <internal>
Type Aliases
LngLat
LngLat: [lon: number, lat: number, alt?: number]
Tuple with geodesic coordinates in longitude latitude order.
GeoJSON also uses this order https://tools.ietf.org/html/rfc7946#appendix-A.1
Projection
Projection: GenericProjection<LngLat>