openstmap: Fix rounding errors
parent
e5c9286e77
commit
56b39fead9
|
|
@ -32,3 +32,4 @@
|
||||||
0.25: Enable scaled image filtering on 2v19+ firmware
|
0.25: Enable scaled image filtering on 2v19+ firmware
|
||||||
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
|
0.26: Ensure that when redrawing, we always cancel any in-progress track draw
|
||||||
0.27: Display message if no map is installed
|
0.27: Display message if no map is installed
|
||||||
|
0.28: Fix rounding errors
|
||||||
|
|
|
||||||
|
|
@ -65,14 +65,16 @@ function redraw() {
|
||||||
|
|
||||||
// Draw the POIs
|
// Draw the POIs
|
||||||
function drawPOI() {
|
function drawPOI() {
|
||||||
|
let waypoints;
|
||||||
try {
|
try {
|
||||||
var waypoints = require("waypoints").load();
|
waypoints = require("waypoints").load();
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
// Waypoints module not available.
|
// Waypoints module not available.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
g.setFont("Vector", 18);
|
g.setFont("Vector", 18);
|
||||||
waypoints.forEach((wp, idx) => {
|
waypoints.forEach((wp, idx) => {
|
||||||
|
if (wp.lat === undefined || wp.lon === undefined) return;
|
||||||
var p = m.latLonToXY(wp.lat, wp.lon);
|
var p = m.latLonToXY(wp.lat, wp.lon);
|
||||||
var sz = 2;
|
var sz = 2;
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
|
|
@ -80,7 +82,7 @@ function drawPOI() {
|
||||||
g.setColor(0,0,0);
|
g.setColor(0,0,0);
|
||||||
g.drawString(wp.name, p.x, p.y);
|
g.drawString(wp.name, p.x, p.y);
|
||||||
//print(wp.name);
|
//print(wp.name);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function isInside(rect, e, w, h) {
|
function isInside(rect, e, w, h) {
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,11 @@
|
||||||
<div id="map">
|
<div id="map">
|
||||||
</div>
|
</div>
|
||||||
<div id="controls">
|
<div id="controls">
|
||||||
<div style="display:inline-block;text-align:center;vertical-align: top;" id="3bitdiv"> <input type="checkbox" id="3bit"></input><br/><span>3 bit</span></div>
|
<div style="display:inline-block;text-align:left;vertical-align: top;" id="3bitdiv">
|
||||||
|
<input type="checkbox" id="3bit"></input><span>3 bit</span>
|
||||||
|
<br>
|
||||||
|
<input type="checkbox" id="preview"><span>Preview</span>
|
||||||
|
</div>
|
||||||
<div class="form-group" style="display:inline-block;">
|
<div class="form-group" style="display:inline-block;">
|
||||||
<select class="form-select" id="mapSize">
|
<select class="form-select" id="mapSize">
|
||||||
<option value="4">Small (4x4)</option>
|
<option value="4">Small (4x4)</option>
|
||||||
|
|
@ -275,7 +279,9 @@ TODO:
|
||||||
options.width = TILESIZE;
|
options.width = TILESIZE;
|
||||||
options.height = TILESIZE;
|
options.height = TILESIZE;
|
||||||
var imgstr = imageconverter.RGBAtoString(rgba, options);
|
var imgstr = imageconverter.RGBAtoString(rgba, options);
|
||||||
//ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE); // write preview
|
if (document.getElementById("preview").checked) {
|
||||||
|
ctx.putImageData(imageData,x*TILESIZE, y*TILESIZE); // write preview
|
||||||
|
}
|
||||||
/*var compress = 'require("heatshrink").decompress('
|
/*var compress = 'require("heatshrink").decompress('
|
||||||
if (!imgstr.startsWith(compress)) throw "Data in wrong format";
|
if (!imgstr.startsWith(compress)) throw "Data in wrong format";
|
||||||
imgstr = imgstr.slice(compress.length,-1);*/
|
imgstr = imgstr.slice(compress.length,-1);*/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "openstmap",
|
"id": "openstmap",
|
||||||
"name": "OpenStreetMap",
|
"name": "OpenStreetMap",
|
||||||
"shortName": "OpenStMap",
|
"shortName": "OpenStMap",
|
||||||
"version": "0.27",
|
"version": "0.28",
|
||||||
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
|
"description": "Loads map tiles from OpenStreetMap onto your Bangle.js and displays a map of where you are. Once installed this also adds map functionality to `GPS Recorder` and `Recorder` apps",
|
||||||
"readme": "README.md",
|
"readme": "README.md",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ exports.draw = function() {
|
||||||
for (var x=ox,ttx=tx; x<mx && ttx<map.w; x+=s,ttx++) {
|
for (var x=ox,ttx=tx; x<mx && ttx<map.w; x+=s,ttx++) {
|
||||||
for (var y=oy,tty=ty;y<my && tty<map.h;y+=s,tty++) {
|
for (var y=oy,tty=ty;y<my && tty<map.h;y+=s,tty++) {
|
||||||
o.frame = ttx+(tty*map.w);
|
o.frame = ttx+(tty*map.w);
|
||||||
g.drawImage(img,x,y,o);
|
g.drawImage(img,Math.round(x),Math.round(y),o);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,8 +91,8 @@ exports.latLonToXY = function(lat, lon) {
|
||||||
var cx = g.getWidth()/2;
|
var cx = g.getWidth()/2;
|
||||||
var cy = g.getHeight()/2;
|
var cy = g.getHeight()/2;
|
||||||
return {
|
return {
|
||||||
x : (q.x-p.x)/m.scale + cx,
|
x : Math.round((q.x-p.x)/m.scale + cx),
|
||||||
y : cy - (q.y-p.y)/m.scale
|
y : Math.round(cy - (q.y-p.y)/m.scale)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue