Commit ce2336fe authored by Baptiste Jonglez's avatar Baptiste Jonglez

Normalize distance display in the frontend ("X.YZ km" or "XYZ m" depending on the value)

parent c2e6f847
...@@ -214,7 +214,7 @@ class Panorama(ReferencePoint): ...@@ -214,7 +214,7 @@ class Panorama(ReferencePoint):
"url": get_url(r), "url": get_url(r),
"cap": self.bearing(r), "cap": self.bearing(r),
"elevation": self.elevation(r), "elevation": self.elevation(r),
"distance": self.line_distance(r) / 1000} "distance": self.line_distance(r)}
for r in refpoints]) for r in refpoints])
def references_data(self): def references_data(self):
......
...@@ -267,7 +267,7 @@ function localate_point() { ...@@ -267,7 +267,7 @@ function localate_point() {
} }
function display_temp(d,cap,ele) { function display_temp(d,cap,ele) {
point_list[point_list.length] = new Array("point temporaire", d,cap,ele, "temporary"); point_list[point_list.length] = new Array("point temporaire", d, d, cap, ele, "temporary");
reset_zooms(); reset_zooms();
putImage(last.x, last.y); putImage(last.x, last.y);
} }
...@@ -587,10 +587,11 @@ function tzoom(zv) { ...@@ -587,10 +587,11 @@ function tzoom(zv) {
for (var i=0; i<point_list.length; i++) { for (var i=0; i<point_list.length; i++) {
var lbl = point_list[i][0]; var lbl = point_list[i][0];
var dst = point_list[i][1]; var dst = point_list[i][1];
var cap = point_list[i][2]; var dst_human = point_list[i][2];
var ele = point_list[i][3]; var cap = point_list[i][3];
var lnk = point_list[i][4]; var ele = point_list[i][4];
var url = point_list[i][5]; var lnk = point_list[i][5];
var url = point_list[i][6];
var typ = 'unlocated'; var typ = 'unlocated';
var rxy = this.get_pos_xy(cap, ele); var rxy = this.get_pos_xy(cap, ele);
var is_visible = ( var is_visible = (
...@@ -621,6 +622,7 @@ function tzoom(zv) { ...@@ -621,6 +622,7 @@ function tzoom(zv) {
this.pt_list[i]['cap'] = cap; this.pt_list[i]['cap'] = cap;
this.pt_list[i]['ele'] = ele; this.pt_list[i]['ele'] = ele;
this.pt_list[i]['dist'] = dst; this.pt_list[i]['dist'] = dst;
this.pt_list[i]['dist_human'] = dst_human;
this.pt_list[i]['label'] = lbl; this.pt_list[i]['label'] = lbl;
this.pt_list[i]['lnk'] = lnk; this.pt_list[i]['lnk'] = lnk;
this.pt_list[i]['url'] = url; this.pt_list[i]['url'] = url;
...@@ -799,11 +801,9 @@ function display_links(e) { ...@@ -799,11 +801,9 @@ function display_links(e) {
if (is_located || zm.pt_list[i]['type'] == 'ref_point') { if (is_located || zm.pt_list[i]['type'] == 'ref_point') {
if (check_prox(zm.pt_list[i]['xc']-pos_x, zm.pt_list[i]['yc']-pos_y, 20)) { if (check_prox(zm.pt_list[i]['xc']-pos_x, zm.pt_list[i]['yc']-pos_y, 20)) {
info.innerHTML = zm.pt_list[i]['label']; info.innerHTML = zm.pt_list[i]['label'];
info.style.opacity = '0.8' info.style.opacity = '0.8';
info.style.color = 'black' info.style.color = 'black';
if (zm.pt_list[i]['dist'] < 10) var dst = Math.round(zm.pt_list[i]['dist']*1000)+' m'; info.innerHTML += '<br/>(' + zm.pt_list[i]['dist_human'] + ')';
else var dst = zm.pt_list[i]['dist'].toFixed(1)+' kms';
info.innerHTML += '<br/>(' + dst + ')';
info.style.backgroundColor = 'rgb('+point_colors[zm.pt_list[i]['type']]+')'; info.style.backgroundColor = 'rgb('+point_colors[zm.pt_list[i]['type']]+')';
canvas.style.cursor='auto'; canvas.style.cursor='auto';
break; break;
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
{% endfor %} {% endfor %}
{% for id, refpoint in panorama.refpoints_data %} {% for id, refpoint in panorama.refpoints_data %}
point_list[{{ id }}] = new Array("{{ refpoint.name|escapejs }}", {{ refpoint.distance }}, {{ 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.url }}", "/api/v1/refpoints/{{ refpoint.id }}/");
{% endfor %} {% endfor %}
ref_points = new Array(); ref_points = new Array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment