All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.geom.flat.deflate.js Maven / Gradle / Ivy

The newest version!
/**
 * @module ol/geom/flat/deflate
 */

/**
 * @param {Array} flatCoordinates Flat coordinates.
 * @param {number} offset Offset.
 * @param {import("../../coordinate.js").Coordinate} coordinate Coordinate.
 * @param {number} stride Stride.
 * @return {number} offset Offset.
 */
export function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {
  for (let i = 0, ii = coordinate.length; i < ii; ++i) {
    flatCoordinates[offset++] = coordinate[i];
  }
  return offset;
}

/**
 * @param {Array} flatCoordinates Flat coordinates.
 * @param {number} offset Offset.
 * @param {Array} coordinates Coordinates.
 * @param {number} stride Stride.
 * @return {number} offset Offset.
 */
export function deflateCoordinates(
  flatCoordinates,
  offset,
  coordinates,
  stride,
) {
  for (let i = 0, ii = coordinates.length; i < ii; ++i) {
    const coordinate = coordinates[i];
    for (let j = 0; j < stride; ++j) {
      flatCoordinates[offset++] = coordinate[j];
    }
  }
  return offset;
}

/**
 * @param {Array} flatCoordinates Flat coordinates.
 * @param {number} offset Offset.
 * @param {Array>} coordinatess Coordinatess.
 * @param {number} stride Stride.
 * @param {Array} [ends] Ends.
 * @return {Array} Ends.
 */
export function deflateCoordinatesArray(
  flatCoordinates,
  offset,
  coordinatess,
  stride,
  ends,
) {
  ends = ends ? ends : [];
  let i = 0;
  for (let j = 0, jj = coordinatess.length; j < jj; ++j) {
    const end = deflateCoordinates(
      flatCoordinates,
      offset,
      coordinatess[j],
      stride,
    );
    ends[i++] = end;
    offset = end;
  }
  ends.length = i;
  return ends;
}

/**
 * @param {Array} flatCoordinates Flat coordinates.
 * @param {number} offset Offset.
 * @param {Array>>} coordinatesss Coordinatesss.
 * @param {number} stride Stride.
 * @param {Array>} [endss] Endss.
 * @return {Array>} Endss.
 */
export function deflateMultiCoordinatesArray(
  flatCoordinates,
  offset,
  coordinatesss,
  stride,
  endss,
) {
  endss = endss ? endss : [];
  let i = 0;
  for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {
    const ends = deflateCoordinatesArray(
      flatCoordinates,
      offset,
      coordinatesss[j],
      stride,
      endss[i],
    );
    if (ends.length === 0) {
      ends[0] = offset;
    }
    endss[i++] = ends;
    offset = ends[ends.length - 1];
  }
  endss.length = i;
  return endss;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy