Skip to content

Commit

Permalink
parseOsmResp: Exclude certain roads
Browse files Browse the repository at this point in the history
Some service roads and roads without access should not be visible in the editor UI. This will filter those roads.
  • Loading branch information
tordans committed Feb 2, 2022
1 parent c35e826 commit 3e273e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/utils/data-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ async function downloadContent(url: string): Promise<RawOsmData> {
return resp.data
}

function includeOsmWay(tags) {
// Filter should never apply to non-highway ways
if (!tags?.highway) return true
const unwantedAccess = tags?.access === 'no' || tags?.access === 'private'
const unwantedService = ['emergency_access', 'parking_aisle', 'driveway'].includes(tags?.service)

return !(unwantedAccess || unwantedService)
}

function parseOsmResp(osmResp: RawOsmData): ParsedOsmData {
const newData: ParsedOsmData = {
ways: {},
Expand All @@ -80,7 +89,8 @@ function parseOsmResp(osmResp: RawOsmData): ParsedOsmData {
break

case 'way':
newData.ways[el.id] = el
if (includeOsmWay(el.tags))
newData.ways[el.id] = el
break

case 'relation':
Expand Down

0 comments on commit 3e273e6

Please sign in to comment.