@kq_npm/client3d_webgl_vue 2.6.2-beta → 2.6.4-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -611,7 +611,7 @@ class DrawManager {
611
611
  //图标宽度
612
612
  height: 32,
613
613
  //图标高度
614
- clampToGround: false //是否贴地
614
+ clampToGround: true //是否贴地
615
615
 
616
616
  },
617
617
  //折线样式
@@ -783,6 +783,7 @@ class DrawManager {
783
783
  if (callback) {
784
784
  var that = this;
785
785
  var removeEventListener = this.drawFinishedEvent.addEventListener(shape => {
786
+ that._viewer.scene.globe.depthTestAgainstTerrain = false;
786
787
  var feature = that.shapeToGeoFeature(shape);
787
788
  callback(feature.geometry);
788
789
  removeEventListener();
@@ -824,6 +825,10 @@ class DrawManager {
824
825
  transformPosition(position) {
825
826
  // 转坐标
826
827
  if (position) {
828
+ if (position instanceof Array && position.length === 3) {
829
+ position = Cesium.Cartesian3.fromDegrees(position[0], position[1], position[2]);
830
+ }
831
+
827
832
  let ellipsoid = this._viewer.scene.globe.ellipsoid;
828
833
  let cartographic = ellipsoid.cartesianToCartographic(position);
829
834
  let lon = Cesium.Math.toDegrees(cartographic.longitude);
@@ -1000,6 +1005,85 @@ class DrawManager {
1000
1005
  clearAll() {
1001
1006
  this.clear();
1002
1007
  this.removeAll();
1008
+ } //ShapeLayer的绘制要素转换为GeoFeature (普通点线面绘制接口使用)
1009
+
1010
+
1011
+ drawToGeoFeature(shape) {
1012
+ var geoFeature = null;
1013
+ var that = this;
1014
+
1015
+ if (shape) {
1016
+ if (shape.type === that._drawHandler.ShapeTypes.MARKER.type) {
1017
+ geoFeature = window.turf.point(shape.latlng);
1018
+ geoFeature.properties = {
1019
+ image: shape.image,
1020
+ width: shape.width,
1021
+ height: shape.height
1022
+ };
1023
+ } else if (shape.type === that._drawHandler.ShapeTypes.CIRCLE.type) {
1024
+ let center = that.transformPosition(shape.controlPoints[0]);
1025
+ let point1 = Cesium.Cartesian3.fromDegrees(shape.controlPoints[0][0], shape.controlPoints[0][1], shape.controlPoints[0][2]);
1026
+ let point2 = Cesium.Cartesian3.fromDegrees(shape.controlPoints[1][0], shape.controlPoints[1][1], shape.controlPoints[1][2]);
1027
+ let radius = Cesium.Cartesian3.distance(point1, point2);
1028
+ geoFeature = window.turf.circle(center, radius, {
1029
+ steps: 64,
1030
+ units: "meters"
1031
+ });
1032
+ } else if (shape.type === that._drawHandler.ShapeTypes.POLYLINE.type) {
1033
+ let position = [[]];
1034
+ shape.controlPoints.forEach(function (val) {
1035
+ position[0].push(that.transformPosition(val));
1036
+ });
1037
+ geoFeature = window.turf.lineStrings(position).features[0];
1038
+ } else if (shape.type === that._drawHandler.ShapeTypes.RECTANGLE.type) {
1039
+ let point1 = that.transformPosition(shape.controlPoints[0]);
1040
+ let point2 = that.transformPosition(shape.controlPoints[1]);
1041
+ let minX = point1[0];
1042
+ let maxX = point2[0];
1043
+ let minY = point1[1];
1044
+ let maxY = point2[1];
1045
+ let positions1 = [[[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]]];
1046
+ geoFeature = window.turf.polygon(positions1);
1047
+ } else if (shape.type === that._drawHandler.ShapeTypes.POLYGON.type) {
1048
+ let positions = [[]];
1049
+ let posi;
1050
+ shape.controlPoints.forEach(function (val, dex) {
1051
+ // 存坐标
1052
+ positions[0].push(that.transformPosition(val)); // 闭合坐标
1053
+
1054
+ if (dex === 0) {
1055
+ posi = that.transformPosition(val);
1056
+ }
1057
+
1058
+ if (dex === shape.controlPoints.length - 1) {
1059
+ positions[0].push(posi);
1060
+ }
1061
+ });
1062
+ geoFeature = window.turf.polygon(positions);
1063
+ }
1064
+ }
1065
+
1066
+ return geoFeature;
1067
+ } // 获取所有绘制图层,geojson数据格式 (普通点线面绘制接口使用)
1068
+
1069
+
1070
+ getAllGeometry() {
1071
+ let features = [];
1072
+
1073
+ let shapes = this._drawLayer.toJSON();
1074
+
1075
+ if (shapes && shapes.draws && shapes.draws.length > 0) {
1076
+ shapes.draws.forEach(shape => {
1077
+ let feature = this.drawToGeoFeature(shape);
1078
+ if (feature) features.push(feature);
1079
+ }, this);
1080
+ }
1081
+
1082
+ let geojson = {
1083
+ type: "FeatureCollection",
1084
+ features: features
1085
+ };
1086
+ return geojson;
1003
1087
  }
1004
1088
 
1005
1089
  }
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@kq_npm/client3d_webgl_vue","description":"KQGIS Client3D for Vue.js","version":"2.6.2-beta","homepage":"","keywords":["KQGIS","webGL","Vue"],"browserslist":["> 1%","last 2 versions","not dead","not ie 11"],"author":"KQWEB GROUP","license":"Apache-2.0","dependencies":{"@kq_npm/client_common_vue":"^2.9.5-beta","colorcolor":"^1.1.1","echarts":"^5.3.3","js-cookie":"^3.0.1","omit.js":"^2.0.2","save":"^2.5.0","tinycolor2":"^1.4.2","vue-i18n":"^9.2.0-beta.36","xlsx":"^0.18.5","css-vars-ponyfill":"^2.4.8","xe-utils":"^3.5.4"}}
1
+ {"name":"@kq_npm/client3d_webgl_vue","description":"KQGIS Client3D for Vue.js","version":"2.6.4-beta","homepage":"","keywords":["KQGIS","webGL","Vue"],"browserslist":["> 1%","last 2 versions","not dead","not ie 11"],"author":"KQWEB GROUP","license":"Apache-2.0","dependencies":{"colorcolor":"^1.1.1","echarts":"^5.3.3","js-cookie":"^3.0.1","omit.js":"^2.0.2","save":"^2.5.0","tinycolor2":"^1.4.2","vue-i18n":"^9.2.0-beta.36","xlsx":"^0.18.5","css-vars-ponyfill":"^2.4.8","xe-utils":"^3.5.4"}}
@@ -136,7 +136,7 @@ class DrawManager {
136
136
  //图标宽度
137
137
  height: 32,
138
138
  //图标高度
139
- clampToGround: false //是否贴地
139
+ clampToGround: true //是否贴地
140
140
 
141
141
  },
142
142
  //折线样式
@@ -308,6 +308,7 @@ class DrawManager {
308
308
  if (callback) {
309
309
  var that = this;
310
310
  var removeEventListener = this.drawFinishedEvent.addEventListener(shape => {
311
+ that._viewer.scene.globe.depthTestAgainstTerrain = false;
311
312
  var feature = that.shapeToGeoFeature(shape);
312
313
  callback(feature.geometry);
313
314
  removeEventListener();
@@ -349,6 +350,10 @@ class DrawManager {
349
350
  transformPosition(position) {
350
351
  // 转坐标
351
352
  if (position) {
353
+ if (position instanceof Array && position.length === 3) {
354
+ position = Cesium.Cartesian3.fromDegrees(position[0], position[1], position[2]);
355
+ }
356
+
352
357
  let ellipsoid = this._viewer.scene.globe.ellipsoid;
353
358
  let cartographic = ellipsoid.cartesianToCartographic(position);
354
359
  let lon = Cesium.Math.toDegrees(cartographic.longitude);
@@ -525,6 +530,85 @@ class DrawManager {
525
530
  clearAll() {
526
531
  this.clear();
527
532
  this.removeAll();
533
+ } //ShapeLayer的绘制要素转换为GeoFeature (普通点线面绘制接口使用)
534
+
535
+
536
+ drawToGeoFeature(shape) {
537
+ var geoFeature = null;
538
+ var that = this;
539
+
540
+ if (shape) {
541
+ if (shape.type === that._drawHandler.ShapeTypes.MARKER.type) {
542
+ geoFeature = window.turf.point(shape.latlng);
543
+ geoFeature.properties = {
544
+ image: shape.image,
545
+ width: shape.width,
546
+ height: shape.height
547
+ };
548
+ } else if (shape.type === that._drawHandler.ShapeTypes.CIRCLE.type) {
549
+ let center = that.transformPosition(shape.controlPoints[0]);
550
+ let point1 = Cesium.Cartesian3.fromDegrees(shape.controlPoints[0][0], shape.controlPoints[0][1], shape.controlPoints[0][2]);
551
+ let point2 = Cesium.Cartesian3.fromDegrees(shape.controlPoints[1][0], shape.controlPoints[1][1], shape.controlPoints[1][2]);
552
+ let radius = Cesium.Cartesian3.distance(point1, point2);
553
+ geoFeature = window.turf.circle(center, radius, {
554
+ steps: 64,
555
+ units: "meters"
556
+ });
557
+ } else if (shape.type === that._drawHandler.ShapeTypes.POLYLINE.type) {
558
+ let position = [[]];
559
+ shape.controlPoints.forEach(function (val) {
560
+ position[0].push(that.transformPosition(val));
561
+ });
562
+ geoFeature = window.turf.lineStrings(position).features[0];
563
+ } else if (shape.type === that._drawHandler.ShapeTypes.RECTANGLE.type) {
564
+ let point1 = that.transformPosition(shape.controlPoints[0]);
565
+ let point2 = that.transformPosition(shape.controlPoints[1]);
566
+ let minX = point1[0];
567
+ let maxX = point2[0];
568
+ let minY = point1[1];
569
+ let maxY = point2[1];
570
+ let positions1 = [[[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]]];
571
+ geoFeature = window.turf.polygon(positions1);
572
+ } else if (shape.type === that._drawHandler.ShapeTypes.POLYGON.type) {
573
+ let positions = [[]];
574
+ let posi;
575
+ shape.controlPoints.forEach(function (val, dex) {
576
+ // 存坐标
577
+ positions[0].push(that.transformPosition(val)); // 闭合坐标
578
+
579
+ if (dex === 0) {
580
+ posi = that.transformPosition(val);
581
+ }
582
+
583
+ if (dex === shape.controlPoints.length - 1) {
584
+ positions[0].push(posi);
585
+ }
586
+ });
587
+ geoFeature = window.turf.polygon(positions);
588
+ }
589
+ }
590
+
591
+ return geoFeature;
592
+ } // 获取所有绘制图层,geojson数据格式 (普通点线面绘制接口使用)
593
+
594
+
595
+ getAllGeometry() {
596
+ let features = [];
597
+
598
+ let shapes = this._drawLayer.toJSON();
599
+
600
+ if (shapes && shapes.draws && shapes.draws.length > 0) {
601
+ shapes.draws.forEach(shape => {
602
+ let feature = this.drawToGeoFeature(shape);
603
+ if (feature) features.push(feature);
604
+ }, this);
605
+ }
606
+
607
+ let geojson = {
608
+ type: "FeatureCollection",
609
+ features: features
610
+ };
611
+ return geojson;
528
612
  }
529
613
 
530
614
  }