serviceAreaAnalysis.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div v-show="ServiceAreaShow">
  3. <div class="sm-function-module-content">
  4. <div class="boxchild">
  5. <el-button type="primary" size="mini" v-on:click="analysis"
  6. >分析</el-button
  7. >
  8. <el-button type="primary" size="mini" @click="clear">清除</el-button>
  9. </div>
  10. <div v-show="GTCShow">
  11. <label class="label-container">分析结果:</label>
  12. <div style="margin: 10px">
  13. <div>
  14. <div class="ui piled segment">
  15. <div id="graph" style="height: 200px; width: 250px"></div>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. let ids1,
  25. ids2,
  26. ids3,
  27. initF = false;
  28. export default {
  29. name: "Sm3dServiceAreaAnalysis",
  30. props: {},
  31. data() {
  32. return {
  33. dsMode: 1,
  34. sharedState: store.state,
  35. GTCShow: false,
  36. };
  37. },
  38. computed: {
  39. ServiceAreaShow: function () {
  40. return this.sharedState.cityPlan[3];
  41. },
  42. cityPlanShow: function () {
  43. return this.sharedState.toolBar[9];
  44. },
  45. initflag() {
  46. return this.sharedState.S3MLayerManage;
  47. },
  48. },
  49. // mounted() {
  50. // if (this.cityPlanShow && this.onLineShow) {
  51. // this.init();
  52. // }
  53. // },
  54. methods: {
  55. init() {
  56. console.log("init", this.initF);
  57. if (this.initF) {
  58. return;
  59. }
  60. let geoCylinder = new Cesium.GeoCylinder(300, 300, 300);
  61. geoCylinder.geoPosition = new Cesium.Point3D(
  62. 115.009302,
  63. 39.006673,
  64. 102.0
  65. );
  66. let datasetSpatialQuery3DPostParameter = {};
  67. datasetSpatialQuery3DPostParameter.operateRegion = geoCylinder;
  68. datasetSpatialQuery3DPostParameter.positionMode = "INTERSECTSORCONTAINS";
  69. datasetSpatialQuery3DPostParameter.sourceDatasetFilter = {
  70. attributeFilter: "",
  71. };
  72. let queryUrl =
  73. "http://www.supermapol.com/realspace/services/spatialAnalysis-data_all/restjsr/spatialanalyst/datasets/building_udb%40building/spatialquery3d.json";
  74. window.axios
  75. .post(queryUrl, JSON.stringify(datasetSpatialQuery3DPostParameter))
  76. .then(function (response) {
  77. window.axios
  78. .get(response.data.newResourceLocation + ".json")
  79. .then(function (response) {
  80. ids1 = response.data.ids;
  81. })
  82. .catch(function (error) {
  83. console.log(error);
  84. });
  85. })
  86. .catch(function (error) {
  87. console.log(error);
  88. });
  89. let geoCylinder2 = new Cesium.GeoCylinder(250, 250, 300);
  90. geoCylinder2.geoPosition = new Cesium.Point3D(
  91. 115.01135582381039,
  92. 39.00765877493075,
  93. 102
  94. );
  95. let datasetSpatialQuery3DPostParameter2 = {};
  96. datasetSpatialQuery3DPostParameter2.operateRegion = geoCylinder2;
  97. datasetSpatialQuery3DPostParameter2.positionMode = "INTERSECTSORCONTAINS";
  98. datasetSpatialQuery3DPostParameter2.sourceDatasetFilter = {
  99. attributeFilter: "",
  100. };
  101. let queryUrl2 =
  102. "http://www.supermapol.com/realspace/services/spatialAnalysis-data_all/restjsr/spatialanalyst/datasets/building_udb%40building/spatialquery3d.json";
  103. window.axios
  104. .post(queryUrl2, JSON.stringify(datasetSpatialQuery3DPostParameter2))
  105. .then(function (response) {
  106. window.axios
  107. .get(response.data.newResourceLocation + ".json")
  108. .then(function (response) {
  109. ids2 = response.data.ids;
  110. })
  111. .catch(function (error) {
  112. console.log(error);
  113. });
  114. })
  115. .catch(function (error) {
  116. console.log(error);
  117. });
  118. let geoCylinder3 = new Cesium.GeoCylinder(200, 300, 300);
  119. geoCylinder3.geoPosition = new Cesium.Point3D(
  120. 115.01249121214373,
  121. 39.00298817909093,
  122. 102
  123. );
  124. let datasetSpatialQuery3DPostParameter3 = {};
  125. datasetSpatialQuery3DPostParameter3.operateRegion = geoCylinder3;
  126. datasetSpatialQuery3DPostParameter3.positionMode = "INTERSECTSORCONTAINS";
  127. datasetSpatialQuery3DPostParameter3.sourceDatasetFilter = {
  128. attributeFilter: "",
  129. };
  130. let queryUrl3 =
  131. "http://www.supermapol.com/realspace/services/spatialAnalysis-data_all/restjsr/spatialanalyst/datasets/building_udb%40building/spatialquery3d.json";
  132. window.axios
  133. .post(queryUrl3, JSON.stringify(datasetSpatialQuery3DPostParameter3))
  134. .then(function (response) {
  135. window.axios
  136. .get(response.data.newResourceLocation + ".json")
  137. .then(function (response) {
  138. ids3 = response.data.ids;
  139. })
  140. .catch(function (error) {
  141. console.log(error);
  142. });
  143. })
  144. .catch(function (error) {
  145. console.log(error);
  146. });
  147. this.initF = true;
  148. },
  149. analysis() {
  150. window.setTimeout(() => {
  151. this.overlayBuildingBuffer(viewer, scene);
  152. }, 8000);
  153. },
  154. clear() {
  155. this.initF = false;
  156. this.GTCShow = false;
  157. viewer.entities.removeAll();
  158. let layerOriginal = scene.layers.find("original");
  159. layerOriginal.removeObjsColor(ids1);
  160. layerOriginal.removeObjsColor(ids2);
  161. layerOriginal.removeObjsColor(ids3);
  162. scene.camera.setView({
  163. destination: Cesium.Cartesian3.fromDegrees(
  164. 115.00022575830863,
  165. 39.009956534844858,
  166. 500
  167. ),
  168. orientation: {
  169. heading: 1.705646,
  170. pitch: -0.499956,
  171. roll: 0.0,
  172. },
  173. });
  174. },
  175. //缓冲分析
  176. overlayBuildingBuffer(viewer, scene) {
  177. console.log(ids1, ids2, ids3);
  178. viewer.camera.flyTo({
  179. destination: Cesium.Cartesian3.fromDegrees(
  180. 114.99950507907676,
  181. 38.999736445753065,
  182. 769.1235709561395
  183. ),
  184. orientation: {
  185. heading: 0.828695,
  186. pitch: -0.461956,
  187. roll: 6.283185,
  188. },
  189. });
  190. window.setTimeout(function () {
  191. viewer.scene.scanEffect.mode = Cesium.ScanEffectMode.CIRCLE; //利用圆环扫描效果
  192. viewer.scene.scanEffect.centerPostion = Cesium.Cartesian3.fromDegrees(
  193. 115.00885354350574,
  194. 39.01094791248316,
  195. 200.0
  196. );
  197. viewer.scene.scanEffect.speed = 250;
  198. let layerOriginal = scene.layers.find("original");
  199. //第二个缓冲区
  200. window.setTimeout(function () {
  201. let greenCircle = viewer.entities.add({
  202. position: Cesium.Cartesian3.fromDegrees(
  203. 115.009302,
  204. 39.006673,
  205. 102.0
  206. ),
  207. name: "Green circle at height with outline",
  208. ellipse: {
  209. semiMinorAxis: 300.0,
  210. semiMajorAxis: 300.0,
  211. height: 102.0,
  212. material: Cesium.Color.DARKORANGE.withAlpha(0.8),
  213. outline: true,
  214. },
  215. });
  216. }, 2000);
  217. console.log(ids1, ids2, ids3);
  218. window.setTimeout(function () {
  219. layerOriginal.setObjsColor(ids1, Cesium.Color.PINK.withAlpha(1));
  220. }, 4000);
  221. //第三个缓冲区
  222. window.setTimeout(function () {
  223. let greenCircle = viewer.entities.add({
  224. position: Cesium.Cartesian3.fromDegrees(
  225. 115.01135582381039,
  226. 39.00765877493075,
  227. 102
  228. ),
  229. name: "Green circle at height with outline",
  230. ellipse: {
  231. semiMinorAxis: 250.0,
  232. semiMajorAxis: 250.0,
  233. height: 102.0,
  234. material: Cesium.Color.DARKORANGE.withAlpha(0.8),
  235. outline: true,
  236. },
  237. });
  238. }, 6000);
  239. window.setTimeout(function () {
  240. layerOriginal.setObjsColor(ids2, Cesium.Color.PINK.withAlpha(1));
  241. }, 8000);
  242. //第四个缓冲区
  243. window.setTimeout(function () {
  244. let greenCircle = viewer.entities.add({
  245. position: Cesium.Cartesian3.fromDegrees(
  246. 115.01249121214373,
  247. 39.00298817909093,
  248. 102
  249. ),
  250. name: "Green circle at height with outline",
  251. ellipse: {
  252. semiMinorAxis: 300.0,
  253. semiMajorAxis: 300.0,
  254. height: 102.0,
  255. material: Cesium.Color.DARKORANGE.withAlpha(0.8),
  256. outline: true,
  257. },
  258. });
  259. }, 10000);
  260. window.setTimeout(function () {
  261. layerOriginal.setObjsColor(ids3, Cesium.Color.PINK.withAlpha(1));
  262. }, 12000);
  263. }, 2000);
  264. window.setTimeout(() => {
  265. viewer.entities.add({
  266. polyline: {
  267. positions: Cesium.Cartesian3.fromDegreesArrayHeights([
  268. 115.009302, 39.006673, 160.0, 115.009302, 39.006673, 250.0,
  269. ]),
  270. width: 1,
  271. material: new Cesium.PolylineDashMaterialProperty({
  272. color: Cesium.Color.YELLOW,
  273. }),
  274. },
  275. });
  276. viewer.entities.add({
  277. polyline: {
  278. positions: Cesium.Cartesian3.fromDegreesArrayHeights([
  279. 115.01135582381039, 39.00765877493075, 148, 115.01135582381039,
  280. 39.00765877493075, 230,
  281. ]),
  282. width: 1,
  283. material: new Cesium.PolylineDashMaterialProperty({
  284. color: Cesium.Color.YELLOW,
  285. }),
  286. },
  287. });
  288. viewer.entities.add({
  289. polyline: {
  290. positions: Cesium.Cartesian3.fromDegreesArrayHeights([
  291. 115.01249121214373, 39.00298817909093, 145.102,
  292. 115.01249121214373, 39.00298817909093, 145.172,
  293. ]),
  294. width: 1,
  295. material: new Cesium.PolylineDashMaterialProperty({
  296. color: Cesium.Color.YELLOW,
  297. }),
  298. },
  299. });
  300. viewer.entities.add({
  301. position: Cesium.Cartesian3.fromDegrees(115.009302, 39.006673, 230.0),
  302. billboard: {
  303. image: "./images/诊所管理.png",
  304. show: true,
  305. pixelOffset: new Cesium.Cartesian2(0, -50),
  306. eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
  307. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  308. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  309. scale: 2.0,
  310. color: Cesium.Color.YELLOW,
  311. alignedAxis: Cesium.Cartesian3.ZERO,
  312. width: 20,
  313. height: 20,
  314. },
  315. });
  316. viewer.entities.add({
  317. position: Cesium.Cartesian3.fromDegrees(
  318. 115.01135582381039,
  319. 39.00765877493075,
  320. 200
  321. ),
  322. billboard: {
  323. image: "./images/诊所管理.png",
  324. show: true,
  325. pixelOffset: new Cesium.Cartesian2(0, -50),
  326. eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
  327. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  328. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  329. scale: 2.0,
  330. color: Cesium.Color.YELLOW,
  331. alignedAxis: Cesium.Cartesian3.ZERO,
  332. width: 20,
  333. height: 20,
  334. },
  335. });
  336. viewer.entities.add({
  337. position: Cesium.Cartesian3.fromDegrees(
  338. 115.01249121214373,
  339. 39.00298817909093,
  340. 145.162
  341. ),
  342. billboard: {
  343. image: "./images/诊所管理.png",
  344. show: true,
  345. pixelOffset: new Cesium.Cartesian2(0, -50),
  346. eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0),
  347. horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
  348. verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
  349. scale: 2.0,
  350. color: Cesium.Color.YELLOW,
  351. alignedAxis: Cesium.Cartesian3.ZERO,
  352. width: 20,
  353. height: 20,
  354. },
  355. });
  356. window.setTimeout(() => {
  357. this.chart();
  358. }, 2000);
  359. }, 15000);
  360. },
  361. chart() {
  362. this.GTCShow = true;
  363. let dom1 = document.getElementById("graph");
  364. let myChart1 = window.echarts.init(dom1);
  365. let option = {
  366. backgroundColor: "rgba(38, 38, 38, 0.5)",
  367. title: {
  368. text: "小区诊所服务范围",
  369. left: "center",
  370. top: 20,
  371. textStyle: {
  372. color: "#ccc",
  373. },
  374. },
  375. tooltip: {
  376. trigger: "item",
  377. formatter: "{a} <br/>{b} : {c} ({d}%)",
  378. },
  379. visualMap: {
  380. show: false,
  381. min: 80,
  382. max: 600,
  383. inRange: {
  384. colorLightness: [0, 1],
  385. },
  386. },
  387. series: [
  388. {
  389. name: "辐射范围",
  390. type: "pie",
  391. radius: "55%",
  392. center: ["50%", "50%"],
  393. data: [
  394. {
  395. value: 335,
  396. name: "A诊所",
  397. },
  398. {
  399. value: 310,
  400. name: "B诊所",
  401. },
  402. {
  403. value: 274,
  404. name: "C诊所",
  405. },
  406. ].sort(function (a, b) {
  407. return a.value - b.value;
  408. }),
  409. roseType: "radius",
  410. label: {
  411. normal: {
  412. textStyle: {
  413. color: "#C83732",
  414. },
  415. },
  416. },
  417. labelLine: {
  418. normal: {
  419. lineStyle: {
  420. color: "#C83732",
  421. },
  422. smooth: 0.2,
  423. length: 10,
  424. length2: 20,
  425. },
  426. },
  427. itemStyle: {
  428. normal: {
  429. color: "#c23531",
  430. shadowBlur: 200,
  431. shadowColor: "rgba(1, 1, 0, 0)",
  432. },
  433. },
  434. animationType: "scale",
  435. animationEasing: "elasticOut",
  436. animationDelay: function (idx) {
  437. return Math.random() * 200;
  438. },
  439. },
  440. ],
  441. };
  442. myChart1.setOption(option);
  443. },
  444. },
  445. watch: {
  446. initflag(val) {
  447. console.log(val);
  448. this.init();
  449. },
  450. },
  451. };
  452. </script>
  453. <style lang="scss" scoped>
  454. @import "serviceAreaAnalysis";
  455. </style>