Sfoglia il codice sorgente

improve the plot #39

tags/2.3.1
Caven Chen 4 anni fa
parent
commit
095a2f870a
3 ha cambiato i file con 16 aggiunte e 25 eliminazioni
  1. 1
    0
      modules/event/EventType.js
  2. 1
    1
      modules/math/index.js
  3. 14
    24
      modules/tools/EditTool.js

+ 1
- 0
modules/event/EventType.js Vedi File

@@ -82,6 +82,7 @@ const PlotEventType = {
EDIT_STOP: 'editEnd',
DRAW_ANCHOR: 'drawAnchor',
CREATE_ANCHOR: 'createAnchor',
UPDATE_ANCHOR: 'updateAnchor',
ANCHOR_MOVING: 'anchorMoving',
EDIT_ANCHOR_STOP: 'editAnchorStop',
CLEAR_ANCHOR: 'clearAnchor'

+ 1
- 1
modules/math/index.js Vedi File

@@ -4,9 +4,9 @@
*/

export { default as area } from './area'
export { default as center } from './center'
export { default as bounds } from './bounds'
export { default as mid } from './mid'
export { default as center } from './center'
export { default as distance } from './distance'
export { default as heading } from './heading'
export { default as isBetween } from './isBetween'

+ 14
- 24
modules/tools/EditTool.js Vedi File

@@ -57,12 +57,9 @@ class EditTool {
this._pickedAnchor.position &&
this._pickedAnchor.properties
) {
let properties = this._pickedAnchor.properties.getValue(
Cesium.JulianDate.now()
)
this._pickedAnchor.position.setValue(position)
this._plotEvent.fire(PlotEventType.EDIT_ANCHOR_STOP, {
index: properties.index,
pickedAnchor: this._pickedAnchor,
position: position
})
}
@@ -96,12 +93,9 @@ class EditTool {
this._pickedAnchor.position &&
this._pickedAnchor.properties
) {
let properties = this._pickedAnchor.properties.getValue(
Cesium.JulianDate.now()
)
this._pickedAnchor.position.setValue(position)
this._plotEvent.fire(PlotEventType.ANCHOR_MOVING, {
index: properties.index,
pickedAnchor: this._pickedAnchor,
position: position
})
}
@@ -113,10 +107,12 @@ class EditTool {
* @private
*/
_onRightClick(e) {
this._plotEvent.fire(
PlotEventType.DRAW_STOP,
let position =
this._options.clampToModel && e.position ? e.position : e.surfacePosition
)
this._plotEvent.fire(PlotEventType.DRAW_STOP, {
pickedAnchor: this._pickedAnchor,
position: position
})
}

/**
@@ -156,12 +152,17 @@ class EditTool {
this._anchors.push(anchor)
}

_onUpdateAnchor({ index, position }) {
this._anchors[index] && this._anchors[index].position.setValue(position)
}

/**
*
* @private
*/
_onClearAnchor() {
this._anchorLayer.entities.removeAll()
this._anchors = []
}

/**
@@ -173,6 +174,7 @@ class EditTool {
this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.on(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
}

@@ -185,22 +187,10 @@ class EditTool {
this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this)
this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this)
this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this)
this.off(PlotEventType.UPDATE_ANCHOR, this._onUpdateAnchor, this)
this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this)
}

/**
*
* @param p1
* @param p2
* @returns {Cartesian3}
*/
computeMidPosition(p1, p2) {
let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p1)
let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p2)
let cm = new Cesium.EllipsoidGeodesic(c1, c2).interpolateUsingFraction(0.5)
return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm)
}

/**
*
* @param type

Loading…
Annulla
Salva