| | |
| | | import store from "@/store"; |
| | | import { none } from "ol/centerconstraint"; |
| | | import * as turf from "@turf/turf"; |
| | | import WKT from "terraformer-wkt-parser"; |
| | | var temporaryTool = { |
| | | isedit: false, |
| | | removeTemporaryLayer(res) { |
| | | var entities = window.Viewer.entities._entities._array; |
| | | for (var i in entities) { |
| | | if (entities[i].id == res.id && entities[i].shpType == res.shpType) { |
| | | if (entities[i].id == res.id && entities[i]._shpType == res.shpType) { |
| | | window.Viewer.entities.remove(entities[i]) |
| | | } |
| | | } |
| | | }, |
| | | removeTemporaryLayerAll() { |
| | | var entities = window.Viewer.entities._entities._array; |
| | | for (var i = 0; i < entities.length; i++) { |
| | | if (entities[i]._shpType && entities[i]._shpType == "temporaryLayer") { |
| | | window.Viewer.entities.remove(entities[i]) |
| | | i--; |
| | | } |
| | | } |
| | | }, |
| | | |
| | | getWKT(res) { |
| | | var geom = res.geometry; |
| | | var coord = null; |
| | | debugger |
| | | switch (res.type) { |
| | | case "point": |
| | | case "label": |
| | | coord = turf.point([geom.lng, geom.lat]); |
| | | break; |
| | | case "polygon": |
| | | var std = []; |
| | | for (var i = 0; i < geom.length; i++) { |
| | | if (i % 2 == 0) { |
| | | std.push([geom[i], geom[i + 1]]) |
| | | } |
| | | } |
| | | std.push(std[0]) |
| | | debugger |
| | | coord = turf.polygon([std]); |
| | | break; |
| | | case "polyline": |
| | | |
| | | var std = []; |
| | | for (var i = 0; i < geom.length; i++) { |
| | | if (i % 2 == 0) { |
| | | std.push([geom[i], geom[i + 1]]) |
| | | } |
| | | } |
| | | |
| | | coord = turf.lineString(std); |
| | | break; |
| | | case "rectangle": |
| | | coord = turf.polygon([[ |
| | | [geom[0], geom[1]], |
| | | [geom[0], geom[3]], |
| | | [geom[2], geom[3]], |
| | | [geom[2], geom[1]], |
| | | [geom[0], geom[1]], |
| | | ]]); |
| | | break; |
| | | } |
| | | var wkt = WKT.convert(coord.geometry); |
| | | debugger |
| | | return WKT.convert(coord.geometry); |
| | | |
| | | }, |
| | | locationTemporaryLayer(res) { |
| | | var entities = window.Viewer.entities._entities._array; |
| | | for (var i in entities) { |
| | | if (entities[i].id == res.id && entities[i]._shpType == res.shpType) { |
| | | window.Viewer.flyTo(entities[i], { |
| | | offset: { |
| | | heading: Cesium.Math.toRadians(0.0), |
| | | pitch: Cesium.Math.toRadians(-90), |
| | | range: 400 |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | |
| | | heightReference = Number.POSITIVE_INFINITY; |
| | | } |
| | | var style; |
| | | if (res.style) { |
| | | if (res.outline) { |
| | | style = Cesium.LabelStyle.FILL_AND_OUTLINE |
| | | } else { |
| | | style = Cesium.LabelStyle.FILL |
| | |
| | | res.outlineColor |
| | | ).withAlpha(res.outlineAlpha), |
| | | |
| | | outlineWidth: res.outlineWidth, |
| | | outlineWidth: res.width, |
| | | scale: res.scale, |
| | | style: style, |
| | | horizontalOrigin: Cesium.HorizontalOrigin.CENTER,//对齐方式 |
| | |
| | | res.near, |
| | | res.far |
| | | ), |
| | | outline: true, |
| | | outlineWidth:res.width, |
| | | outline: false, |
| | | outlineWidth: res.width, |
| | | |
| | | outlineColor: Cesium.Color.fromCssColorString( |
| | | res.outlineColor |
| | | ).withAlpha(res.outlineAlpha), |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | }, |
| | | }); |
| | | }, |
| | | addTemporaryPolylineLayer(res) { |
| | | var outlinewidth = 0 |
| | | if (res.outline) { |
| | | outlinewidth = res.outlineWidth |
| | | outlinewidth = res.width |
| | | } |
| | | |
| | | window.Viewer.entities.add({ |
| | | name: res.cnName, |
| | | id: res.id, |
| | | shpType: res.shpType, |
| | | outline: res.outline, |
| | | polyline: { |
| | | outline: res.outline, |
| | | positions: Cesium.Cartesian3.fromDegreesArray(res.geometry), |
| | | width: res.width, |
| | | distanceDisplayCondition: new Cesium.DistanceDisplayCondition( |
| | | res.near, |
| | | res.far |
| | | ), |
| | | |
| | | material: new Cesium.PolylineOutlineMaterialProperty({ |
| | | color: Cesium.Color.fromCssColorString(res.material).withAlpha( |
| | | res.materialAlpha |
| | |
| | | var coord = this.setCartesianToEightFour(val[i]) |
| | | geom.push(coord.lng, coord.lat) |
| | | } |
| | | debugger |
| | | |
| | | return { |
| | | id: this.isedit ? res.id : (new Date()).getTime(), |
| | | cnName: res.name, |
| | |
| | | type: 'polygon', |
| | | shpType: 'temporaryLayer', |
| | | layerType: '多边形', |
| | | outline: res.outline != null ? res.outline : false, |
| | | outline: res.polygon.outline != null ? res.polygon.outline._value : false, |
| | | width: res.polygon.outlineWidth ? res.polygon.outlineWidth._value : 1, |
| | | } |
| | | }, |
| | |
| | | if (res.label.outlineWidth && res.label.outlineWidth._value) { |
| | | width = res.label.outlineWidth._value |
| | | } |
| | | |
| | | return { |
| | | id: this.isedit ? res.id : (new Date()).getTime(), |
| | | cnName: res.name, |
| | |
| | | layerType: '文本点', |
| | | } |
| | | }, |
| | | |
| | | getPointEntityObj(res) { |
| | | var mataColor = res.point.color._value; |
| | | var outlineColor = res.point.outlineColor._value; |
| | |
| | | layerType: '基本点', |
| | | heightReference: res.point.disableDepthTestDistance != null ? false : true, |
| | | size: res.point.pixelSize._value, |
| | | |
| | | } |
| | | }, |
| | | |