package.geom.flat.inflate.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ol Show documentation
Show all versions of ol Show documentation
OpenLayers mapping library
The newest version!
/**
* @module ol/geom/flat/inflate
*/
/**
* @param {Array} flatCoordinates Flat coordinates.
* @param {number} offset Offset.
* @param {number} end End.
* @param {number} stride Stride.
* @param {Array} [coordinates] Coordinates.
* @return {Array} Coordinates.
*/
export function inflateCoordinates(
flatCoordinates,
offset,
end,
stride,
coordinates,
) {
coordinates = coordinates !== undefined ? coordinates : [];
let i = 0;
for (let j = offset; j < end; j += stride) {
coordinates[i++] = flatCoordinates.slice(j, j + stride);
}
coordinates.length = i;
return coordinates;
}
/**
* @param {Array} flatCoordinates Flat coordinates.
* @param {number} offset Offset.
* @param {Array} ends Ends.
* @param {number} stride Stride.
* @param {Array>} [coordinatess] Coordinatess.
* @return {Array>} Coordinatess.
*/
export function inflateCoordinatesArray(
flatCoordinates,
offset,
ends,
stride,
coordinatess,
) {
coordinatess = coordinatess !== undefined ? coordinatess : [];
let i = 0;
for (let j = 0, jj = ends.length; j < jj; ++j) {
const end = ends[j];
coordinatess[i++] = inflateCoordinates(
flatCoordinates,
offset,
end,
stride,
coordinatess[i],
);
offset = end;
}
coordinatess.length = i;
return coordinatess;
}
/**
* @param {Array} flatCoordinates Flat coordinates.
* @param {number} offset Offset.
* @param {Array>} endss Endss.
* @param {number} stride Stride.
* @param {Array>>} [coordinatesss]
* Coordinatesss.
* @return {Array>>} Coordinatesss.
*/
export function inflateMultiCoordinatesArray(
flatCoordinates,
offset,
endss,
stride,
coordinatesss,
) {
coordinatesss = coordinatesss !== undefined ? coordinatesss : [];
let i = 0;
for (let j = 0, jj = endss.length; j < jj; ++j) {
const ends = endss[j];
coordinatesss[i++] =
ends.length === 1 && ends[0] === offset
? []
: inflateCoordinatesArray(
flatCoordinates,
offset,
ends,
stride,
coordinatesss[i],
);
offset = ends[ends.length - 1];
}
coordinatesss.length = i;
return coordinatesss;
}