'use strict';

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

var _feature = require('./feature');

var _feature2 = _interopRequireDefault(_feature);

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

var LineString = function LineString(ctx, geojson) {
  _feature2['default'].call(this, ctx, geojson);
}; /**
    * @文件说明: 定义LineString要素对象
    * @创建人: pjtools@vip.qq.com
    * @创建时间: 2020-05-27 18:34:13
    */

LineString.prototype = Object.create(_feature2['default'].prototype);

LineString.prototype.isValid = function () {
  return this.coordinates.length > 1;
};

LineString.prototype.addCoordinate = function (path, lng, lat) {
  this.changed();
  var id = parseInt(path, 10);
  this.coordinates.splice(id, 0, [lng, lat]);
};

LineString.prototype.getCoordinate = function (path) {
  var id = parseInt(path, 10);
  return JSON.parse(JSON.stringify(this.coordinates[id]));
};

LineString.prototype.removeCoordinate = function (path) {
  this.changed();
  this.coordinates.splice(parseInt(path, 10), 1);
};

LineString.prototype.updateCoordinate = function (path, lng, lat) {
  var id = parseInt(path, 10);
  this.coordinates[id] = [lng, lat];
  this.changed();
};

exports['default'] = LineString;