Enforce 500 m minimum segment length in UI and API
This commit is contained in:
@@ -2445,8 +2445,8 @@ async def create_segment(
|
|||||||
user = _require_user(bincio_session)
|
user = _require_user(bincio_session)
|
||||||
if len(body.polyline) < 2:
|
if len(body.polyline) < 2:
|
||||||
raise HTTPException(400, "polyline must have at least 2 points")
|
raise HTTPException(400, "polyline must have at least 2 points")
|
||||||
if body.distance_m <= 0:
|
if body.distance_m < 500:
|
||||||
raise HTTPException(400, "distance_m must be positive")
|
raise HTTPException(400, "segment must be at least 500 m long")
|
||||||
|
|
||||||
lats = [p[0] for p in body.polyline]
|
lats = [p[0] for p in body.polyline]
|
||||||
lons = [p[1] for p in body.polyline]
|
lons = [p[1] for p in body.polyline]
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
$: endPct = maxIdx > 0 ? (endIdx / maxIdx) * 100 : 100;
|
$: endPct = maxIdx > 0 ? (endIdx / maxIdx) * 100 : 100;
|
||||||
$: selectedPolyline = gpsPoints.slice(startIdx, endIdx + 1);
|
$: selectedPolyline = gpsPoints.slice(startIdx, endIdx + 1);
|
||||||
$: selectedDistance = polylineDistance(selectedPolyline);
|
$: selectedDistance = polylineDistance(selectedPolyline);
|
||||||
$: canSave = segName.trim().length > 0 && selectedPolyline.length >= 2 && !saving;
|
$: canSave = segName.trim().length > 0 && selectedPolyline.length >= 2 && selectedDistance >= 500 && !saving;
|
||||||
|
|
||||||
// ── Init ──────────────────────────────────────────────────────────────────
|
// ── Init ──────────────────────────────────────────────────────────────────
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@@ -379,6 +379,9 @@
|
|||||||
<p class="text-xs text-zinc-400 mt-2">
|
<p class="text-xs text-zinc-400 mt-2">
|
||||||
Selected: <span class="text-white font-medium">{formatDistance(selectedDistance)}</span>
|
Selected: <span class="text-white font-medium">{formatDistance(selectedDistance)}</span>
|
||||||
({selectedPolyline.length} points)
|
({selectedPolyline.length} points)
|
||||||
|
{#if selectedDistance < 500}
|
||||||
|
<span class="text-amber-400 ml-1">— minimum 500 m</span>
|
||||||
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user