Files
wanderer/plugins/hammerhead/gpx.go
slothful-vassal 485ec53f6d feat: add plugin system (#1034)
* feat: add plugin system

* fix db docker build

* fix hammerhead readme, add strava subscription news to docs

* fixes and sdk improvements

* fix: reduce Meilisearch load, debounce federation sync (#1012)

* optimize meili trail index

* several fixes

---------

Co-authored-by: Flomp <Flomp@users.noreply.github.com>

* Bump svelte from 5.55.5 to 5.56.0 in /docs (#1032)

Bumps [svelte](https://github.com/sveltejs/svelte/tree/HEAD/packages/svelte) from 5.55.5 to 5.56.0.
- [Release notes](https://github.com/sveltejs/svelte/releases)
- [Changelog](https://github.com/sveltejs/svelte/blob/main/packages/svelte/CHANGELOG.md)
- [Commits](https://github.com/sveltejs/svelte/commits/svelte@5.56.0/packages/svelte)

---
updated-dependencies:
- dependency-name: svelte
  dependency-version: 5.56.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Flomp <Flomp@users.noreply.github.com>

* Release v0.19.2 (#1035)

* chore: release v0.19.2

* add changelog

---------

Co-authored-by: Flomp <26000991+Flomp@users.noreply.github.com>
Co-authored-by: Christian Beutel <>

* speed up plugin sync and several small fixes

* concepts for security improvements and process stability

* improve concept

* security concept implemented

* remove insecure TLS

* worker concept implemented

* fixes and cleanup

* fixes

* docu

* mermaid, namings

* WASM plugin host improvements, plugin logging

* fix db migration

* Improve plugin config and category mapping UI

* fixes

* further fixes

* remove manual test sync

* fix db migration and strava mapping

* type added, UI improvements

* fix plugin card toggle clickable area

* optimize synch status card layout

* plugin type 'trails' instead of 'integration'

* session auth validation in UI

* fix komoot date and waypoints

* improve category mapping

* fix send to hammerhead: trail name

* plugin setup error handling improved

* fix review findings

* re-mapping added

* rename remote_category

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Flomp <Flomp@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Flomp <26000991+Flomp@users.noreply.github.com>
2026-06-22 15:00:44 +02:00

67 lines
1.8 KiB
Go

package main
import (
"math"
"time"
sdkgpx "github.com/open-wanderer/wanderer/plugins/sdk/gpx"
"github.com/open-wanderer/wanderer/plugins/sdk/polyline"
)
func activityGPX(activity *activity) ([]byte, error) {
points := make([]sdkgpx.Point, 0, len(activity.RecordData.Timestamp))
const zeroEps = 1e-4
for i, timestamp := range activity.RecordData.Timestamp {
if i >= len(activity.RecordData.Lat) || i >= len(activity.RecordData.Lng) {
continue
}
lat := activity.RecordData.Lat[i]
lng := activity.RecordData.Lng[i]
if math.Abs(lat) < zeroEps && math.Abs(lng) < zeroEps {
continue
}
elevation := 0.0
if i < len(activity.RecordData.Elevation) {
elevation = activity.RecordData.Elevation[i] / 1000.0
}
pointTime := time.Unix(int64(timestamp), 0).UTC()
points = append(points, sdkgpx.Point{
Lat: lat,
Lon: lng,
Elevation: &elevation,
Time: &pointTime,
})
}
return sdkgpx.Track("wanderer Hammerhead plugin", activity.ActivityData.Name, points)
}
func tourGPX(tour *tour) ([]byte, error) {
coords, err := polyline.Decode(tour.RoutePolyline, 1e5)
if err != nil {
return nil, err
}
polyline.NormalizeCoordinateScale(coords)
elevations, _ := polyline.DecodeValues(tour.Elevation.Polyline, 100000)
points := make([]sdkgpx.Point, 0, len(coords))
swap := polyline.ShouldSwapCoordinates(coords)
for i, coord := range coords {
lat := coord[0]
lon := coord[1]
if swap {
lat, lon = coord[1], coord[0]
}
var elevation *float64
if len(elevations) == len(coords) {
elevation = &elevations[i]
} else if len(elevations) > 0 {
elevation = &elevations[polyline.ProportionalIndex(i, len(coords), len(elevations))]
}
points = append(points, sdkgpx.Point{
Lat: lat,
Lon: lon,
Elevation: elevation,
})
}
return sdkgpx.Track("wanderer Hammerhead plugin", tour.Name, points)
}