openstmap: Show currently active gpsrec GPS trace (fix #395)

pull/608/head
Gordon Williams 2020-12-08 15:56:53 +00:00
parent b3e12df673
commit 947731a129
5 changed files with 26 additions and 2 deletions

View File

@ -363,7 +363,7 @@
{ "id": "gpsrec",
"name": "GPS Recorder",
"icon": "app.png",
"version":"0.14",
"version":"0.15",
"interface": "interface.html",
"description": "Application that allows you to record a GPS track. Can run in background",
"tags": "tool,outdoors,gps,widget",
@ -1326,7 +1326,7 @@
"name": "OpenStreetMap",
"shortName":"OpenStMap",
"icon": "app.png",
"version":"0.04",
"version":"0.05",
"description": "[BETA] Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are",
"tags": "outdoors,gps",
"custom": "custom.html",

View File

@ -16,3 +16,4 @@
0.13: Increase GPS recording accuracy by one decimal place
Ensure default time period is 10
0.14: Now use the openstmap lib for map plotting
0.15: Add plotTrack method to allow current track to be plotted on a map (#395)

View File

@ -66,6 +66,24 @@
WIDGETS["gpsrec"]={area:"tl",width:24,draw:draw,reload:function() {
reload();
Bangle.drawWidgets(); // relayout all widgets
},plotTrack:function(m) { // m=instance of openstmap module
settings = require("Storage").readJSON("gpsrec.json",1)||{};
settings.file |= 0;
var n = settings.file.toString(36);
var f = require("Storage").open(".gpsrc"+n,"r");
var l = f.readLine(f);
if (l===undefined) return;
var c = l.split(",");
var mp = m.latLonToXY(+c[1], +c[2]);
g.moveTo(mp.x,mp.y);
l = f.readLine(f);
while(l!==undefined) {
c = l.split(",");
mp = m.latLonToXY(+c[1], +c[2]);
g.lineTo(mp.x,mp.y);
g.fillCircle(mp.x,mp.y,2); // make the track more visible
l = f.readLine(f);
}
}};
// load settings, set correct widget width
reload();

View File

@ -2,3 +2,4 @@
0.02: Fix marker position, color, and map scaling
0.03: Show widgets (mainly so we can use the GPS recorder widget)
0.04: Move map rendering to a module (fix #396)
0.05: Show currently active gpsrec GPS trace (fix #395)

View File

@ -7,6 +7,10 @@ function redraw() {
g.setClipRect(0,y1,g.getWidth()-1,y2);
m.draw();
drawMarker();
if (WIDGETS["gpsrec"] && WIDGETS["gpsrec"].plotTrack) {
g.setColor(0.75,0.2,0);
WIDGETS["gpsrec"].plotTrack(m);
}
g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1);
}