# Global

##

### Methods

#### 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:
  - mercator-gl.js, line 92

##### Returns:

Object containing projection uniforms.

Type
  object

#### 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:
  - mercator-gl.js, line 56

##### Returns:

Array containing the low parts of input longitude/latitude data.

Type
  Float32Array

#### 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:
  - mercator-gl.js, line 77

##### Returns:

Source code with the projection functions injected.

Type
  string

#### 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:
  - mercator-gl.js, line 222

##### Returns:

The "out" array provided, containing the results.

Type
  array

#### 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:
  - mercator-gl.js, line 179

##### Returns:

The "out" array provided, containing the results.

Type
  array

#### 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:
  - mercator-gl.js, line 207

##### Returns:

The "out" array provided, containing the results.

Type
  array

#### 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:
  - mercator-gl.js, line 159

##### Returns:

The "out" array provided, containing the results.

Type
  array

#### 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:
  - mercator-gl.js, line 142

##### Returns:

Number of pixels per meter.

Type
  number

#### 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<elevation meters> 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:
  - mercator-gl.js, line 114

##### Returns:

Object containing updated uniforms.

Type
  object