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

96.88% Statements 31/32
75% Branches 9/12
100% Functions 2/2
96.88% Lines 31/32

    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
    661×

    1×

    1×

    68×
    68×
    68×
    68×
    68×
    68×
    68×
    68×
    68×
    68×
    571×
    571×
    571×
    571×

    68×
    1×

    68×

    1×

    2×
    2×
    2×
    2×
    11×
    11×
    11×
    10×

    2×

    2×

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

    goog.require('goog.vec.Mat4');

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {number} end End.
     * @param {number} stride Stride.
     * @param {goog.vec.Mat4.Number} transform Transform.
     * @param {Array.<number>=} opt_dest Destination.
     * @return {Array.<number>} Transformed coordinates.
     */
    ol.geom.flat.transform.transform2D =
        function(flatCoordinates, offset, end, stride, transform, opt_dest) {
      var m00 = goog.vec.Mat4.getElement(transform, 0, 0);
      var m10 = goog.vec.Mat4.getElement(transform, 1, 0);
      var m01 = goog.vec.Mat4.getElement(transform, 0, 1);
      var m11 = goog.vec.Mat4.getElement(transform, 1, 1);
      var m03 = goog.vec.Mat4.getElement(transform, 0, 3);
      var m13 = goog.vec.Mat4.getElement(transform, 1, 3);
      var dest = opt_dest ? opt_dest : [];
      var i = 0;
      var j;
      for (j = offset; j < end; j += stride) {
        var x = flatCoordinates[j];
        var y = flatCoordinates[j + 1];
        dest[i++] = m00 * x + m01 * y + m03;
        dest[i++] = m10 * x + m11 * y + m13;
      }
      if (opt_dest && dest.length != i) {
        dest.length = i;
      }
      return dest;
    };

    /**
     * @param {Array.<number>} flatCoordinates Flat coordinates.
     * @param {number} offset Offset.
     * @param {number} end End.
     * @param {number} stride Stride.
     * @param {number} deltaX Delta X.
     * @param {number} deltaY Delta Y.
     * @param {Array.<number>=} opt_dest Destination.
     * @return {Array.<number>} Transformed coordinates.
     */
    ol.geom.flat.transform.translate =
        function(flatCoordinates, offset, end, stride, deltaX, deltaY, opt_dest) {
      var dest = opt_dest ? opt_dest : [];
      var i = 0;
      var j, k;
      for (j = offset; j < end; j += stride) {
        dest[i++] = flatCoordinates[j] + deltaX;
        dest[i++] = flatCoordinates[j + 1] + deltaY;
        for (k = j + 2; k < j + stride; ++k) {
          dest[i++] = flatCoordinates[k];
        }
      }
      Iif (opt_dest && dest.length != i) {
        dest.length = i;
      }
      return dest;
    };