-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add File watcher and Mapbox Style support #34
base: master
Are you sure you want to change the base?
Conversation
Removing the use of a shared path aligns better with multi-provider support. Tile paths have a fully qualified path, remove use of relative path.
This is appended to the url path to the mapbox style json file.
Ensure operation behind proxy is not impacted.
Ensure operation behind proxy is not impacted.
@tkurki Can you please review and if all is OK it's good to publish. This code seemed to solve Freeboard-SK issue SignalK/freeboard-sk#211 |
README.md
Outdated
/chart-styles/${mapboxstyle.json} | ||
|
||
# when access token is defined | ||
/chart-styles/${mapboxstyle.json}?access_token=${token} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is local url, right? So why is there an access token needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Mapbox style json file is served locally but may reference resources that are remote which require an access token...
Example: satellite-v9.jon
{
"version": 8,
"name": "Mapbox Satellite",
"metadata": {
"mapbox:autocomposite": true,
"mapbox:type": "default"
},
"sources": {
"mapbox": {
"type": "raster",
"url": "mapbox://mapbox.satellite", // remote resource
"tileSize": 256
}
},
...
const refreshProviders = async () => { | ||
const td = Date.now() - (lastWatchEvent as number) | ||
app.debug(`last watch event time elapsed = ${td}`) | ||
if (lastWatchEvent && td > 5000) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did I understand the logic correctly: if we notice a change in some chart data we reload the chart data the first time the data is needed after 5 seconds of the change?
Could we not just mark the data as stale and when it is next needed reload it? Or always reload when a change is noticed? Why the 5 second delay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is due to the way FSWatcher
produces events and the ability to distinguish when a:
- New file is created
- An exisiting file is replaced
- An existing file is renamed
- Multiple files are being added / deleted
There are multiple events produced during a simple file rename with no discernable metadata to indicate the actual operation taking place.... so the delay is to ensure the stream of events has ceased to indicate the process has completed.
Without it we would trigger multiple reloads while a rename, etc. is in process and throw exceptions.
README.md
Outdated
@@ -2,7 +2,14 @@ | |||
|
|||
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 files: | |||
- Mapbox Tiles _(.mbtiles)_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Afaik MBTiles is better known as just MBTiles and touted as open format. The spec README never mentions Mapbox, while it is under their Github org.
We could link to the canonical resources?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to MBTiles.
Which canonical resources are you refferring to?
Unrelated to this PR: README is not very consistent
|
This PR includes the following changes:
Adds a file watcher to charts folders to detect new files placed in the folder. This makes the new charts available to subsequent requests without having to restart the plugin (Feature request - Possible to re-read charts on the fly? #28).
Adds support for processing mapbox style json files placed in the folder paths configured in the plugin settings, which will in-turn produce a chart metadata entry.