Supermap / Cesium development experience ---- positioning

SuperMap product of WebGL is based on a modified open source JS library to do Cesium formed, similar in theory to use them, look at if there is not the same place, and the structure is basically the interface name and Cesium is the same.

There positioning method based on Cesium.Camera class ( SuperMap / Cesium ), it does not need to create separate this because he is Cesium.viewer one Member members directly create good view of the container, you can get using view.camera

Cesium.Viewer class may also be used to make positioning method will be mentioned below

A positioning method (Camera.setView (_Object))

This method is directly to that location, configuration parameters Obj {destination:, orientation :, endTransform}

destination

The final position of the camera in the world coordinate system WGS84, or top-down view of the rectangular area is visible. That may be a point coordinate ({ Cartesian3 } format point coordinates), or a range of four ({ the Rectangle } format)

Cartesian3 point format structure

There are many ways, I am most commonly used is

  • Cartesian3 from radians to the Cesium.Cartesian3.fromRadians method ( of SuperMap / Cesium )
  • Cartesian3 transferred from the WGS-84 coordinate Cesium.Cartesian3.fromDegrees method ( of SuperMap / Cesium )
      viewer.camera.setView({
            destination:Cesium.Cartesian3.fromDegrees(116.4139265527,39.8865940599,100),
            orientation:{
                pitch: -0.3870743833538963,
                roll: 0.00004766518822663102,
                heading:5.71581666483758,
            }
        });

Rectangle format constructed four boundaries

There are many ways, I am most commonly used is

  • Direct configured rectangle: new new Cesium.Rectangle (West, South, East, North) method ( of SuperMap / Cesium ), to be noted that four units of radians parameters, the range [-PI, PI] and [-PI / 2, PI / 2]
     viewer.camera.setView({
                destination:Cesium.Rectangle(1.9911131841002994,0.6863576116684447,2.0676847898509436, 0.7171078891208857),
                orientation:{
                    pitch: -0.3870743833538963,
                    roll: 0.00004766518822663102,
                    heading:5.71581666483758,
            }
        });
  • Using WGS-84 coordinates to construct Cesium.Rectangle.fromDegrees (west, south, east, north, result) method ( of SuperMap / Cesium ), the range parameter is four [-180.0, 180.0] and [-90.0, 90.0]

Two positioning method (Camera.flyTo (_Object))

Camera.flyTo (_Obj) method parameters and setView almost the same, it is the focus of flying experience, flying to destinations there is a process, which is the duration parameter, which in seconds, to characterize the flight duration. If omitted, a reasonable distance calculated by the flight duration.

viewer.camera.flyTo ({ 
    Where do you want: Cesium.Cartesian3.fromDegrees ( -122.19, 46.25, 5000.0 ), 
    Orientation: { 
        heading: Cesium.Math.toRadians ( 175.0 ), 
        Pitch: Cesium.Math.toRadians ( -35.0 ), 
        roll : 0.0 
    }, 
    DURATION: 3      // flight to destination to spend time three seconds 
})

Positioning method 3 (Viewer.flyTo (target, options))

Difference cesium in viewer.flyTo and Camera.flyTo getting bigger, we usually use camera to locate great time but need to add a tilt angle, the result may be positioned on the difference between expected and

This time, it is possible to formulate a goal, such as the positioning entity created Entity

loactionTectEntity = viewer.entities.add({
            name: 'locationRectangle',
            id: 'locationRectangle',
            rectangle: {
                coordinates: Cesium.Rectangle(1.9911131841002994,0.6863576116684447,2.0676847898509436, 0.7171078891208857),
                material: Cesium.Color.GREEN.withAlpha(1.0),
                height: 10.0,
                outline: false
            }
        });
        var flyPromise = viewer.flyTo(loactionTectEntity, {
            duration: 5,
            offset: new Cesium.HeadingPitchRange(0.0, Cesium.Math.toRadians(-20.0))
        });

The specific method can refer Cesium positioning method , he wrote a very detailed, very clear that this will not go, only finishing

Guess you like

Origin www.cnblogs.com/yangzhengier/p/11847502.html
Recommended