|
@@ -11,6 +11,8 @@ import * as Cesium from 'cesium';
|
|
import * as turf from '@turf/turf'
|
|
import * as turf from '@turf/turf'
|
|
/* 引入墙的材质 */
|
|
/* 引入墙的材质 */
|
|
import WallMaterialProperty from './WallMaterialProperty.js'
|
|
import WallMaterialProperty from './WallMaterialProperty.js'
|
|
|
|
+/* 引入动态圆材质 */
|
|
|
|
+import CircleMaterialProperty from './CircleMaterialProperty.js'
|
|
|
|
|
|
/* 扩展 Cesium.GroundPrimitive 给其添加objId属性*/
|
|
/* 扩展 Cesium.GroundPrimitive 给其添加objId属性*/
|
|
|
|
|
|
@@ -1426,9 +1428,123 @@ class SketchViewModel {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 创建墙
|
|
|
|
|
|
+ * 创建动态圆
|
|
|
|
+ * @param {Cesium.Cartesian3} centerPosition 圆的中心点位置
|
|
|
|
+ */
|
|
|
|
+ _createDynamicCircle(centerPosition) {
|
|
|
|
+ let _self = this;
|
|
|
|
+ /* 动态扩散材质 */
|
|
|
|
+ let wallMaterial = new CircleMaterialProperty({
|
|
|
|
+ viewer: _self._viewer,
|
|
|
|
+ duration: 2000,
|
|
|
|
+ color: _self._toColor(0, 255, 0, 0.6),
|
|
|
|
+ param: {
|
|
|
|
+ count: 3.0,
|
|
|
|
+ direction: 'horizontalA',
|
|
|
|
+ order: '-'
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ /* 存储椭圆中心点位置 */
|
|
|
|
+ this._sketchEllipseCenterPosition = centerPosition.clone();
|
|
|
|
+ /* 创建圆实体 */
|
|
|
|
+ let dynamicCircleEntity = new Cesium.Entity({
|
|
|
|
+ name: _self._sketchEntityName,
|
|
|
|
+ position: centerPosition,
|
|
|
|
+ ellipse: {
|
|
|
|
+ show: true,
|
|
|
|
+ semiMinorAxis: new Cesium.CallbackProperty(_self._callUpdateEllipseMinorAxis(_self
|
|
|
|
+ ._sketchTempPoints), false),
|
|
|
|
+ semiMajorAxis: new Cesium.CallbackProperty(_self._callUpdateEllipseMinorAxis(_self
|
|
|
|
+ ._sketchTempPoints), false),
|
|
|
|
+ material: wallMaterial,
|
|
|
|
+ classificationType: Cesium.ClassificationType.BOTH,
|
|
|
|
+ },
|
|
|
|
+ })
|
|
|
|
+ /* 加入集合 */
|
|
|
|
+ this._sketchCircle = this._entities.add(dynamicCircleEntity);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 更新动态圆
|
|
|
|
+ * @param {Boolean} isEdit [是否可编辑] 可选
|
|
*/
|
|
*/
|
|
- _createNormalWall() {
|
|
|
|
|
|
+ _updateDynamicCircle(isEdit) {
|
|
|
|
+ let _self = this;
|
|
|
|
+ /* 更新位置 */
|
|
|
|
+ this._sketchCircle.position = this._sketchEllipseCenterPosition;
|
|
|
|
+ this._sketchCircle.ellipse.semiMinorAxis = this._sketchEllipseRadius;
|
|
|
|
+ this._sketchCircle.ellipse.semiMajorAxis = this._sketchEllipseRadius;
|
|
|
|
+ /* 设置是否可编辑 */
|
|
|
|
+ if (isEdit != undefined && isEdit === true) {
|
|
|
|
+ this._setEntityIsEdit(this._sketchCircle);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 文字材质
|
|
|
|
+ * @param {JSON} options 配置项
|
|
|
|
+ * @param {String} options.text 文字内容
|
|
|
|
+ * @param {String} options.color 文字颜色 rgba(r,g,b,a)
|
|
|
|
+ */
|
|
|
|
+ _materialTextImageProperty(options) {
|
|
|
|
+ this._canvasId = 'canvasJt';
|
|
|
|
+ /* 获取画布 */
|
|
|
|
+ let canvasObj = document.getElementById(this._canvasId);
|
|
|
|
+ /* 如果画�������已经存在则删除 */
|
|
|
|
+ if (canvasObj != null) {
|
|
|
|
+ document.body.removeChild(canvasObj);
|
|
|
|
+ }
|
|
|
|
+ /* 创建画布 */
|
|
|
|
+ canvasObj = document.createElement('canvas');
|
|
|
|
+ canvasObj.id = this._canvasId;
|
|
|
|
+ /* 设置画布尺寸 */
|
|
|
|
+ canvasObj.setAttribute('width', '1024px');
|
|
|
|
+ canvasObj.setAttribute('height', '256px');
|
|
|
|
+ /* 加入画布 */
|
|
|
|
+ document.body.appendChild(canvasObj);
|
|
|
|
+ /* 获取上下文绘制 */
|
|
|
|
+ let context = canvasObj.getContext('2d');
|
|
|
|
+ context.fillStyle = options.color === undefined ? 'rgba(255,0,0,1)' : options.color;
|
|
|
|
+ context.font = 'bold 240px 微软雅黑';
|
|
|
|
+ context.textAlign = 'left';
|
|
|
|
+ context.textBaseline = 'bottom';
|
|
|
|
+ context.fillText(options.text, 12, 250, 1000);
|
|
|
|
+ /* 创建材质 */
|
|
|
|
+ let textMaterial = new Cesium.ImageMaterialProperty({
|
|
|
|
+ image: canvasObj, //'/img/text.png',
|
|
|
|
+ transparent: true,
|
|
|
|
+ });
|
|
|
|
+ textMaterial._param = {
|
|
|
|
+ color: context.fillStyle,
|
|
|
|
+ text: options.text,
|
|
|
|
+ }
|
|
|
|
+ // var base64Data = canvasObj.toDataURL("image/jpeg", 1);
|
|
|
|
+ /* 返回材质 */
|
|
|
|
+ return textMaterial;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 颜色材质
|
|
|
|
+ * @param {JSON} options 配置项
|
|
|
|
+ * @param {String} options.color 文字颜色 rgba(r,g,b,a)
|
|
|
|
+ */
|
|
|
|
+ _materialColorProperty(options) {
|
|
|
|
+ let mColor = 'rgba(0,255,0,1)';
|
|
|
|
+ if (options !== undefined && options.color !== undefined) mColor = options.color;
|
|
|
|
+ /* 创建材质 */
|
|
|
|
+ let colorMaterial = new Cesium.ColorMaterialProperty(Cesium.Color.fromCssColorString(mColor));
|
|
|
|
+ colorMaterial._param = {
|
|
|
|
+ color: mColor,
|
|
|
|
+ }
|
|
|
|
+ /* 返回材质 */
|
|
|
|
+ return colorMaterial;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 绘制墙
|
|
|
|
+ * @param {SketchViewModel.SketchWallType} wallType 墙的类型
|
|
|
|
+ */
|
|
|
|
+ _createNormalWall(wallType) {
|
|
let _self = this;
|
|
let _self = this;
|
|
/* 创建墙的材质 */
|
|
/* 创建墙的材质 */
|
|
let wallMaterial = new WallMaterialProperty({
|
|
let wallMaterial = new WallMaterialProperty({
|
|
@@ -1442,13 +1558,18 @@ class SketchViewModel {
|
|
order: '-'
|
|
order: '-'
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
- // let wallMaterial = new Cesium.ImageMaterialProperty({
|
|
|
|
- // image: '/img/text.png',
|
|
|
|
- // transparent: true,
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ if (wallType !== undefined && wallType === SketchViewModel.SketchWallType.Text) {
|
|
|
|
+ wallMaterial = this._materialTextImageProperty({
|
|
|
|
+ color: 'rgba(255,255,0,0.75)',
|
|
|
|
+ text: '立体广告牌',
|
|
|
|
+ })
|
|
|
|
+ } else if (wallType !== undefined && wallType === SketchViewModel.SketchWallType.ColorWall) {
|
|
|
|
+ console.log("===>>>", '')
|
|
|
|
+ wallMaterial = this._materialColorProperty({
|
|
|
|
+ color: 'rgba(0,255,0,0.75)',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ console.log('===>>>材质', wallMaterial);
|
|
/* 创建墙 */
|
|
/* 创建墙 */
|
|
let normalWall = new Cesium.Entity({
|
|
let normalWall = new Cesium.Entity({
|
|
name: _self._sketchEntityName,
|
|
name: _self._sketchEntityName,
|
|
@@ -1477,7 +1598,7 @@ class SketchViewModel {
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更新墙的动态属性为固定属性
|
|
* 更新墙的动态属性为固定属性
|
|
- * @param {Boolean} isEdit [是否可编辑]可选
|
|
|
|
|
|
+ * @param {Boolean} isEdit [是否可编���]可选
|
|
*/
|
|
*/
|
|
_updateNormalWall(isEdit) {
|
|
_updateNormalWall(isEdit) {
|
|
/* 获取三个数组的长度 */
|
|
/* 获取三个数组的长度 */
|
|
@@ -2390,6 +2511,64 @@ Object.assign(SketchViewModel.prototype, {
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 绘制动态圆
|
|
|
|
+ * @param {Object} handler 事件句柄
|
|
|
|
+ * @param {JSON} options 配置项
|
|
|
|
+ * @param {Function} [options.onAdded(center)] 添加回调 可选
|
|
|
|
+ * @param {Function} [options.onComplete(center,radius)] 完成回调 可选
|
|
|
|
+ * @param {Function} [options.onError(message)] 错误回到 可选
|
|
|
|
+ */
|
|
|
|
+ _sketchDrawDynamicCircle: function(handler, options) {
|
|
|
|
+ let _self = this;
|
|
|
|
+ /* 注册鼠标左键单击事件 */
|
|
|
|
+ this._registerLeftClickEvent(handler, function(event) {
|
|
|
|
+ if (_self._sketchTempPoints.length === 0) {
|
|
|
|
+ /* 识别屏幕位置 */
|
|
|
|
+ let loc = _self._transfromFromScreenPoint(event.position);
|
|
|
|
+ if (!Cesium.defined(loc.sLocation)) return;
|
|
|
|
+ /* 绘制点 */
|
|
|
|
+ if (_self._isDrawPoint) {
|
|
|
|
+ _self._createPoint(loc.sLocation, '起点');
|
|
|
|
+ }
|
|
|
|
+ /* 添加数据 */
|
|
|
|
+ _self._sketchTempPoints.push(loc.sLocation.clone());
|
|
|
|
+ _self._sketchTempPoints.push(loc.sLocation); //凑数的
|
|
|
|
+ /* 存储正式绘制点集合 */
|
|
|
|
+ _self._sketchPoints.push(loc.sLocation.clone());
|
|
|
|
+ /* 存储经纬度 */
|
|
|
|
+ _self._sketchOutputPoints.push(loc.gLocation);
|
|
|
|
+ /* 创建圆 */
|
|
|
|
+ _self._createDynamicCircle(loc.sLocation);
|
|
|
|
+ /* 监听输出 */
|
|
|
|
+ if (options.onAdded) options.onAdded(loc.sLocation);
|
|
|
|
+ } else {
|
|
|
|
+ /* 删除标记点 */
|
|
|
|
+ _self._removePointEntitys();
|
|
|
|
+ /* 删除临时圆 */
|
|
|
|
+ _self._removeEntityByObject(_self._sketchTempCircle);
|
|
|
|
+ /* 创建正式圆 */
|
|
|
|
+ _self._updateDynamicCircle(options.isEdit);
|
|
|
|
+ /* 干掉事件句柄 释放资源*/
|
|
|
|
+ _self._clearEvent(handler);
|
|
|
|
+ /* 回调返回 */
|
|
|
|
+ if (options.onComplete) options.onComplete(_self._sketchOutputPoints[0], _self
|
|
|
|
+ ._sketchEllipseRadius);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ /* 注册鼠标移动事件 */
|
|
|
|
+ this._registerMouseMoveEvent(handler, function(event) {
|
|
|
|
+ /* 如果还未创建圆 则直接返回 */
|
|
|
|
+ if (_self._sketchPoints.length < 1) return;
|
|
|
|
+ /* 获取空间位置 */
|
|
|
|
+ var cartesian = _self._viewer.scene.pickPosition(event.endPosition);
|
|
|
|
+ /* 如果获取点失败 则直接返回 */
|
|
|
|
+ if (cartesian == undefined) return;
|
|
|
|
+ _self._sketchTempPoints.pop();
|
|
|
|
+ _self._sketchTempPoints.push(cartesian);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 绘制高度线
|
|
* 绘制高度线
|
|
* @param {Object} handler 事件句柄
|
|
* @param {Object} handler 事件句柄
|
|
* @param {JSON} options 配置项
|
|
* @param {JSON} options 配置项
|
|
@@ -2725,6 +2904,8 @@ Object.assign(SketchViewModel.prototype, {
|
|
* 绘制普通墙
|
|
* 绘制普通墙
|
|
* @param {Object} handler 事件句柄
|
|
* @param {Object} handler 事件句柄
|
|
* @param {JSON} options 配置项
|
|
* @param {JSON} options 配置项
|
|
|
|
+ * @param {Boolean} options.isEdit [是否可编辑 可选]
|
|
|
|
+ * @param {SketchViewModel.SketchWallType} options.wallType [绘制墙的类型 可选]
|
|
* @param {Function} [options.onMoving(cPoint)] 移动回调 可选
|
|
* @param {Function} [options.onMoving(cPoint)] 移动回调 可选
|
|
* @param {Function} [options.onComplete(positions)] 完成回调 可选
|
|
* @param {Function} [options.onComplete(positions)] 完成回调 可选
|
|
* @param {Function} [options.onError(message)] 错误回到 可选
|
|
* @param {Function} [options.onError(message)] 错误回到 可选
|
|
@@ -2742,7 +2923,7 @@ Object.assign(SketchViewModel.prototype, {
|
|
}
|
|
}
|
|
/* 第一点击的时候绘制线 */
|
|
/* 第一点击的时候绘制线 */
|
|
if (_self._sketchTempPoints.length === 0) {
|
|
if (_self._sketchTempPoints.length === 0) {
|
|
- _self._createNormalWall();
|
|
|
|
|
|
+ _self._createNormalWall(options.wallType);
|
|
_self._sketchTempPoints.push(loc.sLocation.clone());
|
|
_self._sketchTempPoints.push(loc.sLocation.clone());
|
|
/* 存储墙的高度点集合 */
|
|
/* 存储墙的高度点集合 */
|
|
_self._sketchWallHeights.push(loc.gLocation.height);
|
|
_self._sketchWallHeights.push(loc.gLocation.height);
|
|
@@ -2849,6 +3030,9 @@ Object.assign(SketchViewModel.prototype, {
|
|
case SketchViewModel.SketchType.Wall:
|
|
case SketchViewModel.SketchType.Wall:
|
|
_self._sketchDrawNormalWall(_self._sketchEventHandler, options);
|
|
_self._sketchDrawNormalWall(_self._sketchEventHandler, options);
|
|
break;
|
|
break;
|
|
|
|
+ case SketchViewModel.SketchType.DynamicCircle:
|
|
|
|
+ _self._sketchDrawDynamicCircle(_self._sketchEventHandler, options);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -3034,15 +3218,104 @@ Object.assign(SketchViewModel.prototype, {
|
|
if (feature.id instanceof Cesium.Entity && feature.id.getIsEdit() === true) {
|
|
if (feature.id instanceof Cesium.Entity && feature.id.getIsEdit() === true) {
|
|
/* 获取可编辑实体的类型 */
|
|
/* 获取可编辑实体的类型 */
|
|
let editEntityType = feature.id.getEntityType();
|
|
let editEntityType = feature.id.getEntityType();
|
|
- console.log('===编辑实体的类型', editEntityType);
|
|
|
|
|
|
+ if (editEntityType === SketchViewModel.SketchEntityType.Wall) {
|
|
|
|
+ /* 获取绘制墙的材质 */
|
|
|
|
+ let wallMaterial = feature.id.wall.material;
|
|
|
|
+ /* 获取参数 */
|
|
|
|
+ let param = feature.id.wall.material._param;
|
|
|
|
+ /* 获取墙的高度 */
|
|
|
|
+ let wallHeight = (feature.id.wall.maximumHeights._value[0] - feature.id.wall
|
|
|
|
+ .minimumHeights._value[0]).toFixed(2);
|
|
|
|
+ if (wallMaterial instanceof Cesium.ImageMaterialProperty) {
|
|
|
|
+ if (_self.onEditWall) _self.onEditWall({
|
|
|
|
+ id: 'TextMaterial',
|
|
|
|
+ height: wallHeight,
|
|
|
|
+ color: param.color,
|
|
|
|
+ count: 0,
|
|
|
|
+ direction: 'v',
|
|
|
|
+ order: '-',
|
|
|
|
+ text: param.text,
|
|
|
|
+ })
|
|
|
|
+ } else if (wallMaterial instanceof WallMaterialProperty) {
|
|
|
|
+ if (_self.onEditWall) _self.onEditWall({
|
|
|
|
+ id: 'WallMaterial',
|
|
|
|
+ height: wallHeight,
|
|
|
|
+ color: param.color,
|
|
|
|
+ count: param.count,
|
|
|
|
+ direction: param.direction,
|
|
|
|
+ order: param.order,
|
|
|
|
+ text: '',
|
|
|
|
+ })
|
|
|
|
+ } else if (wallMaterial instanceof Cesium.ColorMaterialProperty) {
|
|
|
|
+ if (_self.onEditWall) _self.onEditWall({
|
|
|
|
+ id: 'ColorMaterial',
|
|
|
|
+ height: wallHeight,
|
|
|
|
+ color: param.color,
|
|
|
|
+ count: 0,
|
|
|
|
+ direction: 'v',
|
|
|
|
+ order: '-',
|
|
|
|
+ text: '',
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
_self._unActivateEdit();
|
|
_self._unActivateEdit();
|
|
_self._activateEdit(feature.id);
|
|
_self._activateEdit(feature.id);
|
|
|
|
+ } else {
|
|
|
|
+ _self._unActivateEdit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 更新当前编辑的实体墙/立体广告牌
|
|
|
|
+ * @param {Object} params
|
|
|
|
+ */
|
|
|
|
+ updateEditEntityWall: function(params) {
|
|
|
|
+ let _self = this;
|
|
|
|
+ console.log('===最终传入的参数', params);
|
|
|
|
+ if (this._editEntity == undefined || this._editEntity.getEntityType() != SketchViewModel
|
|
|
|
+ .SketchEntityType.Wall) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ let minHeights = this._editEntity.wall.minimumHeights._value;
|
|
|
|
+ let maxHeights = [];
|
|
|
|
+ for (let i = 0; i < minHeights.length; i++) {
|
|
|
|
+ maxHeights.push(minHeights[i] + parseFloat(params.height));
|
|
|
|
+ }
|
|
|
|
+ /* 设置墙的最大高度 */
|
|
|
|
+ this._editEntity.wall.maximumHeights = maxHeights;
|
|
|
|
+ /* 更改存储墙的最大高度的数组 */
|
|
|
|
+ this._sketchWallMaxHeights = maxHeights;
|
|
|
|
+ /* 根据传入的参数id判断需要搞什���材质 */
|
|
|
|
+ let wallMaterial = undefined;
|
|
|
|
+ if (params.id === 'TextMaterial') {
|
|
|
|
+ wallMaterial = this._materialTextImageProperty({
|
|
|
|
+ color: params.color,
|
|
|
|
+ text: params.text,
|
|
|
|
+ })
|
|
|
|
+ } else if (params.id === 'WallMaterial') {
|
|
|
|
+ wallMaterial = new WallMaterialProperty({
|
|
|
|
+ viewer: _self._viewer,
|
|
|
|
+ trailImage: '/img/image.png',
|
|
|
|
+ duration: 1500,
|
|
|
|
+ color: Cesium.Color.fromCssColorString(params.color),
|
|
|
|
+ param: {
|
|
|
|
+ count: parseFloat(params.count),
|
|
|
|
+ direction: params.direction,
|
|
|
|
+ order: params.order
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else if (params.id === 'ColorMaterial') {
|
|
|
|
+ wallMaterial = this._materialColorProperty({
|
|
|
|
+ color: params.color,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this._editEntity.wall.material = wallMaterial;
|
|
|
|
+ console.log(this._editEntity);
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 判断并设置实体的数据类型
|
|
* 判断并设置实体的数据类型
|
|
* @param {Cesium.Entity} entity 实体
|
|
* @param {Cesium.Entity} entity 实体
|
|
* @return {Array<Cesium.Cartesian3>} positions
|
|
* @return {Array<Cesium.Cartesian3>} positions
|
|
@@ -3079,7 +3352,7 @@ Object.assign(SketchViewModel.prototype, {
|
|
return [centerPosition, cbPoint];
|
|
return [centerPosition, cbPoint];
|
|
} else if (entity.wall != undefined) {
|
|
} else if (entity.wall != undefined) {
|
|
entity.setEntityType(SketchViewModel.SketchEntityType.Wall);
|
|
entity.setEntityType(SketchViewModel.SketchEntityType.Wall);
|
|
- /* 存储墙的最大高度和最小高度数组 */
|
|
|
|
|
|
+ /* 存储墙���最大高度���最小高度数组 */
|
|
this._sketchWallHeights = [];
|
|
this._sketchWallHeights = [];
|
|
this._sketchWallMaxHeights = [];
|
|
this._sketchWallMaxHeights = [];
|
|
let minHeights = entity.wall.minimumHeights._value;
|
|
let minHeights = entity.wall.minimumHeights._value;
|
|
@@ -3165,7 +3438,7 @@ Object.assign(SketchViewModel.prototype, {
|
|
_calculateTransformPosition: function(position, distance, bearing, options) {
|
|
_calculateTransformPosition: function(position, distance, bearing, options) {
|
|
/* 将移动点转换为经纬度格式 */
|
|
/* 将移动点转换为经纬度格式 */
|
|
let geoPoint = this._cartesian3ToGeo(position);
|
|
let geoPoint = this._cartesian3ToGeo(position);
|
|
- /* 根据点、角度、距离计算移动后的位置 */
|
|
|
|
|
|
+ /* 根据点的角度、距离计算移动后的位置 */
|
|
let point = turf.point([geoPoint.longitude, geoPoint.latitude]);
|
|
let point = turf.point([geoPoint.longitude, geoPoint.latitude]);
|
|
let resPoint = turf.destination(point, distance, bearing, options).geometry
|
|
let resPoint = turf.destination(point, distance, bearing, options).geometry
|
|
.coordinates;
|
|
.coordinates;
|
|
@@ -3200,7 +3473,8 @@ Object.assign(SketchViewModel.prototype, {
|
|
/* 赋值可编辑对象 */
|
|
/* 赋值可编辑对象 */
|
|
this._editEntity = editEntity;
|
|
this._editEntity = editEntity;
|
|
/* 创建节点和中心点 */
|
|
/* 创建节点和中心点 */
|
|
- if (entityType === SketchViewModel.SketchEntityType.Circle) {
|
|
|
|
|
|
+ if (entityType === SketchViewModel.SketchEntityType.Circle || entityType === SketchViewModel
|
|
|
|
+ .SketchEntityType.DynamicCircle) {
|
|
this._createEditCenterPoint(positions[0]);
|
|
this._createEditCenterPoint(positions[0]);
|
|
this._createEditNodePoint(positions, 1);
|
|
this._createEditNodePoint(positions, 1);
|
|
} else if (entityType === SketchViewModel.SketchEntityType.Polyline || entityType ===
|
|
} else if (entityType === SketchViewModel.SketchEntityType.Polyline || entityType ===
|
|
@@ -3212,14 +3486,14 @@ Object.assign(SketchViewModel.prototype, {
|
|
}
|
|
}
|
|
/* 创建中点 */
|
|
/* 创建中点 */
|
|
if (entityType != SketchViewModel.SketchEntityType.Rectangle && entityType != SketchViewModel
|
|
if (entityType != SketchViewModel.SketchEntityType.Rectangle && entityType != SketchViewModel
|
|
- .SketchEntityType.Circle) {
|
|
|
|
|
|
+ .SketchEntityType.Circle && entityType !== SketchViewModel.SketchEntityType.DynamicCircle) {
|
|
this._createEditMiddlePoint(positions);
|
|
this._createEditMiddlePoint(positions);
|
|
}
|
|
}
|
|
/* 判断是否需要创建高空点 */
|
|
/* 判断是否需要创建高空点 */
|
|
if (entityType === SketchViewModel.SketchEntityType.Wall) {
|
|
if (entityType === SketchViewModel.SketchEntityType.Wall) {
|
|
this._createEditSpatialPoint(positions, this._sketchWallMaxHeights);
|
|
this._createEditSpatialPoint(positions, this._sketchWallMaxHeights);
|
|
}
|
|
}
|
|
- /* 创���事件句柄 */
|
|
|
|
|
|
+ /* 创建事件句柄 */
|
|
if (this._sketchEditHandler === undefined) {
|
|
if (this._sketchEditHandler === undefined) {
|
|
this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
|
|
this._sketchEditHandler = new Cesium.ScreenSpaceEventHandler(this._viewer.scene.canvas);
|
|
}
|
|
}
|
|
@@ -3407,15 +3681,18 @@ Object.assign(SketchViewModel.prototype, {
|
|
/* 获取编辑实体的类型 */
|
|
/* 获取编辑实体的类型 */
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
/* 操作的如果是圆 */
|
|
/* 操作的如果是圆 */
|
|
- if (editEntityType === SketchViewModel.SketchEntityType.Circle) {
|
|
|
|
|
|
+ if (editEntityType === SketchViewModel.SketchEntityType.Circle || editEntityType === SketchViewModel
|
|
|
|
+ .SketchEntityType.DynamicCircle) {
|
|
/* 记录移动点为所有的圆边界点 */
|
|
/* 记录移动点为所有的圆边界点 */
|
|
- for (let i = 0; i < this._ellipseOutlineCoordinates.length; i++) {
|
|
|
|
- this._startMovePoints.push(this._ellipseOutlineCoordinates[i]);
|
|
|
|
|
|
+ if (this._editEntity.polyline !== undefined) {
|
|
|
|
+ for (let i = 0; i < this._ellipseOutlineCoordinates.length; i++) {
|
|
|
|
+ this._startMovePoints.push(this._ellipseOutlineCoordinates[i]);
|
|
|
|
+ }
|
|
|
|
+ this._editEntity.polyline.positions = new Cesium.CallbackProperty(
|
|
|
|
+ function() {
|
|
|
|
+ return _self._ellipseOutlineCoordinates;
|
|
|
|
+ }, false);
|
|
}
|
|
}
|
|
- this._editEntity.polyline.positions = new Cesium.CallbackProperty(
|
|
|
|
- function() {
|
|
|
|
- return _self._ellipseOutlineCoordinates;
|
|
|
|
- }, false);
|
|
|
|
this._editEntity.position = new Cesium.CallbackProperty(function() {
|
|
this._editEntity.position = new Cesium.CallbackProperty(function() {
|
|
return _self._movePoint;
|
|
return _self._movePoint;
|
|
}, false);
|
|
}, false);
|
|
@@ -3483,7 +3760,8 @@ Object.assign(SketchViewModel.prototype, {
|
|
var distance = turf.distance(point1, point2, options);
|
|
var distance = turf.distance(point1, point2, options);
|
|
/* 根据移动的不同类型实体进行不同的操作 */
|
|
/* 根据移动的不同类型实体进行不同的操作 */
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
- if (editEntityType === SketchViewModel.SketchEntityType.Circle) {
|
|
|
|
|
|
+ if (editEntityType === SketchViewModel.SketchEntityType.Circle || editEntityType === SketchViewModel
|
|
|
|
+ .SketchEntityType.DynamicCircle) {
|
|
/* 循环处理所有移动点 */
|
|
/* 循环处理所有移动点 */
|
|
for (let i = 0; i < this._startMovePoints.length; i++) {
|
|
for (let i = 0; i < this._startMovePoints.length; i++) {
|
|
/* 计算转换后的位置 */
|
|
/* 计算转换后的位置 */
|
|
@@ -3515,9 +3793,12 @@ Object.assign(SketchViewModel.prototype, {
|
|
let _self = this;
|
|
let _self = this;
|
|
/* 根据不同的实体进行不同的操作 */
|
|
/* 根据不同的实体进行不同的操作 */
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
let editEntityType = this._editEntity.getEntityType();
|
|
- if (editEntityType === SketchViewModel.SketchEntityType.Circle) {
|
|
|
|
|
|
+ if (editEntityType === SketchViewModel.SketchEntityType.Circle || editEntityType === SketchViewModel
|
|
|
|
+ .SketchEntityType.DynamicCircle) {
|
|
this._editEntity.position = this._movePoint;
|
|
this._editEntity.position = this._movePoint;
|
|
- this._editEntity.polyline.positions = this._ellipseOutlineCoordinates;
|
|
|
|
|
|
+ if (this._editEntity.polyline !== undefined) {
|
|
|
|
+ this._editEntity.polyline.positions = this._ellipseOutlineCoordinates;
|
|
|
|
+ }
|
|
} else if (editEntityType === SketchViewModel.SketchEntityType.Polyline) {
|
|
} else if (editEntityType === SketchViewModel.SketchEntityType.Polyline) {
|
|
this._editEntity.polyline.positions = this._sketchEditPoints;
|
|
this._editEntity.polyline.positions = this._sketchEditPoints;
|
|
} else if (editEntityType === SketchViewModel.SketchEntityType.Polygon) {
|
|
} else if (editEntityType === SketchViewModel.SketchEntityType.Polygon) {
|
|
@@ -3731,6 +4012,8 @@ Object.assign(SketchViewModel.prototype, {
|
|
* @param {Number} startIndex [开始索引] 可选 默认为0
|
|
* @param {Number} startIndex [开始索引] 可选 默认为0
|
|
*/
|
|
*/
|
|
_createEditSpatialPoint(positions, heights, startIndex) {
|
|
_createEditSpatialPoint(positions, heights, startIndex) {
|
|
|
|
+ /* 暂时不创建高空点 */
|
|
|
|
+ return;
|
|
if (positions === undefined || heights === undefined) return;
|
|
if (positions === undefined || heights === undefined) return;
|
|
if (positions.length === undefined || heights.length === undefined) return;
|
|
if (positions.length === undefined || heights.length === undefined) return;
|
|
if (heights.length < positions.length) return;
|
|
if (heights.length < positions.length) return;
|
|
@@ -4029,6 +4312,7 @@ SketchViewModel.SketchType = Object.freeze({
|
|
Height: 'height',
|
|
Height: 'height',
|
|
Spatial: 'spatial',
|
|
Spatial: 'spatial',
|
|
Circle: 'circle',
|
|
Circle: 'circle',
|
|
|
|
+ DynamicCircle: 'dynamicCircle',
|
|
Rectangle: 'rectangle',
|
|
Rectangle: 'rectangle',
|
|
Wall: 'wall',
|
|
Wall: 'wall',
|
|
Triangle: 'triangle',
|
|
Triangle: 'triangle',
|
|
@@ -4040,6 +4324,15 @@ SketchViewModel.SketchType = Object.freeze({
|
|
})
|
|
})
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 绘制的墙类型
|
|
|
|
+ */
|
|
|
|
+SketchViewModel.SketchWallType = Object.freeze({
|
|
|
|
+ DynamicWall: 'dynamicWall',
|
|
|
|
+ ColorWall: 'colorWall',
|
|
|
|
+ Text: 'text',
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+/**
|
|
* 点图标类型
|
|
* 点图标类型
|
|
*/
|
|
*/
|
|
SketchViewModel.SketchIconType = Object.freeze({
|
|
SketchViewModel.SketchIconType = Object.freeze({
|