leaflet-city-mapper 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (412) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +78 -2
  3. package/cucumber.mjs +9 -0
  4. package/dist/leaflet-city-mapper.js +2 -0
  5. package/dist/leaflet-city-mapper.js.map +7 -0
  6. package/dist/utils/CELL.js +2 -0
  7. package/dist/utils/CELL.js.map +7 -0
  8. package/dist/utils/addBridges.js +2 -0
  9. package/dist/utils/addBridges.js.map +7 -0
  10. package/dist/utils/addRasterTile.js +2 -0
  11. package/dist/utils/addRasterTile.js.map +7 -0
  12. package/dist/utils/along.js +2 -0
  13. package/dist/utils/along.js.map +7 -0
  14. package/dist/utils/atmosphere.js +2 -0
  15. package/dist/utils/atmosphere.js.map +7 -0
  16. package/dist/utils/attach.js +2 -0
  17. package/dist/utils/attach.js.map +7 -0
  18. package/dist/utils/bindSunlight.js +2 -0
  19. package/dist/utils/bindSunlight.js.map +7 -0
  20. package/dist/utils/box.js +2 -0
  21. package/dist/utils/box.js.map +7 -0
  22. package/dist/utils/bridgeElevation.js +2 -0
  23. package/dist/utils/bridgeElevation.js.map +7 -0
  24. package/dist/utils/build.js +2 -0
  25. package/dist/utils/build.js.map +7 -0
  26. package/dist/utils/cameraControls.js +2 -0
  27. package/dist/utils/cameraControls.js.map +7 -0
  28. package/dist/utils/channel.js +2 -0
  29. package/dist/utils/channel.js.map +7 -0
  30. package/dist/utils/collider.js +2 -0
  31. package/dist/utils/collider.js.map +7 -0
  32. package/dist/utils/colliders.js +2 -0
  33. package/dist/utils/colliders.js.map +7 -0
  34. package/dist/utils/computeBounds.js +2 -0
  35. package/dist/utils/computeBounds.js.map +7 -0
  36. package/dist/utils/conformModelToTerrain.js +2 -0
  37. package/dist/utils/conformModelToTerrain.js.map +7 -0
  38. package/dist/utils/createMesh.js +2 -0
  39. package/dist/utils/createMesh.js.map +7 -0
  40. package/dist/utils/createProgram.js +3 -0
  41. package/dist/utils/createProgram.js.map +7 -0
  42. package/dist/utils/decodeDirectory.js +2 -0
  43. package/dist/utils/decodeDirectory.js.map +7 -0
  44. package/dist/utils/decodeHeader.js +2 -0
  45. package/dist/utils/decodeHeader.js.map +7 -0
  46. package/dist/utils/decodeModel.js +2 -0
  47. package/dist/utils/decodeModel.js.map +7 -0
  48. package/dist/utils/decompress.js +2 -0
  49. package/dist/utils/decompress.js.map +7 -0
  50. package/dist/utils/destroyTexture.js +2 -0
  51. package/dist/utils/destroyTexture.js.map +7 -0
  52. package/dist/utils/disposeMesh.js +2 -0
  53. package/dist/utils/disposeMesh.js.map +7 -0
  54. package/dist/utils/drawGeometry.js +2 -0
  55. package/dist/utils/drawGeometry.js.map +7 -0
  56. package/dist/utils/elevationWGSL.js +24 -0
  57. package/dist/utils/elevationWGSL.js.map +7 -0
  58. package/dist/utils/emptyNode.js +2 -0
  59. package/dist/utils/emptyNode.js.map +7 -0
  60. package/dist/utils/endZoom.js +2 -0
  61. package/dist/utils/endZoom.js.map +7 -0
  62. package/dist/utils/findFeature.js +2 -0
  63. package/dist/utils/findFeature.js.map +7 -0
  64. package/dist/utils/geometry.js +1 -0
  65. package/dist/utils/geometry.js.map +7 -0
  66. package/dist/utils/getElevation.js +2 -0
  67. package/dist/utils/getElevation.js.map +7 -0
  68. package/dist/utils/getHeader.js +2 -0
  69. package/dist/utils/getHeader.js.map +7 -0
  70. package/dist/utils/getZxy.js +2 -0
  71. package/dist/utils/getZxy.js.map +7 -0
  72. package/dist/utils/glass.js +2 -0
  73. package/dist/utils/glass.js.map +7 -0
  74. package/dist/utils/headlight.js +2 -0
  75. package/dist/utils/headlight.js.map +7 -0
  76. package/dist/utils/hit.js +2 -0
  77. package/dist/utils/hit.js.map +7 -0
  78. package/dist/utils/horizontalPosition.js +2 -0
  79. package/dist/utils/horizontalPosition.js.map +7 -0
  80. package/dist/utils/horizontalRay.js +2 -0
  81. package/dist/utils/horizontalRay.js.map +7 -0
  82. package/dist/utils/hull.js +2 -0
  83. package/dist/utils/hull.js.map +7 -0
  84. package/dist/utils/initSunlight.js +2 -0
  85. package/dist/utils/initSunlight.js.map +7 -0
  86. package/dist/utils/initTerrain.js +2 -0
  87. package/dist/utils/initTerrain.js.map +7 -0
  88. package/dist/utils/initTraffic.js +40 -0
  89. package/dist/utils/initTraffic.js.map +7 -0
  90. package/dist/utils/initWalk.js +2 -0
  91. package/dist/utils/initWalk.js.map +7 -0
  92. package/dist/utils/intersectMeshes.js +2 -0
  93. package/dist/utils/intersectMeshes.js.map +7 -0
  94. package/dist/utils/isClockWise.js +2 -0
  95. package/dist/utils/isClockWise.js.map +7 -0
  96. package/dist/utils/lampPostGeometry.js +2 -0
  97. package/dist/utils/lampPostGeometry.js.map +7 -0
  98. package/dist/utils/lightGeometry.js +2 -0
  99. package/dist/utils/lightGeometry.js.map +7 -0
  100. package/dist/utils/lightGrid.js +2 -0
  101. package/dist/utils/lightGrid.js.map +7 -0
  102. package/dist/utils/limbs.js +2 -0
  103. package/dist/utils/limbs.js.map +7 -0
  104. package/dist/utils/loadModel.js +2 -0
  105. package/dist/utils/loadModel.js.map +7 -0
  106. package/dist/utils/loadSource.js +2 -0
  107. package/dist/utils/loadSource.js.map +7 -0
  108. package/dist/utils/loadTerrain.js +2 -0
  109. package/dist/utils/loadTerrain.js.map +7 -0
  110. package/dist/utils/mapCamera.js +2 -0
  111. package/dist/utils/mapCamera.js.map +7 -0
  112. package/dist/utils/materialShaders.js +211 -0
  113. package/dist/utils/materialShaders.js.map +7 -0
  114. package/dist/utils/mirror.js +2 -0
  115. package/dist/utils/mirror.js.map +7 -0
  116. package/dist/utils/moonPosition.js +2 -0
  117. package/dist/utils/moonPosition.js.map +7 -0
  118. package/dist/utils/moves.js +2 -0
  119. package/dist/utils/moves.js.map +7 -0
  120. package/dist/utils/nativeEvents.js +2 -0
  121. package/dist/utils/nativeEvents.js.map +7 -0
  122. package/dist/utils/nativeGeometry.js +2 -0
  123. package/dist/utils/nativeGeometry.js.map +7 -0
  124. package/dist/utils/nativeLayer.js +2 -0
  125. package/dist/utils/nativeLayer.js.map +7 -0
  126. package/dist/utils/nodeMatrix.js +2 -0
  127. package/dist/utils/nodeMatrix.js.map +7 -0
  128. package/dist/utils/onAdd3DLayer.js +2 -0
  129. package/dist/utils/onAdd3DLayer.js.map +7 -0
  130. package/dist/utils/onAddSun.js +2 -0
  131. package/dist/utils/onAddSun.js.map +7 -0
  132. package/dist/utils/onClick.js +2 -0
  133. package/dist/utils/onClick.js.map +7 -0
  134. package/dist/utils/onMapChange.js +2 -0
  135. package/dist/utils/onMapChange.js.map +7 -0
  136. package/dist/utils/onPMTileAdd.js +2 -0
  137. package/dist/utils/onPMTileAdd.js.map +7 -0
  138. package/dist/utils/onPMTileRemove.js +2 -0
  139. package/dist/utils/onPMTileRemove.js.map +7 -0
  140. package/dist/utils/onPointerLeave.js +2 -0
  141. package/dist/utils/onPointerLeave.js.map +7 -0
  142. package/dist/utils/onPointerMove.js +2 -0
  143. package/dist/utils/onPointerMove.js.map +7 -0
  144. package/dist/utils/onRemove3DLayer.js +2 -0
  145. package/dist/utils/onRemove3DLayer.js.map +7 -0
  146. package/dist/utils/onRemoveSun.js +2 -0
  147. package/dist/utils/onRemoveSun.js.map +7 -0
  148. package/dist/utils/onTerrainAdd.js +2 -0
  149. package/dist/utils/onTerrainAdd.js.map +7 -0
  150. package/dist/utils/onTerrainChange.js +2 -0
  151. package/dist/utils/onTerrainChange.js.map +7 -0
  152. package/dist/utils/onTerrainRemove.js +2 -0
  153. package/dist/utils/onTerrainRemove.js.map +7 -0
  154. package/dist/utils/onZoomAnim.js +2 -0
  155. package/dist/utils/onZoomAnim.js.map +7 -0
  156. package/dist/utils/paints.js +2 -0
  157. package/dist/utils/paints.js.map +7 -0
  158. package/dist/utils/parseColor.js +2 -0
  159. package/dist/utils/parseColor.js.map +7 -0
  160. package/dist/utils/parts.js +2 -0
  161. package/dist/utils/parts.js.map +7 -0
  162. package/dist/utils/projectCelestialBody.js +2 -0
  163. package/dist/utils/projectCelestialBody.js.map +7 -0
  164. package/dist/utils/pump.js +2 -0
  165. package/dist/utils/pump.js.map +7 -0
  166. package/dist/utils/rasterTiles.js +2 -0
  167. package/dist/utils/rasterTiles.js.map +7 -0
  168. package/dist/utils/raycast.js +2 -0
  169. package/dist/utils/raycast.js.map +7 -0
  170. package/dist/utils/read.js +2 -0
  171. package/dist/utils/read.js.map +7 -0
  172. package/dist/utils/readAccessor.js +2 -0
  173. package/dist/utils/readAccessor.js.map +7 -0
  174. package/dist/utils/releaseArea.js +2 -0
  175. package/dist/utils/releaseArea.js.map +7 -0
  176. package/dist/utils/removeRasterTile.js +2 -0
  177. package/dist/utils/removeRasterTile.js.map +7 -0
  178. package/dist/utils/render.js +15 -0
  179. package/dist/utils/render.js.map +7 -0
  180. package/dist/utils/renderSunlight.js +13 -0
  181. package/dist/utils/renderSunlight.js.map +7 -0
  182. package/dist/utils/renderers.js +2 -0
  183. package/dist/utils/renderers.js.map +7 -0
  184. package/dist/utils/resizeSunlight.js +2 -0
  185. package/dist/utils/resizeSunlight.js.map +7 -0
  186. package/dist/utils/roofCoverage.js +2 -0
  187. package/dist/utils/roofCoverage.js.map +7 -0
  188. package/dist/utils/routeGeometry.js +2 -0
  189. package/dist/utils/routeGeometry.js.map +7 -0
  190. package/dist/utils/scheduledTrips.js +2 -0
  191. package/dist/utils/scheduledTrips.js.map +7 -0
  192. package/dist/utils/setGeoJSONData.js +2 -0
  193. package/dist/utils/setGeoJSONData.js.map +7 -0
  194. package/dist/utils/setHighlight.js +2 -0
  195. package/dist/utils/setHighlight.js.map +7 -0
  196. package/dist/utils/setPMTileOpacity.js +2 -0
  197. package/dist/utils/setPMTileOpacity.js.map +7 -0
  198. package/dist/utils/setPMTileZIndex.js +2 -0
  199. package/dist/utils/setPMTileZIndex.js.map +7 -0
  200. package/dist/utils/setParent.js +2 -0
  201. package/dist/utils/setParent.js.map +7 -0
  202. package/dist/utils/setTerrainHeight.js +2 -0
  203. package/dist/utils/setTerrainHeight.js.map +7 -0
  204. package/dist/utils/setVertexColor.js +2 -0
  205. package/dist/utils/setVertexColor.js.map +7 -0
  206. package/dist/utils/showFeature.js +2 -0
  207. package/dist/utils/showFeature.js.map +7 -0
  208. package/dist/utils/sizes.js +2 -0
  209. package/dist/utils/sizes.js.map +7 -0
  210. package/dist/utils/skin.js +2 -0
  211. package/dist/utils/skin.js.map +7 -0
  212. package/dist/utils/solarPosition.js +2 -0
  213. package/dist/utils/solarPosition.js.map +7 -0
  214. package/dist/utils/sortMeshes.js +2 -0
  215. package/dist/utils/sortMeshes.js.map +7 -0
  216. package/dist/utils/speed.js +2 -0
  217. package/dist/utils/speed.js.map +7 -0
  218. package/dist/utils/startZoom.js +2 -0
  219. package/dist/utils/startZoom.js.map +7 -0
  220. package/dist/utils/taillight.js +2 -0
  221. package/dist/utils/taillight.js.map +7 -0
  222. package/dist/utils/terrainAtlas.js +2 -0
  223. package/dist/utils/terrainAtlas.js.map +7 -0
  224. package/dist/utils/terrainElevation.js +2 -0
  225. package/dist/utils/terrainElevation.js.map +7 -0
  226. package/dist/utils/terrainGrid.js +2 -0
  227. package/dist/utils/terrainGrid.js.map +7 -0
  228. package/dist/utils/textureSampler.js +2 -0
  229. package/dist/utils/textureSampler.js.map +7 -0
  230. package/dist/utils/tileId.js +2 -0
  231. package/dist/utils/tileId.js.map +7 -0
  232. package/dist/utils/toLanes.js +2 -0
  233. package/dist/utils/toLanes.js.map +7 -0
  234. package/dist/utils/toSRGB.js +2 -0
  235. package/dist/utils/toSRGB.js.map +7 -0
  236. package/dist/utils/tooltip.js +3 -0
  237. package/dist/utils/tooltip.js.map +7 -0
  238. package/dist/utils/traffic.js +2 -0
  239. package/dist/utils/traffic.js.map +7 -0
  240. package/dist/utils/traverse.js +2 -0
  241. package/dist/utils/traverse.js.map +7 -0
  242. package/dist/utils/treeGeometry.js +2 -0
  243. package/dist/utils/treeGeometry.js.map +7 -0
  244. package/dist/utils/triangulate.js +2 -0
  245. package/dist/utils/triangulate.js.map +7 -0
  246. package/dist/utils/tripsAt.js +2 -0
  247. package/dist/utils/tripsAt.js.map +7 -0
  248. package/dist/utils/types.js +2 -0
  249. package/dist/utils/types.js.map +7 -0
  250. package/dist/utils/underEntry.js +2 -0
  251. package/dist/utils/underEntry.js.map +7 -0
  252. package/dist/utils/update.js +2 -0
  253. package/dist/utils/update.js.map +7 -0
  254. package/dist/utils/updateArea.js +2 -0
  255. package/dist/utils/updateArea.js.map +7 -0
  256. package/dist/utils/updateCamera.js +2 -0
  257. package/dist/utils/updateCamera.js.map +7 -0
  258. package/dist/utils/updatePointLights.js +2 -0
  259. package/dist/utils/updatePointLights.js.map +7 -0
  260. package/dist/utils/updateWorldMatrix.js +2 -0
  261. package/dist/utils/updateWorldMatrix.js.map +7 -0
  262. package/dist/utils/vehicleOffsets.js +2 -0
  263. package/dist/utils/vehicleOffsets.js.map +7 -0
  264. package/dist/utils/vehicles.js +2 -0
  265. package/dist/utils/vehicles.js.map +7 -0
  266. package/dist/utils/vertexNormals.js +2 -0
  267. package/dist/utils/vertexNormals.js.map +7 -0
  268. package/dist/utils/walk.js +2 -0
  269. package/dist/utils/walk.js.map +7 -0
  270. package/dist/utils/white.js +2 -0
  271. package/dist/utils/white.js.map +7 -0
  272. package/dist/utils/worldLights.js +2 -0
  273. package/dist/utils/worldLights.js.map +7 -0
  274. package/dist/utils/wrap.js +2 -0
  275. package/dist/utils/wrap.js.map +7 -0
  276. package/package.json +43 -4
  277. package/src/index.js +397 -0
  278. package/src/utils/CELL.js +4 -0
  279. package/src/utils/addBridges.js +66 -0
  280. package/src/utils/addRasterTile.js +112 -0
  281. package/src/utils/along.js +9 -0
  282. package/src/utils/atmosphere.js +20 -0
  283. package/src/utils/attach.js +255 -0
  284. package/src/utils/bindSunlight.js +12 -0
  285. package/src/utils/box.js +1 -0
  286. package/src/utils/bridgeElevation.js +18 -0
  287. package/src/utils/build.js +20 -0
  288. package/src/utils/cameraControls.js +287 -0
  289. package/src/utils/channel.js +4 -0
  290. package/src/utils/collider.js +62 -0
  291. package/src/utils/colliders.js +2 -0
  292. package/src/utils/computeBounds.js +17 -0
  293. package/src/utils/conformModelToTerrain.js +69 -0
  294. package/src/utils/createMesh.js +31 -0
  295. package/src/utils/createProgram.js +92 -0
  296. package/src/utils/decodeDirectory.js +40 -0
  297. package/src/utils/decodeHeader.js +15 -0
  298. package/src/utils/decodeModel.js +43 -0
  299. package/src/utils/decompress.js +5 -0
  300. package/src/utils/destroyTexture.js +7 -0
  301. package/src/utils/disposeMesh.js +13 -0
  302. package/src/utils/drawGeometry.js +122 -0
  303. package/src/utils/elevationWGSL.js +27 -0
  304. package/src/utils/emptyNode.js +9 -0
  305. package/src/utils/endZoom.js +15 -0
  306. package/src/utils/findFeature.js +49 -0
  307. package/src/utils/geometry.js +2 -0
  308. package/src/utils/getElevation.js +10 -0
  309. package/src/utils/getHeader.js +9 -0
  310. package/src/utils/getZxy.js +76 -0
  311. package/src/utils/glass.js +1 -0
  312. package/src/utils/headlight.js +1 -0
  313. package/src/utils/hit.js +41 -0
  314. package/src/utils/horizontalPosition.js +16 -0
  315. package/src/utils/horizontalRay.js +12 -0
  316. package/src/utils/hull.js +1 -0
  317. package/src/utils/initSunlight.js +9 -0
  318. package/src/utils/initTerrain.js +19 -0
  319. package/src/utils/initTraffic.js +93 -0
  320. package/src/utils/initWalk.js +72 -0
  321. package/src/utils/intersectMeshes.js +121 -0
  322. package/src/utils/isClockWise.js +12 -0
  323. package/src/utils/lampPostGeometry.js +26 -0
  324. package/src/utils/lightGeometry.js +22 -0
  325. package/src/utils/lightGrid.js +50 -0
  326. package/src/utils/limbs.js +9 -0
  327. package/src/utils/loadModel.js +217 -0
  328. package/src/utils/loadSource.js +17 -0
  329. package/src/utils/loadTerrain.js +65 -0
  330. package/src/utils/mapCamera.js +432 -0
  331. package/src/utils/materialShaders.js +243 -0
  332. package/src/utils/mirror.js +6 -0
  333. package/src/utils/moonPosition.js +17 -0
  334. package/src/utils/moves.js +11 -0
  335. package/src/utils/nativeEvents.js +77 -0
  336. package/src/utils/nativeGeometry.js +131 -0
  337. package/src/utils/nativeLayer.js +317 -0
  338. package/src/utils/nodeMatrix.js +22 -0
  339. package/src/utils/onAdd3DLayer.js +31 -0
  340. package/src/utils/onAddSun.js +147 -0
  341. package/src/utils/onClick.js +13 -0
  342. package/src/utils/onMapChange.js +16 -0
  343. package/src/utils/onPMTileAdd.js +15 -0
  344. package/src/utils/onPMTileRemove.js +8 -0
  345. package/src/utils/onPointerLeave.js +11 -0
  346. package/src/utils/onPointerMove.js +15 -0
  347. package/src/utils/onRemove3DLayer.js +78 -0
  348. package/src/utils/onRemoveSun.js +3 -0
  349. package/src/utils/onTerrainAdd.js +18 -0
  350. package/src/utils/onTerrainChange.js +13 -0
  351. package/src/utils/onTerrainRemove.js +40 -0
  352. package/src/utils/onZoomAnim.js +14 -0
  353. package/src/utils/paints.js +10 -0
  354. package/src/utils/parseColor.js +42 -0
  355. package/src/utils/parts.js +16 -0
  356. package/src/utils/projectCelestialBody.js +13 -0
  357. package/src/utils/pump.js +226 -0
  358. package/src/utils/rasterTiles.js +285 -0
  359. package/src/utils/raycast.js +60 -0
  360. package/src/utils/read.js +29 -0
  361. package/src/utils/readAccessor.js +68 -0
  362. package/src/utils/releaseArea.js +34 -0
  363. package/src/utils/removeRasterTile.js +13 -0
  364. package/src/utils/render.js +406 -0
  365. package/src/utils/renderSunlight.js +170 -0
  366. package/src/utils/renderers.js +2 -0
  367. package/src/utils/resizeSunlight.js +15 -0
  368. package/src/utils/roofCoverage.js +47 -0
  369. package/src/utils/routeGeometry.js +22 -0
  370. package/src/utils/scheduledTrips.js +29 -0
  371. package/src/utils/setGeoJSONData.js +11 -0
  372. package/src/utils/setHighlight.js +13 -0
  373. package/src/utils/setPMTileOpacity.js +7 -0
  374. package/src/utils/setPMTileZIndex.js +7 -0
  375. package/src/utils/setParent.js +7 -0
  376. package/src/utils/setTerrainHeight.js +10 -0
  377. package/src/utils/setVertexColor.js +14 -0
  378. package/src/utils/showFeature.js +27 -0
  379. package/src/utils/sizes.js +1 -0
  380. package/src/utils/skin.js +2 -0
  381. package/src/utils/solarPosition.js +17 -0
  382. package/src/utils/sortMeshes.js +12 -0
  383. package/src/utils/speed.js +3 -0
  384. package/src/utils/startZoom.js +5 -0
  385. package/src/utils/taillight.js +1 -0
  386. package/src/utils/terrainAtlas.js +21 -0
  387. package/src/utils/terrainElevation.js +20 -0
  388. package/src/utils/terrainGrid.js +23 -0
  389. package/src/utils/textureSampler.js +10 -0
  390. package/src/utils/tileId.js +18 -0
  391. package/src/utils/toLanes.js +7 -0
  392. package/src/utils/toSRGB.js +1 -0
  393. package/src/utils/tooltip.js +6 -0
  394. package/src/utils/traffic.js +315 -0
  395. package/src/utils/traverse.js +6 -0
  396. package/src/utils/treeGeometry.js +45 -0
  397. package/src/utils/triangulate.js +100 -0
  398. package/src/utils/tripsAt.js +16 -0
  399. package/src/utils/types.js +8 -0
  400. package/src/utils/underEntry.js +17 -0
  401. package/src/utils/update.js +18 -0
  402. package/src/utils/updateArea.js +40 -0
  403. package/src/utils/updateCamera.js +32 -0
  404. package/src/utils/updatePointLights.js +38 -0
  405. package/src/utils/updateWorldMatrix.js +47 -0
  406. package/src/utils/vehicleOffsets.js +8 -0
  407. package/src/utils/vehicles.js +65 -0
  408. package/src/utils/vertexNormals.js +30 -0
  409. package/src/utils/walk.js +187 -0
  410. package/src/utils/white.js +1 -0
  411. package/src/utils/worldLights.js +25 -0
  412. package/src/utils/wrap.js +1 -0
