"use strict";
|
|
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
Object.defineProperty(exports, "__esModule", {
|
value: true
|
});
|
exports["default"] = void 0;
|
|
var _axios = _interopRequireDefault(require("axios"));
|
|
var _mapConfig = _interopRequireDefault(require("./mapConfig"));
|
|
var turf = _interopRequireWildcard(require("@turf/turf"));
|
|
var _mapServer = _interopRequireDefault(require("./mapServer"));
|
|
var _auth = require("../../../utils/auth");
|
|
var _modelLayer = _interopRequireDefault(require("./modelLayer"));
|
|
var _modelBase = require("../../../api/modelBase.js");
|
|
var _vue = require("vue");
|
|
var _jsencrypt = _interopRequireDefault(require("jsencrypt"));
|
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
|
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
var layerJson = {
|
layerData: null,
|
url: null,
|
coord: null,
|
rectangularSensor: null,
|
targetList: [],
|
linePath: null,
|
richTextPoint1: null,
|
wfsLayer: null,
|
dataSource: null,
|
init: function init(url) {
|
this.url = url;
|
this.getJsonLayer();
|
},
|
getJsonLayer: function getJsonLayer() {
|
var that = this;
|
Cesium.GeoJsonDataSource.load(this.url, {
|
stroke: Cesium.Color.fromCssColorString("#FFFFFF"),
|
//多边形或线的颜色
|
fill: Cesium.Color.fromCssColorString("#FFFFFF"),
|
//多边形或线的颜色
|
strokeWidth: 1,
|
//多边形或线 宽度
|
clampToGround: true //多边形或线 固定在地面上true/false
|
|
}).then(function (dataSource) {
|
var entities = dataSource.entities.values;
|
that.layerData = dataSource;
|
entities.map(function (item) {
|
item.polygon.heightReference = Cesium.HeightReference.RELATIVE_TO_GROUND; // 贴地
|
|
item.polygon.height = 0; // 距地高度0米
|
|
item.polygon.extrudedHeightReference = Cesium.HeightReference.RELATIVE_TO_GROUND; //拉伸
|
|
item.polygon.extrudedHeight = item.properties["ELEVATION"]; // 拉伸高度
|
|
var polyPositions = item.polygon.hierarchy.getValue().positions;
|
var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //中心点
|
|
polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
|
item.position = polyCenter;
|
|
if (item.id == "965") {
|
that.coord = {
|
lon: item.properties["lon"]._value,
|
lat: item.properties["lat"]._value
|
};
|
}
|
|
item.label = {
|
text: "",
|
font: "500 20px Helvetica",
|
scale: 1,
|
style: Cesium.LabelStyle.FILL,
|
fillColor: Cesium.Color.WHITE,
|
eyeOffset: new Cesium.Cartesian3(0.0, item.polygon.extrudedHeight + 1, -(item.polygon.extrudedHeight + 1)),
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
showBackground: true,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(50.0, 500.0),
|
backgroundColor: new Cesium.Color(26 / 255, 196 / 255, 228 / 255, 1.0) //背景顔色
|
|
};
|
});
|
Viewer.dataSources.add(dataSource);
|
});
|
},
|
setQyeryData: function setQyeryData(res) {
|
// this.setTitleSetRest();
|
if (res.indexOf("海军陆战队") > -1) {
|
this.setQueryExtent2();
|
} else if (res.indexOf("军事目标") > -1) {
|
this.setQueryByFiled("军事目标", "#409EFF", false);
|
} else if (res.indexOf("民宅") > -1) {
|
this.setQueryByFiled("民宅", "#808080", false);
|
} else if (res.indexOf("经济目标") > -1) {
|
this.setQueryByFiled("经济目标", "#FFFF00", true);
|
} else if (res.indexOf("堤丰") > -1) {
|
// this.setQueryTF("SubicBayWeapon_wfs", "weapons", "堤丰系统");
|
this.setQueryTF2("堤丰系统");
|
}
|
},
|
getPublickey: function getPublickey(res) {
|
var encrypt = new _jsencrypt["default"]();
|
encrypt.setPublicKey(_modelLayer["default"].publickey + "");
|
return encrypt.encrypt(res);
|
},
|
setQueryFlywire: function setQueryFlywire() {
|
var obj, filed, layer, data;
|
return regeneratorRuntime.async(function setQueryFlywire$(_context) {
|
while (1) {
|
switch (_context.prev = _context.next) {
|
case 0:
|
obj = "ejfl = '美空军指挥中心'" + "";
|
filed = this.getPublickey(obj);
|
layer = _modelLayer["default"].layers.filter(function (item) {
|
if (item.name == "建筑") {
|
return item;
|
}
|
});
|
|
if (!(layer.length <= 0)) {
|
_context.next = 5;
|
break;
|
}
|
|
return _context.abrupt("return");
|
|
case 5:
|
data = (0, _modelBase.getQueryEentity)({
|
token: (0, _auth.getToken)(),
|
start: 1,
|
count: 0,
|
containCount: true,
|
layerid: layer[0].id,
|
dbid: _modelLayer["default"].dbid,
|
where: filed
|
});
|
|
case 6:
|
case "end":
|
return _context.stop();
|
}
|
}
|
}, null, this);
|
},
|
setQueryTF2: function setQueryTF2(name) {
|
var _this = this;
|
|
// const obj = "weaponname like '%堤丰系统%'" + "";
|
var filed = this.getPublickey(name);
|
|
var layer = _modelLayer["default"].layers.filter(function (item) {
|
if (item.name == "武器点") {
|
return item;
|
}
|
});
|
|
if (layer.length <= 0) return;
|
(0, _modelBase.getQueryEentity)({
|
token: (0, _auth.getToken)(),
|
start: 1,
|
count: 0,
|
containCount: true,
|
layerid: layer[0].id,
|
dbid: _modelLayer["default"].dbid,
|
where: filed
|
}).then(function (response) {
|
if (response.code != 200) return;
|
var geom = response.data.items[0];
|
var position = [geom._x, geom._y, 0];
|
var cylinder = {
|
radius: 400000,
|
//半径
|
angle: 30,
|
//扫描角度(可选)
|
speed: 5,
|
//倍速(可选)
|
stackPartitions: 80,
|
//横向网格数(可选)
|
slicePartitions: 80,
|
//纵向网格数(可选)
|
wallColor: "rgba(255,255,255,0)" //扫描墙颜色(可选)
|
|
};
|
_this.rectangularSensor = earthCtrl.factory.createRectangularSensor(position, cylinder);
|
earthCtrl.camera.flyTo(113.00849464328284, 10.437567580726105, 1101300.7027243855, 57, -45, 0, 2);
|
});
|
},
|
setQueryByFiled: function setQueryByFiled(name, color) {
|
var _this2 = this;
|
|
var filed = this.getPublickey(name);
|
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) return;
|
var tileset = objItem[0];
|
(0, _modelBase.getQueryEentity)({
|
token: (0, _auth.getToken)(),
|
start: 1,
|
count: 0,
|
containCount: true,
|
layerid: tileset.layerId,
|
dbid: _modelLayer["default"].dbid,
|
where: filed
|
}).then(function (response) {
|
if (response.code != 200) return;
|
var std = [];
|
var items = response.data.items;
|
items.map(function (item) {
|
std.push(item.seid);
|
});
|
(0, _vue.nextTick)(function () {
|
if (std.length > 0) {
|
_this2.setTilesetColorChange(tileset, std, color);
|
}
|
});
|
});
|
},
|
setQueryByFiledList: function setQueryByFiledList(list, flag) {
|
var _this3 = this;
|
|
var result = list[flag];
|
var name = result.name;
|
var color = result.color;
|
var obj = "fclass_1 = '" + name + "'" + "";
|
var filed = this.getPublickey(obj);
|
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) return;
|
var tileset = objItem[0];
|
(0, _modelBase.getQueryEentity)({
|
token: "9ce350f238ba44fda10ddfe8b80f8967",
|
start: 1,
|
count: 0,
|
containCount: true,
|
layerid: tileset.layerId,
|
dbid: _modelLayer["default"].dbid,
|
where: filed
|
}).then(function (response) {
|
if (response.code != 200) return;
|
console.log("response", objItem);
|
var std = [];
|
var items = response.data.items;
|
items.map(function (item) {
|
// if (item.targettype == name) {
|
std.push(item.seid); // }.
|
});
|
(0, _vue.nextTick)(function () {
|
if (std.length > 0) {
|
_this3.targetList.push({
|
ids: std,
|
color: color,
|
cname: list[flag].name
|
});
|
}
|
|
flag = flag + 1;
|
|
if (flag >= list.length) {
|
_this3.setTilesetColorChangeTarget();
|
} else {
|
_this3.setQueryByFiledList(list, flag);
|
}
|
});
|
});
|
},
|
delrichTextPoint1: function delrichTextPoint1() {
|
if (this.richTextPoint1) {
|
this.richTextPoint1.deleteObject();
|
this.richTextPoint1 = null;
|
}
|
},
|
setTitleSetRest: function setTitleSetRest() {
|
this.targetList = [];
|
|
if (this.dataSource) {
|
Viewer.dataSources.remove(this.dataSource);
|
this.dataSource = null;
|
}
|
|
this.delrichTextPoint1();
|
|
if (this.wfsLayer) {
|
// this.wfsLayer.removeFromMap();
|
this.wfsLayer.destroy();
|
}
|
|
if (this.linePath) {
|
this.linePath.clear();
|
this.linePath = null;
|
}
|
|
if (this.rectangularSensor) {
|
this.rectangularSensor.wall.forEach(function (wall) {
|
Viewer.entities.remove(wall);
|
});
|
Viewer.entities.remove(this.rectangularSensor.item);
|
this.rectangularSensor = null;
|
}
|
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) return;
|
var tileset = objItem[0].layer;
|
tileset.style = new Cesium.Cesium3DTileStyle({
|
color: {
|
evaluateColor: function evaluateColor(feature) {
|
return new Cesium.Color.fromCssColorString("#FFFFFF");
|
}
|
}
|
});
|
},
|
setTilesetColorChange: function setTilesetColorChange(model, ids, color) {
|
var tileset = model.layer;
|
tileset.style = new Cesium.Cesium3DTileStyle({
|
color: {
|
evaluateColor: function evaluateColor(feature) {
|
var id = feature.getProperty("id");
|
|
if (ids.indexOf(id) > -1) {
|
return new SmartEarth.Cesium.Color.fromCssColorString(color);
|
}
|
}
|
}
|
});
|
},
|
setTilesetColorChangeTarget: function setTilesetColorChangeTarget(color, ids) {
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) return;
|
var tileset = objItem[0].layer;
|
var list = this.targetList;
|
console.log(this.targetList);
|
tileset.style = new Cesium.Cesium3DTileStyle({
|
color: {
|
evaluateColor: function evaluateColor(feature) {
|
var id = feature.getProperty("id");
|
|
for (var i in list) {
|
if (list[i].ids.indexOf(id) > -1) {
|
return new SmartEarth.Cesium.Color.fromCssColorString(list[i].color);
|
}
|
} // if (ids.indexOf(id) > -1) {
|
// return new SmartEarth.Cesium.Color.fromCssColorString(color);
|
// }
|
|
}
|
}
|
});
|
},
|
setAddWfsLayer: function setAddWfsLayer() {
|
this.wfsLayer = earthCtrl.factory.createWfsLayer("polygon", {
|
urls: "https://cim.smartearth.cn/SEserver/wfsserver/SubicBayWeapon_wfs",
|
layer: "weapons",
|
outlineColor: "#ff0000",
|
alpha: 0
|
});
|
},
|
setAddWfsJson: function setAddWfsJson() {
|
var url = this.getQueryUrl("SubicBayWeapon_wfs", "weapons");
|
var that = this;
|
Cesium.GeoJsonDataSource.load(url, {
|
fill: Cesium.Color.fromCssColorString("#FFFFFF00"),
|
stroke: Cesium.Color.fromCssColorString("#FFFFFF00"),
|
//多边形或线的颜色
|
strokeWidth: 0 //多边形或线 宽度
|
|
}).then(function (dataSource) {
|
that.dataSource = dataSource;
|
var entities = that.dataSource.entities.values;
|
entities.map(function (item) {
|
item.polygon._material.color = Cesium.Color.fromCssColorString("#FFFFFF00");
|
item.polygon.heightReference = Cesium.HeightReference.RELATIVE_TO_GROUND; // 贴地
|
|
item.polygon.height = 0; // 距地高度0米
|
|
var polyPositions = item.polygon.hierarchy.getValue().positions;
|
var polyCenter = Cesium.BoundingSphere.fromPoints(polyPositions).center; //中心点
|
|
polyCenter = Cesium.Ellipsoid.WGS84.scaleToGeodeticSurface(polyCenter);
|
item.position = polyCenter;
|
var positions = item.polygon.hierarchy._value.positions; // 设置面轮廓
|
|
item.polyline = new Cesium.PolylineGraphics({
|
positions: positions,
|
clampToGround: true,
|
// 贴地
|
width: 5,
|
material: Cesium.Color.fromCssColorString("#FFA500")
|
});
|
var label_name = item.name ? item.name : "";
|
item.label = {
|
text: label_name,
|
font: "500 16x sans-serif",
|
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
|
// 字体样式
|
fillColor: new Cesium.Color.fromCssColorString("#FFFFFF"),
|
outlineWidth: 1,
|
// 字体外圈线宽度(同样也有颜色可设置)
|
outlineColor: new Cesium.Color.fromCssColorString("#FFFFFF"),
|
verticalOrigin: Cesium.VerticalOrigin.BASELINE,
|
// 垂直位置
|
pixelOffset: new Cesium.Cartesian2(0, 0),
|
// 中心位置
|
disableDepthTestDistance: Number.POSITIVE_INFINITY,
|
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(500.0, 3000.0) // showBackground:true,
|
// backgroundColor: new Cesium.Color(26 / 255, 196 / 255, 228 / 255, 1.0) //背景顔色
|
|
};
|
});
|
Viewer.dataSources.add(that.dataSource);
|
});
|
},
|
getTileSet: function getTileSet() {
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) {
|
return null;
|
}
|
|
return objItem[0];
|
},
|
setQueryExtent2: function setQueryExtent2(res, boolen) {
|
var _this4 = this;
|
|
var tileset = this.getTileSet();
|
|
if (!tileset) {
|
return;
|
} //
|
|
|
var filed = this.getPublickey(res);
|
(0, _modelBase.getQueryEentity)({
|
token: (0, _auth.getToken)(),
|
start: 1,
|
count: 0,
|
containCount: true,
|
layerid: tileset.layerId,
|
dbid: _modelLayer["default"].dbid,
|
where: filed
|
}).then(function (response) {
|
if (response.code != 200) return;
|
var items = response.data.items[0];
|
var std = [];
|
var obj_val = response.data.items.filter(function (rs) {
|
if (rs.enti_uuid == "2a71136119e12b31107d47f22bc5fa29532d3113d1c184e9660b5a840bf3287c") {
|
return rs;
|
} else {
|
std.push({
|
lon: rs.lon,
|
lat: rs.lat
|
});
|
}
|
});
|
response.data.items.filter(function (rs) {
|
if (rs.enti_uuid != "2a71136119e12b31107d47f22bc5fa29532d3113d1c184e9660b5a840bf3287c") {
|
std.push({
|
lon: rs.lon,
|
lat: rs.lat
|
});
|
}
|
});
|
|
if (boolen) {
|
_this4.getQueryGeomExtent(obj_val[0], tileset.layerId);
|
} else {
|
_this4.getshowQueryExtentLabel(obj_val[0], std);
|
}
|
});
|
},
|
getshowQueryExtentLabel: function getshowQueryExtentLabel(res, coord) {
|
this.richTextPoint1 = earthCtrl.factory.createRichTextPoint(res.name_1, [res.lon, res.lat], {
|
fontColor: "#ffff00",
|
fontSize: 18
|
}, "0");
|
var center = {
|
lon: res.lon,
|
lat: res.lat
|
};
|
var cities = coord;
|
var pathOption = {
|
width: 3,
|
//线宽(可选)
|
color: "#00ffff",
|
//线颜色(可选),
|
LightSpot: true,
|
//是否使用光点效果(可选)
|
LightSpotColor: "#ffffff",
|
//光点颜色(可选)
|
height: 100
|
};
|
this.linePath = earthCtrl.factory.createTrailLinePath(center, cities, pathOption);
|
},
|
getQueryGeomExtent: function getQueryGeomExtent(items, layerid) {
|
var _this5 = this;
|
|
var geom = _mapConfig["default"].setPointToCrical(items.lon, items.lat, 1);
|
|
var token = (0, _auth.getToken)();
|
var url = config.modelBase.url + config.modelBase.geo + "/entitydbdata/query/entity";
|
|
_axios["default"].post(url, {
|
layerid: layerid,
|
dbid: _modelLayer["default"].dbid,
|
geometry: JSON.stringify(geom.geometry),
|
returnCountOnly: true,
|
token: token
|
}, {
|
headers: {
|
Authorization: token,
|
"Content-Type": "application/x-www-form-urlencoded" // 'Cookie': "token=" + token,
|
// 'Token': token
|
|
}
|
}).then(function (response) {
|
_this5.getLayerModelList(url, response.data.data, geom.geometry, layerid);
|
});
|
},
|
getLayerModelList: function getLayerModelList(url, count, geom, layerid) {
|
var _this6 = this;
|
|
var token = (0, _auth.getToken)();
|
|
_axios["default"].post(url, {
|
token: token,
|
dbid: _modelLayer["default"].dbid,
|
layerid: layerid,
|
start: 1,
|
count: count,
|
containCount: true,
|
geometry: JSON.stringify(geom)
|
}, {
|
headers: {
|
Authorization: token,
|
"Content-Type": "application/x-www-form-urlencoded"
|
}
|
}).then(function (response) {
|
var std = [];
|
var items = response.data.data.items;
|
items.map(function (val) {
|
std.push(val.seid);
|
});
|
(0, _vue.nextTick)(function () {
|
var objItem = _mapServer["default"].listData.filter(function (item) {
|
if (item.type === "Tileset") {
|
return item;
|
}
|
});
|
|
if (objItem.length <= 0) return;
|
var tileset = objItem[0];
|
if (std.length <= 0) return;
|
|
_this6.setTilesetColorChange(tileset, std, "#FF0000");
|
});
|
});
|
},
|
setQueryExtent: function setQueryExtent(res) {
|
var geom = _mapConfig["default"].setPointToCrical(res.lon, res.lat, 5000);
|
|
var arr = [];
|
var coord = geom.geometry.coordinates[0];
|
coord.map(function (item) {
|
if (arr.length == 0) {
|
arr = item;
|
} else {
|
arr = [].concat(_toConsumableArray(arr), _toConsumableArray(item));
|
}
|
});
|
arr = arr.toString().replaceAll(",", " ");
|
this.getQuery(this.url, arr, this.layerData);
|
},
|
getQuery: function getQuery(url, area, layer) {
|
var entity = layer.entities.values;
|
entity.filter(function (rs) {
|
rs.polygon.material = new Cesium.Color.fromCssColorString("#FFFFFF");
|
});
|
|
_axios["default"].get(url, {
|
params: {
|
version: "1.3.0",
|
request: "GetFeature",
|
typename: "GeoEntity",
|
propertyname: "*",
|
format: "json",
|
filter: "<ogc:Filter xmlns:ogc=\"http://www.opengis.net/ogc\"><ogc:Intersects><ogc:PropertyName /><gml:Polygon xmlns:gml=\"http://www.opengis.net/gml\" srsName=\"EPSG:4326\"><gml:exterior><gml:LinearRing><gml:posList>".concat(area, "</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></ogc:Intersects></ogc:Filter>")
|
}
|
}).then(function (res) {
|
var obj = res.data.features;
|
obj.filter(function (item) {
|
entity.filter(function (rs) {
|
if (item.id == rs.id) {
|
rs.polygon.material = Cesium.Color.RED;
|
}
|
});
|
});
|
});
|
},
|
setQueryTF: function setQueryTF(content, layer, name) {
|
var url = this.getQueryUrl(content, layer);
|
|
_axios["default"].get(url).then(function (res) {
|
var data = res.data.features;
|
var obj = data.filter(function (item) {
|
if (item.properties.weaponname == name) {
|
return item;
|
}
|
});
|
if (obj.length <= 0) return;
|
var centroid = turf.centroid(obj[0]);
|
var geom = centroid.geometry.coordinates;
|
var position = [geom[0], geom[1], 0];
|
var cylinder = {
|
radius: 1000,
|
//半径
|
angle: 30,
|
//扫描角度(可选)
|
speed: 5,
|
//倍速(可选)
|
stackPartitions: 80,
|
//横向网格数(可选)
|
slicePartitions: 80,
|
//纵向网格数(可选)
|
wallColor: "rgba(255,255,255,0)" //扫描墙颜色(可选)
|
|
};
|
var item = earthCtrl.factory.createRectangularSensor(position, cylinder);
|
Viewer.zoomTo(item.item);
|
});
|
},
|
getQueryUrl: function getQueryUrl(content, layer) {
|
return "https://cim.smartearth.cn/SEserver/wfsserver/" + content + "?version=1.1.0&request=GetFeature&format=json&typename=" + layer;
|
}
|
};
|
var _default = layerJson;
|
exports["default"] = _default;
|