Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 68 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,71 @@

Signal K Node server plugin to provide chart metadata, such as name, description and location of the actual chart tile data.

Supports both v1 and v2 Signal K resources api paths.
Chart metadata is derived from the following supported chart file types:
- MBTiles _(.mbtiles)_
- TMS _(tilemapresource.xml and tiles)_

Additionally, chart metadata can be entered via the plugin configuration for other chart sources and types _(e.g. WMS, WMTS, S-57 tiles and tilejson)_.

Chart metadata is made available to both v1 and v2 Signal K `resources` api paths.

| Server Version | API | Path |
|--- |--- |--- |
| 1.x.x | v1 | `/signalk/v1/api/resources/charts` |
| 2.x.x | v2 | `/signalk/v2/api/resources/charts` |


_Note: v2 resource paths will only be made available on Signal K server >= v2._
_Note: Version 2 resource paths will only be made available on Signal K server v2.0.0 and later_

### Usage
## Usage

1. Install "Signal K Charts" plugin from Signal K Appstore
1. Install `@signalk/signalk-charts` from the Signal K Server Appstore

2. Configure plugin in **Plugin Config**
2. Configure the plugin in the Admin UI _(**Server -> Plugin Config -> Signal K Charts**)_

- Add "Chart paths" which are the paths to the folders where chart files are stored. Defaults to `${signalk-configuration-path}/charts`
3. Activate the plugin

