transform

geo. transform

new transform(options) → {geo.transform}

Description:
  • This purpose of this class is to provide a generic interface for computing coordinate transformations. The interface is taken from proj4js, which also provides the geospatial projection implementation. The interface is intentionally simple to allow for custom, non-geospatial use cases. For further details, see http://proj4js.org/

    The default transforms lat/long coordinates into web mercator for use with standard tile sets.

    This class is intended to be extended in the future to support 2.5 and 3 dimensional transformations. The forward/inverse methods take optional z values that are ignored in current mapping context, but will in the future perform more general 3D transformations.

Source:
Parameters:
Name Type Description
options object

Constructor options

Properties
Name Type Description
source string

A proj4 string for the source projection

target string

A proj4 string for the target projection

Returns:
Type
geo.transform

Members

(static) defs

Description:
  • Contains a reference to proj4.defs. The functions serves two purposes.

    1. It is a key value mapping of all loaded projection definitions
    2. It is a function that will add additional definitions.

    See: http://proj4js.org/

Source:

Contains a reference to proj4.defs. The functions serves two purposes.

  1. It is a key value mapping of all loaded projection definitions
  2. It is a function that will add additional definitions.

See: http://proj4js.org/

Methods

(protected) forward(point) → {geo.geoPosition|Array.<geo.geoPosition>}

Description:
  • Perform a forward transformation (source -> target) in place.

Source:
Parameters:
Name Type Description
point geo.geoPosition | Array.<geo.geoPosition>

The point coordinates or array of points in source coordinates.

Returns:

A point object or array in the target coordinates.

Type
geo.geoPosition | Array.<geo.geoPosition>

(protected) inverse(point) → {geo.geoPosition|Array.<geo.geoPosition>}

Description:
  • Perform an inverse transformation (target -> source) in place.

Source:
Parameters:
Name Type Description
point geo.geoPosition | Array.<geo.geoPosition>

The point coordinates or array of points in target coordinates.

Returns:

A point object or array in the source coordinates.

Type
geo.geoPosition | Array.<geo.geoPosition>

source(argopt) → {string|this}

Description:
  • Get/Set the source projection.

Source:
Parameters:
Name Type Attributes Description
arg string <optional>

The new source projection. If undefined, return the current source projection.

Returns:

The current source projection if it was queried, otherwise the current transform object.

Type
string | this

target(argopt) → {string|this}

Description:
  • Get/Set the target projection.

Source:
Parameters:
Name Type Attributes Description
arg string <optional>

The new target projection. If undefined, return the current target projection.

Returns:

The current target projection if it was queried, otherwise the current transform object.

Type
string | this

(static) affineForward(def, coords) → {Array.<geo.geoPosition>}

Description:
  • Apply an affine transformation consisting of a translation then a scaling to the given coordinate array. Note, the transformation occurs in place so the input coordinate object are mutated.

Source:
Parameters:
Name Type Description
def object
Properties
Name Type Description
origin geo.geoPosition

The transformed origin

scale object

The transformed scale factor. This is an object with x, y, and z parameters.

coords Array.<geo.geoPosition>

An array of coordinate objects.

Returns:

The transformed coordinates.

Type
Array.<geo.geoPosition>

(static) affineInverse(def, coords) → {Array.<geo.geoPosition>}

Description:
  • Apply an inverse affine transformation which is the inverse to geo.transform.affineForward. Note, the transformation occurs in place so the input coordinate object are mutated.

Source:
Parameters:
Name Type Description
def object
Properties
Name Type Description
origin geo.geoPosition

The transformed origin

scale object

The transformed scale factor. This is an object with x, y, and z parameters.

coords Array.<geo.geoPosition>

An array of coordinate objects.

Returns:

The transformed coordinates.

Type
Array.<geo.geoPosition>

(static) lookup(projection) → {promise}

Description:
  • Look up a projection definition from epsg.io. For the moment, we only handle EPSG codes.

Source:
Parameters:
Name Type Description
projection string

A projection alias (e.g. EPSG:4326)

Returns:

Resolves with the proj4 definition

Type
promise

(static) onlyInvertedY(srcPrj, tgtPrj) → {boolean}

Description:
  • Return a boolean indicating if the projections only differ in their y coordinate.

Source:
Parameters:
Name Type Description
srcPrj string

The source projection.

tgtPrj string

The destination projection.

Returns:

truthy if only the y coordinate is different between projections.

Type
boolean

(static) sphericalDistance(pt1, pt2, gcsopt, baseGcsopt, ellipsoidopt) → {number}

Description:
  • Compute the distance on the surface on a sphere. The sphere is the major radius of a specified ellipsoid. Altitude is ignored.

Source:
Parameters:
Name Type Attributes Default Description
pt1 geo.geoPosition

The first point.

pt2 geo.geoPosition

The second point.

gcs string | geo.transform <optional>

undefined to use the same gcs as the ellipsoid, otherwise the gcs of the points.

baseGcs string | geo.transform <optional>
'EPSG:4326'

the gcs of the ellipsoid.

ellipsoid object <optional>
proj4.WGS84

An object with at least a and one of b, f, or rf (1 / f) -- this works with proj4 ellipsoid definitions.

Returns:

The distance in meters (or whatever units the ellipsoid was specified in.

Type
number

(static) transformCoordinates(srcPrj, tgtPrj, coordinates, numberOfComponentsopt) → {geo.geoPosition|Array.<geo.geoPosition>|Array.<number>}

Description:
  • Transform an array of coordinates from one projection into another. The transformation may occur in place (modifying the input coordinate array), depending on the input format. The coordinates can be an object with x, y, and (optionally z) or an array of 2 or 3 values, or an array of either of those, or a single flat array with 2 or 3 components per coordinate. Arrays are always modified in place. Individual point objects are not altered; new point objects are returned unless no transform is needed.

Source:
Parameters:
Name Type Attributes Description
srcPrj string

The source projection.

tgtPrj string

The destination projection.

coordinates geo.geoPosition | Array.<geo.geoPosition> | Array.<number>

An array of coordinate objects. These may be in object or array form, or a flat array.

numberOfComponents number <optional>

For flat arrays, either 2 or 3.

Returns:

The transformed coordinates.

Type
geo.geoPosition | Array.<geo.geoPosition> | Array.<number>

(static) transformCoordinatesArray(trans, coordinates, numberOfComponents) → {Array.<geo.geoPosition>|Array.<number>}

Description:
  • Transform an array of coordinates from one projection into another. The transformation may occur in place (modifying the input coordinate array), depending on the input format. The coordinates can be an array of 2 or 3 values, or an array of either of those, or a single flat array with 2 or 3 components per coordinate. The array is modified in place.

Source:
Parameters:
Name Type Description
trans transform

The transformation object.

coordinates Array.<geo.geoPosition> | Array.<number>

An array of coordinate objects or a flat array.

numberOfComponents number

For flat arrays, either 2 or 3.

Returns:

The transformed coordinates

Type
Array.<geo.geoPosition> | Array.<number>

(static) transformCoordinatesFlatArray3(srcPrj, tgtPrj, coordinates) → {Array.<number>}

Description:
  • Transform an array of coordinates from one projection into another. The transformation occurs in place, modifying the input coordinate array. The coordinates are an array of [x0, y0, z0, x1, y1, z1, ...].

Source:
Parameters:
Name Type Description
srcPrj string

The source projection.

tgtPrj string

The destination projection. This must not be the same as the source projection.

coordinates Array.<number>

A flat array of values.

Returns:

The transformed coordinates.

Type
Array.<number>

(static) vincentyDistance(pt1, pt2, gcsopt, baseGcsopt, ellipsoidopt, maxIterationsopt) → {object}

Description:
  • Compute the Vincenty distance on the surface on an ellipsoid. Altitude is ignored.

Source:
Parameters:
Name Type Attributes Default Description
pt1 geo.geoPosition

The first point.

pt2 geo.geoPosition

The second point.

gcs string | geo.transform <optional>

undefined to use the same gcs as the ellipsoid, otherwise the gcs of the points.

baseGcs string | geo.transform <optional>
'EPSG:4326'

the gcs of the ellipsoid.

ellipsoid object <optional>
proj4.WGS84

An object with at least a and one of b, f, or rf (1 / f) -- this works with proj4 ellipsoid definitions.

maxIterations number <optional>
100

Maximum number of iterations to use to test convergence.

Returns:

An object with distance in meters (or whatever units the ellipsoid was specified in), alpha1 and alpha2, the azimuths at the two points in radians. The result may be undefined if the formula fails to converge, which can happen near antipodal points.

Type
object

(inner) parse_projection(value) → {object}

Description:
  • Parse a projection string. If the projection string includes any of +s[123][123]= or +[xyz]off=, those values are converted into a matrix and removed from the projection string. This allows applying affine transforms as specified in Proj 6.0.0 to be used (excluding toff and tscale). This could can be removed once proj4js supports the affine parameters.

Source:
Parameters:
Name Type Description
value string

A proj4 string possibly with affine parameters.

Returns:

An object with a string value 'proj' and optional array values 'matrix' and 'inverse' (either both or neither will be present). The returned matrices are always 16-value arrays if present. The proj value is the proj4 string with the affine parameters removed.

Type
object