GithubHelp home page GithubHelp logo

Comments (7)

rob42 avatar rob42 commented on June 18, 2024

The charts list is auto-populated by simply scanning the mapcache dir for sub-dirs. Hence it finds the mbtiles dirs but doesnt understand them. So yes it will need some adjustment

from freeboard-sk.

zubenubi avatar zubenubi commented on June 18, 2024

Thanks for speedy answer!
So I am looking for the addlayers.js file in my signalk-server-node install on a rpi3 but no joy. These .mbtiles files I understand to be SQLite dbs, correct? What kind of adjustment would I need to make?

from freeboard-sk.

rob42 avatar rob42 commented on June 18, 2024

Not sure - I havent tried using them. If you have js skills then google for openlayers3 and mbtiles - ol3 is the underlying map layer lib.

The code here will need adjustment to read the mbtiles data:

freeboard-sk/lib/charts.js

Lines 230 to 270 in 6217ff5

success: function (data) {
console.log("data:"+JSON.stringify(data));
//now get the tilemapresource.xml
var chartId = data.identifier;
var chartUrl = data.tilemapUrl;
var chartMeta = chartUrl+'/tilemapresource.xml';
console.log("chartUrl:"+chartUrl);
$.ajax({
url: chartMeta,
dataType: "text",
success: function (data) {
console.log("data:"+data);
//now magic, convert the xml to json
xmlParser.parseString(data, function (err, result) {
console.log(JSON.stringify(result));
var tileSets = result.TileMap.TileSets.TileSet;
var chartObj = new ol.layer.Tile({
key: key,
scale: scale,
title: result.TileMap.Title,
type: "overlay",
maxResolution: parseFloat(tileSets[0]['units-per-pixel'])*2,
minResolution: parseFloat(tileSets[tileSets.length-1]['units-per-pixel'])*.5,
source: new ol.source.XYZ({
url: chartUrl+'/{z}/{x}/{-y}.png',
minZoom: parseInt(tileSets[0].href),
maxZoom: parseInt(tileSets[tileSets.length-1].href)
})
});
console.log("chartObj complete: maxResolution:"+ parseFloat(tileSets[0]['units-per-pixel']));
console.log("chartObj complete: minResolution:"+ parseFloat(tileSets[tileSets.length-1]['units-per-pixel']));
console.log("chartObj complete: maxZoom:"+ parseInt(tileSets[0].href));
console.log("chartObj complete: minZoom:"+ parseInt(tileSets[tileSets.length-1].href));
addChartToMap(map, chartObj, scale);
console.log("Added");
});
}});
}});
}

from freeboard-sk.

tkurki avatar tkurki commented on June 18, 2024

To a client application (a browser app like Freeboard) mbtiles charts are normal tiled charts: theSK Node server already takes care of digging out the chart metadata from the mbtiles file and serves the individual map tiles.

The response to /signalk/v1/api/resources/charts will look something like this

{
  "mbtiles-file-name.mbtiles": {
    "identifier": "mbtiles-file-name",
    "name": "Name from the mbtiles file",
    "description": "Description from the mbtiles file",
    "bounds": [
      19.105224609375,
      65.84776766596988,
      27.88330078125,
      59.645540251443215
    ],
    "minzoom": 4,
    "maxzoom": 15,
    "format": "png",
    "tilemapUrl": "/charts/mbtiles-file-name.mbtiles/{z}/{x}/{y}",
    "type": "tilelayer",
    "scale": "250000"
  }
}

So you should be to change Freeboard code so that if server response already includes the necessary information no need to do the secondary http request, just construct the OpenLayers layer.

Btw have you tried tuktuk-chart-plotter, installable from SK Node Server's app store? It supports mbtiles out of the box (to be precise, the server's mbtiles code is mostly copypaste from tuk-tuk's internal server).

from freeboard-sk.

zubenubi avatar zubenubi commented on June 18, 2024

Thanks for the quick responses. I installed tuktuk from the appstore but ran into a permissions issue (signalk-server-node is running as 'pi' - not root). So I sshd to the machine and ran (as root) 'npm install tuktuk-chart-plotter'. Seems like success on install but configuration and start/stop is going to take me a bit. I do like the look of freeboard and so will investigate the js changes that need to be made, although Im no js guru

from freeboard-sk.

tkurki avatar tkurki commented on June 18, 2024

This is a sidetrack, but there should be no need for installing things as root. I assume you did at least part of your original installation as root and the trouble stems from that.

The easiest way to restart the SK server is to reboot the machine. Tuktuk needs no further configuration.

from freeboard-sk.

panaaj avatar panaaj commented on June 18, 2024

#51 adds support for mbtiles served fromresources/charts

from freeboard-sk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.