e05c7808 by chiangbt

20191209

2 parents 4401897e cf92bab6
......@@ -2,7 +2,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:31:52
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 23:36:27
* @LastEditTime: 2019-12-09 13:55:27
* @FilePath: \superglobevue\README.md
-->
# superglobevue
......@@ -19,18 +19,20 @@ SuperGlobeVue是基于vue-cli3和supermap cesium 的一款Globe地球视图。
## 2、功能组件
- viewer_ymo.vue 淹没分析
- viewer_tdt.vue 加载天地图数据
- viewer_s3m.vue 加载倾斜摄影数据+矢量面(构成水面)
- viewer_s3m_single.vue 添加铁岭倾斜摄影数据+矢量面数据+矢量单体化查询效果
- viewer_s3m_wz.vue 自定义添加温州倾斜摄影数据+矢量面数据+单体化查询
- viewer_ms3m.vue 通过scene和addS3MTilesLayerByScp两种方式添加倾斜摄影场景和图层
- viewer_ming.vue 多个栅格图层面的动画效果
- viewer_changeview.vue 地图视图效果,在10000米以上不能改变角度,10000米以下能够改动视角
- viewer_3dmodel.vue 展示矢量数据白模
- viewer_underground.vue 地底开挖效果,实际上是改变某个SCP图层的局部透明度
- viewer_split.vue 地图分屏
- viewer_spatialquery.vue 空间过滤查询
- viewer_ymo.vue 淹没分析
- viewer_tdt.vue 加载天地图数据
- viewer_s3m.vue 加载倾斜摄影数据+矢量面(构成水面)
- viewer_s3m_single.vue 添加铁岭倾斜摄影数据+矢量面数据+矢量单体化查询效果
- viewer_s3m_wz.vue 自定义添加温州倾斜摄影数据+矢量面数据+单体化查询
- viewer_ms3m.vue 通过scene和addS3MTilesLayerByScp两种方式添加倾斜摄影场景和图层
- viewer_ming.vue 多个栅格图层面的动画效果
- viewer_changeview.vue 地图视图效果,在10000米以上不能改变角度,10000米以下能够改动视角
- viewer_3dmodel.vue 展示矢量数据白模
- viewer_underground.vue 地底开挖效果,实际上是改变某个SCP图层的局部透明度
- viewer_split.vue 地图分屏
- viewer_spatialquery.vue 空间过滤查询
- viewer_spatialquery_tl.vue 空间过滤,将结果(面)转换为entity
- viewer_fire.vue 火焰效果
## 2、设置
### 项目依赖库安装
......
<!--
* 矢量数据白模
* 矢量数据白模的展示
* @Author: jiangbotao
* @Date: 2019-12-07 14:24:01
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 18:07:21
* @LastEditTime: 2019-12-09 13:09:00
* @FilePath: \superglobevue\src\components\viewer_3dmodel.vue
-->
<template>
......@@ -64,7 +64,8 @@ export default {
}));
try{
//打开所发布三维服务下的所有图层
//打开所发布三维服务下的所有图层
//GZ_SCENE中只有白模数据,没有矢量数据图层
var promise = scene.open(URL_CONFIG.GZ_SCENE);
Cesium.when.all(promise, function(layers){
//设置图层的阴影模式
......@@ -89,7 +90,6 @@ export default {
widget.showErrorPanel(title, undefined, e);
}
}
$('#loadingbar').remove();
}
}
......
<!--
* 火焰效果
* 鼠标点击处会出现火灾效果
* @Author: jiangbotao
* @Date: 2019-12-08 22:39:07
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-09 12:01:09
* @FilePath: \superglobevue\src\components\viewer_fire.vue
-->
<template>
<div>
<div id="cesiumContainer" v-bind:style="styleObject"></div>
<div id='loadingbar' class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
</div>
</div>
</template>
<script>
import URL_CONFIG from './../config/urlConfig.vue';
const Cesium=window.Cesium;
export default {
data: function(){
return {
styleObject:{
width: '100%',
position: 'absolute',
top: '0px',
bottom: '0px',
left: '0px',
backgroundColor: '#000000'
},
smviewer:{}
}
},
mounted: function(){
var __this = this;
__this.smviewer=new Cesium.Viewer('cesiumContainer', { animation: true });
var scene = __this.smviewer.scene;
// 隐藏logo
$(".cesium-widget-credits")[0].style.visibility="hidden";
$(".cesium-viewer-animationContainer")[0].style.visibility="hidden";
// 隐藏导航工具
// $(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";
// 添加天地图数据
__this.smviewer.imageryLayers.addImageryProvider(new Cesium.TiandituImageryProvider({
mapStyle : Cesium.TiandituMapsStyle.IMG_C,
token: URL_CONFIG.TOKEN_TIANDITU
}));
var imageryLayers = this.smviewer.imageryLayers;
//初始化天地图全球中文注记服务,并添加至影像图层
var labelImagery = new Cesium.TiandituImageryProvider({
mapStyle : Cesium.TiandituMapsStyle.CIA_C, //天地图全球中文注记服务(经纬度投影)
token: URL_CONFIG.TOKEN_TIANDITU
});
imageryLayers.addImageryProvider(labelImagery);
__this.smviewer.camera.setView({
destination : Cesium.Cartesian3.fromDegrees(116.34485552299206, 39.99754814959118, 450.0)
});
// 鼠标左键点击事件
var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(e) {
//获取点击位置笛卡尔坐标
var position = scene.pickPosition(e.position);
//将笛卡尔坐标转化为经纬度坐标
var cartographic = Cesium.Cartographic.fromCartesian(position);
var longitude = Cesium.Math.toDegrees(cartographic.longitude);
var latitude = Cesium.Math.toDegrees(cartographic.latitude);
var height = 2;
// 火灾地点
var staticPosition = Cesium.Cartesian3.fromDegrees(longitude, latitude, height);
var entity = __this.smviewer.entities.add({
position : staticPosition
});
var particleSystem = scene.primitives.add(new Cesium.ParticleSystem({
// 粒子的图片
image: './images/fire.png',
// 起始颜色
startColor: new Cesium.Color(1, 1, 1, 1),
// 结束颜色
endColor: new Cesium.Color(1, 0, 0, 0),
startScale : 1.0,
// 结束大小比例
endScale: 1.5,
// 最小生命周期
minimumParticleLife: 1.5,
// 最大生命周期
maximumParticleLife: 5,
// 最小速度
minimumSpeed: 7.0,
// 最大速度
maximumSpeed: 9.0,
// 粒子大小
imageSize: new Cesium.Cartesian2(12, 12),
// 粒子数量
emissionRate: 200,
lifetime: 16,
// 循环是否开启
loop: true,
// 粒子的释放方向
emitter: new Cesium.ConeEmitter(Cesium.Math.toRadians(45.0)),
// 是否以米为单位
sizeInMeters: true
}))
__this.smviewer.scene.preUpdate.addEventListener(function(scene, time) {
particleSystem.modelMatrix = computeModelMatrix(entity, time)
// Account for any changes to the emitter model matrix.
particleSystem.emitterModelMatrix = computeEmitterModelMatrix()
})
function computeModelMatrix(entity, time) {
return entity.computeModelMatrix(time, new Cesium.Matrix4())
}
var emitterModelMatrix = new Cesium.Matrix4()
var translation = new Cesium.Cartesian3()
var rotation = new Cesium.Quaternion()
var hpr = new Cesium.HeadingPitchRoll()
var trs = new Cesium.TranslationRotationScale()
// 改变粒子系统的位置
function computeEmitterModelMatrix() {
hpr = Cesium.HeadingPitchRoll.fromDegrees(0.0, 0.0, 0.0, hpr)
trs.translation = Cesium.Cartesian3.fromElements(-2, 0, 2, translation)
trs.rotation = Cesium.Quaternion.fromHeadingPitchRoll(hpr, rotation)
return Cesium.Matrix4.fromTranslationRotationScale(trs, emitterModelMatrix)
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
$('#loadingbar').remove();
}
}
</script>
<style scoped>
.sm-compass {
pointer-events: auto;
position: absolute;
right: 10px;
top: 10px;
width: 128px;
height: 128px;
overflow: hidden;
}
.sm-zoom {
top: 130px;
}
</style>
\ No newline at end of file
<!--
* @Author: jiangbotao
* 本例中使用了铁岭的倾斜摄影数据发布的服务
* 1、必须同时发布为三维和Rest服务
* 2、使用要素查询方式来选择倾斜摄影覆盖面
* 1、必须同时发布为三维和Rest数据服务
* 2、使用要素查询方式来选择倾斜摄影覆盖面(a、矢量面紧贴S3M;b、矢量面构筑entity)
* 3、使用Popup来弹出倾斜摄影覆盖面的信息
* @Date: 2019-12-03 22:52:56
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:01:32
* @LastEditTime: 2019-12-09 13:33:21
* @FilePath: \superglobevue\src\components\viewer.vue
-->
<template>
......@@ -62,6 +62,7 @@ export default {
};
},
mounted: function() {
// cesium视图
this.viewer = new Cesium.Viewer("cesiumContainer", { navigationInstructionsInitiallyVisible: false });
// 使用自定义的navigation
var options = {};
......@@ -74,19 +75,24 @@ export default {
$(".cesium-widget-credits")[0].style.visibility = "hidden";
// 隐藏导航工具
$(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";
// 必要的引用对象
var smviewer = this.viewer;
var scene = this.viewer.scene;
var widget = this.viewer.cesiumWidget;
var camera = scene.camera;
// 场景位置,用于popup定位
var scenePosition = null;
var infoboxContainer = document.getElementById("bubble");
var table = document.getElementById("tab");
try {
// 添加s3m图层
var promise2 = scene.addS3MTilesLayerByScp("http://www.supermapol.com/realspace/services/3D-dynamicDTH/rest/realspace/datas/Config%20-%201/config",
{ name: "oblique photography" });
Cesium.when.all([promise2], function(obliqueLayers){ // 等倾斜摄影数据加载完了再去加载矢量面,否则矢量面找不到目标去贴对象
camera.setView({ // 先定位,开始渲染定位区域的倾斜
Cesium.when.all([promise2], function(obliqueLayers){
// 等倾斜摄影数据加载完了再去加载矢量面,否则矢量面找不到目标去贴对象
// 先定位,开始渲染定位区域的倾斜
camera.setView({
destination : new Cesium.Cartesian3(-2623004.4174251584, 3926981.958360567, 4287374.829655093),
orientation : {
heading: 4.39611370540786,
......@@ -103,16 +109,17 @@ export default {
widget.showErrorPanel(title, undefined, e);
}
}
// 倾斜摄影模型下的矢量数据面
var dataSourceName = '铁岭矢量面'; // 数据源名称
var dataSetName = 'New_Region3D_1'; // 数据集名称
var dataServiceUrl = 'http://www.supermapol.com/realspace/services/data-dynamicDTH/rest/data/featureResults.rjson?returnContent=true';
var infoboxContainer = document.getElementById("bubble");
var table = document.getElementById("tab");
// 鼠标左键的触发事件,查询要素并弹出显示
var handler = new Cesium.ScreenSpaceEventHandler(this.viewer.canvas);
handler.setInputAction(function(e) {
// 删除可能存在的identify-area的entity,它是我们后面查询的用于标识模型的三维面
smviewer.entities.removeById('identify-area');
// 当前位置
var position = scene.pickPosition(e.position);
// 设置场景位置
scenePosition = position;
......@@ -123,24 +130,10 @@ export default {
x: longitude,
y: latitude
};
// console.log(queryPoint);
// 将当前点转换为地理坐标后进行查询
queryByPoint(queryPoint);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
var ellipsoid = this.viewer.scene.globe.ellipsoid;
handler.setInputAction(function(e) {
var cartesian = smviewer.camera.pickEllipsoid(e.endPosition, ellipsoid);
if(cartesian){
//将笛卡尔三维坐标转为地图坐标(弧度)
var cartographic = scene.globe.ellipsoid.cartesianToCartographic(cartesian);
//将地图坐标(弧度)转为十进制的度数
var lat_String = Cesium.Math.toDegrees(cartographic.latitude).toFixed(4);
var log_String = Cesium.Math.toDegrees(cartographic.longitude).toFixed(4);
var alti_String = (smviewer.camera.positionCartographic.height).toFixed(2);
$('.ant-layout-footer').text('经度 : ' + log_String +' | 纬度 : ' + lat_String + ' | 高度 : ' + alti_String);
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
$("#close").click(function(){
// 关闭气泡
smviewer.entities.removeAll();
......@@ -182,7 +175,7 @@ export default {
if (resultObj.featureCount > 0) {
var selectedFeature = resultObj.features[0];
addClapFeature(selectedFeature);
console.log(selectedFeature);
// console.log(selectedFeature);
$("#bubble").show();
for (var i=table.rows.length-1; i>-1; i--){
table.deleteRow(i);
......@@ -194,6 +187,8 @@ export default {
cell1.innerHTML = selectedFeature.fieldNames[index];
cell2.innerHTML = selectedFeature.fieldValues[index];
}
}else{
$("#bubble").hide();
}
},
error: function(msg) {
......@@ -203,16 +198,34 @@ export default {
}
// 将数据服务查询到的要素添加到场景中高亮显示,表示选中效果。
// 两种方法:
// a. 矢量面紧贴S3M
// b. 使用entity模型
function addClapFeature(feature) {
var lonLatArr = getLonLatArray(feature.geometry.points);
// smviewer.entities.add({
// id: 'identify-area',
// name: '单体化标识面',
// polygon: {
// hierarchy: Cesium.Cartesian3.fromDegreesArray(lonLatArr),
// material: new Cesium.Color(1.0, 0.0, 0.0, 0.3),
// },
// clampToS3M: true // 贴在S3M模型表面
// });
console.log(lonLatArr);
smviewer.entities.add({
id: 'identify-area',
name: '单体化标识面',
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray(lonLatArr),
material: new Cesium.Color(1.0, 0.0, 0.0, 0.3),
material: new Cesium.Color(0.0, 1.0, 0.0, 0.3),
// perPositionHeight: true,
extrudedHeight: 100,
height: 50,
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
outline : true,
outlineColor : Cesium.Color.BLACK
},
clampToS3M: true // 贴在S3M模型表面
});
}
......
<!--
* 使用本地发布的温州七都村OSGB数据并自己生产了一批矢量面进行贴合
* @Author: jiangbotao
* @Date: 2019-12-03 22:52:56
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:02:03
* @LastEditTime: 2019-12-09 09:46:34
* @FilePath: \superglobevue\src\components\viewer.vue
-->
<template>
......
......@@ -165,7 +165,6 @@ export default {
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: {
......
<!--
* 空间查询
* 二维结果面形成entity
* @Author: jiangbotao
* @Date: 2019-12-03 22:52:56
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-09 13:54:49
* @FilePath: \superglobevue\src\components\viewer.vue
-->
<template>
<div>
<div id="cesiumContainer" v-bind:style="styleObject"></div>
<div id='loadingbar' class="spinner">
<div class="spinner-container container1">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container2">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
<div class="spinner-container container3">
<div class="circle1"></div>
<div class="circle2"></div>
<div class="circle3"></div>
<div class="circle4"></div>
</div>
</div>
<div id="toolbar" class="param-container tool-bar">
<div>
<button id="search" >查询</button>
</div>
</div>
</div>
</template>
<script>
import URL_CONFIG from "./../config/urlConfig.vue";
const Cesium = window.Cesium;
const SuperMap = window.SuperMap;
export default {
data: function() {
return {
styleObject: {
width: "100%",
position: "absolute",
top: "0px",
bottom: "0px",
left: "0px",
backgroundColor: "#000000"
},
smviewer: {}
};
},
mounted: function() {
var __this = this;
__this.viewer = new Cesium.Viewer('cesiumContainer', { animation: true });
var scene = __this.viewer.scene;
var widget = __this.viewer.cesiumWidget;
var camera = scene.camera;
// 隐藏logo
$(".cesium-widget-credits")[0].style.visibility = "hidden";
$(".cesium-viewer-animationContainer")[0].style.visibility="hidden";
$(".cesium-infoBox")[0].style.visibility='hidden';
// 隐藏导航工具
// $(".cesium-viewer-navigationContainer")[0].style.visibility="hidden";
try {
var promise2 = scene.addS3MTilesLayerByScp("http://www.supermapol.com/realspace/services/3D-dynamicDTH/rest/realspace/datas/Config%20-%201/config",
{ name: "oblique photography" });
Cesium.when([promise2], function(layers) {
camera.setView({
destination : new Cesium.Cartesian3(-2623004.4174251584, 3926981.958360567, 4287374.829655093),
orientation : {
heading: 4.39611370540786,
pitch : -0.43458664812464143,
roll : 2.0174972803488345e-11
}
});
// 去除加载动画
$('#loadingbar').remove();
var positions = null;
// 绘制面
var handlerPolygon = new Cesium.DrawHandler(__this.viewer, Cesium.DrawMode.Polygon, 0);
handlerPolygon.drawEvt.addEventListener(function(polygon){
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){
if(isActive === true){
__this.viewer.enableCursorStyle = false;
__this.viewer._element.style.cursor = '';
$('body').removeClass('drawCur').addClass('drawCur');
}else{
__this.viewer.enableCursorStyle = true;
$('body').removeClass('drawCur');
}
});
handlerPolygon && handlerPolygon.deactivate();
handlerPolygon && handlerPolygon.activate();
});
function processCompleted(queryEventArgs){
var selectedFeatures = queryEventArgs.originResult.features;
__this.viewer.entities.removeAll();
console.log(selectedFeatures);
for(var i = 0; i < selectedFeatures.length; i++){
var value = selectedFeatures[i].fieldValues["0"];
var feature = selectedFeatures[i];
var pts = [];
for(var j=0; j< feature.geometry.points.length; j++){
pts.push(feature.geometry.points[j].x);
pts.push(feature.geometry.points[j].y);
}
__this.viewer.entities.add({
id: value,
name: selectedFeatures[i].fieldValues["0"],
polygon: {
hierarchy: Cesium.Cartesian3.fromDegreesArray(pts),
material: new Cesium.Color(0.0, 1.0, 0.0, 0.3),
extrudedHeight: 100,
height: 50,
vertexFormat : Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
outline : true,
outlineColor : Cesium.Color.BLACK
},
});
}
}
function query(drawGeometryArgs){
var getFeaturesByGeometryParameters, getFeaturesByGeometryService;
getFeaturesByGeometryParameters = new SuperMap.REST.GetFeaturesByGeometryParameters({
datasetNames: ["铁岭矢量面:New_Region3D_1"],
toIndex:-1,
spatialQueryMode:SuperMap.REST.SpatialQueryMode.INTERSECT,
geometry: drawGeometryArgs
});
var url = 'http://www.supermapol.com/realspace/services/data-dynamicDTH/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);
});
} catch (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}
$("#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>
<style>
.sm-compass {
pointer-events: auto;
position: absolute;
right: 10px;
top: 10px;
width: 128px;
height: 128px;
overflow: hidden;
}
.sm-zoom {
top: 130px;
}
.drawCur{
cursor: url(/images/cur/draw.cur), auto;
}
.cesium-infoBox{
top: 20;
left: 0;
transition: opacity 0.2s;
}
</style>
......@@ -4,7 +4,7 @@
* 2、添加了超图发布的矢量瓦片服务
* @Date: 2019-12-02 09:05:50
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 13:52:13
* @LastEditTime: 2019-12-08 22:42:53
* @FilePath: \WebGL_Webpack_Vue\components\viewer.vue
-->
<template>
......
......@@ -3,7 +3,7 @@
* @Author: jiangbotao
* @Date: 2019-12-07 14:24:01
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 18:19:06
* @LastEditTime: 2019-12-09 11:46:57
* @FilePath: \superglobevue\src\components\viewer_3dmodel.vue
-->
<template>
......
......@@ -8,7 +8,7 @@
* @Author: jiangbotao
* @Date: 2019-12-02 09:05:50
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:59:33
* @LastEditTime: 2019-12-09 12:22:02
* @FilePath: \WebGL_Webpack_Vue\components\viewer.vue
-->
<template>
......
......@@ -2,7 +2,7 @@
* @Author: jiangbotao
* @Date: 2019-12-03 22:54:10
* @LastEditors: jiangbotao
* @LastEditTime: 2019-12-07 14:31:42
* @LastEditTime: 2019-12-09 13:10:30
* @FilePath: \superglobevue\src\config\urlConfig.vue
-->
<script>
......
......@@ -3,7 +3,7 @@
</template>
<script>
import viewer from "@/components/viewer_split.vue";
import viewer from "@/components/viewer_s3m_wz.vue";
export default {
name: "home",
......