@@ -0,0 +1,47 @@
1
+ /** Test the mesh's ground footprint against loaded imagery, including coarse parent tiles. */
2
+ export function roofCoverage(mesh, backend, rasters) {
3
+ const map = backend._map, bounds = mesh.geometry.bounds, world = mesh.worldMatrix;
4
+ let intersectsArchive = false;
5
+ for (const layer of rasters) {
6
+ const zoom = layer._tileZoom, origin = map.project(backend._sceneOrigin, zoom);
7
+ const scale = map.options.crs.scale(zoom) / (40075016.68557849 * Math.cos(backend._sceneOrigin.lat * Math.PI / 180));
8
+ const min = [Infinity, Infinity], max = [-Infinity, -Infinity];
9
+ for (let i = 0; i < 8; i++) {
10
+ const x = i & 1 ? bounds.max[0] : bounds.min[0], y = i & 2 ? bounds.max[1] : bounds.min[1];
11
+ const z = i & 4 ? bounds.max[2] : bounds.min[2];
12
+ const px = origin.x + (world[0] * x + world[4] * y + world[8] * z + world[12]) * scale;
13
+ const py = origin.y + (world[2] * x + world[6] * y + world[10] * z + world[14]) * scale;
14
+ min[0] = Math.min(min[0], px); min[1] = Math.min(min[1], py);
15
+ max[0] = Math.max(max[0], px); max[1] = Math.max(max[1], py);
16
+ }
17
+ if (layer.header.maxLat !== undefined && layer.header.minLon !== undefined &&
18
+ layer.header.minLat !== undefined && layer.header.maxLon !== undefined) {
19
+ const nw = map.project([layer.header.maxLat, layer.header.minLon], zoom);
20
+ const se = map.project([layer.header.minLat, layer.header.maxLon], zoom);
21
+ min[0] = Math.max(min[0], nw.x); min[1] = Math.max(min[1], nw.y);
22
+ max[0] = Math.min(max[0], se.x); max[1] = Math.min(max[1], se.y);
23
+ if (min[0] >= max[0] || min[1] >= max[1]) continue;
24
+ }
25
+ intersectsArchive = true;
26
+ let remaining = [[min[0], min[1], max[0], max[1]]];
27
+ for (const tile of layer._rasterTiles.values()) {
28
+ // Failed imagery already reports an error; do not hide the building indefinitely.
29
+ if (!tile.done && !tile.error) continue;
30
+ const size = 256 * 2 ** (zoom - tile.coords.z);
31
+ const left = tile.coords.x * size, top = tile.coords.y * size;
32
+ remaining = remaining.flatMap(([x0, y0, x1, y1]) => {
33
+ const l = Math.max(x0, left), t = Math.max(y0, top);
34
+ const r = Math.min(x1, left + size), b = Math.min(y1, top + size);
35
+ if (l >= r || t >= b) return [[x0, y0, x1, y1]];
36
+ const pieces = [];
37
+ if (y0 < t) pieces.push([x0, y0, x1, t]);
38
+ if (b < y1) pieces.push([x0, b, x1, y1]);
39
+ if (x0 < l) pieces.push([x0, t, l, b]);
40
+ if (r < x1) pieces.push([r, t, x1, b]);
41
+ return pieces;
42
+ });
43
+ if (!remaining.length) return true;
44
+ }
45
+ }
46
+ return !intersectsArchive;
47
+ }
@@ -0,0 +1,22 @@
1
+ /** Dashed lane outline, in layer-local metres. */
2
+
3
+ export function routeGeometry(lanes) {
4
+ const position = [], normal = [], color = [];
5
+ for (const { points, lengths } of lanes) for (let i = 1; i < points.length; i++) {
6
+ const a = points[i - 1], b = points[i];
7
+ const dx = b[0] - a[0], dz = b[1] - a[1], length = lengths[i] - lengths[i - 1];
8
+ if (!length) continue;
9
+ const x = -dz / length * 2.5, z = dx / length * 2.5;
10
+ for (let distance = Math.floor(lengths[i - 1] / 30) * 30; distance < lengths[i]; distance += 30) {
11
+ const start = Math.max(0, (distance - lengths[i - 1]) / length);
12
+ const end = Math.min(1, (distance + 18 - lengths[i - 1]) / length);
13
+ if (end <= start) continue;
14
+ const p = [a[0] + dx * start, a[1] + dz * start], q = [a[0] + dx * end, a[1] + dz * end], y = a[2] + 0.4;
15
+ for (const point of [[p[0] - x, p[1] - z], [p[0] + x, p[1] + z], [q[0] + x, q[1] + z],
16
+ [p[0] - x, p[1] - z], [q[0] + x, q[1] + z], [q[0] - x, q[1] - z]]) {
17
+ position.push(point[0], y, point[1]); normal.push(0, 1, 0); color.push(0.08, 0.7, 0.85);
18
+ }
19
+ }
20
+ }
21
+ return { position, normal, color };
22
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Trips of a frequency-based timetable (like GTFS frequencies.txt) underway at `date`, in the timetable's local time.
3
+ * @param {{timeZone: string, duration: number, services: Array<{from: string, to: string, every?: number, months?: number[], weekdays?: number[]}>}} timetable
4
+ * `duration` and `every` are minutes; `from`/`to` are 'HH:MM' first/last departures; months are 1-12, weekdays 0 (Sunday)-6.
5
+ * @returns {Array<{id: string, departure: string, progress: number}>} `progress` is 0-1 along the lane.
6
+ */
7
+
8
+ export function scheduledTrips(date, { timeZone, duration, services }) {
9
+ const time = new Date(date);
10
+ if (!Number.isFinite(time.getTime())) throw new Error('Invalid date');
11
+ const clock = new Intl.DateTimeFormat('en-GB', {
12
+ timeZone, year: 'numeric', month: '2-digit', day: '2-digit',
13
+ hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23',
14
+ });
15
+ const parts = Object.fromEntries(clock.formatToParts(time).filter(p => p.type !== 'literal').map(p => [p.type, Number(p.value)]));
16
+ const minute = parts.hour * 60 + parts.minute + (parts.second + time.getUTCMilliseconds() / 1000) / 60;
17
+ const weekday = new Date(Date.UTC(parts.year, parts.month - 1, parts.day)).getUTCDay();
18
+ const minutes = clockTime => clockTime.split(':').reduce((hours, value) => hours * 60 + Number(value));
19
+ const departures = [];
20
+ for (const { from, to, every = Infinity, months, weekdays } of services) {
21
+ if (months?.includes(parts.month) === false || weekdays?.includes(weekday) === false) continue;
22
+ for (let departure = minutes(from); departure <= minutes(to); departure += every) departures.push(departure);
23
+ }
24
+ return departures.sort((a, b) => a - b).filter(departure => minute >= departure && minute < departure + duration).map(departure => ({
25
+ id: `${parts.year}-${parts.month}-${parts.day}-${departure}`,
26
+ departure: `${String(Math.floor(departure / 60)).padStart(2, '0')}:${String(departure % 60).padStart(2, '0')}`,
27
+ progress: (minute - departure) / duration,
28
+ }));
29
+ }
@@ -0,0 +1,11 @@
1
+ import { releaseArea } from './releaseArea.js';
2
+ import { updateArea } from './updateArea.js';
3
+
4
+ export function setGeoJSONData(layer, data) {
5
+ layer.options.data = data;
6
+ delete layer.options.url;
7
+ for (const area of layer._areas.values()) releaseArea(layer, area);
8
+ layer._areas.clear();
9
+ updateArea(layer);
10
+ return layer;
11
+ }
@@ -0,0 +1,13 @@
1
+ import { update } from './update.js';
2
+
3
+ /** Highlight a source vertex range in the shader; vertex colors stay untouched. */
4
+
5
+ export function setHighlight(backend, feature) {
6
+ if (feature?.model) feature = null;
7
+ if (backend.highlightedFeature?.mesh === feature?.mesh &&
8
+ backend.highlightedFeature?.vertexStart === feature?.vertexStart) return;
9
+ if (backend.highlightedFeature) backend.highlightedFeature.mesh.highlight = null;
10
+ backend.highlightedFeature = feature;
11
+ if (feature) feature.mesh.highlight = [feature.vertexStart, feature.vertexEnd];
12
+ update(backend);
13
+ }
@@ -0,0 +1,7 @@
1
+ import { setRasterOpacity } from './rasterTiles.js';
2
+
3
+ export function setPMTileOpacity(backend, opacity) {
4
+ backend.options.opacity = opacity;
5
+ setRasterOpacity(backend, opacity);
6
+ return backend;
7
+ }
@@ -0,0 +1,7 @@
1
+ import { setRasterZIndex } from './rasterTiles.js';
2
+
3
+ export function setPMTileZIndex(backend, zIndex) {
4
+ backend.options.zIndex = zIndex;
5
+ setRasterZIndex(backend, zIndex);
6
+ return backend;
7
+ }
@@ -0,0 +1,7 @@
1
+ /** Reparent/detach scene data without drawing or disposing GPU resources. */
2
+
3
+ export function setParent(node, parent) {
4
+ if (node.parent) node.parent.children.splice(node.parent.children.indexOf(node), 1);
5
+ node.parent = parent;
6
+ if (parent) parent.children.push(node);
7
+ }
@@ -0,0 +1,10 @@
1
+ import { getElevation } from './getElevation.js';
2
+
3
+ export function setTerrainHeight(layer) {
4
+ if (!layer.root || !layer.location) return;
5
+ layer._terrainBaseY ??= layer.root.position[1];
6
+ const terrain = layer._map?._terrain3D;
7
+ const elevation = terrain && getElevation(terrain, layer.location);
8
+ const offset = Number.isFinite(elevation) ? layer.options.terrainOffset ?? 0 : 0;
9
+ layer.root.position[1] = layer._terrainBaseY + (elevation ?? 0) + offset;
10
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Paints the vertices `[start, end)` of a mesh and marks its color buffer dirty.
3
+ * @param {Object} mesh Layer-created mesh with a color attribute.
4
+ * @param {number} start Inclusive vertex index, not an offset into the RGB array.
5
+ * @param {number} end Exclusive vertex index.
6
+ * @param {Object} color sRGB {r,g,b}, typically from parseColor().
7
+ */
8
+
9
+ export function setVertexColor(mesh, start, end, color) {
10
+ for (let i = start; i < end; i++) {
11
+ mesh.geometry.attributes.color.data.set([color.r, color.g, color.b], i * 3);
12
+ }
13
+ mesh.geometry.attributes.color.needsUpdate = true;
14
+ }
@@ -0,0 +1,27 @@
1
+ /** Update tooltip content/position and arbitrate cursor ownership across shared layers. */
2
+
3
+ export function showFeature(backend, feature, event) {
4
+ const tooltip = backend._tooltip;
5
+ if (!tooltip) return;
6
+ if (feature) {
7
+ tooltip.replaceChildren(backend.options.tooltip(feature));
8
+ tooltip.hidden = false;
9
+ const rect = backend.container.getBoundingClientRect();
10
+ const x = event.clientX - rect.left, y = event.clientY - rect.top;
11
+ tooltip.style.left = `${x + tooltip.offsetWidth + 16 > rect.width ? x - tooltip.offsetWidth - 12 : x + 12}px`;
12
+ tooltip.style.top = `${y + tooltip.offsetHeight + 16 > rect.height ? y - tooltip.offsetHeight - 12 : y + 12}px`;
13
+ } else {
14
+ tooltip.hidden = true;
15
+ }
16
+ const shared = backend._shared;
17
+ if (shared) {
18
+ const visible = [...shared._layers].some(layer => layer._tooltip && !layer._tooltip.hidden);
19
+ if (visible) {
20
+ if (shared._cursor === undefined) shared._cursor = backend.container.style.cursor;
21
+ backend.container.style.cursor = 'pointer';
22
+ } else if (shared._cursor !== undefined) {
23
+ backend.container.style.cursor = shared._cursor;
24
+ delete shared._cursor;
25
+ }
26
+ }
27
+ }
@@ -0,0 +1 @@
1
+ export const sizes = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4 };
@@ -0,0 +1,2 @@
1
+ // Pedestrian, about 1.77 m tall, prisms as in utils/vehicles.js (forward -z). Limbs hang from their pivot at y = 0.
2
+ export const skin = [0.85, 0.64, 0.5], shirt = [0.75, 0.2, 0.15], trousers = [0.16, 0.2, 0.32], dark = [0.08, 0.07, 0.06];
@@ -0,0 +1,17 @@
1
+ import { horizontalPosition } from "./horizontalPosition.js";
2
+
3
+ // Solar centre, without atmospheric refraction.
4
+
5
+ export function solarPosition(date, lat, lng) {
6
+ const time = new Date(date).getTime();
7
+ if (!Number.isFinite(time) || !Number.isFinite(lat) || Math.abs(lat) > 90 ||
8
+ !Number.isFinite(lng) || Math.abs(lng) > 180) throw new Error('Invalid solar date or location');
9
+ const rad = Math.PI / 180, d = time / 86400000 - 10957.5;
10
+ const mean = (357.5291 + 0.98560028 * d) * rad;
11
+ const longitude = mean + (1.9148 * Math.sin(mean) + 0.02 * Math.sin(2 * mean) +
12
+ 0.0003 * Math.sin(3 * mean) + 102.9372 + 180) * rad;
13
+ const obliquity = 23.4397 * rad;
14
+ const declination = Math.asin(Math.sin(longitude) * Math.sin(obliquity));
15
+ const ascension = Math.atan2(Math.sin(longitude) * Math.cos(obliquity), Math.cos(longitude));
16
+ return horizontalPosition(d, lat, lng, ascension, declination);
17
+ }
@@ -0,0 +1,12 @@
1
+
2
+ export function sortMeshes(meshes) {
3
+ return meshes.sort((a, b) => Number(Boolean(b.ground)) - Number(Boolean(a.ground)) ||
4
+ (a.ground && b.ground ? (a.renderOrder || 0) - (b.renderOrder || 0) ||
5
+ a.tile.coords.z - b.tile.coords.z : 0) ||
6
+ Number(a.program.transparent) - Number(b.program.transparent) ||
7
+ (a.program.transparent
8
+ ? (a.renderOrder || 0) - (b.renderOrder || 0) ||
9
+ b._sortDepth - a._sortDepth || a.id - b.id
10
+ : (a._sortDepth ?? 0) - (b._sortDepth ?? 0) || a.id - b.id)
11
+ );
12
+ }
@@ -0,0 +1,3 @@
1
+ // Pure helpers of the 'traffic' type: lane interpolation and vehicle scheduling.
2
+ /** Default urban speed (m/s) used to turn a lane's hourly `flow` into vehicles on the road. */
3
+ export const speed = 8;
@@ -0,0 +1,5 @@
1
+ /** Preserve the outgoing tile level before Leaflet changes its logical zoom. */
2
+
3
+ export function startZoom() {
4
+ this._zoomLevel = null;
5
+ }
@@ -0,0 +1 @@
1
+ export const taillight = [1.7, 0.06, 0.05];
@@ -0,0 +1,21 @@
1
+ /** Float32 DEM atlas; missing samples retain the shader no-data sentinel. */
2
+
3
+ export function terrainAtlas(tiles, bounds) {
4
+ const columns = bounds.max.x - bounds.min.x + 1, rows = bounds.max.y - bounds.min.y + 1;
5
+ const elevations = new Float32Array(columns * rows * 65536).fill(-1e9);
6
+ let low = Infinity, high = -Infinity;
7
+ for (const [key, values] of tiles) {
8
+ const [x, y] = key.split('/').map(Number);
9
+ const start = (y - bounds.min.y) * 256 * columns * 256 + (x - bounds.min.x) * 256;
10
+ for (let row = 0; row < 256; row++) {
11
+ for (let column = 0; column < 256; column++) {
12
+ const value = values[row * 256 + column];
13
+ if (!Number.isFinite(value) || value <= -1000) continue;
14
+ elevations[start + row * columns * 256 + column] = value;
15
+ low = Math.min(low, value);
16
+ high = Math.max(high, value);
17
+ }
18
+ }
19
+ }
20
+ return { elevations, low, high };
21
+ }
@@ -0,0 +1,20 @@
1
+ /** Bilinear DEM sampling, with the original first-valid-neighbour no-data rule. */
2
+
3
+ export function terrainElevation(point, tiles) {
4
+ const x = point.x - 0.5, y = point.y - 0.5;
5
+ const x0 = Math.floor(x), y0 = Math.floor(y);
6
+ const fx = x - x0, fy = y - y0;
7
+ const sample = (px, py) => {
8
+ const tileX = Math.floor(px / 256), tileY = Math.floor(py / 256);
9
+ const tile = tiles.get(`${tileX}/${tileY}`);
10
+ if (!tile) return null;
11
+ const elevation = tile[(py - tileY * 256) * 256 + px - tileX * 256];
12
+ return Number.isFinite(elevation) && elevation > -1000 ? elevation : null;
13
+ };
14
+ const values = [sample(x0, y0), sample(x0 + 1, y0), sample(x0, y0 + 1), sample(x0 + 1, y0 + 1)];
15
+ const valid = values.map((value, i) => Number.isFinite(value) ? i : -1).filter(i => i >= 0);
16
+ if (!valid.length) return null;
17
+ if (valid.length < 4) return values[valid[0]];
18
+ return (values[0] * (1 - fx) + values[1] * fx) * (1 - fy) +
19
+ (values[2] * (1 - fx) + values[3] * fx) * fy;
20
+ }
@@ -0,0 +1,23 @@
1
+ /** Unit tile grid; the vertex shader supplies the elevation. */
2
+
3
+ export function terrainGrid(divisions) {
4
+ const positions = [], normals = [], uvs = [], indices = [];
5
+ for (let row = 0; row <= divisions; row++) {
6
+ for (let column = 0; column <= divisions; column++) {
7
+ positions.push(column / divisions, 0, row / divisions);
8
+ normals.push(0, 1, 0);
9
+ uvs.push(column / divisions, row / divisions);
10
+ if (row < divisions && column < divisions) {
11
+ const a = row * (divisions + 1) + column;
12
+ const b = a + 1, c = a + divisions + 1, d = c + 1;
13
+ indices.push(a, c, b, b, c, d);
14
+ }
15
+ }
16
+ }
17
+ return {
18
+ position: { size: 3, data: new Float32Array(positions) },
19
+ normal: { size: 3, data: new Float32Array(normals) },
20
+ uv: { size: 2, data: new Float32Array(uvs) },
21
+ index: { data: new Uint16Array(indices) },
22
+ };
23
+ }
@@ -0,0 +1,10 @@
1
+ /** Translate glTF sampler constants into WebGPU sampler options. */
2
+
3
+ export function textureSampler(sampler) {
4
+ return {
5
+ addressModeU: sampler.wrapS === 33071 ? 'clamp-to-edge' : sampler.wrapS === 33648 ? 'mirror-repeat' : 'repeat',
6
+ addressModeV: sampler.wrapT === 33071 ? 'clamp-to-edge' : sampler.wrapT === 33648 ? 'mirror-repeat' : 'repeat',
7
+ magFilter: sampler.magFilter === 9728 ? 'nearest' : 'linear',
8
+ minFilter: sampler.minFilter === 9728 || sampler.minFilter === 9984 || sampler.minFilter === 9986 ? 'nearest' : 'linear',
9
+ };
10
+ }
@@ -0,0 +1,18 @@
1
+ /** Cumulative Hilbert ID for an archive tile. */
2
+
3
+ export function tileId(z, x, y) {
4
+ if (![z, x, y].every(Number.isInteger) || z < 0 || z > 26 ||
5
+ x < 0 || y < 0 || x >= 2 ** z || y >= 2 ** z) throw new Error('Invalid PMTiles tile coordinates');
6
+ let id = (4 ** z - 1) / 3;
7
+ const n = 2 ** z;
8
+ // Same cumulative Hilbert ordering used by build/pmtiles.js.
9
+ for (let s = n / 2; s >= 1; s /= 2) {
10
+ const rx = (x & s) ? 1 : 0, ry = (y & s) ? 1 : 0;
11
+ id += s * s * ((3 * rx) ^ ry);
12
+ if (!ry) {
13
+ if (rx) { x = n - 1 - x; y = n - 1 - y; }
14
+ [x, y] = [y, x];
15
+ }
16
+ }
17
+ return id;
18
+ }
@@ -0,0 +1,7 @@
1
+ // GeoJSON (Multi)LineStrings become lanes ({latlngs, properties, elevation?}); prepare() adds `points` ([x, z, ground]),
2
+ // `lengths` and `length` in layer-local metres.
3
+
4
+ export const toLanes = ({ features = [] }) => features.flatMap(({ geometry, properties }) => {
5
+ const lines = geometry?.type === 'LineString' ? [geometry.coordinates] : geometry?.type === 'MultiLineString' ? geometry.coordinates : [];
6
+ return lines.map(line => ({ latlngs: line.map(([lng, lat]) => [lat, lng]), properties: properties ?? {}, elevation: properties?.elevation }));
7
+ });
@@ -0,0 +1 @@
1
+ export const toSRGB = value => value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
@@ -0,0 +1,6 @@
1
+ export const tooltip = ({ properties: p }) => {
2
+ const content = document.createElement('div');
3
+ content.style.whiteSpace = 'pre-line';
4
+ content.textContent = [p.name, p.departure && `Departure ${p.departure} ${p.timetable.timeZone}`, p.description].filter(Boolean).join('\n');
5
+ return content;
6
+ };