#1492

Hong Kong: the Highways Department's lamp posts as mapped street lamps

Openglki6wants to merge intofrom

Summary

In Hong Kong the server guesses every street lamp. OpenStreetMap has 8 lamp nodes in 95 road geotiles there; the Highways Department publishes 3,032 lamp posts for the same tiles. Cities whose lamps are mapped in OpenStreetMap, such as Prague and Utrecht (two of the cities furniture.LAMP_SPACING was measured from), are given each lamp at its mapped point by #981 (worldprops._street_lamps, 44d05fc4). This PR brings Hong Kong on par with them: the department's points go through the same path.

Two commits. The first puts back the mapped_lamps argument that 97d0bcf2 dropped from the roads.build_tile call in blockworker._tile_parts, two hours after #981 added it. Without it a road tile draws no mapped lamp, from OpenStreetMap or from here. That commit's message does not mention lamps, so I read the removal as unintended; if it was deliberate, this PR needs another way in. That commit is also #1493 on its own, with the history behind this reading. The second commit is the Hong Kong source.

How it follows the existing code

  • Same record, same path. hklamps.add appends the records _street_lamps makes (the ordinary post, STREET_LAMP_H, id hk:hyd:<lamp number>). _aim_lamps turns them to the road and furniture.place draws them, unchanged.
  • Fetched like France's buildings. Per z14 cell from the department's layer on the CSDI Portal, under the existing portal.csdi.gov.hk host policy, kept in <cache>/hklamps/v1. Prefetch, a bounded wait (4 s) and a revisit fault when the records are not here yet, as bdtopo.py does.
  • A government point set, as radars.py, frmotorwaymarkers.py and nyctanks.py are.
  • Switch: BNE_HK_LAMPS=off. Only cells that overlap hklidar.BOUNDS are asked for.

Which points become lamps

The layer gives a position and a number, no type and no height. The rules are in hklamps.py; counts are for the 3,032 points of the test tiles.

  1. An OpenStreetMap lamp within 5 m wins (1). Points within 1 m of each other are one lamp.
  2. A point on a bridge or tunnel footprint is not drawn (538 and 40). A mapped lamp stands on the ground, so one that really stands on a deck would be dropped by furniture.under_decks.
  3. A point with no drivable road within 40 m is not drawn (63).
  4. A point inside a ground carriageway is moved out of it. The model's lanes are wider than Hong Kong's, so 658 points are. The width is the one roads.road_specs gives the road. In order:
    • to the near kerb, where a guessed lamp stands (half the width + LAMP_EDGE_M): 434, moved 2.0 m at the median;
    • else into the median, if it leaves LAMP_CURB_M on both sides: 23;
    • else to the far kerb: 110, moved 10.2 m at the median;
    • else not drawn: 78. A post moved into the median or to the far kerb that ends within 6 m of another is not drawn: 13.

Results

12 places all over Hong Kong: city streets, new towns and village roads, 95 road geotiles, 135 km of ground road. Road length is sampled every 10 m; a sample is lit when a drawn lamp of any kind is within 35 m.

devthis PR
Mapped lamps drawn02,293
Road with a lamp within 35 m66.5 %79.7 %
The same, main roads only82.7 %93.6 %
Lit on dev, dark here3.5 km
Dark on dev, lit here21.3 km
  • Lamps in a carriageway: 1 post, 0.29 m in (the builder's lane shift, placement.ring, which hklamps does not apply).
  • Time: hklamps.add takes 5 ms a tile at the median from cache; the worst tile takes 1.36 s, the first read of a big cell's roads.
  • First visit: 14 cells, 18 requests and 2.1 MB for the 12 places. With the default wait all 95 tiles were built with their lamps.

Known limits

  • Dark stretches: 3.5 km of 135 km. 131 stretches; 2 are 100 m or longer, both under flyovers at Hong Kong (22.30625 N 114.16097 E). A road with two mapped lamps anywhere along it guesses none (furniture.roads_with_points), and rule 2 leaves out the points beside decks. I did not change that rule.
  • Two of the 12 places do not gain. Hong Kong (22.31583 N 114.15939 E) is level. Hong Kong (22.30669 N 114.16119 E) loses 0.9 km of lit road and gains 1.8 km.
  • Flyover decks have no lamps, as on dev: none of dev's 1,161 guessed lamps in the test tiles stands at deck level.
  • Far-kerb posts stand about 10 m from their surveyed place, on the right road at the right station along it.
  • One post for every lamp. The layer has no type, so no high masts.
  • Seen in the game on a 1.10.1-beta tree with this change, not on dev.

Who this affects

  • The first commit: every place with OpenStreetMap street lamps. Their lamps stand at their mapped points again, and a road with two of them along it guesses none, as #981 describes. I have not run it outside Hong Kong: my lab could not get map tiles for other cities. In the 95 Hong Kong tiles it draws 6 mapped lamps and changes the rows of 4 tiles. BNE_MAPPED_LAMPS=off still gives guessed lamps only.
  • The second commit: only cells that overlap Hong Kong. With BNE_HK_LAMPS=off the rows of all 95 tiles are identical to dev with the first commit.
  • Other regions: worldprops.tile_props takes an optional spec_args and works out one more list of cells per road tile. Nothing is asked of the network.
  • Cache keys: nothing new; the tiles' code key changes with worldprops.py.
  • Credits: rows in CREDITS.md, SOURCES.md and README.md, under the DATA.GOV.HK terms CREDITS.md already cites.
  • #1466: both add lines at the same places in CREDITS.md, credits.py, mapdata.py, test_env_keys.py and quality_gate.py, so they conflict as text. I will rebase whichever is left when one lands.

Validation

  • test_blockworker has a new test, MappedLampsTest.test_road_tile_gets_the_mapped_lamps, that fails without the first commit's line.
  • test_hklamps (37 tests, made-up points only) passes. test_worldprops, test_furniture, test_blockworker, test_env_keys, test_mapdata and test_credits pass.
  • Two runs of the 95 tiles give identical rows.
  • test_determinism.platform_maths finds nothing in the files changed. I have not run the whole suite.

🤖 Generated with Claude Code on Fable 5.2