# all files / ol/geom/flat/ center.js

100% Statements 12/12
100% Branches 0/0
100% Functions 1/1
100% Lines 12/12

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    261×

    1×

    1×
    3×
    3×
    3×
    3×
    4×
    4×

    4×
    4×

    3×

     goog.provide('ol.geom.flat.center');

    goog.require('ol.extent');

    /**
     * @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 = ol.extent.createEmpty();
      for (i = 0, ii = endss.length; i < ii; ++i) {
        var ends = endss[i];
        extent = ol.extent.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;
    };