night199uk - is there a simple example of a res...
is there a simple example of a resources (routes, waypoints) provider plugin somewhere? I'm looking at the built-in resources provider, which is a little complex. perhaps someone already wrote a very simple route provider i can crib from?
9 Replies
Can you elaborate - where will your route data be coming from?
I have some javascript to pull GPX files from Aqua Maps public folders
I starting using https://github.com/SignalK/simple-gpx as a base, I think that was your project? but looking at the source and the api documentation on line I'm thinking perhaps that is out-of-date/not the latest way of implementing a route provider?
7 years ago...definitely not up to date!
and archived 2020 π
yeah π saw that π
so it's pretty simple to list the routes in a users aqua map public folder. and they're just stored as gpx. so the code that converts gpx to geojson in there is all basically reusable. so if i implement a route provider as an alternative to the standard filesystem based provided users can select routes "live" from their aqua map public folder.
sure. https://demo.signalk.io/documentation/develop/plugins/resource_provider_plugins.html should be pretty straightforward to implement, just listResources and getResource
Resource Providers - Signal K Server Documentation
A Guide for users and developers.
i am not aware of a good example to copy
alright. i'm just going to c&p the default filestorage provider as a base and strip it back
looks easy enough. was just hoping to press a simple button π
okay, i'm doing something dumb. i'm really out of touch on javascript as it's been a while:
following the example on https://demo.signalk.org/documentation/develop/plugins/resource_provider_plugins.html
i get SyntaxError: Missing initializer in const declaration
for this line:
const waypointsProvider: ResourceProvider = {
it doesn't like the colon. is there something i have to do to have it recognise this as typescript or something?
oh, i got it.
i'm rusty on TypeScript and JavaScript. I have retrieved my GPX files from Aqua Maps as GeoJSON objects (@types/geojson).
I'm trying to assign those GeoJSON objects to "Routes" objects, but I'm running into a lot of issues. It seems like the GeoJSON structures in Route objects are not actually @types/geojson, they are hand crafted to have the same format as GeoJSON?
Running into a lot of stuff like this:
Type 'Position' is not assignable to type 'GeoJsonPoint'.
Am I going to have to hand convert the structure between @types/geojson and SIgnalK "geojson"? Is there a better way?
If the structures match but types donβt you can just yolo cast via unknown
got it working.
have a working aqua maps route provider π
https://github.com/night199uk/signalk-aquamap-provider