Chart metadata will then be available to client apps via the resources api `/resources/charts` for example:
- [Freeboard SK](https://www.npmjs.com/package/@signalk/freeboard-sk)
- [Tuktuk Chart Plotter](https://www.npmjs.com/package/tuktuk-chart-plotter)

3. Add "Chart paths" in plugin configuration. Defaults to `${signalk-configuration-path}/charts`

<img src="https://user-images.githubusercontent.com/1435910/39382493-57c1e4dc-4a6e-11e8-93e1-cedb4c7662f4.png" alt="Chart paths configuration" width="450"/>
## Configuration


4. Put charts into selected paths
### Local Chart Files

5. Add optional online chart providers
If you are using chart files stored on the Signal K Server you will need to add the locations where the chart files are stored so the plugin can generate the chart metadata.

<img src="https://user-images.githubusercontent.com/1435910/45048136-c65d2e80-b083-11e8-99db-01e8cece9f89.png" alt="Online chart providers configuration" width="450"/>
Do this by adding "Chart paths" and providing the path to each folder on the Signal K Server where chart files are stored. _(Defaults to `${signalk-configuration-path}/charts`)_

<img src="https://user-images.githubusercontent.com/1435910/39382493-57c1e4dc-4a6e-11e8-93e1-cedb4c7662f4.png" alt="Chart paths configuration" width="450"/>

When chart files are added to the folder(s) they will be processed by the plugin and the chart metadata will be available.


_WMS example:_
### Online chart providers

<img src="https://user-images.githubusercontent.com/38519157/102832518-90077100-443e-11eb-9a1d-d0806bb2b10b.png" alt="server type configuration" width="450"/>
If your chart source is not local to the Signal K Server you can add "Online Chart Providers" and enter the required charts metadata for the source.

6. Activate plugin
You will need to provide the following information:
1. A chart name for client applications to display
2. The URL to the chart source
3. Select the chart image format
4. The minimum and maximum zoom levels where chart data is available.

You can also provide a description detailing the chart content.

<img src="https://github.com/user-attachments/assets/77cb3aaf-5471-4e55-b05d-aad70cacab6a" alt="Online chart providers configuration" width="450"/>

For WMS & WMTS sources you can specify the layers you wish to display.

<img src="https://github.com/user-attachments/assets/b9bfba38-8468-4eca-aeb3-96a80fcbc7a6" alt="Online chart provider layers" width="450"/>

7. Use one of the client apps supporting Signal K charts, for example:
- [Freeboard SK](https://www.npmjs.com/package/@signalk/freeboard-sk)
- [Tuktuk Chart Plotter](https://www.npmjs.com/package/tuktuk-chart-plotter)

### Supported chart formats

- [MBTiles](https://github.com/mapbox/mbtiles-spec) file
- [MBTiles](https://github.com/mapbox/mbtiles-spec) files
- Directory with cached [TMS](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification) tiles and `tilemapresource.xml`
- Directory with XYZ tiles and `metadata.json`
- Online [TMS](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification)
Expand All @@ -57,13 +76,41 @@ Publicly available MBTiles charts can be found from:
- [Finnish Transport Agency nautical charts](https://github.com/vokkim/rannikkokartat-mbtiles)
- [Signal K World Coastline Map](https://github.com/netAction/signalk-world-coastline-map), download [MBTiles release](https://github.com/netAction/signalk-world-coastline-map/releases/download/v1.0/signalk-world-coastline-map-database.tgz)


---

### API

Plugin adds support for `/resources/charts` endpoints described in [Signal K specification](http://signalk.org/specification/1.0.0/doc/otherBranches.html#resourcescharts):

- `GET /signalk/v1/api/resources/charts/` returns metadata for all available charts
- `GET /signalk/v1/api/resources/charts/${identifier}/` returns metadata for selected chart
- `GET /signalk/v1/api/resources/charts/${identifier}/${z}/${x}/${y}` returns a single tile for selected offline chart. As charts-plugin isn't proxy, online charts is not available via this request. You should look the metadata to find proper request.
- List available charts

```bash
# v1 API
GET /signalk/v1/api/resources/charts/`

# v2 API
GET /signalk/v2/api/resources/charts/`
```

- Return metadata for selected chart

```bash
# v1 API
GET /signalk/v1/api/resources/charts/${identifier}`

# v2 API
GET /signalk/v2/api/resources/charts/${identifier}`
```

#### Chart Tiles
Chart tiles are retrieved using the url defined in the chart metadata.

For local chart files located in the Chart Path(s) defined in the plugin configuration, the url will be:

```bash
/signalk/chart-tiles/${identifier}/${z}/${x}/${y}
```

License
-------
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
"dependencies": {
"@mapbox/mbtiles": "^0.12.1",
"@signalk/server-api": "^2.0.0-beta.3",
"baconjs": "1.0.1",
"bluebird": "3.5.1",
"lodash": "^4.17.11",
"xml2js": "0.4.19"
"xml2js": "^0.6.2"
},
"repository": {
"type": "git",
Expand All @@ -47,12 +46,12 @@
"@types/node": "^18.14.4",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"body-parser": "1.18.2",
"body-parser": "^1.18.2",
"chai": "4.1.2",
"chai-http": "^4.2.1",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.6.0",
"express": "4.19.2",
"express": "^4.19.2",
"mocha": "5.0.0",
"prettier": "^2.8.4",
"typescript": "^4.5.4"
Expand Down
8 changes: 4 additions & 4 deletions src/charts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ function openMbtilesFile(file: string, filename: string) {
type: 'tilelayer',
scale: parseInt(res.metadata.scale) || 250000,
v1: {
tilemapUrl: `~basePath~/charts/${identifier}/{z}/{x}/{y}`,
tilemapUrl: `~tilePath~/${identifier}/{z}/{x}/{y}`,
chartLayers: res.metadata.vector_layers
? parseVectorLayers(res.metadata.vector_layers)
: []
},
v2: {
url: `~basePath~/charts/${identifier}/{z}/{x}/{y}`,
url: `~tilePath~/${identifier}/{z}/{x}/{y}`,
layers: res.metadata.vector_layers
? parseVectorLayers(res.metadata.vector_layers)
: []
Expand Down Expand Up @@ -133,11 +133,11 @@ function directoryToMapInfo(file: string, identifier: string) {
;(info._fileFormat = 'directory'),
(info._filePath = file),
(info.v1 = {
tilemapUrl: `~basePath~/charts/${identifier}/{z}/{x}/{y}`,
tilemapUrl: `~tilePath~/${identifier}/{z}/{x}/{y}`,
chartLayers: []
})
info.v2 = {
url: `~basePath~/charts/${identifier}/{z}/{x}/{y}`,
url: `~tilePath~/${identifier}/{z}/{x}/{y}`,
layers: []
}

Expand Down
4 changes: 0 additions & 4 deletions src/constants.ts

This file was deleted.

Loading
Loading