mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor: separate map feature queries and source records
This commit is contained in:
1 parent
a8125ad917
commit
bf1d50f29b
28 files changed
+1128
-675
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user