'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _extent = require('../../extent.js');

var _extent2 = _interopRequireDefault(_extent);

function _interopRequireDefault(obj) {
  return obj && obj.__esModule ? obj : { default: obj };
}

var _ol_geom_flat_center_ = {};

/**
 * @param {Array.<number>} flatCoordinates Flat coordinates.
 * @param {number} offset Offset.
 * @param {Array.<Array.<number>>} endss Endss.
 * @param {number} stride Stride.
 * @return {Array.<number>} Flat centers.
 */
_ol_geom_flat_center_.linearRingss = function (flatCoordinates, offset, endss, stride) {
  var flatCenters = [];
  var i, ii;
  var extent = _extent2.default.createEmpty();
  for (i = 0, ii = endss.length; i < ii; ++i) {
    var ends = endss[i];
    extent = _extent2.default.createOrUpdateFromFlatCoordinates(flatCoordinates, offset, ends[0], stride);
    flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2);
    offset = ends[ends.length - 1];
  }
  return flatCenters;
};
exports.default = _ol_geom_flat_center_;
module.exports = exports['default'];