Skip to content

Commit

Permalink
Release 2025-01-08 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans authored Jan 8, 2025
2 parents 357bd3e + 0af9106 commit 3f3492e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 67 deletions.
85 changes: 43 additions & 42 deletions processing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,57 +15,58 @@ import { logTileInfo } from './utils/logging'
import { params } from './utils/parameters'
import { synologyLogError } from './utils/synology'

try {
// setup directories and backup schema
await setup()
async function main() {
try {
// Setup directories and backup schema
await setup()

// wait for fresh data
if (params.waitForFreshData) {
await waitForFreshData(params.fileURL, 24, 10)
}
// Wait for fresh data
if (params.waitForFreshData) {
await waitForFreshData(params.fileURL, 24, 10)
}

// download osm file
let { fileName, fileChanged } = await downloadFile(params.fileURL, params.skipDownload)
// Download osm file
let { fileName, fileChanged } = await downloadFile(params.fileURL, params.skipDownload)

// filter osm file with /filter/filter-expressions.txt
await tagFilter(fileName, fileChanged)
// Filter osm file with /filter/filter-expressions.txt
await tagFilter(fileName, fileChanged)

// filter osm file by ids if given
if (params.idFilter !== '') {
fileName = await idFilter(fileName, params.idFilter)
fileChanged = true
}
// Filter osm file by ids if given
if (params.idFilter !== '') {
fileName = await idFilter(fileName, params.idFilter)
fileChanged = true
}

// process topics
const { timeElapsed: processingTime, processedTables } = await processTopics(
topicList,
fileName,
fileChanged,
params.skipUnchanged,
params.computeDiffs,
params.freezeData,
)
// Process topics
const { timeElapsed: processingTime, processedTables } = await processTopics(
topicList,
fileName,
fileChanged,
params.skipUnchanged,
params.computeDiffs,
params.freezeData,
)

await generateTypes(params.environment, processedTables)
await generateTypes(params.environment, processedTables)
await writeMetadata(fileName, processingTime)

// write runs metadata
await writeMetadata(fileName, processingTime)
// Call the frontend update hook which registers sql functions and starts the analysis run
await triggerPostProcessing()

// call the frontend update hook
await triggerPostProcessing()
// Restart `tiles` container to refresh `/catalog`
await restartTileServer()

// restart `tiles` container to refresh /catalog
await restartTileServer()
// clear the cache
await clearCache()
// Handle cache warming hook
await clearCache()
if (!params.skipWarmCache) {
await triggerCacheWarming()
}

// call the cache warming hook
if (!params.skipWarmCache) {
await triggerCacheWarming()
await logTileInfo(params.environment)
} catch (error) {
// This `catch` will only trigger if child functions are `await`ed AND file calls a `main()` function. Top level code does not work.
synologyLogError(`Processing failed: ${error}`)
}

await logTileInfo(params.environment)
} catch (error) {
synologyLogError(`Processing failed: ${error}`)
throw error
}

main()
5 changes: 3 additions & 2 deletions processing/steps/externalTriggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ async function triggerPrivateApi(endpoint: string) {
if (!response.ok) {
throw new Error(`The ${endpoint} endpoint failed with status code ${response.status}.`)
}
} catch {
} catch (error) {
console.warn(
`⚠️ Calling the ${endpoint} hook failed. This is likely due to the NextJS application not running.`,
error,
)
}
}
Expand All @@ -29,7 +30,7 @@ export async function clearCache() {
await $`rm -rf "/var/cache/nginx/*"`
console.log('Succesfully cleared the cache.')
} catch (error) {
console.warn(`Clearing the cache failed: ${error}`)
console.warn('Clearing the cache failed:', error)
}
}

