Browse Source

Killer feature: show the height of refpoints in the panorama

Baptiste Jonglez 6 years ago
parent
commit
0d1418cfb7
3 changed files with 13 additions and 4 deletions
  1. 1 0
      panorama/models.py
  2. 11 3
      panorama/static/panorama/js/pano.js
  3. 1 1
      panorama/templates/panorama/view.html

+ 1 - 0
panorama/models.py

@@ -222,6 +222,7 @@ class Panorama(ReferencePoint):
                            "url": get_url(r),
                            "cap": self.bearing(r),
                            "elevation": self.elevation(r),
+                           "elevation_ground": self.elevation(Point(latitude=r.latitude, longitude=r.longitude, ground_altitude=r.ground_altitude, height_above_ground=0)),
                            "distance": self.line_distance(r)}
                           for r in refpoints])
 

+ 11 - 3
panorama/static/panorama/js/pano.js

@@ -207,9 +207,13 @@ function drawDecorations(ox, oy, tx, ty, twidth, theight) {
             cntext.fillStyle = 'rgba('+point_colors[zm.pt_list[i]['type']]+',0.5)';
             var cx = nmodulo(zm.pt_list[i]['xc'] - ox, zm.im.width);
             var cy = zm.pt_list[i]['yc'] - oy;
+            var cy_ground = zm.pt_list[i]['yc_ground'] - oy;
             cntext.beginPath();
             cntext.arc(cx, cy, 20, 0, 2*Math.PI, true);
             cntext.fill();
+            // Draw line that shows the height of the building
+            cntext.fillStyle = "rgba(0,0,255,0.6)";
+            cntext.fillRect(cx-1, cy, 2, cy_ground - cy);
         }
     }
     if (twidth) {
@@ -267,7 +271,7 @@ function localate_point() {
 }
 
 function display_temp(d,cap,ele) {
-    point_list[point_list.length] = new Array("point temporaire", d, d, cap, ele, "temporary");
+    point_list[point_list.length] = new Array("point temporaire", d, d, cap, ele, ele, "temporary");
     reset_zooms();
     putImage(last.x, last.y);
 }
@@ -590,10 +594,12 @@ function tzoom(zv) {
             var dst_human = point_list[i][2];
             var cap = point_list[i][3];
             var ele = point_list[i][4];
-            var lnk = point_list[i][5];
-            var url = point_list[i][6];
+            var ele_ground = point_list[i][5];
+            var lnk = point_list[i][6];
+            var url = point_list[i][7];
             var typ = 'unlocated';
             var rxy = this.get_pos_xy(cap, ele);
+            var rxy_ground = this.get_pos_xy(cap, ele_ground);
             var is_visible = (
                 fmodulo(cap - alpha_domain.start, 360) 
                     <= 
@@ -621,6 +627,7 @@ function tzoom(zv) {
             this.pt_list[i]['type'] = typ;
             this.pt_list[i]['cap'] = cap;
             this.pt_list[i]['ele'] = ele;
+            this.pt_list[i]['ele_ground'] = ele_ground;
             this.pt_list[i]['dist'] = dst;
             this.pt_list[i]['dist_human'] = dst_human;
             this.pt_list[i]['label'] = lbl;
@@ -628,6 +635,7 @@ function tzoom(zv) {
             this.pt_list[i]['url'] = url;
             this.pt_list[i]['xc'] = rxy.x;
             this.pt_list[i]['yc'] = Math.floor(this.im.height/2 - rxy.y);
+            this.pt_list[i]['yc_ground'] = Math.floor(this.im.height/2 - rxy_ground.y);
         }
     },
 

+ 1 - 1
panorama/templates/panorama/view.html

@@ -48,7 +48,7 @@
       {% endfor %}
 
       {% for id, refpoint in panorama.refpoints_data %}
-      point_list[{{ id }}] = new Array("{{ refpoint.name|escapejs }}", {{ refpoint.distance }}, "{{ refpoint.distance|distance|escapejs }}", {{ refpoint.cap }}, {{ refpoint.elevation }}, "{{ refpoint.url }}", "/api/v1/refpoints/{{ refpoint.id }}/");
+      point_list[{{ id }}] = new Array("{{ refpoint.name|escapejs }}", {{ refpoint.distance }}, "{{ refpoint.distance|distance|escapejs }}", {{ refpoint.cap }}, {{ refpoint.elevation }}, {{ refpoint.elevation_ground }}, "{{ refpoint.url }}", "/api/v1/refpoints/{{ refpoint.id }}/");
       {% endfor %}
 
       ref_points = new Array();