refactor: separate map feature queries and source records

This commit is contained in:
Sameh Khamis committed 2026-09-15 08:10:32 -07:00
1 parent a8125ad917
commit bf1d50f29b
28 files changed
+1128 -675

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
/** Decode OSM ways into portable road coordinates, classes and travel direction. */
export function normalizeOverpassRoads(payload) {
const roads = [];
for (const element of payload?.elements || []) {
if (
element.type !== 'way' ||
!element.geometry ||
element.geometry.length < 2
)
continue;
const oneway = element.tags?.oneway;
roads.push({
coordinates: element.geometry.map((point) => [point.lon, point.lat]),
type: element.tags?.highway || 'unclassified',
oneway:
oneway === 'yes' ||
oneway === '1' ||
oneway === 'true' ||
element.tags?.junction === 'roundabout'
? 1
: oneway === '-1'
? -1
: 0,
});
}
return roads;
}