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

100% Statements 37/37
75% Branches 3/4
100% Functions 4/4
100% Lines 37/37

    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
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    941×

    1×

    1×

    508×

    508×
    508×
    1082×

    508×

    1×

    1953×
    1953×
    74686×
    74686×

    74686×
    74686×
    151057×

    1953×

    1×

    1365×
    1365×
    1365×
    1365×
    1582×

    1582×
    1582×

    1365×
    1365×

    1×

    99×
    99×
    99×
    99×
    470×

    470×
    470×

    99×
    99×

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

    goog.require('goog.asserts');

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {ol.Coordinate} coordinate Coordinate.
     * @param {number} stride Stride.
     * @return {number} offset Offset.
     */
    ol.geom.flat.deflate.coordinate =
        function(flatCoordinates, offset, coordinate, stride) {
      goog.asserts.assert(coordinate.length == stride,
          'length of the coordinate array should match stride');
      var i, ii;
      for (i = 0, ii = coordinate.length; i < ii; ++i) {
        flatCoordinates[offset++] = coordinate[i];
      }
      return offset;
    };

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {Array.<ol.Coordinate>} coordinates Coordinates.
     * @param {number} stride Stride.
     * @return {number} offset Offset.
     */
    ol.geom.flat.deflate.coordinates =
        function(flatCoordinates, offset, coordinates, stride) {
      var i, ii;
      for (i = 0, ii = coordinates.length; i < ii; ++i) {
        var coordinate = coordinates[i];
        goog.asserts.assert(coordinate.length == stride,
            'length of coordinate array should match stride');
        var j;
        for (j = 0; j < stride; ++j) {
          flatCoordinates[offset++] = coordinate[j];
        }
      }
      return offset;
    };

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {Array.<Array.<ol.Coordinate>>} coordinatess Coordinatess.
     * @param {number} stride Stride.
     * @param {Array.<number>=} opt_ends Ends.
     * @return {Array.<number>} Ends.
     */
    ol.geom.flat.deflate.coordinatess =
        function(flatCoordinates, offset, coordinatess, stride, opt_ends) {
      var ends = opt_ends ? opt_ends : [];
      var i = 0;
      var j, jj;
      for (j = 0, jj = coordinatess.length; j < jj; ++j) {
        var end = ol.geom.flat.deflate.coordinates(
            flatCoordinates, offset, coordinatess[j], stride);
        ends[i++] = end;
        offset = end;
      }
      ends.length = i;
      return ends;
    };

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {Array.<Array.<Array.<ol.Coordinate>>>} coordinatesss Coordinatesss.
     * @param {number} stride Stride.
     * @param {Array.<Array.<number>>=} opt_endss Endss.
     * @return {Array.<Array.<number>>} Endss.
     */
    ol.geom.flat.deflate.coordinatesss =
        function(flatCoordinates, offset, coordinatesss, stride, opt_endss) {
      var endss = opt_endss ? opt_endss : [];
      var i = 0;
      var j, jj;
      for (j = 0, jj = coordinatesss.length; j < jj; ++j) {
        var ends = ol.geom.flat.deflate.coordinatess(
            flatCoordinates, offset, coordinatesss[j], stride, endss[i]);
        endss[i++] = ends;
        offset = ends[ends.length - 1];
      }
      endss.length = i;
      return endss;
    };