Tweaks to speed up track rendering
parent
bc48d50e3d
commit
69071891f1
|
|
@ -33,4 +33,5 @@
|
|||
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
|
||||
0.27: Display message if no map is installed
|
||||
0.28: Fix rounding errors
|
||||
0.29: move exit to bottom of menu
|
||||
0.29: Keep exit at bottom of menu
|
||||
Speed up latLonToXY for track rendering
|
||||
|
|
@ -38,17 +38,17 @@ if (m.map) {
|
|||
m.lat = m.map.lat; // position of middle of screen
|
||||
m.lon = m.map.lon; // position of middle of screen
|
||||
}
|
||||
var CX = g.getWidth()/2;
|
||||
var CY = g.getHeight()/2;
|
||||
|
||||
// return number of tiles drawn
|
||||
exports.draw = function() {
|
||||
var cx = g.getWidth()/2;
|
||||
var cy = g.getHeight()/2;
|
||||
var p = Bangle.project({lat:m.lat,lon:m.lon});
|
||||
let count = 0;
|
||||
m.maps.forEach((map,idx) => {
|
||||
var d = map.scale/m.scale;
|
||||
var ix = (p.x-map.center.x)/m.scale + (map.imgx*d/2) - cx;
|
||||
var iy = (map.center.y-p.y)/m.scale + (map.imgy*d/2) - cy;
|
||||
var ix = (p.x-map.center.x)/m.scale + (map.imgx*d/2) - CX;
|
||||
var iy = (map.center.y-p.y)/m.scale + (map.imgy*d/2) - CY;
|
||||
var o = {};
|
||||
var s = map.tilesize;
|
||||
if (d!=1) { // if the two are different, add scaling
|
||||
|
|
@ -85,14 +85,12 @@ exports.draw = function() {
|
|||
};
|
||||
|
||||
/// Convert lat/lon to pixels on the screen
|
||||
exports.latLonToXY = function(lat, lon) {
|
||||
var p = Bangle.project({lat:m.lat,lon:m.lon});
|
||||
var q = Bangle.project({lat:lat, lon:lon});
|
||||
var cx = g.getWidth()/2;
|
||||
var cy = g.getHeight()/2;
|
||||
exports.latLonToXY = function(lat, lon) { "ram"
|
||||
var p = Bangle.project({lat:m.lat,lon:m.lon}),
|
||||
q = Bangle.project({lat:lat, lon:lon});
|
||||
return {
|
||||
x : Math.round((q.x-p.x)/m.scale + cx),
|
||||
y : Math.round(cy - (q.y-p.y)/m.scale)
|
||||
x : Math.round((q.x-p.x)/m.scale + CX),
|
||||
y : Math.round(CY - (q.y-p.y)/m.scale)
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -45,3 +45,4 @@
|
|||
0.36: When recording with 1 second periods, log time with one decimal.
|
||||
0.37: 1 second periods + gps log => log when gps event is received, not with
|
||||
setInterval.
|
||||
0.38: Tweaks to speed up track rendering
|
||||
|
|
@ -213,8 +213,10 @@ function viewTrack(filename, info) {
|
|||
});
|
||||
};
|
||||
menu['< Back'] = () => { viewTracks(); };
|
||||
return E.showMenu(menu);
|
||||
}
|
||||
|
||||
function plotTrack(info) { "ram"
|
||||
function plotTrack(info) { "ram"
|
||||
function distance(lat1,long1,lat2,long2) { "ram"
|
||||
var x = (long1-long2) * Math.cos((lat1+lat2)*Math.PI/360);
|
||||
var y = lat2 - lat1;
|
||||
|
|
@ -222,7 +224,7 @@ function viewTrack(filename, info) {
|
|||
}
|
||||
|
||||
// Function to convert lat/lon to XY
|
||||
var getMapXY;
|
||||
var XY;
|
||||
if (info.qOSTM) {
|
||||
// scale map to view full track
|
||||
const max = Bangle.project({lat: info.maxLat, lon: info.maxLong});
|
||||
|
|
@ -230,9 +232,9 @@ function viewTrack(filename, info) {
|
|||
const scaleX = (max.x-min.x)/Bangle.appRect.w;
|
||||
const scaleY = (max.y-min.y)/Bangle.appRect.h;
|
||||
osm.scale = Math.ceil((scaleX > scaleY ? scaleX : scaleY)*1.1); // add 10% margin
|
||||
getMapXY = osm.latLonToXY.bind(osm);
|
||||
XY = osm.latLonToXY.bind(osm);
|
||||
} else {
|
||||
getMapXY = function(lat, lon) { "ram"
|
||||
XY = function(lat, lon) { "ram"
|
||||
return {x:cx + Math.round((long - info.lon)*info.lfactor*info.scale),
|
||||
y:cy + Math.round((info.lat - lat)*info.scale)};
|
||||
};
|
||||
|
|
@ -243,6 +245,7 @@ function viewTrack(filename, info) {
|
|||
g.flip(); // on buffered screens, draw a not saying we're busy
|
||||
g.clear(1);
|
||||
var s = require("Storage");
|
||||
var G = g;
|
||||
var W = g.getWidth();
|
||||
var H = g.getHeight();
|
||||
var cx = W/2;
|
||||
|
|
@ -275,7 +278,7 @@ function viewTrack(filename, info) {
|
|||
// now start plotting
|
||||
var lat = +c[latIdx];
|
||||
var long = +c[lonIdx];
|
||||
var mp = getMapXY(lat, long);
|
||||
var mp = XY(lat, long);
|
||||
g.moveTo(mp.x,mp.y);
|
||||
g.setColor("#0f0");
|
||||
g.fillCircle(mp.x,mp.y,5);
|
||||
|
|
@ -288,16 +291,16 @@ function viewTrack(filename, info) {
|
|||
if (c[latIdx]=="")continue;
|
||||
lat = +c[latIdx];
|
||||
long = +c[lonIdx];
|
||||
mp = getMapXY(lat, long);
|
||||
g.lineTo(mp.x,mp.y);
|
||||
if (info.qOSTM) g.fillCircle(mp.x,mp.y,2); // make the track more visible
|
||||
mp = XY(lat, long);
|
||||
G.lineTo(mp.x,mp.y);
|
||||
if (info.qOSTM) G.fillCircle(mp.x,mp.y,2); // make the track more visible
|
||||
var d = distance(olat,olong,lat,long);
|
||||
if (!isNaN(d)) dist+=d;
|
||||
olat = lat;
|
||||
olong = long;
|
||||
ox = mp.x;
|
||||
oy = mp.y;
|
||||
if (++i > 100) { g.flip();i=0; }
|
||||
if (++i > 100) { G.flip();i=0; }
|
||||
}
|
||||
g.setColor("#f00");
|
||||
g.fillCircle(ox,oy,5);
|
||||
|
|
@ -313,9 +316,9 @@ function viewTrack(filename, info) {
|
|||
}, isBTN3?BTN3:BTN1);
|
||||
Bangle.drawWidgets();
|
||||
g.flip();
|
||||
}
|
||||
}
|
||||
|
||||
function plotGraph(info, style) { "ram"
|
||||
function plotGraph(info, style) { "ram"
|
||||
E.showMenu(); // remove menu
|
||||
E.showMessage(/*LANG*/"Calculating...",/*LANG*/"Track "+info.fn);
|
||||
var filename = info.filename;
|
||||
|
|
@ -433,9 +436,6 @@ function viewTrack(filename, info) {
|
|||
viewTrack(info.filename, info);
|
||||
}, isBTN3?BTN3:BTN1);
|
||||
g.flip();
|
||||
}
|
||||
|
||||
return E.showMenu(menu);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"id": "recorder",
|
||||
"name": "Recorder",
|
||||
"shortName": "Recorder",
|
||||
"version": "0.37",
|
||||
"version": "0.38",
|
||||
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
||||
"icon": "app.png",
|
||||
"tags": "tool,outdoors,gps,widget,clkinfo",
|
||||
|
|
|
|||
Loading…
Reference in New Issue