Add an ol.coordinate.distance() helper method.
The method is a companion to {@link ol.coordinate.squaredDistance}.
The new method returns the Cartesian distance, instead of its square.
Conflicts:
src/ol/coordinate.js
This commit is contained in:
@@ -250,6 +250,16 @@ ol.coordinate.squaredDistance = function(coord1, coord2) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.Coordinate} coord1 First coordinate.
|
||||||
|
* @param {ol.Coordinate} coord2 Second coordinate.
|
||||||
|
* @return {number} Distance between coord1 and coord2.
|
||||||
|
*/
|
||||||
|
ol.coordinate.distance = function(coord1, coord2) {
|
||||||
|
return Math.sqrt(ol.coordinate.squaredDistance(coord1, coord2));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the squared distance from a coordinate to a line segment.
|
* Calculate the squared distance from a coordinate to a line segment.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user