bd48109c by unknown

'20191207'

1 parent a707c407
......@@ -2,7 +2,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:31:52
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:52:28
* @LastEditTime: 2019-12-07 23:36:27
* @FilePath: \superglobevue\README.md
-->
# superglobevue
......@@ -30,6 +30,7 @@ SuperGlobeVue是基于vue-cli3和supermap cesium 的一款Globe地球视图。
- viewer_3dmodel.vue 展示矢量数据白模
- viewer_underground.vue 地底开挖效果,实际上是改变某个SCP图层的局部透明度
- viewer_split.vue 地图分屏
- viewer_spatialquery.vue 空间过滤查询
## 2、设置
### 项目依赖库安装
......
......@@ -2,7 +2,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:31:08
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-04 00:26:36
* @LastEditTime: 2019-12-07 17:35:42
* @FilePath: \superglobevue\public\index.html
-->
<!DOCTYPE html>
......@@ -19,8 +19,9 @@
<script type="text/javascript" src="./js/jquery.min.js" data-main="js/main"></script>
<link href="./css/bootstrap.min.css" rel="stylesheet">
<script src="./js/bootstrap.min.js"></script>
<script src="./js/spectrum.js"></script>
<link href="./css/pretty.css" rel="stylesheet">
<script src="./js/spectrum.js"></script>
<link href="./css/pretty.css" rel="stylesheet">
<script type="text/javascript" src="./js/supermap/SuperMap.Include.js"></script>
<script type="text/javascript" src="./js/require.min.js" data-main="js/main"></script>
<title>超图三维地图Demo</title>
<style type="text/css">
......
var CesiumToSuperMap = {
convertPoint : function(Cesium,SuperMap,point){
if(!Cesium || !SuperMap || !point){
return undefined;
}
var lonlatPoint = Cesium.Cartographic.fromCartesian(point);
var x = Cesium.Math.toDegrees(lonlatPoint.longitude);
var y = Cesium.Math.toDegrees(lonlatPoint.latitude);
if(x && y){
return new SuperMap.Geometry.Point(x,y);
}
return undefined;
},
convertPolyline : function(Cesium,SuperMap,polyline){
if(!Cesium || !SuperMap || !polyline){
throw undefined;
}
var points = polyline.positions;
if(points && points instanceof Array && points.length >= 2){
var arr = [];
for(var i = 0,j = points.length;i < j;i++){
var point = this.convertPoint(Cesium,SuperMap,points[i]);
if(point){
arr.push(point);
}
}
return new SuperMap.Geometry.LineString(arr);
}
return undefined;
},
convertPolygon : function(Cesium, SuperMap, polygon){
if(!Cesium || !SuperMap || !polygon){
throw undefined;
}
var points = polygon.positions;
if(points && points instanceof Array && points.length >= 3){
var arr = [];
for(var i = 0,j = points.length;i < j;i++){
var point = this.convertPoint(Cesium,SuperMap,points[i]);
if(point){
arr.push(point);
}
}
var linearRing = new SuperMap.Geometry.LinearRing(arr);
return new SuperMap.Geometry.Polygon(linearRing);
}
return undefined;
}
};
var SuperMapToCesium = {
geometryToEntity : function(Cesium,SuperMap,geometry){
var className = geometry.CLASS_NAME;
if(className == 'SuperMap.Geometry.MultiPolygon'){
return this.multipolygonToEntities(Cesium,SuperMap,geometry);
}
else if(className == 'SuperMap.Geometry.Polygon'){
return [this.polygonToEntity(Cesium,SuperMap,geometry)];
}
return undefined;
},
polygonToEntity : function(Cesium,SuperMap,geometry){
var hierarchy = {};
for(var i = 0,j = geometry.components.length;i < j;i++){
if(i == 0){
hierarchy.positions = this.GeometrytoDegreesArray(Cesium,SuperMap,geometry.components[i]);
}
else{
if(!hierarchy.holes){
hierarchy.holes = [];
}
hierarchy.holes.push({
positions : this.GeometrytoDegreesArray(Cesium,SuperMap,geometry.components[i])
});
}
}
return new Cesium.Entity({
polygon : {
hierarchy : hierarchy,
material : Cesium.Color.BLUE.withAlpha(0.5)
},
depthTestEnabled : false
});
},
multipolygonToEntities : function(Cesium,SuperMap,geometry){
var components = geometry.components;
var resultEntities = [];
var entity;
for(var item in components){
entity = this.polygonToEntity(Cesium,SuperMap,components[item]);
resultEntities.push(entity);
}
return resultEntities;
},
GeometrytoDegreesArray : function(Cesium,SuperMap,geometry){
var vertices = geometry.getVertices();
var degreesArr = [];
for(var o in vertices){
degreesArr.push(vertices[o].x,vertices[o].y);
}
return Cesium.Cartesian3.fromDegreesArray(degreesArr);
}
};
\ No newline at end of file
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-07 14:24:01
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:28:38
* @LastEditTime: 2019-12-07 18:07:21
* @FilePath: \superglobevue\src\components\viewer_3dmodel.vue
-->
<template>
......
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:52:56
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-04 22:23:44
* @LastEditTime: 2019-12-07 23:25:28
* @FilePath: \superglobevue\src\components\viewer.vue
-->
<template>
......@@ -40,6 +40,7 @@
<script>
import URL_CONFIG from "./../config/urlConfig.vue";
const Cesium = window.Cesium;
const SuperMap = window.SuperMap;
export default {
data: function() {
return {
......@@ -61,6 +62,7 @@ export default {
var widget = __this.viewer.cesiumWidget;
// 隐藏logo
$(".cesium-widget-credits")[0].style.visibility = "hidden";
$(".cesium-viewer-animationContainer")[0].style.visibility="hidden";
// 隐藏导航工具
// $(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";
......@@ -89,10 +91,21 @@ export default {
});
var positions = null;
// 绘制面
var handlerPolygon = new Cesium.DrawHandler(__this.viewer, Cesium.DrawMode.Polygon, 0);
var handlerPolygon = new Cesium.DrawHandler(__this.viewer, Cesium.DrawMode.Polygon, 0);
handlerPolygon.drawEvt.addEventListener(function(polygon){
console.log(polygon.object.positions);
return polygon.object.positions;
var points = polygon.object.positions;
var arr = [];
if(points && points instanceof Array && points.length >= 3){
for(var i = 0, j = points.length; i < j; i++){
var point = __this.convertPoint(points[i]);
if(point){
arr.push(point);
}
}
}
var linearRing = new SuperMap.Geometry.LinearRing(arr);
var searchPolygon = new SuperMap.Geometry.Polygon(linearRing);
query(searchPolygon);
});
$("#search").on("click", function(){
handlerPolygon.activeEvt.addEventListener(function(isActive){
......@@ -108,6 +121,63 @@ export default {
handlerPolygon && handlerPolygon.deactivate();
handlerPolygon && handlerPolygon.activate();
});
var IDs=[];
function processCompleted(queryEventArgs){
var selectedFeatures = queryEventArgs.originResult.features;
var color;
IDs=[];
__this.viewer.entities.removeAll();
for(var i = 0; i < selectedFeatures.length; i++){
var value = selectedFeatures[i].fieldValues["0"];
var feature = selectedFeatures[i];
for(var j = 0; j < feature.fieldNames.length; j++){
var index = j.toString();
if(j === 0){
var des = '<table class="cesium-infoBox-defaultTable"><tbody>' + '<tr><th>' + selectedFeatures[i].fieldNames["0"] + '</th><td>' + selectedFeatures[i].fieldValues["0"] + '</td></tr>';
}else if(j === feature.fieldNames.length - 1){
des += '<tr><th>' + selectedFeatures[i].fieldNames[index] + '</th><td>' + selectedFeatures[i].fieldValues[index] + '</td></tr>' + "</tbody></table>";
}else{
des += '<tr><th>' + selectedFeatures[i].fieldNames[index] + '</th><td>' + selectedFeatures[i].fieldValues[index] + '</td></tr>';
}
}
__this.viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(parseFloat(selectedFeatures[i].fieldValues["12"]), parseFloat(selectedFeatures[i].fieldValues["13"]), parseFloat(selectedFeatures[i].fieldValues["16"])),
billboard :{
image : './images/location4.png',
width:30,
height:40,
},
name : selectedFeatures[i].fieldValues["11"],
description: des
});
IDs.push(parseInt(value)+11);
}
var buildingLayer = scene.layers.find("Building@CBD");
if(IDs.length>0){
// buildingLayer.setSelection(IDs);
}
}
function query(drawGeometryArgs){
var getFeaturesByGeometryParameters, getFeaturesByGeometryService;
getFeaturesByGeometryParameters = new SuperMap.REST.GetFeaturesByGeometryParameters({
datasetNames: ["二维数据:building"],
toIndex:-1,
spatialQueryMode:SuperMap.REST.SpatialQueryMode.CONTAIN,
geometry: drawGeometryArgs
});
console.log('aa');
var url = 'http://www.supermapol.com/realspace/services/data-cbd/rest/data';
getFeaturesByGeometryService = new SuperMap.REST.GetFeaturesByGeometryService(url, {
eventListeners: {
"processCompleted": processCompleted,
"processFailed": processFailed
}
});
getFeaturesByGeometryService.processAsync(getFeaturesByGeometryParameters);
}
function processFailed(e) {
alert(e.error.errorMsg);
}
}, function() {
var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
widget.showErrorPanel(title, undefined, e);
......@@ -120,6 +190,17 @@ export default {
}
$("#loadingbar").remove();
},
methods:{
convertPoint : function(point){
var lonlatPoint = Cesium.Cartographic.fromCartesian(point);
var x = Cesium.Math.toDegrees(lonlatPoint.longitude);
var y = Cesium.Math.toDegrees(lonlatPoint.latitude);
if(x && y){
return new SuperMap.Geometry.Point(x, y);
}
return undefined;
}
}
};
</script>
......@@ -140,4 +221,9 @@ export default {
.drawCur{
cursor: url(/images/cur/draw.cur), auto;
}
.cesium-infoBox{
top: 20;
left: 0;
transition: opacity 0.2s;
}
</style>
......
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:52:56
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-04 22:23:44
* @LastEditTime: 2019-12-07 23:37:13
* @FilePath: \superglobevue\src\components\viewer.vue
-->
<template>
......@@ -81,17 +81,13 @@ export default {
var groundPromise = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_GROUND1, {
name: 'ground'
});
var ground2Promise = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_GROUND2, {
name: 'ground2'
});
var buildPromise = scene.addS3MTilesLayerByScp(URL_CONFIG.SCP_CBD_BUILD, {
name: 'build'
});
// 添加倾斜摄影模型图层
Cesium.when([groundPromise, ground2Promise, buildPromise], function(layers) {
Cesium.when([groundPromise, buildPromise], function(layers) {
var build = scene.layers.find("build");
var ground = scene.layers.find("ground");
var ground2 = scene.layers.find("ground2");
// 图层加载完成,设置相机位置
scene.camera.setView({
destination: Cesium.Cartesian3.fromDegrees(116.4563, 39.8969, 553),
......@@ -121,9 +117,11 @@ export default {
$('#pannel').show();
$('#b_one,#b_two,#g_one,#g_two').show();
$('#b_three,#g_three,#b_four,#g_four').hide();
// ground2.setVisibleInViewport(1, false);
scene.multiViewportMode = Cesium.MultiViewportMode["HORIZONTAL"];
});
ground.setViewportVisible(1, false);
ground.setViewportVisible(0, true);
});
}, function() {
var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
widget.showErrorPanel(title, undefined, e);
......
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-07 14:24:01
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:58:44
* @LastEditTime: 2019-12-07 18:19:06
* @FilePath: \superglobevue\src\components\viewer_3dmodel.vue
-->
<template>
......
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:31:08
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:49:20
* @LastEditTime: 2019-12-07 17:18:34
* @FilePath: \superglobevue\src\views\Home.vue
-->
<template>
......@@ -11,7 +11,7 @@
</template>
<script>
import viewer from "@/components/viewer_spatialquery.vue";
import viewer from "@/components/viewer_split.vue";
export default {
name: "home",
......