ol/geom/flat/length export
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
/**
|
||||
* @module ol/geom/flat/length
|
||||
*/
|
||||
const _ol_geom_flat_length_ = {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,7 +10,7 @@ const _ol_geom_flat_length_ = {};
|
||||
* @param {number} stride Stride.
|
||||
* @return {number} Length.
|
||||
*/
|
||||
_ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride) {
|
||||
export function lineStringLength(flatCoordinates, offset, end, stride) {
|
||||
let x1 = flatCoordinates[offset];
|
||||
let y1 = flatCoordinates[offset + 1];
|
||||
let length = 0;
|
||||
@@ -23,7 +22,7 @@ _ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride
|
||||
y1 = y2;
|
||||
}
|
||||
return length;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,11 +32,10 @@ _ol_geom_flat_length_.lineString = function(flatCoordinates, offset, end, stride
|
||||
* @param {number} stride Stride.
|
||||
* @return {number} Perimeter.
|
||||
*/
|
||||
_ol_geom_flat_length_.linearRing = function(flatCoordinates, offset, end, stride) {
|
||||
let perimeter = _ol_geom_flat_length_.lineString(flatCoordinates, offset, end, stride);
|
||||
export function linearRingLength(flatCoordinates, offset, end, stride) {
|
||||
let perimeter = lineStringLength(flatCoordinates, offset, end, stride);
|
||||
const dx = flatCoordinates[end - stride] - flatCoordinates[offset];
|
||||
const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];
|
||||
perimeter += Math.sqrt(dx * dx + dy * dy);
|
||||
return perimeter;
|
||||
};
|
||||
export default _ol_geom_flat_length_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user