Skip to content

Commit

Permalink
Merge pull request #11 from SamuelDudley/wp_labels
Browse files Browse the repository at this point in the history
Added WP numbers above WP markers in Cesium
  • Loading branch information
SamuelDudley committed Feb 20, 2017
2 parents 5c0ffbc + 7d2aa81 commit 1cc1476
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
18 changes: 12 additions & 6 deletions app/static/DST/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ $(function () {
})


var position = Cesium.Cartesian3.fromDegrees(136.861933, -35.370903, -2000.0);
var yaw = Cesium.Math.toRadians(45.0);
var pitch = Cesium.Math.toRadians(15.0);
var roll = Cesium.Math.toRadians(10.0);
var position = Cesium.Cartesian3.fromDegrees(0, 0, -2000.0);
var yaw = Cesium.Math.toRadians(0);
var pitch = Cesium.Math.toRadians(0);
var roll = Cesium.Math.toRadians(0);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, yaw, pitch, roll);
var vehicle_offset_x = 25
var vehicle_offset_y = 25
Expand Down Expand Up @@ -406,6 +406,7 @@ $(function () {
var selected = {
marker : null,
alt_line : null, // line that joins the wp to the ground (has same id as marker)
label : null, // wp label (has same id as marker)
dragging : false,
camera_stored : false} // used for waypoint

Expand Down Expand Up @@ -487,7 +488,11 @@ $(function () {

cartographic.longitude,
cartographic.latitude,
cartographic.height])
cartographic.height]);

selected.label.position = Cesium.Cartesian3.fromRadians(cartographic.longitude,
cartographic.latitude, cartographic.height+300);

}
return // get out of the mouse movement function here if we are dragging and have a wp selected

Expand All @@ -514,7 +519,8 @@ $(function () {
// we dont select if we are dragging otherwise we can move wp's accidentally when panning the camera...
document.getElementsByTagName("body")[0].style.cursor = "pointer" // change the pointer to a hand
selected.marker.image= '/static/DST/wp_icons/ylw-blank.png'
selected.alt_line = get_by_id(alt_lines, selected.marker.id) //
selected.alt_line = get_by_id(alt_lines, selected.marker.id) //
selected.label = get_by_id(labels, selected.marker.id)
} else { // we have not picked a wp
clear_selected_marker()
}
Expand Down
15 changes: 14 additions & 1 deletion app/static/DST/js/wp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var alt_lines = scene.primitives.add(new Cesium.PolylineCollection)
var markers = scene.primitives.add(new Cesium.BillboardCollection)
var labels = scene.primitives.add(new Cesium.LabelCollection)
var paths = scene.primitives.add(new Cesium.PolylineCollection)

function create_wp(id, wp_data){
Expand Down Expand Up @@ -42,8 +43,18 @@ function create_wp(id, wp_data){
id : id,
position : Cesium.Cartesian3.fromDegrees(wp_data.y, wp_data.x, wp_data.z+height_offset),
image : '/static/DST/wp_icons/blu-blank.png',
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
verticalOrigin : Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin : Cesium.HorizontalOrigin.CENTER
});

labels.add({
id : id,
position : Cesium.Cartesian3.fromDegrees(wp_data.y, wp_data.x, wp_data.z+height_offset),
text : id,
font : '20px Arial',
pixelOffset : new Cesium.Cartesian2(0, -70),
horizontalOrigin : Cesium.HorizontalOrigin.CENTER,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM
});
}

Expand All @@ -54,6 +65,8 @@ function destroy_wp(id){
alt_lines.remove(wp_alt_line)
var wp_marker = get_by_id(markers, id)
markers.remove(wp_marker)
var wp_label = get_by_id(labels, id)
labels.remove(wp_label)
}

function clear_mission(){
Expand Down

0 comments on commit 1cc1476

Please sign in to comment.