fix polyline db field size (#1047)

This commit is contained in:
slothful-vassal
2026-06-04 17:47:04 +02:00
committed by GitHub
parent 8153cfe14e
commit b304e9975a
2 changed files with 42 additions and 0 deletions

View File

@@ -10,6 +10,8 @@ import (
"github.com/twpayne/go-polyline"
)
const PolylineMaxLength = 5 * 1024 * 1024
func ComputePolyline(app core.App, r *core.Record) (string, error) {
gpxPath := r.GetString("gpx")
if len(gpxPath) == 0 {
@@ -56,6 +58,10 @@ func SavePolyline(app core.App, r *core.Record) error {
if err != nil {
return err
}
// Encoded polylines are ASCII-only, so byte length matches character length.
if len(encoded) > PolylineMaxLength {
return fmt.Errorf("polyline exceeds maximum length of %d characters", PolylineMaxLength)
}
r.Set("polyline", encoded)
if err := app.UnsafeWithoutHooks().Save(r); err != nil {
return fmt.Errorf("save trail polyline: %w", err)