Plane coordinate system model
In some projects, the 3D data is modeled according to the plane coordinate system, and it is considered that some requirements cannot be converted to the longitude and latitude coordinate system, so some means are needed - after calculating and converting the coordinates of the model, the scene is placed at the position of longitude 0 ° (primary meridian).
1. Operations in idesktop
Load the model data into the plane scene, generate the scene cache (s3m) after confirmation, and find the center point of the model by querying the coordinate value.
2. Operation in webgl (code)
Iserver publishes the workspace as a 3D service. Use it after publishing. Because Cesium does not support loading 3D in plane coordinate system, there will be no model preview in iserver, or even an error.
To load the published model in webgl, first set the sceneMode scene mode of the viewer to Columbus mode (Cesium.SceneMode.COLUMBUS_VIEW). Then through scene Open() adds the model.
Code:
viewer = new Cesium.Viewer('cesiumContainer');
viewer.scene.mode = Cesium.SceneMode.COLUMBUS_VIEW;
At this time, the model has been added to the scene, but Cesium cannot recognize the coordinates of the plane coordinate system and cannot locate the model location. Therefore, it is necessary to convert the center point just obtained in idesktop. Then set the camera attribute and fly to the center of the model.
Conversion code:
var point = new Cesium.Cartesian3(X, Y, Z);
var pointCartographic = scene.camera._projection.unproject(point);
var pointCX = Cesium.Math.toDegrees(pointCartographic.longitude);
var pointCY = Cesium.Math.toDegrees(pointCartographic.latitude);
At this point, the webgl can load the plane coordinate system model and display it. If you want to fully simulate the plane scene in idesktop, you can replace the spherical background image.
3. some 3D analysis functions cannot be used
As of January 16, 2019, functions closely related to layer operation cannot be realized, such as terrain excavation (terrain data required), shadow analysis, lighting analysis, height control analysis (terrain data required), etc
Normally used and commonly used: viewable analysis, intervisibility analysis, skyline analysis, scene flight, measurement;
4. complete code
// Loading a flat scene model function onload(Cesium) { //initialization viewer parts viewer = new Cesium.Viewer('cesiumContainer'); var scene = viewer.scene; var widget = viewer.cesiumWidget; viewer.scene.mode = Cesium.SceneMode.COLUMBUS_VIEW; viewer._cesiumWidget._creditContainer.style.display = 'none'; try { //Open all layers under the published 3D service var url5 = "http://localhost:8090/iserver/services/3D-a701-a7-01/rest/realspace"; var promise = scene.open(url5); Cesium.when.all(promise, function(layers) { layers.forEach(function(item, index) { item.ignoreNormal = true // Gets or sets whether the GPU Automatically calculate normals in item.clearMemoryImmediately = true // Whether to release memory in time }) var point = new Cesium.Cartesian3(4057.48, 1554.01, 10); var pointCartographic = scene.camera._projection.unproject(point); var pointCX = Cesium.Math.toDegrees(pointCartographic.longitude); var pointCY = Cesium.Math.toDegrees(pointCartographic.latitude); //Set camera position and position to model scene.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees(pointCX, pointCY, pointCartographic.height), orientation: { heading: 0, pitch: 0, roll: 0 } }); }, function(e) { if (widget._showRenderLoopErrors) { var title = 'loading SCP Failed, please check the network connection status or url Is the address correct?'; widget.showErrorPanel(title, undefined, e); } }); } catch (e) { if (widget._showRenderLoopErrors) { var title = 'An error occurred while rendering, rendering stopped.'; widget.showErrorPanel(title, undefined, e); } } }