SK
Signal Kβ€’9mo ago
night199uk

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
Teppo Kurki
Teppo Kurkiβ€’9mo ago
Can you elaborate - where will your route data be coming from?
night199uk
night199ukOPβ€’9mo ago
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?
Teppo Kurki
Teppo Kurkiβ€’9mo ago
7 years ago...definitely not up to date! and archived 2020 😁
night199uk
night199ukOPβ€’9mo ago
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.
Teppo Kurki
Teppo Kurkiβ€’9mo ago
sure. https://demo.signalk.io/documentation/develop/plugins/resource_provider_plugins.html should be pretty straightforward to implement, just listResources and getResource
Teppo Kurki
Teppo Kurkiβ€’9mo ago
i am not aware of a good example to copy
night199uk
night199ukOPβ€’9mo ago
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?
Teppo Kurki
Teppo Kurkiβ€’9mo ago
If the structures match but types don’t you can just yolo cast via unknown
night199uk
night199ukOPβ€’9mo ago
got it working. have a working aqua maps route provider πŸ™‚ https://github.com/night199uk/signalk-aquamap-provider

Did you find this page helpful?