Methods
(static) allocateMercatorUniforms(uniformsopt) → {object}
Allocate arrays to store projection uniform values. Will add uniforms
to existing object, if provided.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
uniforms |
object |
<optional> |
Optional object containing existing uniforms. |
- Source:
Returns:
Object containing projection uniforms.
- Type
- object
(static) highPrecisionLngLat(lnglat, offset, stride) → {Float32Array}
Create a Float32Array containing the low-part of 64-bit floats. The
low parts can be passed to GLSL projection functions to improve numerical
stability.
Parameters:
Name | Type | Description |
---|---|---|
lnglat |
Float32Array | Array containing longitude latitude data (assumed to be in adjacent elements). |
offset |
number | Offset of the first longitude value from the start of the array. |
stride |
number | Number of elements between each pair of longitude/latitude values. |
- Source:
Returns:
Array containing the low parts of input longitude/latitude data.
- Type
- Float32Array
(static) injectMercatorGLSL(vsSource) → {string}
Inject MercatorGL projection functions in to GLSL vertex shader source string.
Parameters:
Name | Type | Description |
---|---|---|
vsSource |
string | Vertex shader source code. Can be GLSL 1 or 3. |
- Source:
Returns:
Source code with the projection functions injected.
- Type
- string
(static) lngLatToClip(out, lngLat, viewProjectionMatrix) → {array}
Transform a 2d longitude/latitude point to clip space to clip space.
Parameters:
Name | Type | Description |
---|---|---|
out |
array | 4-element array into which the results will be written. |
lngLat |
array | Longitude/latitude coordinate. |
viewProjectionMatrix |
array | 4x4 matrix to transform from mercator space to clip space. |
- Source:
Returns:
The "out" array provided, containing the results.
- Type
- array
(static) lngLatToMercator(out, lngLat, zoom) → {array}
Transform a longitude/latitude point to a 4d homegeneous coordinate in Mercator space.
Parameters:
Name | Type | Description |
---|---|---|
out |
array | 4-element array into which the results will be written. |
lngLat |
array | Longitude/latitude coordinate. |
zoom |
number | Current mercator zoom level. |
- Source:
Returns:
The "out" array provided, containing the results.
- Type
- array
(static) mercatorToClip(out, mercatorPosition, viewProjectionMatrix) → {array}
Transform a homegeneous 4d representation of a mercator point on the plane
(x, y, 0, 1) to clip space.
Parameters:
Name | Type | Description |
---|---|---|
out |
array | 4-element array into which the results will be written. |
mercatorPosition |
array | Homegeneous 4d coordinate on the mercator plane. |
viewProjectionMatrix |
array | 4x4 matrix to transform from mercator space to clip space. |
- Source:
Returns:
The "out" array provided, containing the results.
- Type
- array
(static) pixelsPerDegree(out, latitude, zoom) → {array}
Mercator pixels/degree of longitude and latitude at the current latitude and zoom level (using 512x512 tile size).
Parameters:
Name | Type | Description |
---|---|---|
out |
array | Two-element array into which the results will be written. |
latitude |
number | Current latitude of the camera center. |
zoom |
number | Current mercator zoom level. |
- Source:
Returns:
The "out" array provided, containing the results.
- Type
- array
(static) pixelsPerMeter(latitude, zoom) → {number}
Mercator pixels/meter at the current latitude and zoom level (using 512x512 tile size).
Parameters:
Name | Type | Description |
---|---|---|
latitude |
number | Current latitude of the camera center. |
zoom |
number | Current mercator zoom level. |
- Source:
Returns:
Number of pixels per meter.
- Type
- number
(static) updateMercatorUniforms(uniforms, lngLat, zoom, viewProjectionMatrix) → {object}
Update projection uniforms based on current mercator settings and provided
view-projection matrix. The view projection matrix is expected to project from
a 512x512x mercator space to clip space.
Parameters:
Name | Type | Description |
---|---|---|
uniforms |
object | Object containing existing uniforms. |
lngLat |
array | Current camera center as a 2-element longitude/latitude array. |
zoom |
number | Current mercator zoom level. |
viewProjectionMatrix |
array | 4x4 matrix to transform from mercator space to clip space. |
- Source:
Returns:
Object containing updated uniforms.
- Type
- object