Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using NOAA Quilted .mbtiles? #33

Closed
zubenubi opened this issue Dec 27, 2017 · 7 comments
Closed

Using NOAA Quilted .mbtiles? #33

zubenubi opened this issue Dec 27, 2017 · 7 comments
Labels

Comments

@zubenubi
Copy link

Hi,
I noted in another issue that we need to edit lib/addlayers in order to use other map formats. Does that extend to the .mbtiles that are now being quilted and distributed by NOAA? I see that these automatically appear in the Charts List, but I am not able to see anything when clicking Show/Hide buttons.

@rob42
Copy link
Contributor

rob42 commented Dec 27, 2017

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

@zubenubi
Copy link
Author

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?

@rob42
Copy link
Contributor

rob42 commented Dec 27, 2017

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");
});
}});
}});
}

@tkurki
Copy link
Member

tkurki commented Dec 27, 2017

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).

@zubenubi
Copy link
Author

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

@tkurki
Copy link
Member

tkurki commented Dec 28, 2017

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.

@rob42 rob42 added legacy and removed legacy labels Sep 24, 2018
@panaaj
Copy link
Member

panaaj commented Oct 12, 2018

#51 adds support for mbtiles served fromresources/charts

@panaaj panaaj closed this as completed Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants