fix: find fire perimeters that overlap an area

Fire perimeters were placed at their average vertex, so a fire enclosing the
whole requested area was missed. Polygons now count when a vertex is inside
the area, an edge crosses it, or the polygon contains it outside any hole.
This commit is contained in:
Sameh Khamis committed 2026-10-02 15:21:36 -07:00
1 parent 4af15aa6a9
commit dd8ba562d2
4 files changed
+88 -1

No files matched your search

+3 -1
View File
@@ -10,6 +10,7 @@ import {
areaCenter,
areaContains,
distanceKm,
polygonsTouchArea,
resolveArea,
resolvePoint,
} from '../area.js';
@@ -237,8 +238,9 @@ export const getFirePerimeters = defineTool({
async run(args, { services, signal }) {
const area = await resolveArea(args.area, { services, signal });
const rows = (await services.perimeters.getSnapshot({ signal }))
.filter((fire) => polygonsTouchArea(fire.polygons, area))
.map((fire) => ({ fire, point: polygonCenter(fire.polygons) }))
.filter(({ point }) => point && areaContains(area, point))
.filter(({ point }) => point)
.map(({ fire, point }) => ({
id: fire.stableId,
name: fire.name,