Expand Down
42 changes: 27 additions & 15 deletions processing/topics/roads_bikelanes/bikelanes/BikelaneCategories.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package.path = package.path .. ";/processing/topics/roads_bikelanes/bikelanes/categories/?.lua"
package.path = package.path .. ";/processing/topics/helper/?.lua"
require("Set")
require("ContainsSubstring")
require("IsSidepath")
require("CreateSubcategoriesAdjoiningOrIsolated")
Expand Down Expand Up @@ -432,29 +431,38 @@ local protectedCyclewayOnHighway = BikelaneCategory.new({
return false
end

-- We don't use our `Set` pattern here because we need a Substring check
local function isPhysicalSeperation(separation)
local physicalSeparations = {
'bollard',
'parking_lane',
'bump',
'separation_kerb',
'vertical_panel',
'fence',
'flex_post',
'jersey_barrier',
'kerb'
}
for _, value in pairs(physicalSeparations) do
if ContainsSubstring(separation, value) then
return true
end
end
end

-- We go from specific to general tags (:side > :both > '')
local separation_left = tags['separation:left'] or tags['separation:both'] or tags['separation']
local separation_right = tags['separation:right'] or tags['separation:both'] or tags['separation']
local physicalSeparations = Set({
'bollard',
'parking_lane',
'bump',
'separation_kerb',
'vertical_panel',
'fence',
'flex_post',
'jersey_barrier',
'kerb'
})

if not physicalSeparations[separation_left] then

if not isPhysicalSeperation(separation_left) then
return false
end

-- Check also the left separation for the rare case that there is motorized traffic on the right hand side
local traffic_mode_right = tags['traffic_mode:right'] or tags['traffic_mode:both'] or tags['traffic_mode']
if traffic_mode_right == 'motorized' then
if not physicalSeparations[separation_right] then
if not isPhysicalSeperation(separation_right) then
return false
end
end
Expand Down Expand Up @@ -516,6 +524,10 @@ local sharedBusLaneBikeWithBus = BikelaneCategory.new({

-- This is where we collect bike lanes that do not have sufficient tagging to be categorized well.
-- They are in OSM, but they need to be improved, which we show in the UI.
-- GOTCHA:
-- This category will also collect all transformed geometries that had any `cycleway:*` tag.
-- This can include false translformations like when someone tagged `cycleway:separation:right=foo` which will create a transformed object
-- (which we "see" as an `highway=cycleway`) for both sides (based on `cycleway:NIL` being recognized as `cycleway:both`).
local needsClarification = BikelaneCategory.new({
id = 'needsClarification',
desc = 'Bike infrastructure that we cannot categories properly due to missing or ambiguous tagging.' ..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ describe("Bikelanes", function()
local result = Bikelanes(input_object)
for _, v in pairs(result) do
if v._side == 'right' and v.prefix == 'cycleway' then
-- Any `cycleway:(nil|both|right)` creates a transformed geometry for `right` which will fall back to `needsClarification` if no other tags are given
assert.are.equal("needsClarification", v.category)
end
if v._side == 'left' and v.prefix == 'cycleway' then
Expand All @@ -250,25 +251,22 @@ describe("Bikelanes", function()
end
end)

pending('Bug https://www.openstreetmap.org/way/565095160/history/5', function()
it('Categories for protected bikelanes (only left)', function()
local input_object = {
highway = 'primary',
tags = {
['cycleway:left'] = 'lane',
['cycleway:left:bicyle'] = 'yes',
['cycleway:separation:left'] = 'yes'
['cycleway:left:separation:left'] = 'yes'
},
id = 1,
type = 'way'
}
local result = Bikelanes(input_object)
for _, v in pairs(result) do
if v._side == 'right' and v.prefix == 'cycleway' then
assert.are.equal("a", v)
assert.are.equal("a", v.category)
end
for _, v in pairs(result) do
assert.are.equal('left', v._side) -- no 'right' side
if v._side == 'left' and v.prefix == 'cycleway' then
assert.are.equal("cyclewayOnHighway_advisoryOrExclusive", v.category)
assert.are.equal('cyclewayOnHighway_advisoryOrExclusive', v.category)
end
end
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function GetTransformedObjects(tags, transformations)
_side = side,
_parent = tags,
_parent_highway = tags.highway,
-- REFACOTRING: This should be `_highway`, see https://github.com/FixMyBerlin/private-issues/issues/2236
highway = transformation.highway
}

Expand Down
1 change: 1 addition & 0 deletions processing/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const lineLength = process.stdout.columns || 120
export function logPadded(left: string, right: string = '') {
console.log(chalk.inverse(left.padEnd(lineLength - right.length) + right))
}

export function logStart(id: string) {
const message = `${id} started`
synologyLogInfo(message)
Expand Down

0 comments on commit 3f3492e

Please sign in to comment.