diff --git a/apps/planner/app/components/PlannerMap.tsx b/apps/planner/app/components/PlannerMap.tsx index d8d3499..0ec1aef 100644 --- a/apps/planner/app/components/PlannerMap.tsx +++ b/apps/planner/app/components/PlannerMap.tsx @@ -170,8 +170,15 @@ function CursorTracker({ awareness }: { awareness: YjsState["awareness"] }) { } function NoGoAreaButton({ active, onClick }: { active: boolean; onClick: () => void }) { + const ref = useRef(null); + + // Prevent clicks from reaching the Leaflet map (same as built-in controls) + useEffect(() => { + if (ref.current) L.DomEvent.disableClickPropagation(ref.current); + }, []); + return ( -
+
): Map { - const pts = area.points; - if (pts.length === 0) return null; - // Centroid - const cLat = pts.reduce((s, p) => s + p.lat, 0) / pts.length; - const cLon = pts.reduce((s, p) => s + p.lon, 0) / pts.length; - // Max distance from centroid in meters (approximate) - const maxDist = Math.max( - ...pts.map((p) => haversineMeters(cLat, cLon, p.lat, p.lon)), - ); - return `${cLon},${cLat},${Math.ceil(maxDist)}`; + if (area.points.length < 3) return null; + return area.points.map((p) => `${p.lon},${p.lat}`).join(","); }) .filter(Boolean) .join("|"); } -function haversineMeters(lat1: number, lon1: number, lat2: number, lon2: number): number { - const R = 6371000; - const dLat = ((lat2 - lat1) * Math.PI) / 180; - const dLon = ((lon2 - lon1) * Math.PI) / 180; - const a = - Math.sin(dLat / 2) ** 2 + - Math.cos((lat1 * Math.PI) / 180) * - Math.cos((lat2 * Math.PI) / 180) * - Math.sin(dLon / 2) ** 2; - return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); -} - export function getBRouterUrl(): string { return BROUTER_URL; } diff --git a/docs/spec-drift.md b/docs/spec-drift.md index 36d6612..95067cb 100644 --- a/docs/spec-drift.md +++ b/docs/spec-drift.md @@ -8,12 +8,7 @@ This document lists all known drifts between the OpenSpec specifications in `ope ## Active Drifts -### 1. No-go areas are converted to circles for BRouter, not passed as polygons - -- **Spec**: `openspec/specs/brouter-integration/spec.md` — "BRouter request includes nogo parameters for each polygon" -- **Implementation**: `apps/planner/app/lib/brouter.ts` (`noGoAreasToParam()`) converts each polygon to a circle by computing the centroid and using the maximum distance from centroid to any vertex as the radius. BRouter receives `lon,lat,radius` parameters, not polygon coordinates. -- **Impact**: Routing avoidance is approximate. Elongated or concave polygons may not be accurately represented as circles, allowing routes to pass through parts of the drawn area. -- **Resolution options**: Update the spec to document the circle approximation (BRouter only supports circle-based no-go areas), or implement polygon decomposition into multiple overlapping circles for better coverage. +None — all identified drifts have been resolved. --- @@ -23,9 +18,10 @@ Previously identified drifts that have been fixed via code changes or spec updat | # | Drift | Fixed in | Resolution | |---|-------|----------|------------| -| 2 | PostGIS `geom` column never populated | PR #150, #151 | `setGeomFromGpx()` now populates geometry via `ST_GeomFromGeoJSON` on route/activity creation | -| 3 | Planner metrics gauges always zero | PR #149 | Gauges wired to `.inc()`/`.dec()` in `yjs-server.ts` on client connect/disconnect | -| 4 | Email provider spec said Resend, impl uses SMTP | PR #153 | Spec updated to document Nodemailer + SMTP | +| 1 | PostGIS `geom` column never populated | PR #150, #151 | `setGeomFromGpx()` now populates geometry via `ST_GeomFromGeoJSON` on route/activity creation | +| 2 | Planner metrics gauges always zero | PR #149 | Gauges wired to `.inc()`/`.dec()` in `yjs-server.ts` on client connect/disconnect | +| 3 | Email provider spec said Resend, impl uses SMTP | PR #153 | Spec updated to document Nodemailer + SMTP | +| 4 | No-go areas converted to circles instead of polygons | PR #155 | `noGoAreasToParam()` now passes polygon vertices directly via BRouter's `polygons` parameter | | 5 | Server type spec said CX21, Terraform has cx23 | PR #153 | Spec updated to document cx23 | | 6 | Secret files split into two instead of one | PR #153 | Spec updated to document `secrets.app.env` + `secrets.infra.env` split | | 7 | BRouter host failover spec said "within 5 seconds" | PR #153 | Spec updated to document immediate deterministic election | diff --git a/openspec/specs/no-go-areas/spec.md b/openspec/specs/no-go-areas/spec.md index 91dfdb0..dd6bfe4 100644 --- a/openspec/specs/no-go-areas/spec.md +++ b/openspec/specs/no-go-areas/spec.md @@ -9,7 +9,8 @@ Users SHALL be able to draw polygons on the map that BRouter avoids when computi #### Scenario: Route avoids no-go area - **WHEN** a route is computed and a no-go area intersects the direct path -- **THEN** BRouter routes around the no-go area +- **THEN** BRouter request includes the polygon vertices via the `polygons` parameter +- **AND** BRouter routes around the no-go area #### Scenario: Delete no-go area - **WHEN** a user deletes a no-go area polygon