'use strict';

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

exports['default'] = function (features, delta) {
  features.map(function (feature) {
    var currentCoordinates = feature.getCoordinates();

    var moveCoordinate = function moveCoordinate(coord) {
      var point = {
        lng: coord[0] + delta.lng,
        lat: coord[1] + delta.lat
      };
      return [point.lng, point.lat];
    };
    var moveRing = function moveRing(ring) {
      return ring.map(function (coord) {
        return moveCoordinate(coord);
      });
    };
    var moveMultiPolygon = function moveMultiPolygon(multi) {
      return multi.map(function (ring) {
        return moveRing(ring);
      });
    };

    var nextCoordinates = void 0;
    if (feature.type === _constants2['default'].geojsonTypes.POINT) {
      nextCoordinates = moveCoordinate(currentCoordinates);
    } else if (feature.type === _constants2['default'].geojsonTypes.LINE_STRING || feature.type === _constants2['default'].geojsonTypes.MULTI_POINT) {
      nextCoordinates = currentCoordinates.map(moveCoordinate);
    } else if (feature.type === _constants2['default'].geojsonTypes.POLYGON || feature.type === _constants2['default'].geojsonTypes.MULTI_LINE_STRING) {
      nextCoordinates = currentCoordinates.map(moveRing);
    } else if (feature.type === _constants2['default'].geojsonTypes.MULTI_POLYGON) {
      nextCoordinates = currentCoordinates.map(moveMultiPolygon);
    }

    // 判断是否有圆心属性
    if (feature.center) {
      feature.center = moveCoordinate(feature.center);
    }
    if (feature.properties['draw:center']) {
      var center = feature.properties['draw:center'].split(',');
      center = [Number(center[0]), Number(center[1])];
      center = moveCoordinate(center);
      feature.updateInternalProperty('center', center.join(','));
    }

    feature.incomingCoords(nextCoordinates);
  });
};

var _constants = require('../constants');

var _constants2 = _interopRequireDefault(_constants);

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