@mountaya/elements 0.0.0-stage → 0.1.0
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.
- package/CHANGELOG.md +235 -0
- package/LICENCE.fr.txt +280 -0
- package/LICENSE.txt +262 -0
- package/README.md +1509 -2
- package/THIRD-PARTY-NOTICES.txt +103 -0
- package/dist/accentColor-GNKBD2CW.js +4 -0
- package/dist/accentColor-GNKBD2CW.js.map +1 -0
- package/dist/accentColor-VX2JSMGE.cjs +17 -0
- package/dist/accentColor-VX2JSMGE.cjs.map +1 -0
- package/dist/agent/index.cjs +1964 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +2016 -0
- package/dist/agent/index.d.ts +2016 -0
- package/dist/agent/index.js +1937 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/amenities-B3-qAjxu.d.cts +160 -0
- package/dist/amenities-B3-qAjxu.d.ts +160 -0
- package/dist/bundle-Je5zsRFg.d.cts +222 -0
- package/dist/bundle-xYrrbJTH.d.ts +222 -0
- package/dist/camera/index.cjs +3477 -0
- package/dist/camera/index.cjs.map +1 -0
- package/dist/camera/index.d.cts +1751 -0
- package/dist/camera/index.d.ts +1751 -0
- package/dist/camera/index.js +3328 -0
- package/dist/camera/index.js.map +1 -0
- package/dist/camera-BrFLU1DH.d.cts +549 -0
- package/dist/camera-C48Ykaxv.d.ts +549 -0
- package/dist/chunk-23PFRRB6.js +3 -0
- package/dist/chunk-23PFRRB6.js.map +1 -0
- package/dist/chunk-2GI5SAH2.js +71 -0
- package/dist/chunk-2GI5SAH2.js.map +1 -0
- package/dist/chunk-2MQK6A74.js +39 -0
- package/dist/chunk-2MQK6A74.js.map +1 -0
- package/dist/chunk-2RE7R4LD.js +73 -0
- package/dist/chunk-2RE7R4LD.js.map +1 -0
- package/dist/chunk-3JZQKN4O.js +6 -0
- package/dist/chunk-3JZQKN4O.js.map +1 -0
- package/dist/chunk-3NDXVUUI.js +50 -0
- package/dist/chunk-3NDXVUUI.js.map +1 -0
- package/dist/chunk-3R4GFTUM.cjs +59 -0
- package/dist/chunk-3R4GFTUM.cjs.map +1 -0
- package/dist/chunk-3RVUQ6JN.cjs +22 -0
- package/dist/chunk-3RVUQ6JN.cjs.map +1 -0
- package/dist/chunk-4F6BJMJC.cjs +49 -0
- package/dist/chunk-4F6BJMJC.cjs.map +1 -0
- package/dist/chunk-4NWQD4BX.js +132 -0
- package/dist/chunk-4NWQD4BX.js.map +1 -0
- package/dist/chunk-5K2MH3R6.js +10 -0
- package/dist/chunk-5K2MH3R6.js.map +1 -0
- package/dist/chunk-6ACRNQQQ.cjs +8 -0
- package/dist/chunk-6ACRNQQQ.cjs.map +1 -0
- package/dist/chunk-6D26E3IA.js +66 -0
- package/dist/chunk-6D26E3IA.js.map +1 -0
- package/dist/chunk-6ESAW35P.cjs +80 -0
- package/dist/chunk-6ESAW35P.cjs.map +1 -0
- package/dist/chunk-6LIW2A5M.cjs +1176 -0
- package/dist/chunk-6LIW2A5M.cjs.map +1 -0
- package/dist/chunk-6OTTWVCA.js +57 -0
- package/dist/chunk-6OTTWVCA.js.map +1 -0
- package/dist/chunk-6VROJ4UG.js +862 -0
- package/dist/chunk-6VROJ4UG.js.map +1 -0
- package/dist/chunk-6Y7FTGO4.js +23 -0
- package/dist/chunk-6Y7FTGO4.js.map +1 -0
- package/dist/chunk-75I4CG64.js +104 -0
- package/dist/chunk-75I4CG64.js.map +1 -0
- package/dist/chunk-7CUBXHAH.cjs +14 -0
- package/dist/chunk-7CUBXHAH.cjs.map +1 -0
- package/dist/chunk-7GTCURVY.js +52 -0
- package/dist/chunk-7GTCURVY.js.map +1 -0
- package/dist/chunk-7IWOL6AM.cjs +100 -0
- package/dist/chunk-7IWOL6AM.cjs.map +1 -0
- package/dist/chunk-7QN7M667.cjs +151 -0
- package/dist/chunk-7QN7M667.cjs.map +1 -0
- package/dist/chunk-A6KQDKLM.cjs +1197 -0
- package/dist/chunk-A6KQDKLM.cjs.map +1 -0
- package/dist/chunk-A77EA67G.js +354 -0
- package/dist/chunk-A77EA67G.js.map +1 -0
- package/dist/chunk-AFKOABJ4.cjs +7194 -0
- package/dist/chunk-AFKOABJ4.cjs.map +1 -0
- package/dist/chunk-AG6JV5Z2.cjs +183 -0
- package/dist/chunk-AG6JV5Z2.cjs.map +1 -0
- package/dist/chunk-APBK7NMS.js +30 -0
- package/dist/chunk-APBK7NMS.js.map +1 -0
- package/dist/chunk-AWO5YA7A.cjs +33 -0
- package/dist/chunk-AWO5YA7A.cjs.map +1 -0
- package/dist/chunk-AZATU6QW.js +108 -0
- package/dist/chunk-AZATU6QW.js.map +1 -0
- package/dist/chunk-BD2U3WST.cjs +623 -0
- package/dist/chunk-BD2U3WST.cjs.map +1 -0
- package/dist/chunk-BHBEOU6L.cjs +65 -0
- package/dist/chunk-BHBEOU6L.cjs.map +1 -0
- package/dist/chunk-CNOSNYNE.js +8 -0
- package/dist/chunk-CNOSNYNE.js.map +1 -0
- package/dist/chunk-CW3EFR4O.js +12 -0
- package/dist/chunk-CW3EFR4O.js.map +1 -0
- package/dist/chunk-DASVRNBK.js +7187 -0
- package/dist/chunk-DASVRNBK.js.map +1 -0
- package/dist/chunk-DJ6LCKYP.js +42 -0
- package/dist/chunk-DJ6LCKYP.js.map +1 -0
- package/dist/chunk-E5FHQAIO.cjs +45 -0
- package/dist/chunk-E5FHQAIO.cjs.map +1 -0
- package/dist/chunk-EOML5OTY.cjs +360 -0
- package/dist/chunk-EOML5OTY.cjs.map +1 -0
- package/dist/chunk-EP5CASHL.js +613 -0
- package/dist/chunk-EP5CASHL.js.map +1 -0
- package/dist/chunk-EP5OEEVZ.cjs +14 -0
- package/dist/chunk-EP5OEEVZ.cjs.map +1 -0
- package/dist/chunk-EUXI3FGQ.js +150 -0
- package/dist/chunk-EUXI3FGQ.js.map +1 -0
- package/dist/chunk-EWFSHCOS.js +40 -0
- package/dist/chunk-EWFSHCOS.js.map +1 -0
- package/dist/chunk-EX2C5K2T.cjs +25 -0
- package/dist/chunk-EX2C5K2T.cjs.map +1 -0
- package/dist/chunk-FEXWDQIZ.cjs +8 -0
- package/dist/chunk-FEXWDQIZ.cjs.map +1 -0
- package/dist/chunk-FEYBFY7H.cjs +358 -0
- package/dist/chunk-FEYBFY7H.cjs.map +1 -0
- package/dist/chunk-FRGAV6N6.cjs +34 -0
- package/dist/chunk-FRGAV6N6.cjs.map +1 -0
- package/dist/chunk-G5DHP5VF.js +6 -0
- package/dist/chunk-G5DHP5VF.js.map +1 -0
- package/dist/chunk-G5W2UHV2.js +99 -0
- package/dist/chunk-G5W2UHV2.js.map +1 -0
- package/dist/chunk-G7OP7O2C.cjs +39 -0
- package/dist/chunk-G7OP7O2C.cjs.map +1 -0
- package/dist/chunk-GE6CFCAM.cjs +25 -0
- package/dist/chunk-GE6CFCAM.cjs.map +1 -0
- package/dist/chunk-GIFALLHI.cjs +111 -0
- package/dist/chunk-GIFALLHI.cjs.map +1 -0
- package/dist/chunk-GLFET5GM.js +129 -0
- package/dist/chunk-GLFET5GM.js.map +1 -0
- package/dist/chunk-GQ6UFPFM.js +22 -0
- package/dist/chunk-GQ6UFPFM.js.map +1 -0
- package/dist/chunk-GQJWVMXS.js +129 -0
- package/dist/chunk-GQJWVMXS.js.map +1 -0
- package/dist/chunk-GVVJPUKC.js +80 -0
- package/dist/chunk-GVVJPUKC.js.map +1 -0
- package/dist/chunk-GZ2HOCQ2.cjs +134 -0
- package/dist/chunk-GZ2HOCQ2.cjs.map +1 -0
- package/dist/chunk-HCBOHXWP.js +37 -0
- package/dist/chunk-HCBOHXWP.js.map +1 -0
- package/dist/chunk-IBQJDVHF.cjs +281 -0
- package/dist/chunk-IBQJDVHF.cjs.map +1 -0
- package/dist/chunk-ISLB6Y5Q.cjs +106 -0
- package/dist/chunk-ISLB6Y5Q.cjs.map +1 -0
- package/dist/chunk-J55CRR4F.js +105 -0
- package/dist/chunk-J55CRR4F.js.map +1 -0
- package/dist/chunk-JBG6Z6MQ.cjs +28 -0
- package/dist/chunk-JBG6Z6MQ.cjs.map +1 -0
- package/dist/chunk-K3RQOZRU.js +61 -0
- package/dist/chunk-K3RQOZRU.js.map +1 -0
- package/dist/chunk-KDJYS4GB.cjs +703 -0
- package/dist/chunk-KDJYS4GB.cjs.map +1 -0
- package/dist/chunk-KMCAHUZM.cjs +4 -0
- package/dist/chunk-KMCAHUZM.cjs.map +1 -0
- package/dist/chunk-KUCBNPC6.js +87 -0
- package/dist/chunk-KUCBNPC6.js.map +1 -0
- package/dist/chunk-KV6UE5A4.js +50 -0
- package/dist/chunk-KV6UE5A4.js.map +1 -0
- package/dist/chunk-L6TZ2HQR.cjs +18 -0
- package/dist/chunk-L6TZ2HQR.cjs.map +1 -0
- package/dist/chunk-L7QHHGG2.cjs +141 -0
- package/dist/chunk-L7QHHGG2.cjs.map +1 -0
- package/dist/chunk-LHK3Y2AL.js +271 -0
- package/dist/chunk-LHK3Y2AL.js.map +1 -0
- package/dist/chunk-LO5RYRBH.cjs +6317 -0
- package/dist/chunk-LO5RYRBH.cjs.map +1 -0
- package/dist/chunk-LS5SJMUO.cjs +194 -0
- package/dist/chunk-LS5SJMUO.cjs.map +1 -0
- package/dist/chunk-LUGTMZFN.cjs +42 -0
- package/dist/chunk-LUGTMZFN.cjs.map +1 -0
- package/dist/chunk-LVUQU6D5.js +32 -0
- package/dist/chunk-LVUQU6D5.js.map +1 -0
- package/dist/chunk-M2QRC2GZ.js +166 -0
- package/dist/chunk-M2QRC2GZ.js.map +1 -0
- package/dist/chunk-M6QJYQIM.cjs +53 -0
- package/dist/chunk-M6QJYQIM.cjs.map +1 -0
- package/dist/chunk-MGCPH5EO.js +12 -0
- package/dist/chunk-MGCPH5EO.js.map +1 -0
- package/dist/chunk-MLVUWEZR.cjs +474 -0
- package/dist/chunk-MLVUWEZR.cjs.map +1 -0
- package/dist/chunk-MTAMJMZL.cjs +707 -0
- package/dist/chunk-MTAMJMZL.cjs.map +1 -0
- package/dist/chunk-MXL5AT3N.js +48 -0
- package/dist/chunk-MXL5AT3N.js.map +1 -0
- package/dist/chunk-MYEQSESM.cjs +75 -0
- package/dist/chunk-MYEQSESM.cjs.map +1 -0
- package/dist/chunk-N3VPF6ZD.js +427 -0
- package/dist/chunk-N3VPF6ZD.js.map +1 -0
- package/dist/chunk-N6VUAIGI.js +7 -0
- package/dist/chunk-N6VUAIGI.js.map +1 -0
- package/dist/chunk-N6XRLUN6.js +6286 -0
- package/dist/chunk-N6XRLUN6.js.map +1 -0
- package/dist/chunk-NOGDOZIT.cjs +114 -0
- package/dist/chunk-NOGDOZIT.cjs.map +1 -0
- package/dist/chunk-NUWXEISH.cjs +10 -0
- package/dist/chunk-NUWXEISH.cjs.map +1 -0
- package/dist/chunk-NZCZHXYN.cjs +161 -0
- package/dist/chunk-NZCZHXYN.cjs.map +1 -0
- package/dist/chunk-ODROSWQX.cjs +53 -0
- package/dist/chunk-ODROSWQX.cjs.map +1 -0
- package/dist/chunk-OE36AYKG.cjs +82 -0
- package/dist/chunk-OE36AYKG.cjs.map +1 -0
- package/dist/chunk-OLON7MO6.cjs +437 -0
- package/dist/chunk-OLON7MO6.cjs.map +1 -0
- package/dist/chunk-PBUOR2IT.js +277 -0
- package/dist/chunk-PBUOR2IT.js.map +1 -0
- package/dist/chunk-PC2ELXFF.cjs +225 -0
- package/dist/chunk-PC2ELXFF.cjs.map +1 -0
- package/dist/chunk-PCSGXLOC.js +71 -0
- package/dist/chunk-PCSGXLOC.js.map +1 -0
- package/dist/chunk-PFNMP6FQ.js +56 -0
- package/dist/chunk-PFNMP6FQ.js.map +1 -0
- package/dist/chunk-PIWSZTIP.js +690 -0
- package/dist/chunk-PIWSZTIP.js.map +1 -0
- package/dist/chunk-PKWHJ2GI.js +136 -0
- package/dist/chunk-PKWHJ2GI.js.map +1 -0
- package/dist/chunk-PLMVBX2A.cjs +76 -0
- package/dist/chunk-PLMVBX2A.cjs.map +1 -0
- package/dist/chunk-PM3XCD2G.cjs +113 -0
- package/dist/chunk-PM3XCD2G.cjs.map +1 -0
- package/dist/chunk-QAL4GZO7.cjs +143 -0
- package/dist/chunk-QAL4GZO7.cjs.map +1 -0
- package/dist/chunk-QDB2SEA2.js +74 -0
- package/dist/chunk-QDB2SEA2.js.map +1 -0
- package/dist/chunk-QOV7UNUN.js +25 -0
- package/dist/chunk-QOV7UNUN.js.map +1 -0
- package/dist/chunk-QQUWYLSF.cjs +50 -0
- package/dist/chunk-QQUWYLSF.cjs.map +1 -0
- package/dist/chunk-QUMBH3U4.cjs +9 -0
- package/dist/chunk-QUMBH3U4.cjs.map +1 -0
- package/dist/chunk-R4KA7OFQ.js +12 -0
- package/dist/chunk-R4KA7OFQ.js.map +1 -0
- package/dist/chunk-RBSGAZQQ.js +17 -0
- package/dist/chunk-RBSGAZQQ.js.map +1 -0
- package/dist/chunk-RM5YJWZI.js +46 -0
- package/dist/chunk-RM5YJWZI.js.map +1 -0
- package/dist/chunk-ROKNKXA4.cjs +8 -0
- package/dist/chunk-ROKNKXA4.cjs.map +1 -0
- package/dist/chunk-RQG6D546.cjs +75 -0
- package/dist/chunk-RQG6D546.cjs.map +1 -0
- package/dist/chunk-SG4YDD5L.cjs +74 -0
- package/dist/chunk-SG4YDD5L.cjs.map +1 -0
- package/dist/chunk-SNRCA7EO.js +56 -0
- package/dist/chunk-SNRCA7EO.js.map +1 -0
- package/dist/chunk-SO75R4WW.cjs +22 -0
- package/dist/chunk-SO75R4WW.cjs.map +1 -0
- package/dist/chunk-SP34NHFI.js +45 -0
- package/dist/chunk-SP34NHFI.js.map +1 -0
- package/dist/chunk-SSKSSBWJ.cjs +179 -0
- package/dist/chunk-SSKSSBWJ.cjs.map +1 -0
- package/dist/chunk-TB5663C2.js +1108 -0
- package/dist/chunk-TB5663C2.js.map +1 -0
- package/dist/chunk-TGH4NRES.js +220 -0
- package/dist/chunk-TGH4NRES.js.map +1 -0
- package/dist/chunk-TJ6ZPNID.js +189 -0
- package/dist/chunk-TJ6ZPNID.js.map +1 -0
- package/dist/chunk-U45T35N2.cjs +90 -0
- package/dist/chunk-U45T35N2.cjs.map +1 -0
- package/dist/chunk-UKVOPEZ2.js +442 -0
- package/dist/chunk-UKVOPEZ2.js.map +1 -0
- package/dist/chunk-UTB4NROA.cjs +887 -0
- package/dist/chunk-UTB4NROA.cjs.map +1 -0
- package/dist/chunk-UTW33B5V.js +6 -0
- package/dist/chunk-UTW33B5V.js.map +1 -0
- package/dist/chunk-UYUBSD2V.cjs +33 -0
- package/dist/chunk-UYUBSD2V.cjs.map +1 -0
- package/dist/chunk-V3JEP5AG.cjs +59 -0
- package/dist/chunk-V3JEP5AG.cjs.map +1 -0
- package/dist/chunk-VFAGJXHR.js +18 -0
- package/dist/chunk-VFAGJXHR.js.map +1 -0
- package/dist/chunk-VMEE57E5.cjs +58 -0
- package/dist/chunk-VMEE57E5.cjs.map +1 -0
- package/dist/chunk-VQVBEX3Y.cjs +113 -0
- package/dist/chunk-VQVBEX3Y.cjs.map +1 -0
- package/dist/chunk-VZDXX7TT.cjs +64 -0
- package/dist/chunk-VZDXX7TT.cjs.map +1 -0
- package/dist/chunk-WE5ZTI4D.js +346 -0
- package/dist/chunk-WE5ZTI4D.js.map +1 -0
- package/dist/chunk-WEFUVABP.js +19 -0
- package/dist/chunk-WEFUVABP.js.map +1 -0
- package/dist/chunk-WMU4LRKC.js +28 -0
- package/dist/chunk-WMU4LRKC.js.map +1 -0
- package/dist/chunk-WQ24RRHL.cjs +354 -0
- package/dist/chunk-WQ24RRHL.cjs.map +1 -0
- package/dist/chunk-WW4CGS7G.cjs +26 -0
- package/dist/chunk-WW4CGS7G.cjs.map +1 -0
- package/dist/chunk-WXE5WCTM.js +1144 -0
- package/dist/chunk-WXE5WCTM.js.map +1 -0
- package/dist/chunk-X23BGIYA.cjs +37 -0
- package/dist/chunk-X23BGIYA.cjs.map +1 -0
- package/dist/chunk-XEW4FTR2.js +98 -0
- package/dist/chunk-XEW4FTR2.js.map +1 -0
- package/dist/chunk-XIOI4IYW.js +167 -0
- package/dist/chunk-XIOI4IYW.js.map +1 -0
- package/dist/chunk-XLVPJ37V.cjs +44 -0
- package/dist/chunk-XLVPJ37V.cjs.map +1 -0
- package/dist/chunk-XOHAXXZA.cjs +51 -0
- package/dist/chunk-XOHAXXZA.cjs.map +1 -0
- package/dist/chunk-Y4NRIHK6.cjs +313 -0
- package/dist/chunk-Y4NRIHK6.cjs.map +1 -0
- package/dist/chunk-Y4YMMKL3.js +23 -0
- package/dist/chunk-Y4YMMKL3.js.map +1 -0
- package/dist/chunk-YJNYBVE3.cjs +14 -0
- package/dist/chunk-YJNYBVE3.cjs.map +1 -0
- package/dist/chunk-Z762QNQP.cjs +60 -0
- package/dist/chunk-Z762QNQP.cjs.map +1 -0
- package/dist/chunk-ZG5KMBOF.js +669 -0
- package/dist/chunk-ZG5KMBOF.js.map +1 -0
- package/dist/chunk-ZKONQEFA.js +344 -0
- package/dist/chunk-ZKONQEFA.js.map +1 -0
- package/dist/chunk-ZR5X7QMH.js +39 -0
- package/dist/chunk-ZR5X7QMH.js.map +1 -0
- package/dist/chunk-ZW4BJQ26.js +84 -0
- package/dist/chunk-ZW4BJQ26.js.map +1 -0
- package/dist/climbs-BhlWuu0x.d.ts +70 -0
- package/dist/climbs-DgBFwySV.d.cts +70 -0
- package/dist/collab/index.cjs +1283 -0
- package/dist/collab/index.cjs.map +1 -0
- package/dist/collab/index.d.cts +850 -0
- package/dist/collab/index.d.ts +850 -0
- package/dist/collab/index.js +1274 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/data/index.cjs +132 -0
- package/dist/data/index.cjs.map +1 -0
- package/dist/data/index.d.cts +468 -0
- package/dist/data/index.d.ts +468 -0
- package/dist/data/index.js +15 -0
- package/dist/data/index.js.map +1 -0
- package/dist/editor/index.cjs +4506 -0
- package/dist/editor/index.cjs.map +1 -0
- package/dist/editor/index.d.cts +59 -0
- package/dist/editor/index.d.ts +59 -0
- package/dist/editor/index.js +4486 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/elevationTiles-pmsb9wnU.d.cts +77 -0
- package/dist/elevationTiles-pmsb9wnU.d.ts +77 -0
- package/dist/errors/index.cjs +28 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.cts +125 -0
- package/dist/errors/index.d.ts +125 -0
- package/dist/errors/index.js +3 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/geo/index.cjs +232 -0
- package/dist/geo/index.cjs.map +1 -0
- package/dist/geo/index.d.cts +821 -0
- package/dist/geo/index.d.ts +821 -0
- package/dist/geo/index.js +15 -0
- package/dist/geo/index.js.map +1 -0
- package/dist/geodesy-543qXKtI.d.cts +78 -0
- package/dist/geodesy-543qXKtI.d.ts +78 -0
- package/dist/geolocation-DDkQdWMN.d.cts +106 -0
- package/dist/geolocation-DDkQdWMN.d.ts +106 -0
- package/dist/i18n/fr/index.cjs +338 -0
- package/dist/i18n/fr/index.cjs.map +1 -0
- package/dist/i18n/fr/index.d.cts +25 -0
- package/dist/i18n/fr/index.d.ts +25 -0
- package/dist/i18n/fr/index.js +336 -0
- package/dist/i18n/fr/index.js.map +1 -0
- package/dist/i18n/index.cjs +464 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +227 -0
- package/dist/i18n/index.d.ts +227 -0
- package/dist/i18n/index.js +430 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/icons/index.cjs +116 -0
- package/dist/icons/index.cjs.map +1 -0
- package/dist/icons/index.d.cts +457 -0
- package/dist/icons/index.d.ts +457 -0
- package/dist/icons/index.js +11 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.cjs +1869 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +251 -0
- package/dist/index.d.ts +251 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/itinerary-Dp2ZnqgD.d.cts +178 -0
- package/dist/itinerary-Dp2ZnqgD.d.ts +178 -0
- package/dist/language-CEWQ5uYw.d.cts +69 -0
- package/dist/language-CEWQ5uYw.d.ts +69 -0
- package/dist/layers/index.cjs +318 -0
- package/dist/layers/index.cjs.map +1 -0
- package/dist/layers/index.d.cts +1555 -0
- package/dist/layers/index.d.ts +1555 -0
- package/dist/layers/index.js +17 -0
- package/dist/layers/index.js.map +1 -0
- package/dist/map-client/index.cjs +4 -0
- package/dist/map-client/index.cjs.map +1 -0
- package/dist/map-client/index.d.cts +1856 -0
- package/dist/map-client/index.d.ts +1856 -0
- package/dist/map-client/index.js +3 -0
- package/dist/map-client/index.js.map +1 -0
- package/dist/maplibre-worker.mjs +12 -0
- package/dist/markerSprite-DGBQF6PO.cjs +49 -0
- package/dist/markerSprite-DGBQF6PO.cjs.map +1 -0
- package/dist/markerSprite-DZLTR6F6.js +8 -0
- package/dist/markerSprite-DZLTR6F6.js.map +1 -0
- package/dist/mountayaMap-C9mxRFib.d.cts +3277 -0
- package/dist/mountayaMap-DgnlQ2fE.d.ts +3277 -0
- package/dist/navigation/index.cjs +699 -0
- package/dist/navigation/index.cjs.map +1 -0
- package/dist/navigation/index.d.cts +632 -0
- package/dist/navigation/index.d.ts +632 -0
- package/dist/navigation/index.js +689 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/order-BLhsGsH8.d.ts +132 -0
- package/dist/order-BZkUwMou.d.cts +132 -0
- package/dist/paint-BgUcj8l7.d.cts +118 -0
- package/dist/paint-Dx_qGNE_.d.ts +118 -0
- package/dist/profile/index.cjs +675 -0
- package/dist/profile/index.cjs.map +1 -0
- package/dist/profile/index.d.cts +2086 -0
- package/dist/profile/index.d.ts +2086 -0
- package/dist/profile/index.js +18 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/provider-DM71XnLX.d.cts +121 -0
- package/dist/provider-DM71XnLX.d.ts +121 -0
- package/dist/roadAccess-D_rOE4xW.d.cts +86 -0
- package/dist/roadAccess-D_rOE4xW.d.ts +86 -0
- package/dist/routeProfile-BKfSfxx6.d.ts +210 -0
- package/dist/routeProfile-BsSUABXv.d.cts +210 -0
- package/dist/seams/index.cjs +39 -0
- package/dist/seams/index.cjs.map +1 -0
- package/dist/seams/index.d.cts +254 -0
- package/dist/seams/index.d.ts +254 -0
- package/dist/seams/index.js +6 -0
- package/dist/seams/index.js.map +1 -0
- package/dist/search/index.cjs +147 -0
- package/dist/search/index.cjs.map +1 -0
- package/dist/search/index.d.cts +888 -0
- package/dist/search/index.d.ts +888 -0
- package/dist/search/index.js +14 -0
- package/dist/search/index.js.map +1 -0
- package/dist/searchHighlight-DFE7LVIL.cjs +33 -0
- package/dist/searchHighlight-DFE7LVIL.cjs.map +1 -0
- package/dist/searchHighlight-MHAQZVWG.js +12 -0
- package/dist/searchHighlight-MHAQZVWG.js.map +1 -0
- package/dist/searchLimits-j99-NTXR.d.cts +24 -0
- package/dist/searchLimits-j99-NTXR.d.ts +24 -0
- package/dist/sections-CVlc2Inr.d.cts +953 -0
- package/dist/sections-CmtaduLc.d.ts +953 -0
- package/dist/segmentRoute-C5UL_5bp.d.ts +172 -0
- package/dist/segmentRoute-CIo6dR8Y.d.cts +172 -0
- package/dist/strings-30RSdIat.d.cts +552 -0
- package/dist/strings-DPTIbzT5.d.ts +552 -0
- package/dist/stripeImage-CQUXM2YI.js +14 -0
- package/dist/stripeImage-CQUXM2YI.js.map +1 -0
- package/dist/stripeImage-R43OPA6U.cjs +39 -0
- package/dist/stripeImage-R43OPA6U.cjs.map +1 -0
- package/dist/style/index.cjs +116 -0
- package/dist/style/index.cjs.map +1 -0
- package/dist/style/index.d.cts +538 -0
- package/dist/style/index.d.ts +538 -0
- package/dist/style/index.js +11 -0
- package/dist/style/index.js.map +1 -0
- package/dist/styles.css +11 -0
- package/dist/testing/index.cjs +629 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +265 -0
- package/dist/testing/index.d.ts +265 -0
- package/dist/testing/index.js +623 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/timezone/index.cjs +759 -0
- package/dist/timezone/index.cjs.map +1 -0
- package/dist/timezone/index.d.cts +53 -0
- package/dist/timezone/index.d.ts +53 -0
- package/dist/timezone/index.js +757 -0
- package/dist/timezone/index.js.map +1 -0
- package/dist/types-B034JMjl.d.ts +973 -0
- package/dist/types-B2NDLxQA.d.cts +21 -0
- package/dist/types-B2NDLxQA.d.ts +21 -0
- package/dist/types-BEv8V_8V.d.cts +55 -0
- package/dist/types-BEv8V_8V.d.ts +55 -0
- package/dist/types-C8aX5KMU.d.cts +973 -0
- package/dist/types-CTQwbSdA.d.cts +321 -0
- package/dist/types-nO2joeRk.d.ts +321 -0
- package/dist/units/index.cjs +99 -0
- package/dist/units/index.cjs.map +1 -0
- package/dist/units/index.d.cts +75 -0
- package/dist/units/index.d.ts +75 -0
- package/dist/units/index.js +6 -0
- package/dist/units/index.js.map +1 -0
- package/dist/units-D9mBrusY.d.cts +900 -0
- package/dist/units-D9mBrusY.d.ts +900 -0
- package/dist/video/index.cjs +2198 -0
- package/dist/video/index.cjs.map +1 -0
- package/dist/video/index.d.cts +873 -0
- package/dist/video/index.d.ts +873 -0
- package/dist/video/index.js +2173 -0
- package/dist/video/index.js.map +1 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.cts +44 -0
- package/dist/videoOverlay-Dh_D5_Zs.d.ts +44 -0
- package/dist/view/index.cjs +43 -0
- package/dist/view/index.cjs.map +1 -0
- package/dist/view/index.d.cts +836 -0
- package/dist/view/index.d.ts +836 -0
- package/dist/view/index.js +34 -0
- package/dist/view/index.js.map +1 -0
- package/dist/zones-B05QA8fy.d.cts +75 -0
- package/dist/zones-B05QA8fy.d.ts +75 -0
- package/package.json +433 -4
- package/src/agent/engines/session.ts +2255 -0
- package/src/agent/index.ts +109 -0
- package/src/agent/rules/agentError.ts +128 -0
- package/src/agent/rules/boundedInputJson.ts +53 -0
- package/src/agent/rules/conversation.ts +629 -0
- package/src/agent/rules/conversationFaults.ts +349 -0
- package/src/agent/rules/conversationHost.ts +390 -0
- package/src/agent/rules/dispatcher.ts +102 -0
- package/src/agent/rules/errorCodes.ts +78 -0
- package/src/agent/rules/errorStatus.ts +65 -0
- package/src/agent/rules/scriptedTransport.ts +390 -0
- package/src/agent/rules/stickToBottom.ts +38 -0
- package/src/agent/rules/toolResultPayload.ts +197 -0
- package/src/auth/rules/clientHeader.ts +22 -0
- package/src/auth/rules/sentCredential.ts +76 -0
- package/src/auth/rules/transformRequest.ts +803 -0
- package/src/camera/engines/videoFlight.ts +1758 -0
- package/src/camera/index.ts +157 -0
- package/src/camera/rules/clearance.ts +1099 -0
- package/src/camera/rules/fit.ts +132 -0
- package/src/camera/rules/modes.ts +1023 -0
- package/src/camera/rules/plan.ts +478 -0
- package/src/camera/rules/planner.ts +129 -0
- package/src/camera/rules/poseRanges.ts +38 -0
- package/src/camera/rules/presets.ts +185 -0
- package/src/camera/rules/profileSamples.ts +243 -0
- package/src/camera/rules/route.ts +596 -0
- package/src/camera/rules/routeContent.ts +104 -0
- package/src/camera/rules/spline.ts +765 -0
- package/src/camera/rules/sweptViewports.ts +39 -0
- package/src/camera/rules/track.ts +1412 -0
- package/src/camera/rules/vocabulary.ts +130 -0
- package/src/camera/rules/zoom.ts +216 -0
- package/src/collab/engines/session.ts +1902 -0
- package/src/collab/engines/trailingThrottle.ts +151 -0
- package/src/collab/index.ts +56 -0
- package/src/collab/rules/dispatch.ts +143 -0
- package/src/collab/rules/peerNames.ts +51 -0
- package/src/collab/rules/scriptedTransport.ts +244 -0
- package/src/compose/engines/baseMapSwitch.ts +1136 -0
- package/src/compose/engines/events.ts +962 -0
- package/src/compose/engines/mountayaMap.ts +5674 -0
- package/src/compose/engines/sentCredentials.ts +146 -0
- package/src/compose/engines/slotRequests.ts +413 -0
- package/src/compose/rules/accessRefusal.ts +109 -0
- package/src/compose/rules/accessStanding.ts +75 -0
- package/src/compose/rules/analysisKinds.ts +331 -0
- package/src/compose/rules/analysisLayers.ts +176 -0
- package/src/compose/rules/cameraMoves.ts +38 -0
- package/src/compose/rules/carriedLayers.ts +87 -0
- package/src/compose/rules/developmentWarnings.ts +166 -0
- package/src/compose/rules/fitCamera.ts +54 -0
- package/src/compose/rules/geoJsonSlot.ts +61 -0
- package/src/compose/rules/geometrySlots.ts +155 -0
- package/src/compose/rules/glyphNode.ts +62 -0
- package/src/compose/rules/layerKeys.ts +92 -0
- package/src/compose/rules/layerOrder.ts +85 -0
- package/src/compose/rules/layersManifest.ts +26 -0
- package/src/compose/rules/mapOptions.ts +300 -0
- package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
- package/src/compose/rules/markerPin.ts +122 -0
- package/src/compose/rules/markerRegistry.ts +85 -0
- package/src/compose/rules/markerSprite.ts +382 -0
- package/src/compose/rules/maxBounds.ts +120 -0
- package/src/compose/rules/overlayLookup.ts +49 -0
- package/src/compose/rules/paintDiff.ts +38 -0
- package/src/compose/rules/panLock.ts +77 -0
- package/src/compose/rules/patch.ts +124 -0
- package/src/compose/rules/queriedFeature.ts +55 -0
- package/src/compose/rules/queryLayers.ts +46 -0
- package/src/compose/rules/searchHighlight.ts +313 -0
- package/src/compose/rules/slotNames.ts +19 -0
- package/src/compose/rules/stripeImage.ts +253 -0
- package/src/compose/rules/swapMarker.ts +66 -0
- package/src/compose/rules/terrainVariant.ts +88 -0
- package/src/compose/rules/types.ts +566 -0
- package/src/compose/rules/urlHash.ts +19 -0
- package/src/compose/rules/viewOptions.ts +451 -0
- package/src/compose/rules/workerUrl.ts +96 -0
- package/src/data/engines/itineraryResource.ts +643 -0
- package/src/data/index.ts +78 -0
- package/src/data/rules/adapt.ts +473 -0
- package/src/data/rules/editModes.ts +51 -0
- package/src/data/rules/itinerary.ts +168 -0
- package/src/data/rules/nullable.ts +63 -0
- package/src/data/rules/roadAccess.ts +169 -0
- package/src/data/rules/segmentGroups.ts +309 -0
- package/src/data/rules/selectors.ts +95 -0
- package/src/data/rules/zones.ts +79 -0
- package/src/draw/engines/boundaryEngine.ts +1003 -0
- package/src/draw/engines/framedAdapter.ts +198 -0
- package/src/draw/engines/pointerCursor.ts +205 -0
- package/src/draw/engines/segmentEngine.ts +1405 -0
- package/src/draw/engines/snapIndex.ts +254 -0
- package/src/draw/engines/waypointEngine.ts +574 -0
- package/src/draw/engines/zoneEngine.ts +1137 -0
- package/src/draw/rules/drawFrame.ts +123 -0
- package/src/draw/rules/insertVertex.ts +226 -0
- package/src/draw/rules/screenSpace.ts +62 -0
- package/src/draw/rules/seeds.ts +185 -0
- package/src/draw/rules/snap.ts +115 -0
- package/src/draw/rules/snapCameraKey.ts +50 -0
- package/src/draw/rules/terraDrawShared.ts +214 -0
- package/src/draw/rules/zoneOutline.ts +213 -0
- package/src/editing/engines/cursor.ts +505 -0
- package/src/editing/engines/draftMarker.ts +149 -0
- package/src/editing/rules/accent.ts +11 -0
- package/src/editing/rules/engine.ts +286 -0
- package/src/editing/rules/placement.ts +22 -0
- package/src/editing/rules/positions.ts +89 -0
- package/src/editing/rules/sources.ts +9 -0
- package/src/editing/rules/types.ts +457 -0
- package/src/editing/rules/vocabulary.ts +10 -0
- package/src/editing/rules/waypointCursor.ts +228 -0
- package/src/editor/engines/directionArrows.ts +459 -0
- package/src/editor/engines/directions.ts +1383 -0
- package/src/editor/engines/editorClient.ts +134 -0
- package/src/editor/engines/eventScope.ts +59 -0
- package/src/editor/engines/frameLoop.ts +159 -0
- package/src/editor/engines/itineraryPreview.ts +272 -0
- package/src/editor/engines/mapLockGuard.ts +66 -0
- package/src/editor/engines/overlayRenderer.ts +2696 -0
- package/src/editor/engines/peerDraft.ts +760 -0
- package/src/editor/engines/poiPick.ts +305 -0
- package/src/editor/engines/pointPick.ts +84 -0
- package/src/editor/engines/roadAccessLine.ts +140 -0
- package/src/editor/engines/searchHighlight.ts +183 -0
- package/src/editor/engines/viewClient.ts +4083 -0
- package/src/editor/engines/zoneBadges.ts +503 -0
- package/src/editor/index.ts +97 -0
- package/src/editor/rules/accentColor.ts +116 -0
- package/src/editor/rules/camera.ts +121 -0
- package/src/editor/rules/contract.ts +125 -0
- package/src/editor/rules/icons.ts +825 -0
- package/src/editor/rules/markerElements.ts +244 -0
- package/src/editor/rules/style.ts +51 -0
- package/src/editor/rules/terrain.ts +98 -0
- package/src/editor/rules/tileWarm.ts +191 -0
- package/src/editor/rules/tilesReload.ts +158 -0
- package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
- package/src/editor/rules/zoneTimeStyling.ts +119 -0
- package/src/errors/index.ts +25 -0
- package/src/errors/rules/errors.ts +157 -0
- package/src/errors/rules/print.ts +129 -0
- package/src/geo/index.ts +94 -0
- package/src/geo/rules/boundaries.ts +105 -0
- package/src/geo/rules/camera.ts +496 -0
- package/src/geo/rules/corridor.ts +242 -0
- package/src/geo/rules/elevationTiles.ts +269 -0
- package/src/geo/rules/formatLngLat.ts +63 -0
- package/src/geo/rules/geodesy.ts +125 -0
- package/src/geo/rules/geometry.ts +362 -0
- package/src/geo/rules/lineWalk.ts +77 -0
- package/src/geo/rules/longitude.ts +99 -0
- package/src/geo/rules/searchLimits.ts +22 -0
- package/src/geo/rules/segmentGeometry.ts +80 -0
- package/src/geo/rules/terrain.ts +107 -0
- package/src/geo/rules/tuples.ts +124 -0
- package/src/geo/rules/types.ts +54 -0
- package/src/geo/rules/webMercator.ts +57 -0
- package/src/i18n/fr/index.ts +17 -0
- package/src/i18n/fr/rules/fr.ts +85 -0
- package/src/i18n/fr/rules/words.gen.ts +277 -0
- package/src/i18n/index.ts +81 -0
- package/src/i18n/rules/bundle.ts +378 -0
- package/src/i18n/rules/config.ts +71 -0
- package/src/i18n/rules/endonyms.gen.ts +19 -0
- package/src/i18n/rules/language.ts +92 -0
- package/src/i18n/rules/localizedName.ts +33 -0
- package/src/i18n/rules/merge.ts +106 -0
- package/src/i18n/rules/scope.ts +127 -0
- package/src/i18n/rules/strings.ts +632 -0
- package/src/i18n/rules/videoOverlay.ts +121 -0
- package/src/i18n/rules/wordForms.ts +95 -0
- package/src/i18n/rules/words.gen.ts +277 -0
- package/src/icons/index.ts +54 -0
- package/src/icons/rules/activities.ts +40 -0
- package/src/icons/rules/amenities.ts +250 -0
- package/src/icons/rules/artwork.gen.ts +83 -0
- package/src/icons/rules/artwork.ts +47 -0
- package/src/icons/rules/fallback.ts +21 -0
- package/src/icons/rules/lucideMarkers.gen.ts +112 -0
- package/src/icons/rules/lucideUi.gen.ts +197 -0
- package/src/icons/rules/paint.ts +107 -0
- package/src/icons/rules/parse.ts +475 -0
- package/src/icons/rules/provider.ts +373 -0
- package/src/icons/rules/sprites.ts +54 -0
- package/src/icons/rules/ui.ts +348 -0
- package/src/icons/rules/waypoints.ts +215 -0
- package/src/index.ts +1012 -0
- package/src/layers/engines/layersSelection.ts +515 -0
- package/src/layers/engines/readoutEngine.ts +131 -0
- package/src/layers/index.ts +151 -0
- package/src/layers/rules/analysis.ts +135 -0
- package/src/layers/rules/enrichment.ts +30 -0
- package/src/layers/rules/geoJson.ts +270 -0
- package/src/layers/rules/hover.ts +67 -0
- package/src/layers/rules/itineraries.ts +182 -0
- package/src/layers/rules/layersPanel.ts +237 -0
- package/src/layers/rules/order.ts +194 -0
- package/src/layers/rules/overlayInstant.ts +49 -0
- package/src/layers/rules/overlays.ts +52 -0
- package/src/layers/rules/poiPanel.ts +119 -0
- package/src/layers/rules/pois.ts +114 -0
- package/src/layers/rules/readout.ts +340 -0
- package/src/layers/rules/streetView.ts +16 -0
- package/src/layers/rules/tileTimestamp.ts +146 -0
- package/src/layers/rules/timeSlider.ts +192 -0
- package/src/layers/rules/timeWindow.ts +123 -0
- package/src/layers/rules/zones.ts +43 -0
- package/src/layers/rules/zoom.ts +77 -0
- package/src/map-client/index.ts +71 -0
- package/src/map-client/rules/mapClient.ts +1943 -0
- package/src/navigation/engines/navigation.ts +493 -0
- package/src/navigation/index.ts +51 -0
- package/src/navigation/rules/followedRoute.ts +78 -0
- package/src/navigation/rules/instructions.ts +89 -0
- package/src/navigation/rules/itineraryRoute.ts +232 -0
- package/src/navigation/rules/offRoute.ts +41 -0
- package/src/navigation/rules/progress.ts +230 -0
- package/src/navigation/rules/prompts.ts +217 -0
- package/src/navigation/rules/routeRequest.ts +98 -0
- package/src/navigation/rules/status.ts +142 -0
- package/src/navigation/rules/steps.ts +234 -0
- package/src/navigation/rules/types.ts +83 -0
- package/src/profile/index.ts +307 -0
- package/src/profile/rules/amenityBadge.ts +35 -0
- package/src/profile/rules/amenityFilter.ts +74 -0
- package/src/profile/rules/amenityStacks.ts +66 -0
- package/src/profile/rules/axis.ts +89 -0
- package/src/profile/rules/axisCulling.ts +83 -0
- package/src/profile/rules/axisLookup.ts +180 -0
- package/src/profile/rules/climbs.ts +292 -0
- package/src/profile/rules/cursorMarker.ts +122 -0
- package/src/profile/rules/cursorReadout.ts +104 -0
- package/src/profile/rules/curvePlacement.ts +216 -0
- package/src/profile/rules/dock.ts +293 -0
- package/src/profile/rules/elevation.ts +1263 -0
- package/src/profile/rules/instant.ts +89 -0
- package/src/profile/rules/intl.ts +237 -0
- package/src/profile/rules/legEmphasis.ts +53 -0
- package/src/profile/rules/profileColors.ts +66 -0
- package/src/profile/rules/profileLayout.ts +59 -0
- package/src/profile/rules/profileSlices.ts +55 -0
- package/src/profile/rules/routeProfile.ts +475 -0
- package/src/profile/rules/rowMatch.ts +50 -0
- package/src/profile/rules/scale.ts +650 -0
- package/src/profile/rules/scaleFrame.ts +171 -0
- package/src/profile/rules/sectionChips.ts +83 -0
- package/src/profile/rules/sections.ts +923 -0
- package/src/profile/rules/slopeRamp.ts +160 -0
- package/src/profile/rules/statStrip.ts +103 -0
- package/src/profile/rules/steepness.ts +51 -0
- package/src/profile/rules/tableCells.ts +269 -0
- package/src/profile/rules/tableCursor.ts +87 -0
- package/src/profile/rules/unitPatterns.ts +335 -0
- package/src/profile/rules/units.ts +1025 -0
- package/src/profile/rules/waypointCard.ts +593 -0
- package/src/profile/rules/webAddress.ts +130 -0
- package/src/profile/rules/windowSpans.ts +65 -0
- package/src/rules/asciiFold.ts +17 -0
- package/src/rules/inDevelopment.ts +54 -0
- package/src/rules/listeners.ts +62 -0
- package/src/rules/timers.ts +9 -0
- package/src/rules/types.ts +22 -0
- package/src/rules/uuid.ts +87 -0
- package/src/seams/engines/geolocateControl.ts +286 -0
- package/src/seams/index.ts +50 -0
- package/src/seams/rules/clock.ts +169 -0
- package/src/seams/rules/geolocation.ts +165 -0
- package/src/seams/rules/segmentRoute.ts +187 -0
- package/src/search/engines/search.ts +1093 -0
- package/src/search/index.ts +114 -0
- package/src/search/rules/describe.ts +383 -0
- package/src/search/rules/filters.ts +195 -0
- package/src/search/rules/highlight.ts +270 -0
- package/src/search/rules/pick.ts +90 -0
- package/src/search/rules/rows.ts +258 -0
- package/src/search/rules/searchFocus.ts +27 -0
- package/src/search/rules/searchViewport.ts +44 -0
- package/src/search/rules/shown.ts +77 -0
- package/src/search/rules/types.ts +340 -0
- package/src/stream/rules/reconnectSchedule.ts +83 -0
- package/src/style/engines/organizationRead.ts +80 -0
- package/src/style/index.ts +63 -0
- package/src/style/rules/apply.ts +268 -0
- package/src/style/rules/attribution.ts +119 -0
- package/src/style/rules/itineraryLine.ts +142 -0
- package/src/style/rules/language.ts +668 -0
- package/src/style/rules/layout.gen.ts +27 -0
- package/src/style/rules/organization.ts +96 -0
- package/src/style/rules/paint.ts +143 -0
- package/src/style/rules/panelLayout.ts +51 -0
- package/src/style/rules/roadAccessColors.ts +29 -0
- package/src/style/rules/roadAccessLine.ts +267 -0
- package/src/style/rules/segmentColors.ts +207 -0
- package/src/testing/catalogs.ts +103 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/mapClient.ts +241 -0
- package/src/testing/mountayaMap.ts +741 -0
- package/src/timezone/index.ts +14 -0
- package/src/timezone/rules/viewport.ts +875 -0
- package/src/units/index.ts +55 -0
- package/src/units/rules/conversions.ts +620 -0
- package/src/units/rules/preferenceChoices.ts +124 -0
- package/src/units/rules/preferences.ts +77 -0
- package/src/units/rules/rounding.ts +69 -0
- package/src/video/engines/videoRun.ts +654 -0
- package/src/video/engines/viewClient.ts +6 -0
- package/src/video/index.ts +83 -0
- package/src/video/profileOverlay/rules/contract.ts +212 -0
- package/src/video/profileOverlay/rules/curve.ts +216 -0
- package/src/video/profileOverlay/rules/draw.ts +410 -0
- package/src/video/profileOverlay/rules/fonts.ts +54 -0
- package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
- package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
- package/src/video/profileOverlay/rules/registry.ts +23 -0
- package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
- package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
- package/src/video/profileOverlay/rules/types.ts +78 -0
- package/src/video/rules/videoConstants.ts +250 -0
- package/src/video/rules/videoEncoder.ts +277 -0
- package/src/video/rules/videoFrames.ts +99 -0
- package/src/video/rules/videoPreview.ts +185 -0
- package/src/video/rules/videoRecorder.ts +746 -0
- package/src/video/rules/videoWatermark.ts +155 -0
- package/src/video/rules/watermarkMark.ts +40 -0
- package/src/view/engines/viewClient.ts +6 -0
- package/src/view/index.ts +20 -0
|
@@ -0,0 +1,2696 @@
|
|
|
1
|
+
import type { Position } from "geojson";
|
|
2
|
+
import type {
|
|
3
|
+
AddLayerObject,
|
|
4
|
+
AllPaintProperties,
|
|
5
|
+
ExpressionSpecification,
|
|
6
|
+
FilterSpecification,
|
|
7
|
+
LineLayerSpecification,
|
|
8
|
+
Map as MapLibreMap,
|
|
9
|
+
RasterTileSource,
|
|
10
|
+
TransitionSpecification,
|
|
11
|
+
VectorTileSource,
|
|
12
|
+
} from "maplibre-gl";
|
|
13
|
+
|
|
14
|
+
import type { TileSchema } from "@mountaya/client";
|
|
15
|
+
|
|
16
|
+
import type { MapEventEngine } from "../../compose/engines/events.js";
|
|
17
|
+
import type { MountayaMap } from "../../compose/engines/mountayaMap.js";
|
|
18
|
+
import { ENRICHMENT_SLOT_PREFIX } from "../../compose/rules/slotNames.js";
|
|
19
|
+
import type { MountedSpecification, Overlay } from "../../compose/rules/types.js";
|
|
20
|
+
import { errorFrom } from "../../errors/rules/errors.js";
|
|
21
|
+
import type { IconProvider } from "../../icons/index.js";
|
|
22
|
+
import { waypointIconImageId } from "../../icons/rules/sprites.js";
|
|
23
|
+
import {
|
|
24
|
+
ITINERARY_ENDPOINT_ICONS,
|
|
25
|
+
ITINERARY_LINE_SOURCE_LAYER,
|
|
26
|
+
ITINERARY_POINT_SOURCE_LAYER,
|
|
27
|
+
isItineraryCasingLayer,
|
|
28
|
+
roadAccessIconLayerId,
|
|
29
|
+
roadAccessLineLayerOf,
|
|
30
|
+
roadAccessStripeLayerId,
|
|
31
|
+
} from "../../layers/rules/itineraries.js";
|
|
32
|
+
import { LayerRank } from "../../layers/rules/order.js";
|
|
33
|
+
import { ZONE_FILL_SOURCE_LAYER } from "../../layers/rules/zones.js";
|
|
34
|
+
import {
|
|
35
|
+
ROAD_ACCESS_STRIPE_OPACITY,
|
|
36
|
+
roadAccessLayersOf,
|
|
37
|
+
} from "../../style/rules/roadAccessLine.js";
|
|
38
|
+
import { DEGREES_PER_TURN, MILLISECONDS_PER_SECOND } from "../../units/rules/conversions.js";
|
|
39
|
+
import type {
|
|
40
|
+
ItineraryEmphasis,
|
|
41
|
+
ItineraryExclusions,
|
|
42
|
+
OverlayZoomRange,
|
|
43
|
+
} from "../rules/contract.js";
|
|
44
|
+
import {
|
|
45
|
+
loadDirectionArrowIcon,
|
|
46
|
+
loadMissingIcon,
|
|
47
|
+
loadRoadAccessIcons,
|
|
48
|
+
loadWaypointIcon,
|
|
49
|
+
loadZoneClockIcon,
|
|
50
|
+
loadZoneStripeIcons,
|
|
51
|
+
schedulePrebakeMarkerIcons,
|
|
52
|
+
} from "../rules/icons.js";
|
|
53
|
+
import { bustItineraryTileCache } from "../rules/tilesReload.js";
|
|
54
|
+
import {
|
|
55
|
+
ZONE_FILL_OPACITY,
|
|
56
|
+
ZONE_INACTIVE_FILL_OPACITY,
|
|
57
|
+
zoneClockVisibilityFilter,
|
|
58
|
+
zoneStripeFillPattern,
|
|
59
|
+
} from "../rules/zoneTimeStyling.js";
|
|
60
|
+
import { DIRECTION_CHEVRON_OPACITY, directionChevronLayout } from "./directionArrows.js";
|
|
61
|
+
import { ZoneBadgeEngine } from "./zoneBadges.js";
|
|
62
|
+
|
|
63
|
+
// The opacity an unfocused itinerary geometry dims to under an emphasis; the
|
|
64
|
+
// focused entity stays at full opacity. The manifest sets no opacity, so 1 is
|
|
65
|
+
// the natural reset. The dim is intentionally pronounced (0.25) so the focused
|
|
66
|
+
// segment or waypoint reads as clearly distinct against the de-emphasised
|
|
67
|
+
// background: a subtler value (0.5) makes the contrast hard to
|
|
68
|
+
// follow at the zoom levels where multiple itineraries overlap on screen.
|
|
69
|
+
const ITINERARY_DIM_OPACITY = 0.25;
|
|
70
|
+
// The transition every paint write of the renderer's folds is made under: none. A fold writes a
|
|
71
|
+
// state (a focus, a dim, an edit's de-emphasis, a tint, a zone's base opacity) that lands at once,
|
|
72
|
+
// and the renderer's own default eases it over 300 ms, which the 3D relief never shows. Under the relief MapLibre draws
|
|
73
|
+
// the line layers into the terrain's drape and draws the drape again on the frame a style change
|
|
74
|
+
// lands, and on no later frame of the ease, so a line eased from full strength stays drawn at the
|
|
75
|
+
// strength it had while the points, drawn over the drape, finish the ease. With no transition the
|
|
76
|
+
// lines and the points take the new value in the same frame, on a flat map and under the relief.
|
|
77
|
+
const noTransition: TransitionSpecification = { delay: 0, duration: 0 };
|
|
78
|
+
// The paint properties the renderer's folds write, each beside the name its transition takes.
|
|
79
|
+
const transitionOf = {
|
|
80
|
+
"circle-opacity": "circle-opacity-transition",
|
|
81
|
+
"fill-opacity": "fill-opacity-transition",
|
|
82
|
+
"icon-opacity": "icon-opacity-transition",
|
|
83
|
+
"line-color": "line-color-transition",
|
|
84
|
+
"line-opacity": "line-opacity-transition",
|
|
85
|
+
"line-width": "line-width-transition",
|
|
86
|
+
} as const;
|
|
87
|
+
// The opacity the segment being edited paints at on its ghost layer, so the user sees the saved
|
|
88
|
+
// version alongside the editable overlay (TerraDraw or the directions SDK) which renders on top at
|
|
89
|
+
// full opacity. Lower would blur it into the emphasis dim, and full opacity would compete with the
|
|
90
|
+
// overlay. 0.75 reads as "still there, just secondary".
|
|
91
|
+
const ITINERARY_EDIT_OPACITY = 0.75;
|
|
92
|
+
// The dash pattern the segment being edited paints on its ghost layer. The pair
|
|
93
|
+
// is in line-widths, so [2, 2] yields a 1:1 dash that reads as "this segment is
|
|
94
|
+
// being modified" without obscuring the overlay above it.
|
|
95
|
+
const ITINERARY_EDIT_DASHARRAY = [2, 2] as const;
|
|
96
|
+
// The layer id suffix appended to an itinerary line layer id to name the layer the segment
|
|
97
|
+
// under edit is drawn on, dashed, while the edit lasts. Keyed off the line's id so the draw,
|
|
98
|
+
// the clear and the source's teardown resolve the same layer.
|
|
99
|
+
const ITINERARY_EDIT_GHOST_LAYER_SUFFIX = "__edit-ghost";
|
|
100
|
+
// The factor an emphasized itinerary line's width is multiplied by so the focused
|
|
101
|
+
// geometry reads thicker than the dimmed rest. It wraps the manifest's
|
|
102
|
+
// zoom-interpolated base width, so the line still scales with zoom: only the
|
|
103
|
+
// focused feature is scaled up. Unfocused features keep the base width (factor 1).
|
|
104
|
+
const HOVER_WIDTH_MULTIPLIER = 1.75;
|
|
105
|
+
// The line width used when the manifest layer declares none, so the emphasis
|
|
106
|
+
// multiplier always wraps a concrete base rather than an undefined value.
|
|
107
|
+
const DEFAULT_LINE_WIDTH = 1;
|
|
108
|
+
// Each leg of the zoom jog repaintBustedTiles uses to force MapLibre to fold
|
|
109
|
+
// reloaded tiles into a static render. Deliberately shorter than the published
|
|
110
|
+
// ZOOM_EASE_MS the facade eases an out-of-range overlay with: that one is a
|
|
111
|
+
// camera move the user is meant to follow, where this one is a jog out and back
|
|
112
|
+
// that should read as a repaint rather than as motion.
|
|
113
|
+
const REPAINT_JOG_MS = 200;
|
|
114
|
+
|
|
115
|
+
// The fill layer id suffix for a zone's inactive-only diagonal-stripe overlay: a
|
|
116
|
+
// SEPARATE layer above the base fill so the base keeps its solid fill-color for
|
|
117
|
+
// every zone (a fill-pattern on the base hides active zones in MapLibre). The clock
|
|
118
|
+
// badge an out-of-window zone also carries is no layer on the zones' tiles: it is the
|
|
119
|
+
// ZoneBadgeEngine's, one point per zone on a source of its own.
|
|
120
|
+
const ZONE_STRIPE_LAYER_SUFFIX = "__zone-stripe";
|
|
121
|
+
// The layer id suffix appended to an itinerary line layer id to name its synthetic
|
|
122
|
+
// direction-indicator layer: the static chevron symbols. The manifest emits no direction
|
|
123
|
+
// layer (only lines and points), so the renderer adds one per itinerary line layer, keyed off
|
|
124
|
+
// its id so the add, the emphasis, exclusion and edit folds, and the teardown all resolve the
|
|
125
|
+
// same companion id. The chevron rides the GPU symbol pipeline with no per-frame cost. The
|
|
126
|
+
// tile view draws no animated flow line: that one follows a segment's draft, in the edit view.
|
|
127
|
+
const DIRECTION_CHEVRON_LAYER_SUFFIX = "__direction-chevron";
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* editGhostLayerId names the layer the segment under edit is drawn on, beside the itinerary
|
|
131
|
+
* line layer it stands in for.
|
|
132
|
+
*
|
|
133
|
+
* @param lineLayerId The id of the itinerary line layer.
|
|
134
|
+
*/
|
|
135
|
+
const editGhostLayerId = (lineLayerId: string): string =>
|
|
136
|
+
`${lineLayerId}${ITINERARY_EDIT_GHOST_LAYER_SUFFIX}`;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* isZoneSourceLayer reports whether a manifest tile layer draws the zone geometry
|
|
140
|
+
* source-layer (`fills`). The single predicate the zone time-styling walk, the
|
|
141
|
+
* edited-zone exclusion and the zone query read, so what counts as a zone layer is
|
|
142
|
+
* decided in one place. A zone is a single polygon, so every layer on that
|
|
143
|
+
* source-layer (the area, and an outline when a manifest styles one) is a zone
|
|
144
|
+
* layer, and a layer on any other source-layer is skipped rather than styled.
|
|
145
|
+
*/
|
|
146
|
+
const isZoneSourceLayer = (sourceLayer: string): boolean => sourceLayer === ZONE_FILL_SOURCE_LAYER;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* hasZoneLayer reports whether a tile source carries any zone geometry layer, used
|
|
150
|
+
* to decide whether a freshly-added manifest needs the current zone time reference
|
|
151
|
+
* re-asserted and its stripe overlay attached.
|
|
152
|
+
*/
|
|
153
|
+
const hasZoneLayer = (source: TileSchema.TileSource): boolean =>
|
|
154
|
+
source.layers.some((layer) => isZoneSourceLayer(layer.source_layer));
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* itineraryOpacityProperty maps an itinerary tile layer's kind to the paint
|
|
158
|
+
* property that controls its opacity: line-opacity for lines, icon-opacity for
|
|
159
|
+
* symbols, circle-opacity for circles (the last for future start/end markers).
|
|
160
|
+
* Any other kind has no opacity to drive and returns null so the caller skips
|
|
161
|
+
* it.
|
|
162
|
+
*/
|
|
163
|
+
const itineraryOpacityProperty = (
|
|
164
|
+
type: TileSchema.TileLayer["type"],
|
|
165
|
+
): "line-opacity" | "icon-opacity" | "circle-opacity" | null => {
|
|
166
|
+
switch (type) {
|
|
167
|
+
case "line":
|
|
168
|
+
return "line-opacity";
|
|
169
|
+
case "symbol":
|
|
170
|
+
return "icon-opacity";
|
|
171
|
+
case "circle":
|
|
172
|
+
return "circle-opacity";
|
|
173
|
+
default:
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* itineraryOpacity builds the opacity value an itinerary layer paints under the
|
|
180
|
+
* given emphasis. `none` is full opacity, `dimAll` dims everything, and the
|
|
181
|
+
* focused variants keep the matching feature at full opacity while dimming the
|
|
182
|
+
* rest via a per-feature `case` expression. `isLine` selects the property the
|
|
183
|
+
* `itinerary` and `segment` variants compare: lines carry segment_id, so a
|
|
184
|
+
* segment focus targets them; points carry no segment_id, so under a segment
|
|
185
|
+
* focus they simply dim (the focus is the segment's line). The `segments`
|
|
186
|
+
* variant is the same focus over a set, matching with `in` instead of `==`. A
|
|
187
|
+
* waypoint focus is NOT the mirror of that: it dims the other points and keeps the
|
|
188
|
+
* lines at full strength, because the line is what says where the focused point is
|
|
189
|
+
* (see the case below). The return is a MapLibre opacity expression (number or
|
|
190
|
+
* `case` array) handed straight to setPaintProperty.
|
|
191
|
+
*/
|
|
192
|
+
const itineraryOpacity = (
|
|
193
|
+
emphasis: ItineraryEmphasis,
|
|
194
|
+
isLine: boolean,
|
|
195
|
+
): number | ExpressionSpecification => {
|
|
196
|
+
switch (emphasis.mode) {
|
|
197
|
+
case "none":
|
|
198
|
+
return 1;
|
|
199
|
+
case "dimAll":
|
|
200
|
+
return ITINERARY_DIM_OPACITY;
|
|
201
|
+
case "itinerary":
|
|
202
|
+
return ["case", ["==", ["get", "itinerary_id"], emphasis.id], 1, ITINERARY_DIM_OPACITY];
|
|
203
|
+
case "segment":
|
|
204
|
+
// Points carry no segment_id, so a segment focus only highlights the
|
|
205
|
+
// segment's line; the points dim with the rest.
|
|
206
|
+
return isLine
|
|
207
|
+
? ["case", ["==", ["get", "segment_id"], emphasis.id], 1, ITINERARY_DIM_OPACITY]
|
|
208
|
+
: ITINERARY_DIM_OPACITY;
|
|
209
|
+
case "segments":
|
|
210
|
+
return isLine
|
|
211
|
+
? [
|
|
212
|
+
"case",
|
|
213
|
+
["in", ["get", "segment_id"], ["literal", emphasis.ids]],
|
|
214
|
+
1,
|
|
215
|
+
ITINERARY_DIM_OPACITY,
|
|
216
|
+
]
|
|
217
|
+
: ITINERARY_DIM_OPACITY;
|
|
218
|
+
case "waypoint":
|
|
219
|
+
// A waypoint focus dims the other POINTS and leaves the lines alone. It is not
|
|
220
|
+
// the mirror image of a segment focus, because a waypoint is not the mirror
|
|
221
|
+
// image of a segment: a segment IS a line, so dimming the points around it
|
|
222
|
+
// leaves the thing in focus legible, while a waypoint is a dot ON a line and
|
|
223
|
+
// the line is the only thing that says where the dot is. Dimming it was worst
|
|
224
|
+
// exactly where the focus matters most: dragging a waypoint, where the route
|
|
225
|
+
// is the drop target the magnet snaps onto and the user was aiming at a route
|
|
226
|
+
// drawn at a quarter strength. The focused point still stands out, because
|
|
227
|
+
// every other point still dims.
|
|
228
|
+
return isLine
|
|
229
|
+
? 1
|
|
230
|
+
: ["case", ["==", ["get", "waypoint_id"], emphasis.id], 1, ITINERARY_DIM_OPACITY];
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* scaleLineWidth multiplies a base line-width by a per-feature factor while
|
|
236
|
+
* keeping the result a VALID MapLibre line-width. MapLibre permits a ["zoom"]
|
|
237
|
+
* reference only as the direct input of a top-level "interpolate"/"step", so a
|
|
238
|
+
* zoom-interpolated base must NOT be wrapped in ["*", base, factor]: that buries
|
|
239
|
+
* the zoom below the top level and MapLibre rejects the whole expression. Instead
|
|
240
|
+
* the factor (feature-data only, never zoom) is pushed into each stop OUTPUT,
|
|
241
|
+
* leaving zoom as the interpolation input. A plain numeric base is multiplied
|
|
242
|
+
* directly; an expression that is neither a number nor a recognized zoom curve is
|
|
243
|
+
* returned unchanged rather than risk an invalid wrap.
|
|
244
|
+
*/
|
|
245
|
+
const scaleLineWidth = (
|
|
246
|
+
base: number | ExpressionSpecification,
|
|
247
|
+
factor: ExpressionSpecification,
|
|
248
|
+
): number | ExpressionSpecification => {
|
|
249
|
+
if (typeof base === "number") {
|
|
250
|
+
return ["*", base, factor];
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const [op, ...rest] = base;
|
|
254
|
+
if (op === "interpolate" || op === "interpolate-hcl" || op === "interpolate-lab") {
|
|
255
|
+
// ["interpolate", interpolation, input, z0, out0, z1, out1, …]: scale the
|
|
256
|
+
// outputs (the odd positions after interpolation + input), keep the zoom stops.
|
|
257
|
+
const [interpolation, input, ...stops] = rest;
|
|
258
|
+
const scaled = stops.map((value, index) => (index % 2 === 1 ? ["*", value, factor] : value));
|
|
259
|
+
|
|
260
|
+
// Asserted, since a spread of stops is an array of any length to the type-checker, where
|
|
261
|
+
// the expression type lists each curve as a tuple. The curve is the one read above with
|
|
262
|
+
// its outputs scaled, so it is an expression of the same form.
|
|
263
|
+
return [op, interpolation, input, ...scaled] as ExpressionSpecification;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (op === "step") {
|
|
267
|
+
// ["step", input, out0, z1, out1, z2, out2, …]: scale out0 and every later
|
|
268
|
+
// output, keep the zoom stops.
|
|
269
|
+
const [input, firstOutput, ...stops] = rest;
|
|
270
|
+
const scaled = stops.map((value, index) => (index % 2 === 1 ? ["*", value, factor] : value));
|
|
271
|
+
|
|
272
|
+
// Asserted for the reason the interpolation above gives.
|
|
273
|
+
return [op, input, ["*", firstOutput, factor], ...scaled] as ExpressionSpecification;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// An unrecognized base could carry zoom in a position we cannot safely wrap;
|
|
277
|
+
// leave it untouched rather than emit an invalid expression.
|
|
278
|
+
return base;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* itineraryLineWidth builds the line-width an itinerary line layer paints under
|
|
283
|
+
* the given emphasis. `none`/`dimAll` return the manifest base untouched, as does
|
|
284
|
+
* `waypoint`: its focus is a point, so the lines keep their base width (and, unlike
|
|
285
|
+
* the others, their full opacity). The line-targeting variants thicken the matching
|
|
286
|
+
* feature by
|
|
287
|
+
* HOVER_WIDTH_MULTIPLIER (others by 1) via the same id `case` the opacity uses,
|
|
288
|
+
* pushed through scaleLineWidth so the manifest's zoom interpolation stays a
|
|
289
|
+
* valid top-level expression.
|
|
290
|
+
*/
|
|
291
|
+
const itineraryLineWidth = (
|
|
292
|
+
emphasis: ItineraryEmphasis,
|
|
293
|
+
baseWidth: number | ExpressionSpecification,
|
|
294
|
+
): number | ExpressionSpecification => {
|
|
295
|
+
switch (emphasis.mode) {
|
|
296
|
+
case "none":
|
|
297
|
+
case "dimAll":
|
|
298
|
+
case "waypoint":
|
|
299
|
+
return baseWidth;
|
|
300
|
+
case "itinerary":
|
|
301
|
+
return scaleLineWidth(baseWidth, [
|
|
302
|
+
"case",
|
|
303
|
+
["==", ["get", "itinerary_id"], emphasis.id],
|
|
304
|
+
HOVER_WIDTH_MULTIPLIER,
|
|
305
|
+
1,
|
|
306
|
+
]);
|
|
307
|
+
case "segment":
|
|
308
|
+
return scaleLineWidth(baseWidth, [
|
|
309
|
+
"case",
|
|
310
|
+
["==", ["get", "segment_id"], emphasis.id],
|
|
311
|
+
HOVER_WIDTH_MULTIPLIER,
|
|
312
|
+
1,
|
|
313
|
+
]);
|
|
314
|
+
case "segments":
|
|
315
|
+
return scaleLineWidth(baseWidth, [
|
|
316
|
+
"case",
|
|
317
|
+
["in", ["get", "segment_id"], ["literal", emphasis.ids]],
|
|
318
|
+
HOVER_WIDTH_MULTIPLIER,
|
|
319
|
+
1,
|
|
320
|
+
]);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* endpointColorIconImage wraps the manifest's own icon-image expression so the two
|
|
326
|
+
* synthetic endpoint rows resolve to the given color's sprite while every other
|
|
327
|
+
* feature falls through to the manifest branch unchanged. The endpoints carry the
|
|
328
|
+
* SEGMENT's color and a true waypoint carries its own, so a single-segment-color
|
|
329
|
+
* override has to recolor the former without touching the latter, and the icon name
|
|
330
|
+
* is the only thing that separates the two in one shared symbol layer.
|
|
331
|
+
*
|
|
332
|
+
* The endpoint ids come from waypointIconImageId, the same builder loadWaypointIcon
|
|
333
|
+
* registers the sprites under, so a referenced id can never drift from a registered
|
|
334
|
+
* one. `match` needs a non-null input, so a feature with no icon coalesces to "" and
|
|
335
|
+
* lands on the fallback branch.
|
|
336
|
+
*/
|
|
337
|
+
const endpointColorIconImage = (
|
|
338
|
+
color: string,
|
|
339
|
+
base: string | ExpressionSpecification,
|
|
340
|
+
): ExpressionSpecification => [
|
|
341
|
+
"match",
|
|
342
|
+
["coalesce", ["get", "icon"], ""],
|
|
343
|
+
ITINERARY_ENDPOINT_ICONS[0],
|
|
344
|
+
waypointIconImageId(ITINERARY_ENDPOINT_ICONS[0], color),
|
|
345
|
+
ITINERARY_ENDPOINT_ICONS[1],
|
|
346
|
+
waypointIconImageId(ITINERARY_ENDPOINT_ICONS[1], color),
|
|
347
|
+
base,
|
|
348
|
+
];
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* hasItineraryLayer reports whether a tile source carries any itinerary
|
|
352
|
+
* geometry layer (line or point), used to decide whether a freshly-added
|
|
353
|
+
* manifest needs the current emphasis re-asserted.
|
|
354
|
+
*/
|
|
355
|
+
const hasItineraryLayer = (source: TileSchema.TileSource): boolean =>
|
|
356
|
+
source.layers.some(
|
|
357
|
+
(layer) =>
|
|
358
|
+
layer.source_layer === ITINERARY_LINE_SOURCE_LAYER ||
|
|
359
|
+
layer.source_layer === ITINERARY_POINT_SOURCE_LAYER,
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* itineraryExclusionFilter builds the filter an itinerary tile layer paints
|
|
364
|
+
* under the current exclusions: it drops every feature whose `idProp`
|
|
365
|
+
* (segment_id for lines, waypoint_id for points) is in the excluded `ids`,
|
|
366
|
+
* combined with the layer's manifest base filter so any styling predicate the
|
|
367
|
+
* manifest declared still applies. With no ids to exclude it returns the base
|
|
368
|
+
* filter untouched (null when the manifest declared none), restoring the full
|
|
369
|
+
* layer. The base is read fresh from the manifest layer each call, so a repeated
|
|
370
|
+
* exclusion change always wraps the pristine filter rather than a previously-
|
|
371
|
+
* combined one.
|
|
372
|
+
*/
|
|
373
|
+
const itineraryExclusionFilter = (
|
|
374
|
+
base: FilterSpecification | undefined,
|
|
375
|
+
idProp: string,
|
|
376
|
+
ids: string[],
|
|
377
|
+
): FilterSpecification | null => {
|
|
378
|
+
if (ids.length === 0) {
|
|
379
|
+
return base ?? null;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const exclude: ExpressionSpecification = ["!", ["in", ["get", idProp], ["literal", ids]]];
|
|
383
|
+
|
|
384
|
+
// The manifest base filter (a renderer-agnostic expression) and the exclusion
|
|
385
|
+
// combine under a top-level `all`. The combined array is built as an expression
|
|
386
|
+
// and cast to FilterSpecification at the MapLibre boundary (the same posture
|
|
387
|
+
// tileLayerSpec takes when it attaches a manifest filter) because the SDK's
|
|
388
|
+
// FilterSpecification union also admits a legacy form the type-checker cannot
|
|
389
|
+
// narrow this fresh array out of.
|
|
390
|
+
const combined: ExpressionSpecification = base
|
|
391
|
+
? ["all", base as ExpressionSpecification, exclude]
|
|
392
|
+
: ["all", exclude];
|
|
393
|
+
|
|
394
|
+
return combined as FilterSpecification;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* zoneExclusionFilter builds the filter a zone tile layer paints under the
|
|
399
|
+
* current edit: it drops the single feature whose `id` PROPERTY equals the
|
|
400
|
+
* excluded zone id (the zone tile carries the zone UUID as its `id` property, not
|
|
401
|
+
* the tile feature id), combined with the layer's manifest base filter so any
|
|
402
|
+
* styling predicate the manifest declared still applies. With no zone excluded it
|
|
403
|
+
* returns the base filter untouched (null when the manifest declared none),
|
|
404
|
+
* restoring the full layer. The base is read fresh from the manifest layer each
|
|
405
|
+
* call, so a repeated edit change always wraps the pristine filter rather than a
|
|
406
|
+
* previously-combined one, the same posture itineraryExclusionFilter takes, only
|
|
407
|
+
* keyed on a single `["!=", ["get", "id"], excludedId]` rather than a negated `in`
|
|
408
|
+
* over a list.
|
|
409
|
+
*/
|
|
410
|
+
const zoneExclusionFilter = (
|
|
411
|
+
base: FilterSpecification | undefined,
|
|
412
|
+
excludedId: string | null,
|
|
413
|
+
): FilterSpecification | null => {
|
|
414
|
+
if (excludedId === null) {
|
|
415
|
+
return base ?? null;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
const exclude: ExpressionSpecification = ["!=", ["get", "id"], excludedId];
|
|
419
|
+
|
|
420
|
+
// The manifest base filter (a renderer-agnostic expression) and the exclusion
|
|
421
|
+
// combine under a top-level `all`. The combined array is built as an expression
|
|
422
|
+
// and cast to FilterSpecification at the MapLibre boundary (the same posture
|
|
423
|
+
// itineraryExclusionFilter + tileLayerSpec take) because the SDK's
|
|
424
|
+
// FilterSpecification union also admits a legacy form the type-checker cannot
|
|
425
|
+
// narrow this fresh array out of.
|
|
426
|
+
const combined: ExpressionSpecification = base
|
|
427
|
+
? ["all", base as ExpressionSpecification, exclude]
|
|
428
|
+
: ["all", exclude];
|
|
429
|
+
|
|
430
|
+
return combined as FilterSpecification;
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* CATEGORY_OVERLAY_SLOT names the facade slot this renderer tracks its category overlay's
|
|
435
|
+
* post-mount work under, and {@link ENRICHMENT_SLOT_PREFIX} the slot of each enrichment. They
|
|
436
|
+
* are the facade's own vocabulary, so the two sides describe the same drawing by the same name.
|
|
437
|
+
*/
|
|
438
|
+
const CATEGORY_OVERLAY_SLOT = "overlay";
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* SlotMount is what one facade slot currently has on the map: the layer ids to
|
|
442
|
+
* re-light or re-style, and the source ids whose pinned tile URLs must be
|
|
443
|
+
* re-applied. Both are read back off the mount rather than derived from the
|
|
444
|
+
* overlay, because those are the ids that actually reached the style.
|
|
445
|
+
*/
|
|
446
|
+
interface SlotMount {
|
|
447
|
+
readonly layerIds: readonly string[];
|
|
448
|
+
/**
|
|
449
|
+
* Which overlay the slot is holding. The exclusive category slot changes hands without
|
|
450
|
+
* being cleared, and a replay of the same overlay looks identical from the ids alone,
|
|
451
|
+
* so this is what tells "the same drawing, redrawn" from "a different overlay now".
|
|
452
|
+
*/
|
|
453
|
+
readonly slug: string;
|
|
454
|
+
readonly sourceIds: readonly string[];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* DepartedPins is what an overlay left a slot with when the slot was cleared: the tile URLs its
|
|
459
|
+
* sources were pinned to, under the slug that says whose they are.
|
|
460
|
+
*/
|
|
461
|
+
interface DepartedPins {
|
|
462
|
+
readonly slug: string;
|
|
463
|
+
readonly tilesById: ReadonlyMap<string, string[]>;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* ManifestMount is what one `/v1/tile-layers` tile source currently has on the map: the manifest
|
|
468
|
+
* record itself (which every fold reads its pristine paint, filter and source-layer back off)
|
|
469
|
+
* the layer ids the facade drew from it, and the ids of the synthetic companion layers this
|
|
470
|
+
* renderer attached beside them.
|
|
471
|
+
*
|
|
472
|
+
* It is LIVE state, not a desired set. The facade holds the intent and owns the replay, so
|
|
473
|
+
* this is written only from the slot's onMounted (which fires on the mount and again after
|
|
474
|
+
* every style swap) and nothing is ever re-added from it.
|
|
475
|
+
*/
|
|
476
|
+
interface ManifestMount {
|
|
477
|
+
/**
|
|
478
|
+
* The synthetic layers this renderer added beside the manifest's own: the itinerary
|
|
479
|
+
* direction chevrons, the stripes and icons of its restricted stretches, and a zone source's
|
|
480
|
+
* stripe fill. They are not in the
|
|
481
|
+
* specification, so the facade neither draws nor removes them; recorded here, the teardown
|
|
482
|
+
* takes them off BEFORE the source they bind, which MapLibre requires.
|
|
483
|
+
*/
|
|
484
|
+
readonly companionLayerIds: readonly string[];
|
|
485
|
+
readonly layerIds: readonly string[];
|
|
486
|
+
readonly source: TileSchema.TileSource;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* sameManifestValue compares two manifest values structurally.
|
|
491
|
+
*
|
|
492
|
+
* The manifest is plain JSON (objects, arrays, strings, numbers, booleans and nulls) so a
|
|
493
|
+
* recursive walk is total over it. Key ORDER is deliberately not part of the answer: the same
|
|
494
|
+
* source rebuilt by the hook that declares it is the same drawing however its keys landed.
|
|
495
|
+
*/
|
|
496
|
+
const sameManifestValue = (left: unknown, right: unknown): boolean => {
|
|
497
|
+
if (left === right) {
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
502
|
+
return (
|
|
503
|
+
Array.isArray(left) &&
|
|
504
|
+
Array.isArray(right) &&
|
|
505
|
+
left.length === right.length &&
|
|
506
|
+
left.every((value, index) => sameManifestValue(value, right[index]))
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Both are objects and neither is an array or null, which in JSON leaves a keyed record. The
|
|
515
|
+
// narrowing above cannot say so, so each is asserted to be read by key.
|
|
516
|
+
const leftFields = left as Record<string, unknown>;
|
|
517
|
+
const rightFields = right as Record<string, unknown>;
|
|
518
|
+
const keys = Object.keys(leftFields);
|
|
519
|
+
|
|
520
|
+
return (
|
|
521
|
+
keys.length === Object.keys(rightFields).length &&
|
|
522
|
+
keys.every(
|
|
523
|
+
(key) =>
|
|
524
|
+
Object.hasOwn(rightFields, key) && sameManifestValue(leftFields[key], rightFields[key]),
|
|
525
|
+
)
|
|
526
|
+
);
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* zoneOverlayFilter is the filter the synthetic stripe overlay paints under and the clock
|
|
531
|
+
* badges are read under: the out-of-window predicate (zoneClockVisibilityFilter) composed
|
|
532
|
+
* with the edited-zone exclusion, so an edited zone hides its stripe + clock exactly as
|
|
533
|
+
* setEditedZone hides its base geometry. The stripe layers are not in
|
|
534
|
+
* source.layers, so the applyZoneExclusions manifest walk cannot reach them through
|
|
535
|
+
* their layer record; this composes the time predicate (their "base") with the
|
|
536
|
+
* exclusion and is applied at add time, on the reference tick (applyZoneTimeStyling),
|
|
537
|
+
* and on every setEditedZone change (applyZoneExclusions). The badges take the same
|
|
538
|
+
* filter at the same three moments (drawZoneBadges), so a zone is badged exactly when it
|
|
539
|
+
* is striped. It always returns a non-null FilterSpecification (the time filter alone
|
|
540
|
+
* when nothing is excluded).
|
|
541
|
+
*/
|
|
542
|
+
const zoneOverlayFilter = (reference: number, excludedId: string | null): FilterSpecification => {
|
|
543
|
+
const inactive = zoneClockVisibilityFilter(reference);
|
|
544
|
+
|
|
545
|
+
return zoneExclusionFilter(inactive, excludedId) ?? inactive;
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
/** The greatest illumination direction the renderer takes, in degrees: one short of a turn. */
|
|
549
|
+
const HILLSHADE_DIRECTION_MAX_DEG = 359;
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* hillshadeDirection reads a bearing in degrees as the direction the renderer lights a hillshade
|
|
553
|
+
* layer from, which it takes from 0 to {@link HILLSHADE_DIRECTION_MAX_DEG} and refuses outside.
|
|
554
|
+
*
|
|
555
|
+
* The bearing is wrapped into one turn, so 495 and -225 both read 135. What is left between 359
|
|
556
|
+
* and 360 is inside the turn and outside the range, and reads as the nearer of the two ends:
|
|
557
|
+
* 359 below the half degree, 0 from it on.
|
|
558
|
+
*/
|
|
559
|
+
const hillshadeDirection = (bearing: number): number => {
|
|
560
|
+
const wrapped = ((bearing % DEGREES_PER_TURN) + DEGREES_PER_TURN) % DEGREES_PER_TURN;
|
|
561
|
+
if (wrapped <= HILLSHADE_DIRECTION_MAX_DEG) {
|
|
562
|
+
return wrapped;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
const middle = (HILLSHADE_DIRECTION_MAX_DEG + DEGREES_PER_TURN) / 2;
|
|
566
|
+
|
|
567
|
+
return wrapped < middle ? HILLSHADE_DIRECTION_MAX_DEG : 0;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* OverlayRenderer owns the studio's tile-overlay surface and the itinerary
|
|
572
|
+
* render painted on top of it. The two are inseparable: a persisted itinerary
|
|
573
|
+
* is drawn by the always-on vector TILES (the itinerary line/point source-
|
|
574
|
+
* layers), so emphasis, exclusions, and the per-edit de-emphasis are all
|
|
575
|
+
* paint/filter writes on those tile layers: there is no separate itinerary
|
|
576
|
+
* geometry. So this one collaborator holds the itinerary focus/exclusion/edit
|
|
577
|
+
* state and the zone time reference, and exposes the commands that (re-)paint them.
|
|
578
|
+
*
|
|
579
|
+
* What it does NOT hold is a second answer to "what should be on the map". Every
|
|
580
|
+
* drawing (a manifest tile source, the category overlay, an enrichment) is a
|
|
581
|
+
* MountayaMap slot, and the facade owns the intent, the stacking rank, the per-layer
|
|
582
|
+
* visibility and the style-swap replay for all of them. The index below is live state
|
|
583
|
+
* read back off each mount, so a fold knows which ids to write onto; nothing here is
|
|
584
|
+
* ever re-added from.
|
|
585
|
+
*
|
|
586
|
+
* It holds no back-reference to the MapLibreClient: it takes the MountayaMap and
|
|
587
|
+
* the shared MapEventEngine (so its one piece of map-level state, the
|
|
588
|
+
* missing-image sprite resolver, is swept on the shared dispose), mirroring
|
|
589
|
+
* SearchHighlightLayer and CursorEngine. The dependency direction stays
|
|
590
|
+
* one-way; the client delegates the tile/itinerary commands to it and reads back
|
|
591
|
+
* through a handful of seams (the active-itinerary snap geometries, the overlay
|
|
592
|
+
* query layer scope, and the ordered-insert + rank-forget primitives the Street
|
|
593
|
+
* View coverage layer shares).
|
|
594
|
+
*/
|
|
595
|
+
export class OverlayRenderer {
|
|
596
|
+
// What each manifest tile source currently has on the map, keyed by source id.
|
|
597
|
+
// Written from the slot's onMounted hook, which fires on the mount AND on every
|
|
598
|
+
// style-swap replay, so the ids and the manifest record here are always the ones
|
|
599
|
+
// currently in the style. It is live state and never a desired set: the facade
|
|
600
|
+
// holds the intent for each slot and replays it itself.
|
|
601
|
+
private readonly manifestMounts = new Map<string, ManifestMount>();
|
|
602
|
+
// What the facade has drawn for each overlay slot it owns: the category
|
|
603
|
+
// overlay and one entry per enrichment slug. Written from the same onMounted
|
|
604
|
+
// hook, so the ids here are likewise always the ones currently in the style. It
|
|
605
|
+
// is the reach the hillshade illumination needs: an enrichment's layers belong
|
|
606
|
+
// to a slot of its own, and a later setHillshadeIllumination would otherwise
|
|
607
|
+
// find nothing to light.
|
|
608
|
+
private readonly slotMounts = new Map<string, SlotMount>();
|
|
609
|
+
// The tile URLs a source is currently meant to serve, when they differ from the
|
|
610
|
+
// manifest's own: the `timestamp` param the layers-panel slider writes onto a
|
|
611
|
+
// server-timestamped overlay. Kept per source id because the facade replays the
|
|
612
|
+
// specification it was mounted with (the manifest URLs), so without this a
|
|
613
|
+
// base-map switch would snap a pinned overlay back to "now". The slot's
|
|
614
|
+
// onMounted re-applies it onto the fresh source.
|
|
615
|
+
private readonly tileOverridesById = new Map<string, string[]>();
|
|
616
|
+
// The pins a slot's overlay left with when the slot was cleared, by slot. They wait for one
|
|
617
|
+
// thing: the same overlay mounted in the same slot again, which takes them back. Held apart
|
|
618
|
+
// from the live pins so that nothing else mounted on one of those source ids meanwhile is
|
|
619
|
+
// handed a timestamp chosen for this overlay.
|
|
620
|
+
private readonly departedPins = new Map<string, DepartedPins>();
|
|
621
|
+
// The waits for a category overlay to be on the map, by the slug awaited: one function a
|
|
622
|
+
// wait, which ends it. A wait takes its own out when it ends, so the map holds the waits
|
|
623
|
+
// still open and nothing else.
|
|
624
|
+
private readonly overlayMountWaits = new Map<string, Set<(mounted: boolean) => void>>();
|
|
625
|
+
// Whether the renderer is disposed: a wait asked of it then has no mount to come.
|
|
626
|
+
private disposed = false;
|
|
627
|
+
// Serializes the facade's slot writes. Mounting is asynchronous (it waits out a
|
|
628
|
+
// style swap in flight) while clearing is not, so a clear issued while a mount
|
|
629
|
+
// is still in flight would otherwise be overtaken by it and leave the overlay
|
|
630
|
+
// drawn. Chaining every slot write onto one tail makes the LAST call win, which
|
|
631
|
+
// is what a caller toggling a selection means.
|
|
632
|
+
private slotWrites: Promise<void> = Promise.resolve();
|
|
633
|
+
// How many slot writes are queued or running. It is what tells a tail with work on it from
|
|
634
|
+
// a tail at rest, which the promise alone cannot say.
|
|
635
|
+
private pendingSlotWrites = 0;
|
|
636
|
+
// The layer ids a right-click overlay-feature query is scoped to: the active
|
|
637
|
+
// overlay's vector layers, set by the active-overlay hook. Empty when no
|
|
638
|
+
// overlay (or a raster overlay) is active, so queryOverlayFeaturesAt is then a
|
|
639
|
+
// no-op. Not a per-style set: it is the desired query scope, re-read on the
|
|
640
|
+
// next query, so a style reload does not need to replay it.
|
|
641
|
+
private overlayQueryLayerIds: string[] = [];
|
|
642
|
+
// The last hillshade illumination direction (degrees), re-applied after a style
|
|
643
|
+
// reload so a base-map switch keeps the time-of-day shading (null = none yet).
|
|
644
|
+
private lastHillshadeDirection: number | null = null;
|
|
645
|
+
// The current itinerary emphasis, re-applied after the tile layers are re-added
|
|
646
|
+
// on a base-map switch (the layers are torn down and replayed by setStyle, so
|
|
647
|
+
// the opacity override is lost unless re-asserted). Defaults to no focus.
|
|
648
|
+
private itineraryEmphasis: ItineraryEmphasis = { mode: "none" };
|
|
649
|
+
// The single color every itinerary segment paints in, or null to keep the
|
|
650
|
+
// manifest's own per-segment expression. Re-applied after the tile layers are
|
|
651
|
+
// re-added on a base-map switch (setStyle replays them with the manifest paint, so
|
|
652
|
+
// the override is lost unless re-asserted). Null on every surface but the embed.
|
|
653
|
+
private itinerarySegmentColor: string | null = null;
|
|
654
|
+
// Whether the restricted stretches of the itinerary tiles are drawn: their stripes and their
|
|
655
|
+
// warning icons. Written on the layers when they are created, so a base-map switch keeps it,
|
|
656
|
+
// and true on every surface but an embed that turns them off.
|
|
657
|
+
private accessRestrictionsVisible = true;
|
|
658
|
+
// The features currently suppressed from the itinerary tile render, re-applied
|
|
659
|
+
// after the tile layers are re-added on a base-map switch (setStyle replays the
|
|
660
|
+
// layers with the manifest's own filters, so the exclusion filter is lost unless
|
|
661
|
+
// re-asserted). Defaults to nothing excluded.
|
|
662
|
+
private itineraryExclusions: ItineraryExclusions = { segmentIds: [], waypointIds: [] };
|
|
663
|
+
// The active itinerary's segment geometries: the LineString coordinate
|
|
664
|
+
// arrays the waypoint magnet snaps onto. Held imperatively (not reactive
|
|
665
|
+
// state) because the magnet reads it on every pointer-move frame, and a
|
|
666
|
+
// re-render of `useStudioMapSync` updates it through `setActiveItinerarySegments`
|
|
667
|
+
// when the active itinerary or its segments change. Empty list = no magnet.
|
|
668
|
+
private activeItinerarySegments: readonly Position[][] = [];
|
|
669
|
+
// The segment id whose saved geometry paints de-emphasized (75% opacity + dashed,
|
|
670
|
+
// on a ghost layer) while a segment edit is active. It drives the edit STYLE (not
|
|
671
|
+
// a filter) so the saved geometry stays visible underneath the editable overlay
|
|
672
|
+
// rather than being hidden. Re-asserted after a base-map switch via the same
|
|
673
|
+
// post-style-load replay path as itineraryEmphasis and itineraryExclusions, so
|
|
674
|
+
// the de-emphasis survives a restyle that races past the edit lock. Null when
|
|
675
|
+
// no edit is active.
|
|
676
|
+
private editStyledSegmentId: string | null = null;
|
|
677
|
+
// The epoch (seconds) the zone tile layers evaluate their time-bound styling
|
|
678
|
+
// against: "now", or the pinned slider instant. MapLibre cannot read the wall
|
|
679
|
+
// clock, so the studio drives this (from the layers-panel timestamp when set, or as
|
|
680
|
+
// each clock minute turns when not) and the value is injected as a literal into the
|
|
681
|
+
// filter the stripes paint under and the clock badges are read under (a filter write,
|
|
682
|
+
// never a tile refetch; the base opacity is a uniform constant, time-independent). Re-asserted after a
|
|
683
|
+
// base-map switch replays the zone layers, so the time styling survives a terrain
|
|
684
|
+
// swap. Seeded to the construct-time epoch so a zone manifest that lands before
|
|
685
|
+
// the first setZoneTimeReference still styles against a sane "now" rather than 0
|
|
686
|
+
// (which would mark every bounded-start zone out-of-window).
|
|
687
|
+
private zoneTimeReference: number = Math.floor(Date.now() / MILLISECONDS_PER_SECOND);
|
|
688
|
+
// The zone id whose tile copy is suppressed (filtered out) while a zone edit is
|
|
689
|
+
// armed, so the persisted vector copy does not paint underneath the live
|
|
690
|
+
// TerraDraw editable feature and double-render the zone. It drives a FILTER
|
|
691
|
+
// (not a paint dim like the segment edit) because the editable overlay fully
|
|
692
|
+
// replaces the zone (the user is reshaping it), so the saved copy must vanish
|
|
693
|
+
// entirely rather than ghost behind it. Re-asserted after a base-map switch
|
|
694
|
+
// replays the zone layers via the same addTileSources path as the zone time
|
|
695
|
+
// styling, so the suppression survives a terrain swap mid-edit. Null when no zone
|
|
696
|
+
// edit is active. For a fresh create the id is not in the tile yet, so the filter
|
|
697
|
+
// is a harmless no-op; for an edit/reshape it hides the persisted copy.
|
|
698
|
+
private excludedZoneId: string | null = null;
|
|
699
|
+
// The waypoint id whose committed tile copy is suppressed (filtered out) while a
|
|
700
|
+
// custom-point waypoint edit is armed, so the persisted vector copy does not paint
|
|
701
|
+
// under the live DraftWaypointMarker and double-render the point. Like the zone
|
|
702
|
+
// suppression it composes into a FILTER (the point branch of applyItineraryExclusions
|
|
703
|
+
// drops it alongside the tool-bus waypointIds) because the draft fully stands in for
|
|
704
|
+
// the committed point while the user drags it, so the saved copy must vanish entirely
|
|
705
|
+
// rather than ghost behind it. Re-asserted after a base-map switch replays the point
|
|
706
|
+
// layers via the same addTileSources path, so the suppression survives a terrain swap
|
|
707
|
+
// mid-edit. Null when no waypoint edit is active; kept independent of
|
|
708
|
+
// itineraryExclusions so the tool-bus exclusion set is never mutated by an edit.
|
|
709
|
+
private excludedWaypointId: string | null = null;
|
|
710
|
+
// The resolver that generates the itinerary waypoint + POI marker sprites on demand.
|
|
711
|
+
// It is map-level state that outlives base-map switches (setStyle replaces the style,
|
|
712
|
+
// not the resolver), so it is installed once and lives for the life of the map.
|
|
713
|
+
//
|
|
714
|
+
// A resolver rather than a `styleimagemissing` listener because from MapLibre 6 on that
|
|
715
|
+
// event is notify-only: it fires AFTER the resolver has declined, to report an image
|
|
716
|
+
// that is still missing, and a listener calling `addImage` there does not answer the
|
|
717
|
+
// request that raised it. The event stays the right place to LEARN a sprite was missed
|
|
718
|
+
// and the wrong place to supply it.
|
|
719
|
+
//
|
|
720
|
+
// It returns the load rather than starting it and returning: MapLibre awaits the answer
|
|
721
|
+
// before it lays the symbol out, so a sprite that lands after an early return misses
|
|
722
|
+
// that layout and the marker draws without its icon until a later tile reload.
|
|
723
|
+
private readonly resolveMissingImage = (id: string): Promise<void> =>
|
|
724
|
+
loadMissingIcon(this.map, id, this.icons);
|
|
725
|
+
|
|
726
|
+
// The MapLibre map underneath the MountayaMap, held directly because every
|
|
727
|
+
// paint, filter and source write below is native style state MountayaMap does
|
|
728
|
+
// not wrap. Only the ordered insert and its teardown half go through the map
|
|
729
|
+
// itself, because those are the two that touch the shared rank registry.
|
|
730
|
+
//
|
|
731
|
+
// That split is the division between the facade and the renderer, read from this side. The facade
|
|
732
|
+
// owns the ONE rank registry, the shared event engine and the style swap
|
|
733
|
+
// (the seams where a second copy anchors against the wrong set, misses a swap,
|
|
734
|
+
// or wipes what it just added) and this renderer routes all three through it.
|
|
735
|
+
// What stays here is the studio's own cartography on layers this file created:
|
|
736
|
+
// per-layer visibility baked at creation, itinerary emphasis, the exclusion
|
|
737
|
+
// filters, edit re-assertion and hillshade illumination. Those describe the
|
|
738
|
+
// studio's map rather than the published contract, and no other writer exists
|
|
739
|
+
// for them, so there is nothing for a second registry to disagree with.
|
|
740
|
+
private readonly map: MapLibreMap;
|
|
741
|
+
// The glyph set the marker sprites are baked from, taken off the map at construction.
|
|
742
|
+
private readonly icons: IconProvider;
|
|
743
|
+
// Cancels the marker-sprite warm pass scheduled at construction. Held for dispose.
|
|
744
|
+
private readonly cancelMarkerWarm: () => void;
|
|
745
|
+
// Draws the clock badge of every out-of-window zone on screen: one per zone, on a source
|
|
746
|
+
// of its own, read off the zone layers this renderer mounts. It attaches nothing to the
|
|
747
|
+
// map until a zone source is mounted.
|
|
748
|
+
private readonly zoneBadges: ZoneBadgeEngine;
|
|
749
|
+
|
|
750
|
+
constructor(
|
|
751
|
+
private readonly mountayaMap: MountayaMap,
|
|
752
|
+
private readonly events: MapEventEngine,
|
|
753
|
+
) {
|
|
754
|
+
this.map = mountayaMap.raw;
|
|
755
|
+
// The glyph set every sprite this renderer bakes is drawn from. Read off the map
|
|
756
|
+
// rather than taken as a second parameter: the host already chose a set when it
|
|
757
|
+
// constructed the map, and a renderer that asked again could be handed a different
|
|
758
|
+
// one: a marker whose sprite and whose cursor disagree.
|
|
759
|
+
this.icons = mountayaMap.icons;
|
|
760
|
+
|
|
761
|
+
// The itinerary + POI tile symbol layers reference their marker sprites by id;
|
|
762
|
+
// MapLibre asks the resolver for any not yet registered, and it rasterizes the
|
|
763
|
+
// matching glyph in the feature color and adds it. It is map-level state, so the
|
|
764
|
+
// manager clears it on dispose.
|
|
765
|
+
this.events.setMissingImageResolver(this.resolveMissingImage);
|
|
766
|
+
|
|
767
|
+
// Warm the marker-sprite registry so the first paint of an itinerary or POI overlay finds every
|
|
768
|
+
// bounded-vocabulary id present: without it, the tile worker would request each sprite before
|
|
769
|
+
// the missing-image resolver could answer it, and MapLibre would log `Image "section-icon-…"
|
|
770
|
+
// could not be loaded` for the one-frame gap. Scheduled off the critical path rather than run
|
|
771
|
+
// inline: the vocabulary is a cross product of icons and colors, and its rasterizations would
|
|
772
|
+
// otherwise compete with the map's own first paint. The missing-image resolver is the safety
|
|
773
|
+
// net until it lands, and every subsequent map (or remount) reuses the module-level bitmap
|
|
774
|
+
// cache.
|
|
775
|
+
this.cancelMarkerWarm = schedulePrebakeMarkerIcons(this.map, this.icons);
|
|
776
|
+
|
|
777
|
+
// The badge layer is ranked through this renderer's own ordered insert, the one registry
|
|
778
|
+
// every other layer here records into, and the engine calls it only once a zone source
|
|
779
|
+
// is mounted.
|
|
780
|
+
this.zoneBadges = new ZoneBadgeEngine(this.map, this, this.events);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* dispose cancels the marker-sprite warm pass the renderer scheduled at construction, when it
|
|
785
|
+
* has not run or is still rasterizing, so no sprite is registered on a map its client let go
|
|
786
|
+
* of, and takes the zone clock badges off: nothing would place them from here on. The
|
|
787
|
+
* missing-image resolver is the event engine's to sweep. Calling it again does nothing.
|
|
788
|
+
*/
|
|
789
|
+
dispose(): void {
|
|
790
|
+
this.cancelMarkerWarm();
|
|
791
|
+
this.zoneBadges.dispose();
|
|
792
|
+
this.disposed = true;
|
|
793
|
+
// No mount is coming for an overlay still awaited, so each wait ends unanswered.
|
|
794
|
+
for (const waits of [...this.overlayMountWaits.values()]) {
|
|
795
|
+
for (const end of [...waits]) {
|
|
796
|
+
end(false);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/**
|
|
802
|
+
* whenCategoryOverlayMounted answers a promise for the category slot holding the overlay of
|
|
803
|
+
* the given slug, drawn, with no slot write queued behind it: `true` once that is so, at once
|
|
804
|
+
* when it already is, and `false` when the signal aborts or the renderer is disposed first.
|
|
805
|
+
*
|
|
806
|
+
* It is what a caller that did not mount the overlay itself waits on. A tool selects an
|
|
807
|
+
* overlay in a store and a binding mounts it in reaction, a turn or more later, so until the
|
|
808
|
+
* binding has called {@link setCategoryOverlay} nothing is queued and nothing is in flight:
|
|
809
|
+
* a wait for the map to settle resolves within a frame, over a map that holds none of the
|
|
810
|
+
* overlay.
|
|
811
|
+
*
|
|
812
|
+
* The slot is read while the queue of slot writes is at rest, and never between two of them.
|
|
813
|
+
* A wait asked while a clear or another overlay is queued over the one drawn is answered by
|
|
814
|
+
* what the slot holds once the queue has run, and a mount with a clear queued behind it tells
|
|
815
|
+
* nobody that the overlay is drawn.
|
|
816
|
+
*
|
|
817
|
+
* The wait ends on that overlay and on no other: another overlay drawn in the slot meanwhile,
|
|
818
|
+
* a clear, and an enrichment of the same slug leave it waiting. It never rejects. It runs no
|
|
819
|
+
* timer of its own, so a caller that cannot wait for ever passes a signal.
|
|
820
|
+
*
|
|
821
|
+
* The slot is what is read, and never the style. A base-map switch in flight keeps the slot
|
|
822
|
+
* and the map draws the overlay again on the style it brings, so a wait asked meanwhile is
|
|
823
|
+
* answered `true` at once, ahead of that draw.
|
|
824
|
+
*
|
|
825
|
+
* @param slug The slug of the overlay awaited, as its manifest entry states it.
|
|
826
|
+
* @param signal Ends the wait unanswered when it aborts.
|
|
827
|
+
*/
|
|
828
|
+
whenCategoryOverlayMounted(slug: string, signal?: AbortSignal): Promise<boolean> {
|
|
829
|
+
// Asked first: the slot of a disposed renderer still records the overlay it drew last, on a
|
|
830
|
+
// map that is gone.
|
|
831
|
+
if (this.disposed) {
|
|
832
|
+
return Promise.resolve(false);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
if (this.pendingSlotWrites === 0 && this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug === slug) {
|
|
836
|
+
return Promise.resolve(true);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (signal?.aborted === true) {
|
|
840
|
+
return Promise.resolve(false);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return new Promise<boolean>((resolve) => {
|
|
844
|
+
const waits = this.overlayMountWaits.get(slug) ?? new Set<(mounted: boolean) => void>();
|
|
845
|
+
this.overlayMountWaits.set(slug, waits);
|
|
846
|
+
|
|
847
|
+
const end = (mounted: boolean): void => {
|
|
848
|
+
waits.delete(end);
|
|
849
|
+
if (waits.size === 0 && this.overlayMountWaits.get(slug) === waits) {
|
|
850
|
+
this.overlayMountWaits.delete(slug);
|
|
851
|
+
}
|
|
852
|
+
signal?.removeEventListener("abort", onAbort);
|
|
853
|
+
resolve(mounted);
|
|
854
|
+
};
|
|
855
|
+
const onAbort = (): void => {
|
|
856
|
+
end(false);
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
waits.add(end);
|
|
860
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
861
|
+
});
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* answerOverlayMountWaits tells each wait for the overlay the category slot holds that it is
|
|
866
|
+
* drawn, while the queue of slot writes is at rest. With a write queued or running it tells
|
|
867
|
+
* nobody: the slot is then between two states, and the queue calls this again as it empties.
|
|
868
|
+
*/
|
|
869
|
+
private answerOverlayMountWaits(): void {
|
|
870
|
+
if (this.pendingSlotWrites > 0) {
|
|
871
|
+
return;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
const slug = this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug;
|
|
875
|
+
if (slug === undefined) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
for (const end of [...(this.overlayMountWaits.get(slug) ?? [])]) {
|
|
880
|
+
end(true);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* setTileLayerVisibility shows or hides one already-added tile layer by id, the
|
|
886
|
+
* per-layer toggle the POI overlay menu drives.
|
|
887
|
+
*
|
|
888
|
+
* The intent is the facade's: it records the value whether or not the layer is on the map
|
|
889
|
+
* yet, defers the live write past a style swap in flight, and re-applies it on the incoming
|
|
890
|
+
* style, so a category hidden before its overlay arrived mounts hidden, and stays hidden
|
|
891
|
+
* across a base-map switch. Keeping a second copy here would mean two answers to "is this
|
|
892
|
+
* layer meant to be visible", and the one the replay reads decides.
|
|
893
|
+
*
|
|
894
|
+
* What this adds is the order. A slot write runs on the queue, after the call that asked for
|
|
895
|
+
* it, and a removal forgets the visibility of every layer it takes off. A value written while
|
|
896
|
+
* one is still queued therefore waits behind it: written at once, it would be forgotten by a
|
|
897
|
+
* removal the caller asked for first, and an overlay drawn again in the same step would come
|
|
898
|
+
* back with every layer shown. With nothing queued it is written at once.
|
|
899
|
+
*/
|
|
900
|
+
setTileLayerVisibility(layerId: string, visible: boolean): void {
|
|
901
|
+
if (this.pendingSlotWrites === 0) {
|
|
902
|
+
this.mountayaMap.setLayerVisibility(layerId, visible);
|
|
903
|
+
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
this.queueSlotWrite(async () => {
|
|
908
|
+
this.mountayaMap.setLayerVisibility(layerId, visible);
|
|
909
|
+
});
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* setCategoryOverlay draws the one active category overlay into the facade's
|
|
914
|
+
* exclusive overlay slot, replacing whichever was drawn before; `null` clears it.
|
|
915
|
+
*
|
|
916
|
+
* The slot is the facade's, and so is everything that follows from it: the layers
|
|
917
|
+
* land at their ranks through the one stacking registry, a hidden layer is born
|
|
918
|
+
* hidden, the camera eases into the sources' zoom window, and a base-map switch
|
|
919
|
+
* replays the whole thing. What stays here is the studio's own post-mount work,
|
|
920
|
+
* carried by {@link adoptSlotMount} so it survives that replay.
|
|
921
|
+
*/
|
|
922
|
+
setCategoryOverlay(overlay: Overlay | null): void {
|
|
923
|
+
this.queueSlotWrite(async () => {
|
|
924
|
+
if (overlay === null) {
|
|
925
|
+
this.releaseSlot(CATEGORY_OVERLAY_SLOT);
|
|
926
|
+
this.mountayaMap.clearOverlay();
|
|
927
|
+
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
await this.mountayaMap.setOverlaySpecification(overlay, {
|
|
932
|
+
onMounted: (mounted) => {
|
|
933
|
+
this.adoptSlotMount(CATEGORY_OVERLAY_SLOT, overlay.slug, mounted);
|
|
934
|
+
},
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* addEnrichmentOverlay stacks one enrichment overlay into its own facade slot,
|
|
941
|
+
* keyed on the overlay's slug, leaving the category overlay and every other
|
|
942
|
+
* enrichment drawn.
|
|
943
|
+
*/
|
|
944
|
+
addEnrichmentOverlay(overlay: Overlay): void {
|
|
945
|
+
const slot = `${ENRICHMENT_SLOT_PREFIX}${overlay.slug}`;
|
|
946
|
+
|
|
947
|
+
this.queueSlotWrite(async () => {
|
|
948
|
+
await this.mountayaMap.addEnrichmentSpecification(overlay, {
|
|
949
|
+
onMounted: (mounted) => {
|
|
950
|
+
this.adoptSlotMount(slot, overlay.slug, mounted);
|
|
951
|
+
},
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/** removeEnrichmentOverlay removes the enrichment drawn for `slug`. */
|
|
957
|
+
removeEnrichmentOverlay(slug: string): void {
|
|
958
|
+
this.queueSlotWrite(async () => {
|
|
959
|
+
this.releaseSlot(`${ENRICHMENT_SLOT_PREFIX}${slug}`);
|
|
960
|
+
this.mountayaMap.removeEnrichment(slug);
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* queueSlotWrite chains one facade slot write onto the single tail every other
|
|
966
|
+
* one rides.
|
|
967
|
+
*
|
|
968
|
+
* Mounting waits out a style swap in flight and is therefore asynchronous, while
|
|
969
|
+
* clearing is immediate. Left unordered, a clear issued while a mount is still in
|
|
970
|
+
* flight is overtaken by it and the overlay stays drawn, with nothing on the map
|
|
971
|
+
* to blame, because the slot reports exactly what the caller last asked for. One
|
|
972
|
+
* tail makes the LAST call win, which is what a caller toggling a selection means.
|
|
973
|
+
*
|
|
974
|
+
* A rejection goes to the map's error stream rather than out of the tail: nobody
|
|
975
|
+
* is awaiting these, so an unhandled rejection is the alternative, and one refused
|
|
976
|
+
* mount must not stop the writes queued behind it.
|
|
977
|
+
*/
|
|
978
|
+
private queueSlotWrite(write: () => Promise<void>): void {
|
|
979
|
+
this.pendingSlotWrites += 1;
|
|
980
|
+
this.slotWrites = this.slotWrites
|
|
981
|
+
.then(write)
|
|
982
|
+
.catch((cause: unknown) => {
|
|
983
|
+
this.map.fire("error", {
|
|
984
|
+
error: errorFrom(
|
|
985
|
+
cause,
|
|
986
|
+
"A write to an overlay slot failed. Check what the overlay's mount rejects with.",
|
|
987
|
+
),
|
|
988
|
+
});
|
|
989
|
+
})
|
|
990
|
+
.finally(() => {
|
|
991
|
+
this.pendingSlotWrites -= 1;
|
|
992
|
+
// The queue is at rest when its last write lands, and the slot then holds what its
|
|
993
|
+
// caller asked for last: whoever waits for that overlay is told.
|
|
994
|
+
this.answerOverlayMountWaits();
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/**
|
|
999
|
+
* whenSlotWritesLand answers a promise for every slot write queued so far, or `null` when
|
|
1000
|
+
* none is queued or running.
|
|
1001
|
+
*
|
|
1002
|
+
* A mount is drawn when its turn on the tail comes, which is after the call that asked for
|
|
1003
|
+
* it returned. So a caller that waits for the map to finish drawing waits for this first:
|
|
1004
|
+
* a map with a write still queued is idle and has not been handed what it was asked to draw.
|
|
1005
|
+
* The promise never rejects, since a refused write goes to the map's error stream. `null`
|
|
1006
|
+
* lets a caller with nothing to wait for go on in the same turn.
|
|
1007
|
+
*/
|
|
1008
|
+
whenSlotWritesLand(): Promise<void> | null {
|
|
1009
|
+
return this.pendingSlotWrites === 0 ? null : this.slotWrites;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* adoptSlotMount records what a facade slot just drew and re-applies the studio's
|
|
1014
|
+
* own state onto it.
|
|
1015
|
+
*
|
|
1016
|
+
* Called from the slot's onMounted hook, which fires on the mount AND after every
|
|
1017
|
+
* style-swap replay with the ids that actually reached the style, so this is the
|
|
1018
|
+
* one place both the first draw and the base-map switch are covered. Two pieces of
|
|
1019
|
+
* state need it, and only these two: the pinned tile URLs a timestamped overlay
|
|
1020
|
+
* serves (the facade replays the manifest's own URLs, so a switch would otherwise
|
|
1021
|
+
* snap the overlay back to "now"), and the hillshade illumination (an enrichment
|
|
1022
|
+
* holds a slot of its own, so its layers are out of reach of the per-source fold
|
|
1023
|
+
* {@link adoptManifestMount} runs). Per-layer visibility needs nothing here: the
|
|
1024
|
+
* facade bakes its own hidden set into the layout on both paths.
|
|
1025
|
+
*/
|
|
1026
|
+
private adoptSlotMount(slot: string, slug: string, mounted: MountedSpecification): void {
|
|
1027
|
+
// One overlay replacing another in the same slot never passes through releaseSlot, so a
|
|
1028
|
+
// pin the departing drawing set is forgotten here instead. A pin describes one drawing,
|
|
1029
|
+
// not a source id: an id the manifest reuses would otherwise hand the next overlay a
|
|
1030
|
+
// timestamp chosen for the last one, and stale tiles are the only symptom.
|
|
1031
|
+
//
|
|
1032
|
+
// The slug is what makes that safe to do, because onMounted also fires on every replay,
|
|
1033
|
+
// where dropping the pin is exactly the bug this hook exists to prevent. Same overlay is a
|
|
1034
|
+
// redraw and keeps what it holds; a different one is a new drawing and keeps nothing.
|
|
1035
|
+
//
|
|
1036
|
+
// Here rather than at the head of the queued write, which would read more tidily and would
|
|
1037
|
+
// drop the wrong pin: `setSourceTiles` records synchronously while the write it belongs to
|
|
1038
|
+
// is still queued, so a release up there deletes an override that was just set.
|
|
1039
|
+
const departing = this.slotMounts.get(slot);
|
|
1040
|
+
if (departing) {
|
|
1041
|
+
const replaced = departing.slug !== slug;
|
|
1042
|
+
const incoming = new Set(mounted.sourceIds);
|
|
1043
|
+
for (const sourceId of departing.sourceIds) {
|
|
1044
|
+
if (replaced || !incoming.has(sourceId)) {
|
|
1045
|
+
this.tileOverridesById.delete(sourceId);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// An overlay that was cleared from this slot and is mounted in it again takes back the pins
|
|
1051
|
+
// it left with: the instant its reader pinned is still the one they are looking at, and a
|
|
1052
|
+
// host that states the same overlay again writes no pin a second time. A pin set since the
|
|
1053
|
+
// clear is the newer word and stands. Another overlay takes nothing, and what the first one
|
|
1054
|
+
// left is forgotten with it.
|
|
1055
|
+
const departed = this.departedPins.get(slot);
|
|
1056
|
+
this.departedPins.delete(slot);
|
|
1057
|
+
if (departed?.slug === slug) {
|
|
1058
|
+
for (const sourceId of mounted.sourceIds) {
|
|
1059
|
+
const tiles = departed.tilesById.get(sourceId);
|
|
1060
|
+
if (tiles !== undefined && !this.tileOverridesById.has(sourceId)) {
|
|
1061
|
+
this.tileOverridesById.set(sourceId, tiles);
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
this.slotMounts.set(slot, {
|
|
1067
|
+
layerIds: mounted.layerIds,
|
|
1068
|
+
slug,
|
|
1069
|
+
sourceIds: mounted.sourceIds,
|
|
1070
|
+
});
|
|
1071
|
+
|
|
1072
|
+
for (const sourceId of mounted.sourceIds) {
|
|
1073
|
+
const tiles = this.tileOverridesById.get(sourceId);
|
|
1074
|
+
if (tiles) {
|
|
1075
|
+
this.applySourceTiles(sourceId, tiles);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
this.applyHillshadeIllumination();
|
|
1080
|
+
|
|
1081
|
+
// The category overlay is on the map as its reader left it, pins included. A mount drawn
|
|
1082
|
+
// outside the queue (a replay, a draw the map held back) tells whoever waits for it here.
|
|
1083
|
+
// One drawn by a queued write tells nobody yet: the queue answers as it comes to rest, by
|
|
1084
|
+
// what the slot holds then.
|
|
1085
|
+
if (slot === CATEGORY_OVERLAY_SLOT) {
|
|
1086
|
+
this.answerOverlayMountWaits();
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* releaseSlot forgets what a facade slot held, so nothing it left behind can be
|
|
1092
|
+
* re-applied onto an unrelated layer or source later. Called before the clear
|
|
1093
|
+
* rather than after, so the slot is already forgotten if the clear throws.
|
|
1094
|
+
*
|
|
1095
|
+
* The pins of the overlay that leaves are taken off the live set and kept under the slot and
|
|
1096
|
+
* the overlay's slug ({@link departedPins}), for {@link adoptSlotMount} to hand back to that
|
|
1097
|
+
* overlay alone. That includes a pin recorded after the clear was asked for and before its
|
|
1098
|
+
* turn on the queue came: `setSourceTiles` records at once, and the clear runs later.
|
|
1099
|
+
*/
|
|
1100
|
+
private releaseSlot(slot: string): void {
|
|
1101
|
+
const mount = this.slotMounts.get(slot);
|
|
1102
|
+
if (!mount) {
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
const tilesById = new Map<string, string[]>();
|
|
1107
|
+
for (const sourceId of mount.sourceIds) {
|
|
1108
|
+
const tiles = this.tileOverridesById.get(sourceId);
|
|
1109
|
+
if (tiles !== undefined) {
|
|
1110
|
+
tilesById.set(sourceId, tiles);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
this.tileOverridesById.delete(sourceId);
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
if (tilesById.size > 0) {
|
|
1117
|
+
this.departedPins.set(slot, { slug: mount.slug, tilesById });
|
|
1118
|
+
} else {
|
|
1119
|
+
this.departedPins.delete(slot);
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
this.slotMounts.delete(slot);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* addTileSources draws vector/raster tile sources from the GET /v1/tile-layers manifest,
|
|
1127
|
+
* each one into its own facade slot named by its source id.
|
|
1128
|
+
*
|
|
1129
|
+
* The slot is the facade's, and so is everything that follows from it: the layers land at
|
|
1130
|
+
* their ranks through the one stacking registry, a hidden layer is born hidden, the mount
|
|
1131
|
+
* waits out a style swap in flight, and a base-map switch replays the whole set. What stays
|
|
1132
|
+
* here is the studio's own post-mount work (the synthetic companion layers and the
|
|
1133
|
+
* paint/filter folds) carried by {@link adoptManifestMount} so it survives that replay.
|
|
1134
|
+
*
|
|
1135
|
+
* Restating unchanged content is a no-op: a source structurally identical to the one its
|
|
1136
|
+
* slot already holds is skipped rather than re-mounted, so the hook that re-declares the
|
|
1137
|
+
* manifest on every render never costs a remove-and-redraw. A source that CHANGED under a
|
|
1138
|
+
* live id does re-mount, which is what makes restating it the way to update it.
|
|
1139
|
+
*/
|
|
1140
|
+
addTileSources(sources: TileSchema.TileSource[]): void {
|
|
1141
|
+
for (const source of sources) {
|
|
1142
|
+
this.queueSlotWrite(async () => {
|
|
1143
|
+
// Read the live mount inside the queued write rather than at the call site: the
|
|
1144
|
+
// write may be sitting behind a mount or a removal that has not run yet, and the
|
|
1145
|
+
// question this answers is whether the source is drawn when its own turn comes.
|
|
1146
|
+
const mounted = this.manifestMounts.get(source.id);
|
|
1147
|
+
if (mounted) {
|
|
1148
|
+
if (sameManifestValue(mounted.source, source)) {
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
// A re-mount takes the manifest layers off and then the source, and the companions
|
|
1153
|
+
// bind that same source: MapLibre refuses to remove a source a layer still
|
|
1154
|
+
// references. They are rebuilt from the incoming manifest by the hook below.
|
|
1155
|
+
this.releaseCompanionLayers(mounted);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
await this.mountayaMap.setSpecification(
|
|
1159
|
+
source.id,
|
|
1160
|
+
{ sources: [source] },
|
|
1161
|
+
{
|
|
1162
|
+
onMounted: (mount) => {
|
|
1163
|
+
this.adoptManifestMount(source, mount);
|
|
1164
|
+
},
|
|
1165
|
+
},
|
|
1166
|
+
);
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* removeTileSources removes the layers + sources for the given tile-source ids.
|
|
1173
|
+
*
|
|
1174
|
+
* Queued onto the same tail the mounts ride, because a removal is immediate where a mount
|
|
1175
|
+
* is not: issued while a mount is still in flight, an unqueued removal is overtaken by it
|
|
1176
|
+
* and the source stays drawn, with the slot reporting exactly what the caller last asked
|
|
1177
|
+
* for and nothing on the map to blame.
|
|
1178
|
+
*/
|
|
1179
|
+
removeTileSources(ids: string[]): void {
|
|
1180
|
+
this.queueSlotWrite(async () => {
|
|
1181
|
+
for (const id of ids) {
|
|
1182
|
+
this.releaseManifestMount(id);
|
|
1183
|
+
}
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
/**
|
|
1188
|
+
* adoptManifestMount records what a manifest slot just drew and re-applies the studio's own
|
|
1189
|
+
* cartography onto it.
|
|
1190
|
+
*
|
|
1191
|
+
* Called from the slot's onMounted hook, which fires on the mount AND after every
|
|
1192
|
+
* style-swap replay with the ids that actually reached the style, so this is the one place
|
|
1193
|
+
* both the first draw and the base-map switch are covered. It attaches the synthetic
|
|
1194
|
+
* companion layers the manifest does not carry, re-applies the pinned tile URLs (the facade
|
|
1195
|
+
* replays the specification it was mounted with, so a switch would otherwise snap a
|
|
1196
|
+
* timestamped source back to "now"), and re-runs the paint/filter folds so the itinerary
|
|
1197
|
+
* keeps its color, focus, suppressions and edit de-emphasis and the zones keep their
|
|
1198
|
+
* time-bound treatment. Every fold reads its base fresh from the manifest record and writes
|
|
1199
|
+
* an absolute value, so running them again is idempotent.
|
|
1200
|
+
*
|
|
1201
|
+
* Per-layer visibility needs nothing here: the facade bakes its own hidden set into each
|
|
1202
|
+
* layer's layout on both paths.
|
|
1203
|
+
*/
|
|
1204
|
+
private adoptManifestMount(source: TileSchema.TileSource, mounted: MountedSpecification): void {
|
|
1205
|
+
// The companions come first so the folds below find them present and write their
|
|
1206
|
+
// opacity/filter/edit overrides onto them in the same pass.
|
|
1207
|
+
const companionLayerIds: string[] = [];
|
|
1208
|
+
if (hasItineraryLayer(source)) {
|
|
1209
|
+
// Warm the chevron sprite so the indicator's first paint finds its image present;
|
|
1210
|
+
// the missing-image resolver remains the net if the warm-load loses the race.
|
|
1211
|
+
void loadDirectionArrowIcon(this.map);
|
|
1212
|
+
this.addDirectionLayers(source, companionLayerIds);
|
|
1213
|
+
this.addRoadAccessLayers(source, companionLayerIds, mounted.layerIds);
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
if (hasZoneLayer(source)) {
|
|
1217
|
+
// The clock sprite and the per-level diagonal-stripe pattern images are warmed here so
|
|
1218
|
+
// the badge layer's first paint and the fill layer's fill-pattern both find their
|
|
1219
|
+
// images present.
|
|
1220
|
+
void loadZoneClockIcon(this.map, this.icons);
|
|
1221
|
+
void loadZoneStripeIcons(this.map);
|
|
1222
|
+
// The diagonal-stripe FILL rides LayerRank.ZONE beside the base fill, added after it so
|
|
1223
|
+
// it lands on top: beforeIdForRank only anchors an insert beneath a STRICTLY-higher-ranked
|
|
1224
|
+
// tracked layer, so of two same-rank layers the one added LAST is placed above. The clock
|
|
1225
|
+
// badges are no companion of this source: they stand a rank above the zone band, on one
|
|
1226
|
+
// layer every zone source shares (drawZoneBadges below).
|
|
1227
|
+
this.addZoneStripeLayer(source, companionLayerIds);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Recorded before the folds because they walk this index to find the manifest layers
|
|
1231
|
+
// they write onto: a fold running against the previous mount would write onto the ids
|
|
1232
|
+
// of a drawing that is no longer there.
|
|
1233
|
+
this.manifestMounts.set(source.id, {
|
|
1234
|
+
companionLayerIds,
|
|
1235
|
+
layerIds: mounted.layerIds,
|
|
1236
|
+
source,
|
|
1237
|
+
});
|
|
1238
|
+
|
|
1239
|
+
for (const sourceId of mounted.sourceIds) {
|
|
1240
|
+
const tiles = this.tileOverridesById.get(sourceId);
|
|
1241
|
+
if (tiles) {
|
|
1242
|
+
this.applySourceTiles(sourceId, tiles);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
if (hasItineraryLayer(source)) {
|
|
1247
|
+
// The tint is the BASE color the folds below layer opacity and width onto, and the
|
|
1248
|
+
// color the edit ghost is drawn in, so it is re-asserted first. Gated on a set override so a surface that never tints
|
|
1249
|
+
// (the in-app studio, the share view) issues no line-color or icon-image write onto its
|
|
1250
|
+
// itinerary layers at all. Edit styling runs last so its per-feature paint override
|
|
1251
|
+
// sits on top of the emphasis-derived base it reads.
|
|
1252
|
+
if (this.itinerarySegmentColor !== null) {
|
|
1253
|
+
this.applyItinerarySegmentColor();
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
this.applyItineraryEmphasis();
|
|
1257
|
+
this.applyItineraryExclusions();
|
|
1258
|
+
this.applyEditStyling();
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
if (hasZoneLayer(source)) {
|
|
1262
|
+
// The time styling pins every zone to the uniform base opacity and marks its
|
|
1263
|
+
// out-of-window zones with the stripe overlay against the current reference,
|
|
1264
|
+
// rather than leaving them at the manifest's own (possibly opaque) opacity. The
|
|
1265
|
+
// exclusion composes with it rather than replacing it: the opacity is a paint write
|
|
1266
|
+
// and the suppression a filter write, so the two ride independent layer properties.
|
|
1267
|
+
this.applyZoneTimeStyling();
|
|
1268
|
+
this.applyZoneExclusions();
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
// The clock badges are read off every zone layer mounted: this source's from here on, or
|
|
1272
|
+
// none of its own where the source came back under its id with no zone layer. Stated after
|
|
1273
|
+
// every mount because the hook also fires on the style a base-map switch brings in, which
|
|
1274
|
+
// holds neither the badge layer nor its source.
|
|
1275
|
+
this.drawZoneBadges();
|
|
1276
|
+
|
|
1277
|
+
// Re-light any hillshade layer this source carries with the last illumination direction:
|
|
1278
|
+
// this is the point at which the layers exist to receive the time-of-day shading.
|
|
1279
|
+
this.applyHillshadeIllumination();
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* releaseCompanionLayers takes the synthetic layers a manifest mount attached back off the
|
|
1284
|
+
* map, the edit ghost of each of its line layers among them.
|
|
1285
|
+
*
|
|
1286
|
+
* Every one of them is static: the chevrons an overview source carries are drawn once and
|
|
1287
|
+
* never animated, which is why nothing here touches the flow animator. Removing a layer also
|
|
1288
|
+
* forgets what the facade knows about it, its rank and its visibility intent. Both must go:
|
|
1289
|
+
* a future source reusing the id should start at its manifest default rather than inherit a
|
|
1290
|
+
* stale hidden state, and a rank left behind would anchor later inserts against a layer
|
|
1291
|
+
* nobody is drawing.
|
|
1292
|
+
*/
|
|
1293
|
+
private releaseCompanionLayers(mount: ManifestMount): void {
|
|
1294
|
+
for (const layerId of mount.companionLayerIds) {
|
|
1295
|
+
this.forgetLayerRank(layerId);
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
// A ghost stands only while an edit does, so it is named from the line rather than
|
|
1299
|
+
// recorded with the mount; the removal is a no-op for a line drawing none.
|
|
1300
|
+
for (const layer of mount.source.layers) {
|
|
1301
|
+
if (layer.source_layer === ITINERARY_LINE_SOURCE_LAYER) {
|
|
1302
|
+
this.forgetLayerRank(editGhostLayerId(layer.id));
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* releaseManifestMount tears down everything one manifest source has on the map: its
|
|
1309
|
+
* companion layers first (MapLibre rejects removing a source a layer still references),
|
|
1310
|
+
* then the pin it was serving, then the slot itself. Idempotent: an id holding nothing is
|
|
1311
|
+
* a no-op, which is what lets removeTileSources call it unguarded for a set the caller
|
|
1312
|
+
* assembled from its own bookkeeping.
|
|
1313
|
+
*/
|
|
1314
|
+
private releaseManifestMount(id: string): void {
|
|
1315
|
+
const mount = this.manifestMounts.get(id);
|
|
1316
|
+
if (!mount) {
|
|
1317
|
+
return;
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
this.releaseCompanionLayers(mount);
|
|
1321
|
+
// A pin describes one drawing. Kept past it, a source id the manifest reuses would hand
|
|
1322
|
+
// the next drawing a timestamp chosen for this one, and stale tiles are the only symptom.
|
|
1323
|
+
this.tileOverridesById.delete(id);
|
|
1324
|
+
this.mountayaMap.removeSpecification(id);
|
|
1325
|
+
this.manifestMounts.delete(id);
|
|
1326
|
+
// The badges are read off the zone layers left, and go with the last of them.
|
|
1327
|
+
this.drawZoneBadges();
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* manifestLayers walks every manifest layer currently drawn, across every mounted source.
|
|
1332
|
+
*
|
|
1333
|
+
* Each fold keys off the layer's own manifest record (its pristine paint, filter, type and
|
|
1334
|
+
* source-layer) so they share this one walk over what is live rather than each holding a
|
|
1335
|
+
* copy of the source list.
|
|
1336
|
+
*/
|
|
1337
|
+
private *manifestLayers(): Generator<TileSchema.TileLayer> {
|
|
1338
|
+
for (const mount of this.manifestMounts.values()) {
|
|
1339
|
+
yield* mount.source.layers;
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
/**
|
|
1344
|
+
* repaintBustedTiles re-folds freshly-busted tile sources back into the render on a static
|
|
1345
|
+
* camera. bustItineraryTileCache (setTiles) evicts and refetches the tiles, but MapLibre only
|
|
1346
|
+
* folds the reloaded tiles into the render on a viewport change: a same-camera bust leaves the
|
|
1347
|
+
* overlay blank until a manual zoom (the "blank until zoom" bug). A brief zoom jog (out a tenth
|
|
1348
|
+
* of a level, then back to the original zoom) drives that reconcile with no lasting viewport
|
|
1349
|
+
* change. Skipped when no busted source is on the map, and reduced to a plain repaint while a
|
|
1350
|
+
* camera animation is already running (it re-renders on its own). `_removed` is the flag
|
|
1351
|
+
* MapLibre raises in `remove()`, read so the deferred restore never eases a map that is gone.
|
|
1352
|
+
*
|
|
1353
|
+
* The restore waits on the jog's `moveend`, and a gesture landing during the jog fires that
|
|
1354
|
+
* too: MapLibre stops an ease for the gesture, and by then the map reports the gesture moving
|
|
1355
|
+
* it. Restoring there would ease back over the zoom the user just chose, so the jog leaves the
|
|
1356
|
+
* camera to them. The wait is held through the event engine, so a dispose before the jog ends
|
|
1357
|
+
* takes it off rather than letting it move a map that may already belong to the next client.
|
|
1358
|
+
*/
|
|
1359
|
+
private repaintBustedTiles(sourceIds: readonly string[]): void {
|
|
1360
|
+
const map = this.map;
|
|
1361
|
+
if (!sourceIds.some((id) => map.getSource(id))) {
|
|
1362
|
+
return;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
// `isMoving()` alone answers it. From MapLibre 6 on, the Map COMPOSES its Camera rather than
|
|
1366
|
+
// extending it and forwards no `isEasing`, and `isMoving` is true for the whole of an ease
|
|
1367
|
+
// (the camera raises `_moving` before the first frame and lowers it after the last), so it
|
|
1368
|
+
// answers everything an `isEasing` term would.
|
|
1369
|
+
if (map.isMoving()) {
|
|
1370
|
+
map.triggerRepaint();
|
|
1371
|
+
|
|
1372
|
+
return;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
const zoom = map.getZoom();
|
|
1376
|
+
// The restore listens before the jog starts. A reader who asks for reduced motion gets an
|
|
1377
|
+
// ease applied in one step, with its `moveend` fired before easeTo returns: a listener
|
|
1378
|
+
// attached after the call would miss that one and wait for the end of the reader's next
|
|
1379
|
+
// move, to ease back over the zoom they chose.
|
|
1380
|
+
const detach = this.events.on("moveend", () => {
|
|
1381
|
+
detach();
|
|
1382
|
+
|
|
1383
|
+
if (map.isMoving() || map._removed) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
map.easeTo({ duration: REPAINT_JOG_MS, zoom });
|
|
1388
|
+
});
|
|
1389
|
+
map.easeTo({ duration: REPAINT_JOG_MS, zoom: zoom - 0.1 });
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* bustableSources lists the mounted tile sources a refresh should re-point, picked by the
|
|
1394
|
+
* predicate that names the family (itinerary or zone) and paired with the URLs each is
|
|
1395
|
+
* currently meant to serve.
|
|
1396
|
+
*
|
|
1397
|
+
* The URLs are the pinned ones where a pin exists and the manifest's own otherwise, because
|
|
1398
|
+
* a bust re-points a live source: rebuilding it from the manifest alone would drop a
|
|
1399
|
+
* timestamp the layers panel chose and snap that source silently back to "now".
|
|
1400
|
+
*/
|
|
1401
|
+
private bustableSources(
|
|
1402
|
+
matches: (source: TileSchema.TileSource) => boolean,
|
|
1403
|
+
): Array<{ id: string; tiles: readonly string[] }> {
|
|
1404
|
+
const sources: Array<{ id: string; tiles: readonly string[] }> = [];
|
|
1405
|
+
for (const mount of this.manifestMounts.values()) {
|
|
1406
|
+
if (matches(mount.source)) {
|
|
1407
|
+
sources.push({
|
|
1408
|
+
id: mount.source.id,
|
|
1409
|
+
tiles: this.tileOverridesById.get(mount.source.id) ?? mount.source.tiles,
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
return sources;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* refreshItineraryTiles tells MapLibre to refetch every tile of the currently-
|
|
1419
|
+
* mounted itinerary tile sources, the post-commit seam the write-through path
|
|
1420
|
+
* drives so a freshly-persisted segment or waypoint shows up at the current
|
|
1421
|
+
* camera without a pan or zoom-change to evict the tile cache. It busts each
|
|
1422
|
+
* source's URLs (setTiles) then reconciles them via repaintBustedTiles: setTiles evicts +
|
|
1423
|
+
* refetches but does not fold the reloaded tiles into a static-camera render, so without the
|
|
1424
|
+
* reconcile the itinerary stays blank until the next viewport change. A no-op when no itinerary
|
|
1425
|
+
* tile sources are mounted.
|
|
1426
|
+
*
|
|
1427
|
+
* `bustToken`, when given (a collaborator change frame's stream id), scopes
|
|
1428
|
+
* the refetch to a deterministic per-change URL every peer shares; absent, a
|
|
1429
|
+
* wall-clock token forces a plain cache-miss: the local post-commit path,
|
|
1430
|
+
* which has no change frame to key on.
|
|
1431
|
+
*/
|
|
1432
|
+
refreshItineraryTiles(bustToken?: string): void {
|
|
1433
|
+
// The set of itinerary tile sources is derived from what is mounted so a
|
|
1434
|
+
// base-terrain replay never sees a stale list; every source that paints an
|
|
1435
|
+
// itinerary line or point source-layer rides through. Each source's tile
|
|
1436
|
+
// URLs are rewritten with a fresh bust token so MapLibre evicts its
|
|
1437
|
+
// in-memory tile cache AND the browser HTTP cache misses on the new URLs:
|
|
1438
|
+
// `source.load()` alone re-initialises the TileJSON but leaves cached
|
|
1439
|
+
// tile data painting the stale geometry, which the user observed as
|
|
1440
|
+
// ghost waypoints / segments lingering at the edit zoom. The layers,
|
|
1441
|
+
// paint expressions, emphasis, and exclusions are untouched; only the
|
|
1442
|
+
// tile URL templates change.
|
|
1443
|
+
const itinerarySources = this.bustableSources(hasItineraryLayer);
|
|
1444
|
+
if (itinerarySources.length === 0) {
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// The bust helper owns the param choice: a supplied change-feed token rides
|
|
1449
|
+
// the `revision` param the backend reads (token-scoped immutable caching of
|
|
1450
|
+
// the latest content), while an absent one falls back to a monotonic
|
|
1451
|
+
// wall-clock `_t` token that only forces a cache-miss on the same tiles.
|
|
1452
|
+
bustItineraryTileCache(this.map, itinerarySources, bustToken);
|
|
1453
|
+
|
|
1454
|
+
// setTiles refetches the tiles but MapLibre does not fold them into a static-camera render;
|
|
1455
|
+
// repaintBustedTiles jogs the zoom a notch and back to reconcile them in place.
|
|
1456
|
+
this.repaintBustedTiles(itinerarySources.map((source) => source.id));
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
/**
|
|
1460
|
+
* refreshZoneTiles tells MapLibre to refetch every tile of the currently-
|
|
1461
|
+
* mounted zone tile sources, the post-mutation seam the zone write paths
|
|
1462
|
+
* drive (create / delete / an edit teardown after a reshape commit) so a
|
|
1463
|
+
* freshly-persisted or deleted zone shows up at the current camera without a
|
|
1464
|
+
* pan or zoom-change to evict the tile cache. It mirrors refreshItineraryTiles
|
|
1465
|
+
* exactly: the same setTiles bust-token eviction plus the repaintBustedTiles zoom jog
|
|
1466
|
+
* that lands the refetched tiles on a static camera. Only the source predicate
|
|
1467
|
+
* differs (hasZoneLayer vs hasItineraryLayer). A no-op when no zone tile sources are
|
|
1468
|
+
* mounted.
|
|
1469
|
+
*
|
|
1470
|
+
* It must run when the map is idle, NOT mid-edit: an edit hides the zone's
|
|
1471
|
+
* tile copy and the live draw engine paints the in-flight shape, and a bust
|
|
1472
|
+
* fired during that dual-render does not repaint the saved geometry at the
|
|
1473
|
+
* current zoom (the same setTiles-mid-edit constraint the itinerary commit
|
|
1474
|
+
* path observes). The zone editCommit tool deliberately does NOT refetch (it
|
|
1475
|
+
* keeps the edit armed and the live draft covers the in-edit view) so the
|
|
1476
|
+
* refetch is owned by the edit TEARDOWN instead: editCancel and the cross-
|
|
1477
|
+
* family teardown (which the panel-close / sidenav-back path routes through)
|
|
1478
|
+
* call this right AFTER endZoneEdit disposes the engine, so a reshape saved
|
|
1479
|
+
* during a still-armed edit lands its current geometry into the tile by the
|
|
1480
|
+
* time the suppression filter clears. The create/delete paths run while the
|
|
1481
|
+
* map is already idle.
|
|
1482
|
+
*/
|
|
1483
|
+
refreshZoneTiles(): void {
|
|
1484
|
+
// Derive the zone tile sources from what is mounted so a base-terrain replay
|
|
1485
|
+
// never sees a stale list; every source that paints a zone fill, line, or
|
|
1486
|
+
// point source-layer rides through. Only the tile URL templates change (a
|
|
1487
|
+
// fresh bust token): the layers, level paint and time-bound styling are
|
|
1488
|
+
// untouched, and the clock badges are placed again as the tiles come back.
|
|
1489
|
+
const zoneSources = this.bustableSources(hasZoneLayer);
|
|
1490
|
+
if (zoneSources.length === 0) {
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
// Zones carry no revision pin, so the bust falls back to the monotonic
|
|
1495
|
+
// wall-clock `_t` token the helper picks when no revision is passed: the
|
|
1496
|
+
// token always advances across consecutive mutations within a browser
|
|
1497
|
+
// session, the same reasoning the itinerary bust relies on.
|
|
1498
|
+
bustItineraryTileCache(this.map, zoneSources);
|
|
1499
|
+
|
|
1500
|
+
// Reconcile the busted zone tiles on a static camera, the same zoom jog the itinerary
|
|
1501
|
+
// refresh applies (see repaintBustedTiles).
|
|
1502
|
+
this.repaintBustedTiles(zoneSources.map((source) => source.id));
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
/**
|
|
1506
|
+
* setSourceTiles refreshes a tile source's URLs in place (e.g. an overlay
|
|
1507
|
+
* timestamp change) without a remove/add, so the tiles refetch with no
|
|
1508
|
+
* flicker.
|
|
1509
|
+
*/
|
|
1510
|
+
setSourceTiles(sourceId: string, tiles: string[]): void {
|
|
1511
|
+
// Remember the pin so a style reload (a base-map switch) serves the timestamped URLs
|
|
1512
|
+
// rather than reverting to the manifest's untimestamped ones. The facade replays the
|
|
1513
|
+
// specification the slot was mounted with (the manifest's own URLs) so the pin is
|
|
1514
|
+
// re-asserted onto the fresh source from the slot's onMounted rather than riding the
|
|
1515
|
+
// replay itself.
|
|
1516
|
+
this.tileOverridesById.set(sourceId, tiles);
|
|
1517
|
+
|
|
1518
|
+
this.applySourceTiles(sourceId, tiles);
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* applySourceTiles writes the tile URLs onto a live source, the write half of
|
|
1523
|
+
* {@link setSourceTiles} that a facade slot's onMounted replays after a base-map
|
|
1524
|
+
* switch.
|
|
1525
|
+
*
|
|
1526
|
+
* setTiles refreshes the URLs in place on the already-present source so it
|
|
1527
|
+
* refetches without a remove/add (no flicker). The source is updated directly:
|
|
1528
|
+
* deferring to a style-load event would drop the refresh while any other source is
|
|
1529
|
+
* mid-load (the event has already fired and never re-fires). Only raster/vector
|
|
1530
|
+
* tile sources expose setTiles, so narrow on the method before calling rather than
|
|
1531
|
+
* on the source kind.
|
|
1532
|
+
*/
|
|
1533
|
+
private applySourceTiles(sourceId: string, tiles: string[]): void {
|
|
1534
|
+
const source = this.map.getSource(sourceId);
|
|
1535
|
+
if (source && "setTiles" in source) {
|
|
1536
|
+
// The guard proves the member and not its signature, so the two kinds of source that
|
|
1537
|
+
// declare it are asserted.
|
|
1538
|
+
(source as RasterTileSource | VectorTileSource).setTiles(tiles);
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
/**
|
|
1543
|
+
* setOverlayQueryLayers sets which layer ids a right-click overlay-feature
|
|
1544
|
+
* query inspects: the active overlay's vector layers. An empty set makes that
|
|
1545
|
+
* query a no-op. The client's queryOverlayFeaturesAt reads the scope back
|
|
1546
|
+
* through getOverlayQueryLayerIds.
|
|
1547
|
+
*/
|
|
1548
|
+
setOverlayQueryLayers(layerIds: string[]): void {
|
|
1549
|
+
// Store the scope verbatim; queryOverlayFeaturesAt reads it on each query, so
|
|
1550
|
+
// there is no map write here and nothing to replay across a style reload.
|
|
1551
|
+
this.overlayQueryLayerIds = layerIds;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
/**
|
|
1555
|
+
* getOverlayQueryLayerIds returns the layer ids a right-click overlay-feature
|
|
1556
|
+
* query is currently scoped to, the read seam the client's
|
|
1557
|
+
* queryOverlayFeaturesAt picking method reaches for. The picking lives on the
|
|
1558
|
+
* client (it composes with the POI/terrain readouts), so the scope it queries
|
|
1559
|
+
* is exposed here rather than the query being moved.
|
|
1560
|
+
*/
|
|
1561
|
+
getOverlayQueryLayerIds(): string[] {
|
|
1562
|
+
return this.overlayQueryLayerIds;
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* getZoneQueryLayerIds returns the layer ids a right-click zone query inspects:
|
|
1567
|
+
* every mounted zone geometry layer. Unlike the overlay
|
|
1568
|
+
* query scope (a stored, hook-set list) the zone scope is DERIVED fresh from the
|
|
1569
|
+
* live tile sources each call: the manifest assigns zone layers unstable
|
|
1570
|
+
* per-source ids, so the scope is resolved by matching each tracked source-layer
|
|
1571
|
+
* against the stable zone source-layer contract (isZoneSourceLayer) rather than
|
|
1572
|
+
* held statically. Empty when no zone tile source is mounted, making the
|
|
1573
|
+
* client's zoneAtPoint a clean no-op then. The client's zoneAtPoint picking
|
|
1574
|
+
* method reads the scope back through this seam, mirroring how
|
|
1575
|
+
* queryOverlayFeaturesAt reads getOverlayQueryLayerIds.
|
|
1576
|
+
*/
|
|
1577
|
+
getZoneQueryLayerIds(): string[] {
|
|
1578
|
+
const layerIds: string[] = [];
|
|
1579
|
+
for (const layer of this.manifestLayers()) {
|
|
1580
|
+
if (isZoneSourceLayer(layer.source_layer)) {
|
|
1581
|
+
layerIds.push(layer.id);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
return layerIds;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* ensureOverlayInZoomRange eases the camera's zoom into the overlay's
|
|
1590
|
+
* `[minzoom, maxzoom]` range when the current zoom falls outside it. A no-op
|
|
1591
|
+
* when the current zoom is already in range.
|
|
1592
|
+
*
|
|
1593
|
+
* The easing itself is the façade's: a layer outside its zoom window renders nothing and
|
|
1594
|
+
* reports nothing, which is a trap any consumer of the tile manifest hits, so the answer
|
|
1595
|
+
* to it belongs in the published package. This resolves the window (the studio holds an
|
|
1596
|
+
* overlay, not a specification) and hands it over.
|
|
1597
|
+
*/
|
|
1598
|
+
ensureOverlayInZoomRange(overlay: OverlayZoomRange): void {
|
|
1599
|
+
this.mountayaMap.easeIntoZoomRange({ maxzoom: overlay.maxzoom, minzoom: overlay.minzoom });
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* prewarmItineraryIcons asks the map to pre-register the waypoint and endpoint
|
|
1604
|
+
* sprites the active itinerary's tiles will paint, so the first paint never logs
|
|
1605
|
+
* a missing-image warning for a sprite the tiles always reference. Best-effort
|
|
1606
|
+
* and render-only: it never throws and an unknown glyph is silently skipped.
|
|
1607
|
+
*/
|
|
1608
|
+
prewarmItineraryIcons(icons: { color: string; icon: string }[]): void {
|
|
1609
|
+
// Fire-and-forget the sprite registrations. loadWaypointIcon is idempotent
|
|
1610
|
+
// (an already-present id short-circuits before AND after the async raster)
|
|
1611
|
+
// so a re-entry from the studio sync hook is a no-op for sprites that
|
|
1612
|
+
// already landed. The missing-image resolver stays as the safety net.
|
|
1613
|
+
for (const entry of icons) {
|
|
1614
|
+
void loadWaypointIcon(this.map, entry.icon, entry.color, this.icons);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
/**
|
|
1619
|
+
* setItineraryEmphasis rebuilds the opacity of the itinerary tile geometries to
|
|
1620
|
+
* reflect the given focus, dimming the unfocused ones. It only touches the
|
|
1621
|
+
* itinerary layers and persists the last emphasis so it is re-asserted after the
|
|
1622
|
+
* tile layers are re-added on a base-terrain switch.
|
|
1623
|
+
*/
|
|
1624
|
+
setItineraryEmphasis(target: ItineraryEmphasis): void {
|
|
1625
|
+
// Remember the target so the override survives a base-map switch: setStyle
|
|
1626
|
+
// tears down and replays the tile layers, and each slot's onMounted re-asserts
|
|
1627
|
+
// the paint over what came back.
|
|
1628
|
+
this.itineraryEmphasis = target;
|
|
1629
|
+
this.applyItineraryEmphasis();
|
|
1630
|
+
// The emphasis writes the opacity of every itinerary line, of the casing and of the
|
|
1631
|
+
// direction companions, which are the properties a segment edit overrides for the one
|
|
1632
|
+
// segment under edit. So the override is laid over the emphasis again, as a slot's
|
|
1633
|
+
// onMounted does: the edited segment keeps its ghost and its hidden casing and chevrons
|
|
1634
|
+
// whatever emphasis is written while the edit is open.
|
|
1635
|
+
if (this.editStyledSegmentId !== null) {
|
|
1636
|
+
this.applyEditStyling();
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
/**
|
|
1641
|
+
* setItinerarySegmentColor paints every itinerary segment in one color instead of
|
|
1642
|
+
* each segment's own, or restores the manifest's per-segment expression with null.
|
|
1643
|
+
* It rewrites line-color on the solid + dashed line layers and swaps the two
|
|
1644
|
+
* synthetic endpoint sprites (flag-start / flag-end, which carry the SEGMENT color)
|
|
1645
|
+
* on the points symbol layer, leaving an author's own waypoint pins untouched. The
|
|
1646
|
+
* color persists so it is re-asserted after the tile layers are re-added on a
|
|
1647
|
+
* base-terrain switch. An unchanged value is a no-op, so a surface that never tints
|
|
1648
|
+
* issues no write at all.
|
|
1649
|
+
*/
|
|
1650
|
+
setItinerarySegmentColor(color: string | null): void {
|
|
1651
|
+
if (this.itinerarySegmentColor === color) {
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
this.itinerarySegmentColor = color;
|
|
1656
|
+
this.applyItinerarySegmentColor();
|
|
1657
|
+
// The edit ghost paints the segment under edit in the tint, so it takes the new one.
|
|
1658
|
+
if (this.editStyledSegmentId !== null) {
|
|
1659
|
+
this.applyEditStyling();
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* setAccessRestrictionsVisibility shows or hides the restricted stretches of every itinerary
|
|
1665
|
+
* source: their stripes and their warning icons. The layers stay in the style while hidden, so
|
|
1666
|
+
* showing them again fetches nothing, and the choice is kept for the layers a later mount or a
|
|
1667
|
+
* base-map switch creates. An unchanged value is a no-op.
|
|
1668
|
+
*/
|
|
1669
|
+
setAccessRestrictionsVisibility(visible: boolean): void {
|
|
1670
|
+
if (this.accessRestrictionsVisible === visible) {
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
this.accessRestrictionsVisible = visible;
|
|
1675
|
+
for (const mount of this.manifestMounts.values()) {
|
|
1676
|
+
const line = roadAccessLineLayerOf(mount.source);
|
|
1677
|
+
if (!line) {
|
|
1678
|
+
continue;
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
for (const layerId of [roadAccessStripeLayerId(line.id), roadAccessIconLayerId(line.id)]) {
|
|
1682
|
+
if (this.map.getLayer(layerId)) {
|
|
1683
|
+
this.map.setLayoutProperty(layerId, "visibility", visible ? "visible" : "none");
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* setZoneTimeReference sets the epoch (seconds) the zone tile layers evaluate their time-bound
|
|
1691
|
+
* styling against, then re-applies the styling: every zone keeps the same uniform base opacity,
|
|
1692
|
+
* and an out-of-window zone additionally gains the diagonal-stripe overlay fill + a clock badge
|
|
1693
|
+
* while an in-window (or unbounded) zone shows neither. The reference is injected as a literal
|
|
1694
|
+
* into the filter the stripes paint under and the badges are read under (MapLibre cannot read the clock), so the studio's
|
|
1695
|
+
* driver re-issues it (on the slider value, or as each clock minute turns and on a camera move
|
|
1696
|
+
* once the minute has turned when no value is pinned) to keep the styling current without a tile
|
|
1697
|
+
* refetch. The value is remembered so it is re-asserted after the zone layers are re-added on a
|
|
1698
|
+
* base-terrain switch. A no-op-to-paint when no zone layers are mounted (the reference is still
|
|
1699
|
+
* recorded for the replay).
|
|
1700
|
+
*/
|
|
1701
|
+
setZoneTimeReference(epochSeconds: number): void {
|
|
1702
|
+
// Remember the reference so the styling survives a base-map switch: setStyle
|
|
1703
|
+
// tears down and replays the zone layers, and each slot's onMounted re-asserts
|
|
1704
|
+
// the opacity + stripe filter over what came back.
|
|
1705
|
+
this.zoneTimeReference = epochSeconds;
|
|
1706
|
+
this.applyZoneTimeStyling();
|
|
1707
|
+
// The set of out-of-window zones moved with the reference: the badges follow it.
|
|
1708
|
+
this.drawZoneBadges();
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* setEditedZone marks (or, with null, clears) the zone whose tile copy is
|
|
1713
|
+
* suppressed while a zone edit is armed, then re-applies the zone exclusion
|
|
1714
|
+
* filter. It is the seam the client's begin/endZoneEdit drive in place of
|
|
1715
|
+
* touching the exclusion state directly: beginZoneEdit sets the edited id so the
|
|
1716
|
+
* persisted copy stops painting under the live TerraDraw feature, endZoneEdit
|
|
1717
|
+
* clears it so the saved geometry repaints. The id persists so it is re-asserted
|
|
1718
|
+
* after the zone layers are re-added on a base-terrain switch. A no-op-to-paint
|
|
1719
|
+
* when no zone layers are mounted (the id is still recorded for the replay).
|
|
1720
|
+
*/
|
|
1721
|
+
setEditedZone(zoneId: string | null): void {
|
|
1722
|
+
// Remember the id so the suppression survives a base-map switch: setStyle
|
|
1723
|
+
// tears down and replays the zone layers with the manifest's own filters, so
|
|
1724
|
+
// applyZoneExclusions is run again from the slot's onMounted to re-assert the filter.
|
|
1725
|
+
this.excludedZoneId = zoneId;
|
|
1726
|
+
this.applyZoneExclusions();
|
|
1727
|
+
// The zone under edit carries no badge, and gets it back as the edit ends.
|
|
1728
|
+
this.drawZoneBadges();
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* setEditedWaypoint marks (or, with null, clears) the custom-point waypoint whose
|
|
1733
|
+
* committed tile copy is suppressed while a waypoint edit is armed, then re-applies
|
|
1734
|
+
* the itinerary exclusion filter. It is the seam the client's begin/endWaypointEdit
|
|
1735
|
+
* drive in place of touching the exclusion state directly: beginWaypointEdit sets the
|
|
1736
|
+
* edited id so the persisted point stops painting under the live DraftWaypointMarker,
|
|
1737
|
+
* endWaypointEdit clears it so the committed point repaints. The id persists so it is
|
|
1738
|
+
* re-asserted after the point layers are re-added on a tile re-add / base-terrain
|
|
1739
|
+
* switch. A no-op-to-paint when the point layers aren't mounted (the id is still
|
|
1740
|
+
* recorded for the replay).
|
|
1741
|
+
*/
|
|
1742
|
+
setEditedWaypoint(waypointId: string | null): void {
|
|
1743
|
+
// Remember the id so the suppression survives a base-map switch: setStyle tears
|
|
1744
|
+
// down and replays the tile layers with the manifest's own filters, so
|
|
1745
|
+
// applyItineraryExclusions is run again from the slot's onMounted to re-assert it.
|
|
1746
|
+
this.excludedWaypointId = waypointId;
|
|
1747
|
+
this.applyItineraryExclusions();
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
/**
|
|
1751
|
+
* setItineraryExclusions suppresses the given itinerary features from the tile
|
|
1752
|
+
* render by filtering them out of the matching tile layers. It only touches the
|
|
1753
|
+
* itinerary layers and persists the last set so it is re-asserted after the tile
|
|
1754
|
+
* layers are re-added on a base-terrain switch. Empty lists restore the full
|
|
1755
|
+
* itinerary.
|
|
1756
|
+
*/
|
|
1757
|
+
setItineraryExclusions(exclusions: ItineraryExclusions): void {
|
|
1758
|
+
// Remember the set so the suppression survives a base-map switch: setStyle
|
|
1759
|
+
// tears down and replays the tile layers with the manifest's own filters, so
|
|
1760
|
+
// applyItineraryExclusions is run again from the slot's onMounted to re-assert the
|
|
1761
|
+
// filter.
|
|
1762
|
+
this.itineraryExclusions = exclusions;
|
|
1763
|
+
this.applyItineraryExclusions();
|
|
1764
|
+
// The edit ghost leaves out an excluded segment as its line does.
|
|
1765
|
+
if (this.editStyledSegmentId !== null) {
|
|
1766
|
+
this.applyEditStyling();
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* setActiveItinerarySegments registers the LineString coordinate arrays the
|
|
1772
|
+
* waypoint magnet should snap onto, the active itinerary's segment geometries,
|
|
1773
|
+
* so a click near one of them lands the draft marker on the line. An empty list
|
|
1774
|
+
* disables the magnet.
|
|
1775
|
+
*/
|
|
1776
|
+
setActiveItinerarySegments(lines: readonly Position[][]): void {
|
|
1777
|
+
// Hold the geometries imperatively (not reactive): the magnet reads them
|
|
1778
|
+
// on every pointer-move frame from the point engine, and the studio
|
|
1779
|
+
// re-sets the list whenever the active itinerary's segments change. An
|
|
1780
|
+
// empty list disables the magnet (no active itinerary, or none of its
|
|
1781
|
+
// segments carries a routed geometry yet).
|
|
1782
|
+
this.activeItinerarySegments = lines;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* getActiveItinerarySegments is the read seam the waypoint engines reach for
|
|
1787
|
+
* inside the map quarantine: the point engine consults it on every placement to
|
|
1788
|
+
* project the cursor onto a nearby segment. Exposed off the renderer so a re-arm
|
|
1789
|
+
* of the engine after a segment edit picks up the latest geometries without
|
|
1790
|
+
* re-injection.
|
|
1791
|
+
*/
|
|
1792
|
+
getActiveItinerarySegments(): readonly Position[][] {
|
|
1793
|
+
return this.activeItinerarySegments;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* setHillshadeIllumination sets the illumination direction in degrees on the
|
|
1798
|
+
* hillshade tile layers (e.g. the sun azimuth at the selected time), so terrain
|
|
1799
|
+
* shading tracks the time-of-day the user picks. The direction is remembered so
|
|
1800
|
+
* a base-map switch re-lights the replayed hillshade layers.
|
|
1801
|
+
*
|
|
1802
|
+
* The renderer takes a direction from 0 to 359 and refuses any other, so the direction is
|
|
1803
|
+
* written as {@link hillshadeDirection} reads it. A direction that is no finite number
|
|
1804
|
+
* has no bearing to read, and leaves the lighting as it is.
|
|
1805
|
+
*/
|
|
1806
|
+
setHillshadeIllumination(direction: number): void {
|
|
1807
|
+
if (!Number.isFinite(direction)) {
|
|
1808
|
+
return;
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
// Remember the direction so a style reload (a base-map switch) re-lights the
|
|
1812
|
+
// replayed hillshade layers instead of reverting to MapLibre's default.
|
|
1813
|
+
this.lastHillshadeDirection = hillshadeDirection(direction);
|
|
1814
|
+
this.applyHillshadeIllumination();
|
|
1815
|
+
}
|
|
1816
|
+
|
|
1817
|
+
/**
|
|
1818
|
+
* setEditedSegment marks (or, with null, clears) the segment whose tile copy
|
|
1819
|
+
* paints de-emphasized while a segment edit is active, then re-applies the edit
|
|
1820
|
+
* styling. It is the seam the client's begin/endSegmentEdit drive in place of
|
|
1821
|
+
* touching the edit-style state directly: beginSegmentEdit sets the edited id,
|
|
1822
|
+
* endSegmentEdit clears it (paired with reapplyItineraryPaint so the rest of the
|
|
1823
|
+
* itinerary repaints from a clean base).
|
|
1824
|
+
*/
|
|
1825
|
+
setEditedSegment(segmentId: string | null): void {
|
|
1826
|
+
this.editStyledSegmentId = segmentId;
|
|
1827
|
+
this.applyEditStyling();
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
/**
|
|
1831
|
+
* reapplyItineraryPaint re-asserts the itinerary emphasis and exclusions from
|
|
1832
|
+
* the current state. It is the seam the client's endSegmentEdit runs before
|
|
1833
|
+
* setEditedSegment(null) so the in-edit paint fold on the line/point layers is
|
|
1834
|
+
* rebuilt from a clean base and features outside the edit reappear immediately,
|
|
1835
|
+
* the same emphasis-then-exclusions order a slot's onMounted uses, with the edit
|
|
1836
|
+
* styling layered on last by the paired setEditedSegment call.
|
|
1837
|
+
*/
|
|
1838
|
+
reapplyItineraryPaint(): void {
|
|
1839
|
+
this.applyItineraryEmphasis();
|
|
1840
|
+
this.applyItineraryExclusions();
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* addLayerOrdered adds a layer at its deterministic stacking position rather
|
|
1845
|
+
* than on top, by handing it to MountayaMap at its rank. Routing every one of
|
|
1846
|
+
* our layer adds through this keeps z-order independent of add order (a
|
|
1847
|
+
* hillshade added after a route still sinks beneath it, and an overlay added
|
|
1848
|
+
* after a route still sits under it) so the ordering self-heals even across a
|
|
1849
|
+
* terrain-switch replay. It goes through the map rather than `map.raw.addLayer`
|
|
1850
|
+
* because ONE registry is the point: anchoring weighs the ranks of the layers
|
|
1851
|
+
* already placed, so two callers ordering against two registries would each
|
|
1852
|
+
* place correctly within their own set and wrongly against the other's, and the
|
|
1853
|
+
* result is a route drawn under its own overlay: a wrong-looking map rather
|
|
1854
|
+
* than an error. Accepts MapLibre's full AddLayerObject union so any native
|
|
1855
|
+
* layer spec (raster, hillshade, line, …) inserts at the same rank as another.
|
|
1856
|
+
* Public so the Street View coverage layer (owned by the client) shares it.
|
|
1857
|
+
*/
|
|
1858
|
+
addLayerOrdered(spec: AddLayerObject, rank: LayerRank): void {
|
|
1859
|
+
this.mountayaMap.addLayer(spec, rank);
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
/**
|
|
1863
|
+
* forgetLayerRank is the teardown half of addLayerOrdered: it removes the layer if
|
|
1864
|
+
* it is still in the style and drops its rank and visibility intent either way, so
|
|
1865
|
+
* a layer nobody is drawing stops anchoring later inserts. Idempotent, which is what
|
|
1866
|
+
* lets a caller whose layer may or may not be standing (a clear before any paint, a
|
|
1867
|
+
* double clear, a style swap that already wiped it) call it unguarded.
|
|
1868
|
+
*/
|
|
1869
|
+
forgetLayerRank(layerId: string): void {
|
|
1870
|
+
this.mountayaMap.removeLayer(layerId);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* applyEditStyling stacks the per-edit de-emphasis onto the edited segment, leaving the
|
|
1875
|
+
* focus/dim treatment of every other feature intact: the segment leaves its line, its casing
|
|
1876
|
+
* and its chevrons, and its saved geometry is drawn dashed at 75% on a ghost layer of its own
|
|
1877
|
+
* (see {@link drawEditGhost}). With no segment under edit it takes the ghosts off and re-folds
|
|
1878
|
+
* the plain emphasis. Walks the tracked tile sources and writes only the itinerary line
|
|
1879
|
+
* layers; the getLayer guard skips a layer not yet added or mid-rebuild on a terrain switch.
|
|
1880
|
+
*/
|
|
1881
|
+
private applyEditStyling(): void {
|
|
1882
|
+
const editingId = this.editStyledSegmentId;
|
|
1883
|
+
if (editingId === null) {
|
|
1884
|
+
// Taking the ghosts off and re-folding the emphasis-derived opacity leaves every line,
|
|
1885
|
+
// casing and chevron exactly as it was before the edit.
|
|
1886
|
+
for (const layer of this.manifestLayers()) {
|
|
1887
|
+
if (layer.source_layer === ITINERARY_LINE_SOURCE_LAYER) {
|
|
1888
|
+
this.forgetLayerRank(editGhostLayerId(layer.id));
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
this.applyItineraryEmphasis();
|
|
1893
|
+
|
|
1894
|
+
return;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
for (const layer of this.manifestLayers()) {
|
|
1898
|
+
if (layer.source_layer !== ITINERARY_LINE_SOURCE_LAYER || layer.type !== "line") {
|
|
1899
|
+
continue;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
const drawn = this.map.getLayer(layer.id);
|
|
1903
|
+
if (!drawn) {
|
|
1904
|
+
continue;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
// The edited segment leaves the line, its casing and its direction companion: the live
|
|
1908
|
+
// edit overlay (DirectionArrowLayer) renders the chevrons and the flow on the draft
|
|
1909
|
+
// geometry, and the ghost below draws the saved one. Every other segment keeps the
|
|
1910
|
+
// emphasis-derived opacity, which the clear path (editingId === null) restores through
|
|
1911
|
+
// the applyItineraryEmphasis re-fold.
|
|
1912
|
+
const editHidden: ExpressionSpecification = [
|
|
1913
|
+
"case",
|
|
1914
|
+
["==", ["get", "segment_id"], editingId],
|
|
1915
|
+
0,
|
|
1916
|
+
itineraryOpacity(this.itineraryEmphasis, true),
|
|
1917
|
+
];
|
|
1918
|
+
this.setFoldPaint(layer.id, "line-opacity", editHidden);
|
|
1919
|
+
|
|
1920
|
+
// The casing follows the line above it into the edit, and all the way out: a solid
|
|
1921
|
+
// white halo under a dashed ghost reads as a second route. It takes the opacity write
|
|
1922
|
+
// and nothing else: no ghost it could not keep in phase, no direction companion.
|
|
1923
|
+
if (isItineraryCasingLayer(layer)) {
|
|
1924
|
+
continue;
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
this.applyDirectionOpacity(layer.id, editHidden);
|
|
1928
|
+
this.drawEditGhost(layer, drawn.source, editingId);
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
// The edited segment's restricted stretches leave with it: the live edit draws them on the
|
|
1932
|
+
// draft route (RoadAccessLineEngine), and saved stripes left under it would mark a line the
|
|
1933
|
+
// edit may already have moved off.
|
|
1934
|
+
this.applyRoadAccessOpacity([
|
|
1935
|
+
"case",
|
|
1936
|
+
["==", ["get", "segment_id"], editingId],
|
|
1937
|
+
0,
|
|
1938
|
+
itineraryOpacity(this.itineraryEmphasis, true),
|
|
1939
|
+
]);
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
/**
|
|
1943
|
+
* drawEditGhost draws the saved geometry of the segment under edit, dashed and at 75%, on a
|
|
1944
|
+
* layer of its own above the itinerary line it stands in for, so the user sees the saved
|
|
1945
|
+
* version beside the editable overlay drawn over it.
|
|
1946
|
+
*
|
|
1947
|
+
* The dash is the ghost layer's constant paint, never a data expression on the line layer.
|
|
1948
|
+
* MapLibre builds a tile's paint buffers for `line-dasharray` from the value the layer holds
|
|
1949
|
+
* when the tile is parsed, and a constant one leaves no dash positions behind; a line whose
|
|
1950
|
+
* dash then turns into a data expression draws those buffers for every frame until its
|
|
1951
|
+
* tiles have been parsed again, and each of those frames throws from the renderer's dash
|
|
1952
|
+
* uniforms. A layer added with its dash is parsed with it, so no frame draws a dash its
|
|
1953
|
+
* buffers do not hold.
|
|
1954
|
+
*
|
|
1955
|
+
* The ghost takes what the line paints under the current folds: the tint or the manifest's
|
|
1956
|
+
* color, the emphasis width, the manifest's caps, zoom bounds and filter, and the segment
|
|
1957
|
+
* exclusions. A ghost already standing is written in place, so an emphasis that changes
|
|
1958
|
+
* during the edit reaches it with no re-parse of its tiles.
|
|
1959
|
+
*
|
|
1960
|
+
* @param layer The manifest record of the itinerary line layer.
|
|
1961
|
+
* @param sourceId The source the line layer draws from.
|
|
1962
|
+
* @param segmentId The segment under edit.
|
|
1963
|
+
*/
|
|
1964
|
+
private drawEditGhost(layer: TileSchema.TileLayer, sourceId: string, segmentId: string): void {
|
|
1965
|
+
const ghostId = editGhostLayerId(layer.id);
|
|
1966
|
+
const shown = itineraryExclusionFilter(
|
|
1967
|
+
layer.filter as FilterSpecification | undefined,
|
|
1968
|
+
"segment_id",
|
|
1969
|
+
this.itineraryExclusions.segmentIds,
|
|
1970
|
+
);
|
|
1971
|
+
const edited: ExpressionSpecification = ["==", ["get", "segment_id"], segmentId];
|
|
1972
|
+
// Cast at the MapLibre boundary, as itineraryExclusionFilter casts its own combination.
|
|
1973
|
+
const filter = (
|
|
1974
|
+
shown === null ? edited : ["all", shown as ExpressionSpecification, edited]
|
|
1975
|
+
) as FilterSpecification;
|
|
1976
|
+
// The manifest types a paint value as the contract's own JSON; a line's color and width
|
|
1977
|
+
// are values the renderer takes, as the tint and emphasis folds assert them.
|
|
1978
|
+
const color =
|
|
1979
|
+
this.itinerarySegmentColor ??
|
|
1980
|
+
(layer.paint?.["line-color"] as string | ExpressionSpecification | undefined);
|
|
1981
|
+
const width = itineraryLineWidth(
|
|
1982
|
+
this.itineraryEmphasis,
|
|
1983
|
+
(layer.paint?.["line-width"] as number | ExpressionSpecification | undefined) ??
|
|
1984
|
+
DEFAULT_LINE_WIDTH,
|
|
1985
|
+
);
|
|
1986
|
+
|
|
1987
|
+
if (this.map.getLayer(ghostId)) {
|
|
1988
|
+
this.map.setFilter(ghostId, filter);
|
|
1989
|
+
this.setFoldPaint(ghostId, "line-color", color);
|
|
1990
|
+
this.setFoldPaint(ghostId, "line-width", width);
|
|
1991
|
+
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1995
|
+
this.addLayerOrdered(
|
|
1996
|
+
{
|
|
1997
|
+
filter,
|
|
1998
|
+
id: ghostId,
|
|
1999
|
+
// The manifest's caps and joins, so the dashes end as the line they stand in for. The
|
|
2000
|
+
// wire types a layout as an open map the Tile API validated, asserted at this boundary
|
|
2001
|
+
// as tileLayerSpec asserts it.
|
|
2002
|
+
layout: (layer.layout ?? {}) as LineLayerSpecification["layout"],
|
|
2003
|
+
maxzoom: layer.zoom_max,
|
|
2004
|
+
minzoom: layer.zoom_min,
|
|
2005
|
+
paint: {
|
|
2006
|
+
...(color === undefined ? {} : { "line-color": color }),
|
|
2007
|
+
"line-dasharray": [...ITINERARY_EDIT_DASHARRAY],
|
|
2008
|
+
"line-opacity": ITINERARY_EDIT_OPACITY,
|
|
2009
|
+
"line-width": width,
|
|
2010
|
+
},
|
|
2011
|
+
source: sourceId,
|
|
2012
|
+
"source-layer": layer.source_layer,
|
|
2013
|
+
type: "line",
|
|
2014
|
+
},
|
|
2015
|
+
LayerRank.ITINERARY_LINE,
|
|
2016
|
+
);
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
/**
|
|
2020
|
+
* applyHillshadeIllumination writes the last illumination direction onto every
|
|
2021
|
+
* hillshade tile layer, the time-of-day shading re-applied whenever the layers
|
|
2022
|
+
* (re-)exist. A no-op until a direction has been set; the getLayer/type check
|
|
2023
|
+
* skips a layer not yet added or mid-rebuild on a terrain switch.
|
|
2024
|
+
*
|
|
2025
|
+
* It walks BOTH halves of what is drawn, because hillshade reaches the map two
|
|
2026
|
+
* ways: as a source of the manifest the studio mounts per source id, and as an
|
|
2027
|
+
* enrichment holding a slot of its own. Walking only one leaves the shading on
|
|
2028
|
+
* the other half stuck at the style's default, which renders as flat relief
|
|
2029
|
+
* rather than as an error. The companion layers need no walk: the chevrons
|
|
2030
|
+
* and stripe fills this renderer attaches are never hillshade.
|
|
2031
|
+
*/
|
|
2032
|
+
private applyHillshadeIllumination(): void {
|
|
2033
|
+
const direction = this.lastHillshadeDirection;
|
|
2034
|
+
if (direction === null) {
|
|
2035
|
+
return;
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
const drawn = [
|
|
2039
|
+
...[...this.manifestMounts.values()].map((mount) => mount.layerIds),
|
|
2040
|
+
...[...this.slotMounts.values()].map((mount) => mount.layerIds),
|
|
2041
|
+
];
|
|
2042
|
+
for (const layerIds of drawn) {
|
|
2043
|
+
for (const layerId of layerIds) {
|
|
2044
|
+
if (this.map.getLayer(layerId)?.type === "hillshade") {
|
|
2045
|
+
this.map.setPaintProperty(layerId, "hillshade-illumination-anchor", "map");
|
|
2046
|
+
this.map.setPaintProperty(layerId, "hillshade-illumination-direction", direction);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
|
|
2052
|
+
/**
|
|
2053
|
+
* drawZoneBadges states what the clock badges are read off: the layers that draw the zones'
|
|
2054
|
+
* polygons across every zone source mounted, the sources they draw from, and the filter that
|
|
2055
|
+
* picks the zones to badge, which is the one the stripes paint under.
|
|
2056
|
+
*
|
|
2057
|
+
* A zone source's fill layers are the ones read: a fill answers a zone wherever the screen is
|
|
2058
|
+
* inside it, where an outline answers it only along its edge. A source that styles its zones
|
|
2059
|
+
* with no fill is read off whatever it does draw them with.
|
|
2060
|
+
*
|
|
2061
|
+
* The engine draws one badge per zone inside what the screen shows of it, on a layer and a
|
|
2062
|
+
* source of its own, and takes both off when no zone layer is left. Called after every mount
|
|
2063
|
+
* and removal, and whenever the reference instant or the zone under edit changes.
|
|
2064
|
+
*/
|
|
2065
|
+
private drawZoneBadges(): void {
|
|
2066
|
+
const layerIds: string[] = [];
|
|
2067
|
+
const sourceIds = new Set<string>();
|
|
2068
|
+
for (const mount of this.manifestMounts.values()) {
|
|
2069
|
+
const zoneLayers = mount.source.layers.filter((layer) =>
|
|
2070
|
+
isZoneSourceLayer(layer.source_layer),
|
|
2071
|
+
);
|
|
2072
|
+
const fills = zoneLayers.filter((layer) => layer.type === "fill");
|
|
2073
|
+
for (const layer of fills.length > 0 ? fills : zoneLayers) {
|
|
2074
|
+
layerIds.push(layer.id);
|
|
2075
|
+
sourceIds.add(layer.source ?? mount.source.id);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
this.zoneBadges.draw({
|
|
2080
|
+
filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
|
|
2081
|
+
layerIds,
|
|
2082
|
+
sourceIds: [...sourceIds],
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
/**
|
|
2087
|
+
* addZoneStripeLayer attaches the inactive-only diagonal-stripe overlay fill
|
|
2088
|
+
* layer(s) for a zone source: the distinct out-of-window treatment a zone gets
|
|
2089
|
+
* alongside its dimmed base fill and clock badge. One fill layer per zone fill layer, bound
|
|
2090
|
+
* to the same vector source + source-layer, FILTERED to the out-of-window zones
|
|
2091
|
+
* at the current reference, painting the per-level `zone-stripe-<level>` image as
|
|
2092
|
+
* a `fill-pattern` at {@link ZONE_INACTIVE_FILL_OPACITY}. It is a SEPARATE layer
|
|
2093
|
+
* above the base fill on purpose: a `fill-pattern` on the base fill makes MapLibre
|
|
2094
|
+
* render no fill for an active zone (whose pattern is empty), hiding and
|
|
2095
|
+
* un-clicking it, so the pattern lives here while the base fill keeps its solid
|
|
2096
|
+
* `fill-color` for every zone. Added at the ZONE rank so it bands with the zone
|
|
2097
|
+
* geometry. Idempotent via the getLayer guard; every id it names is appended to
|
|
2098
|
+
* `companionLayerIds` so the source's teardown takes them off before the source.
|
|
2099
|
+
*/
|
|
2100
|
+
private addZoneStripeLayer(source: TileSchema.TileSource, companionLayerIds: string[]): void {
|
|
2101
|
+
for (const layer of source.layers) {
|
|
2102
|
+
if (layer.source_layer !== ZONE_FILL_SOURCE_LAYER) {
|
|
2103
|
+
continue;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
|
|
2107
|
+
companionLayerIds.push(stripeLayerId);
|
|
2108
|
+
if (this.map.getLayer(stripeLayerId)) {
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
// The overlay rides the same vector source + source-layer as the base fill,
|
|
2113
|
+
// filtered to the out-of-window zones, so the stripe pattern paints only on
|
|
2114
|
+
// inactive zones while the base fill underneath keeps every zone's solid
|
|
2115
|
+
// color. Inserted at the ZONE rank so it bands with the zone geometry.
|
|
2116
|
+
this.addLayerOrdered(
|
|
2117
|
+
{
|
|
2118
|
+
filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
|
|
2119
|
+
id: stripeLayerId,
|
|
2120
|
+
maxzoom: layer.zoom_max,
|
|
2121
|
+
minzoom: layer.zoom_min,
|
|
2122
|
+
paint: {
|
|
2123
|
+
"fill-opacity": ZONE_INACTIVE_FILL_OPACITY,
|
|
2124
|
+
"fill-pattern": zoneStripeFillPattern(),
|
|
2125
|
+
},
|
|
2126
|
+
source: layer.source ?? source.id,
|
|
2127
|
+
"source-layer": layer.source_layer,
|
|
2128
|
+
type: "fill",
|
|
2129
|
+
},
|
|
2130
|
+
LayerRank.ZONE,
|
|
2131
|
+
);
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* addDirectionLayers attaches the static chevron-symbol direction indicator for
|
|
2137
|
+
* every itinerary LINE layer a source carries. The manifest emits no direction
|
|
2138
|
+
* layer (only lines and points), so the renderer adds the chevrons per line layer,
|
|
2139
|
+
* bound to the same vector source + `itinerary_lines` source-layer so they carry
|
|
2140
|
+
* the same `segment_id` / `itinerary_id` the emphasis + exclusion folds key on.
|
|
2141
|
+
* Their `[minzoom,maxzoom]` is taken from the source's `itinerary_points` layer so
|
|
2142
|
+
* the indicator appears at the SAME zoom as the waypoints (the lines paint from
|
|
2143
|
+
* further out, where the map is just undirected strokes and a direction cue would
|
|
2144
|
+
* clutter), falling back to the line layer's own zoom bounds when the source
|
|
2145
|
+
* carries no point layer.
|
|
2146
|
+
*
|
|
2147
|
+
* The overview indicator is the chevron symbol layer ALONE: no animated flow line.
|
|
2148
|
+
* A symbol layer is a static GPU stamp with no per-frame cost, so an idle overview
|
|
2149
|
+
* parks at ~0% GPU; the animated flow (its `line-dasharray` stepped every frame)
|
|
2150
|
+
* would force a full-canvas repaint per registered layer for as long as the map is
|
|
2151
|
+
* on screen, with no extra direction information over the chevrons. The flow stays
|
|
2152
|
+
* for the live segment edit only (DirectionArrowLayer), where it is one transient,
|
|
2153
|
+
* user-focused layer. Idempotent via the getLayer guard; every id it names is appended
|
|
2154
|
+
* to `companionLayerIds` so the source's teardown takes them off before the source.
|
|
2155
|
+
*/
|
|
2156
|
+
private addDirectionLayers(source: TileSchema.TileSource, companionLayerIds: string[]): void {
|
|
2157
|
+
// The waypoint zoom bounds the indicator inherits, so the chevrons appear exactly
|
|
2158
|
+
// when the waypoint pins do. Resolved once per source from its point layer; null
|
|
2159
|
+
// when the source carries none, in which case each line layer falls back to its
|
|
2160
|
+
// own bounds below.
|
|
2161
|
+
const waypointZoom = this.waypointZoomBounds(source);
|
|
2162
|
+
|
|
2163
|
+
for (const layer of source.layers) {
|
|
2164
|
+
if (layer.source_layer !== ITINERARY_LINE_SOURCE_LAYER) {
|
|
2165
|
+
continue;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
// The casing draws the same geometry as the line above it, so generating a
|
|
2169
|
+
// companion from it too would lay a second flow and a second set of chevrons
|
|
2170
|
+
// over every route: the arrows doubled, at slightly different widths.
|
|
2171
|
+
if (isItineraryCasingLayer(layer)) {
|
|
2172
|
+
continue;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
const minzoom = waypointZoom?.minzoom ?? layer.zoom_min;
|
|
2176
|
+
const maxzoom = waypointZoom?.maxzoom ?? layer.zoom_max;
|
|
2177
|
+
|
|
2178
|
+
const chevronLayerId = `${layer.id}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
|
|
2179
|
+
companionLayerIds.push(chevronLayerId);
|
|
2180
|
+
if (this.map.getLayer(chevronLayerId)) {
|
|
2181
|
+
continue;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
// The chevron symbols stamp the direction arrows along the line. They share
|
|
2185
|
+
// directionChevronLayout with the edit-view layer so the persisted and live
|
|
2186
|
+
// indicators are identical, and seed the subtle base icon-opacity so the
|
|
2187
|
+
// arrows read as an accent before the emphasis fold (which multiplies this
|
|
2188
|
+
// base by the line-keyed opacity) runs.
|
|
2189
|
+
this.addLayerOrdered(
|
|
2190
|
+
{
|
|
2191
|
+
id: chevronLayerId,
|
|
2192
|
+
layout: { ...directionChevronLayout() },
|
|
2193
|
+
maxzoom,
|
|
2194
|
+
minzoom,
|
|
2195
|
+
paint: { "icon-opacity": DIRECTION_CHEVRON_OPACITY },
|
|
2196
|
+
source: layer.source ?? source.id,
|
|
2197
|
+
"source-layer": layer.source_layer,
|
|
2198
|
+
type: "symbol",
|
|
2199
|
+
},
|
|
2200
|
+
LayerRank.ITINERARY_DIRECTION,
|
|
2201
|
+
);
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
/**
|
|
2206
|
+
* addRoadAccessLayers attaches the layers a source's restricted stretches are drawn on: the
|
|
2207
|
+
* stripes and the warning icon of each stretch's kind, over the `itinerary_restrictions`
|
|
2208
|
+
* source-layer the itinerary tiles carry and no specification declares a layer for
|
|
2209
|
+
* ({@link roadAccessLayersOf}). They bind the vector source of the line they mark, so they carry
|
|
2210
|
+
* the same `segment_id` and `itinerary_id` the emphasis, exclusion and edit folds key on.
|
|
2211
|
+
*
|
|
2212
|
+
* A map that draws the source draws its stretches itself, and a pair already in the style takes
|
|
2213
|
+
* this renderer's word on whether the stretches are shown, since a base-map switch draws them
|
|
2214
|
+
* again before this runs. A layer the map lists among those it drew (`drawnLayerIds`) and the
|
|
2215
|
+
* style does not hold is one the style refused, and it is not asked of the style again: the
|
|
2216
|
+
* refusal reached `error` once already. Every id it names is appended to `companionLayerIds` so
|
|
2217
|
+
* the source's teardown takes them off before the source.
|
|
2218
|
+
*/
|
|
2219
|
+
private addRoadAccessLayers(
|
|
2220
|
+
source: TileSchema.TileSource,
|
|
2221
|
+
companionLayerIds: string[],
|
|
2222
|
+
drawnLayerIds: readonly string[],
|
|
2223
|
+
): void {
|
|
2224
|
+
const layers = roadAccessLayersOf(source, { visible: this.accessRestrictionsVisible });
|
|
2225
|
+
if (layers.length === 0) {
|
|
2226
|
+
return;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
// Warm every kind's stripe and sprite before the layers reference them; the missing-image
|
|
2230
|
+
// resolver remains the net for whatever the warm pass has not reached.
|
|
2231
|
+
void loadRoadAccessIcons(this.map, this.icons);
|
|
2232
|
+
|
|
2233
|
+
for (const { layer, rank } of layers) {
|
|
2234
|
+
companionLayerIds.push(layer.id);
|
|
2235
|
+
if (this.map.getLayer(layer.id)) {
|
|
2236
|
+
this.map.setLayoutProperty(
|
|
2237
|
+
layer.id,
|
|
2238
|
+
"visibility",
|
|
2239
|
+
this.accessRestrictionsVisible ? "visible" : "none",
|
|
2240
|
+
);
|
|
2241
|
+
} else if (!drawnLayerIds.includes(layer.id)) {
|
|
2242
|
+
this.addLayerOrdered(layer, rank);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
/**
|
|
2248
|
+
* applyRoadAccessOpacity writes the opacity of every source's restricted stretches from the
|
|
2249
|
+
* line-keyed opacity their segments paint under (the emphasis `case`, or the edit `case` that
|
|
2250
|
+
* zeroes the segment under edit), and the stripes' width from the emphasis, so a focused
|
|
2251
|
+
* segment's stripes thicken with its line. The stripes multiply the opacity by their own base
|
|
2252
|
+
* ({@link ROAD_ACCESS_STRIPE_OPACITY}); the icons take it as it is. Each write is guarded by
|
|
2253
|
+
* getLayer because the layers may not be added yet or may be mid-rebuild on a terrain switch.
|
|
2254
|
+
*/
|
|
2255
|
+
private applyRoadAccessOpacity(lineOpacity: number | ExpressionSpecification): void {
|
|
2256
|
+
for (const mount of this.manifestMounts.values()) {
|
|
2257
|
+
const line = roadAccessLineLayerOf(mount.source);
|
|
2258
|
+
if (!line) {
|
|
2259
|
+
continue;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
const stripeLayerId = roadAccessStripeLayerId(line.id);
|
|
2263
|
+
if (this.map.getLayer(stripeLayerId)) {
|
|
2264
|
+
const stripeOpacity: ExpressionSpecification = [
|
|
2265
|
+
"*",
|
|
2266
|
+
lineOpacity,
|
|
2267
|
+
ROAD_ACCESS_STRIPE_OPACITY,
|
|
2268
|
+
];
|
|
2269
|
+
this.setFoldPaint(stripeLayerId, "line-opacity", stripeOpacity);
|
|
2270
|
+
// Asserted as the emphasis fold asserts the line's own base width.
|
|
2271
|
+
const baseWidth =
|
|
2272
|
+
(line.paint?.["line-width"] as number | ExpressionSpecification | undefined) ??
|
|
2273
|
+
DEFAULT_LINE_WIDTH;
|
|
2274
|
+
this.setFoldPaint(
|
|
2275
|
+
stripeLayerId,
|
|
2276
|
+
"line-width",
|
|
2277
|
+
itineraryLineWidth(this.itineraryEmphasis, baseWidth),
|
|
2278
|
+
);
|
|
2279
|
+
}
|
|
2280
|
+
|
|
2281
|
+
const iconLayerId = roadAccessIconLayerId(line.id);
|
|
2282
|
+
if (this.map.getLayer(iconLayerId)) {
|
|
2283
|
+
this.setFoldPaint(iconLayerId, "icon-opacity", lineOpacity);
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
/**
|
|
2289
|
+
* applyRoadAccessExclusion writes the segment exclusion filter onto every source's restricted
|
|
2290
|
+
* stretches, so an excluded segment's stripes and icons go with its line. The layers carry no
|
|
2291
|
+
* manifest base filter, so the exclusion is built from undefined, and an empty excluded list
|
|
2292
|
+
* resets them to no filter.
|
|
2293
|
+
*/
|
|
2294
|
+
private applyRoadAccessExclusion(): void {
|
|
2295
|
+
const filter = itineraryExclusionFilter(
|
|
2296
|
+
undefined,
|
|
2297
|
+
"segment_id",
|
|
2298
|
+
this.itineraryExclusions.segmentIds,
|
|
2299
|
+
);
|
|
2300
|
+
|
|
2301
|
+
for (const mount of this.manifestMounts.values()) {
|
|
2302
|
+
const line = roadAccessLineLayerOf(mount.source);
|
|
2303
|
+
if (!line) {
|
|
2304
|
+
continue;
|
|
2305
|
+
}
|
|
2306
|
+
|
|
2307
|
+
for (const layerId of [roadAccessStripeLayerId(line.id), roadAccessIconLayerId(line.id)]) {
|
|
2308
|
+
if (this.map.getLayer(layerId)) {
|
|
2309
|
+
this.map.setFilter(layerId, filter);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
/**
|
|
2316
|
+
* waypointZoomBounds resolves the `[minzoom,maxzoom]` of a source's
|
|
2317
|
+
* `itinerary_points` layer, so the direction indicator can appear at the same zoom
|
|
2318
|
+
* as the waypoint pins. Returns null when the source carries no point layer, in
|
|
2319
|
+
* which case the caller falls back to the line layer's own bounds.
|
|
2320
|
+
*/
|
|
2321
|
+
private waypointZoomBounds(
|
|
2322
|
+
source: TileSchema.TileSource,
|
|
2323
|
+
): { maxzoom?: number | undefined; minzoom?: number | undefined } | null {
|
|
2324
|
+
for (const layer of source.layers) {
|
|
2325
|
+
if (layer.source_layer === ITINERARY_POINT_SOURCE_LAYER) {
|
|
2326
|
+
return { maxzoom: layer.zoom_max, minzoom: layer.zoom_min };
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
return null;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
/**
|
|
2334
|
+
* applyZoneTimeStyling pins every zone geometry layer to its uniform base opacity and re-applies
|
|
2335
|
+
* the out-of-window filter of every synthetic stripe overlay to reflect the current reference
|
|
2336
|
+
* epoch. It walks the tracked tile sources, picks
|
|
2337
|
+
* out the zone geometry layers, and sets each fill's opacity to the renderer's own constant
|
|
2338
|
+
* ({@link ZONE_FILL_OPACITY}), the SAME value for an active and an out-of-window zone, with NO
|
|
2339
|
+
* active/inactive case and NO manifest read. That makes the base opacity time-INDEPENDENT and
|
|
2340
|
+
* robust: a stale/cached `/v1/tile-layers` (or a backend not carrying the opacity) can never
|
|
2341
|
+
* push an active zone to an opaque 1. An outline on the same source-layer keeps its manifest
|
|
2342
|
+
* paint. The time distinction is ADDITIVE: the FILL's separate diagonal-stripe layer, FILTERED
|
|
2343
|
+
* to the out-of-window zones at this reference, and the clock badges, read under the same
|
|
2344
|
+
* filter (drawZoneBadges), so an out-of-window zone gains a striped fill + a
|
|
2345
|
+
* clock while an active zone shows neither. The base opacity write does not depend on the
|
|
2346
|
+
* reference, but it stays here (run on add, on the reference tick, and on a restyle replay) so a
|
|
2347
|
+
* stale manifest opacity is always overridden back to that constant. Each write is guarded by a
|
|
2348
|
+
* getLayer check because the layers may not be added yet or may be mid-rebuild on a terrain
|
|
2349
|
+
* switch. Non-zone overlays are never touched.
|
|
2350
|
+
*/
|
|
2351
|
+
private applyZoneTimeStyling(): void {
|
|
2352
|
+
const reference = this.zoneTimeReference;
|
|
2353
|
+
|
|
2354
|
+
for (const layer of this.manifestLayers()) {
|
|
2355
|
+
if (!isZoneSourceLayer(layer.source_layer)) {
|
|
2356
|
+
continue;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
if (!this.map.getLayer(layer.id)) {
|
|
2360
|
+
continue;
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
// Set the uniform base opacity of the area directly: the same for an active and an
|
|
2364
|
+
// out-of-window zone, with no time case and no manifest read. It is the renderer's own value
|
|
2365
|
+
// (mirroring the backend's zone fill value) and NEVER an opaque 1: an active fill painted at
|
|
2366
|
+
// 1 hides the terrain beneath it, and pinning it here overrides any stale/cached manifest
|
|
2367
|
+
// opacity. The out-of-window treatment is the additive stripe + clock below, not a dim of
|
|
2368
|
+
// this base.
|
|
2369
|
+
if (layer.type === "fill") {
|
|
2370
|
+
this.setFoldPaint(layer.id, "fill-opacity", ZONE_FILL_OPACITY);
|
|
2371
|
+
}
|
|
2372
|
+
|
|
2373
|
+
// Re-assert the out-of-window filter on this layer's synthetic stripe
|
|
2374
|
+
// overlay so the diagonal-stripe fill paints on exactly the out-of-window
|
|
2375
|
+
// zones at this reference. The stripe is
|
|
2376
|
+
// a SEPARATE overlay above the base fill, never the base fill's own
|
|
2377
|
+
// `fill-pattern`, which would make MapLibre drop the fill of every active
|
|
2378
|
+
// zone (it ignores fill-color once a pattern is set), so the base fill
|
|
2379
|
+
// keeps its solid color, visible and clickable, for all zones.
|
|
2380
|
+
const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
|
|
2381
|
+
if (this.map.getLayer(stripeLayerId)) {
|
|
2382
|
+
this.map.setFilter(stripeLayerId, zoneOverlayFilter(reference, this.excludedZoneId));
|
|
2383
|
+
}
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
/**
|
|
2388
|
+
* applyZoneExclusions rebuilds the filter of every zone geometry tile layer to
|
|
2389
|
+
* suppress the zone currently under edit. It walks the tracked tile sources,
|
|
2390
|
+
* picks out the zone geometry layers, and writes a filter
|
|
2391
|
+
* that drops the feature whose `id` property equals the excluded zone id while
|
|
2392
|
+
* preserving the manifest's own filter. The base filter is read fresh from the
|
|
2393
|
+
* manifest layer each call so a repeated change always wraps the pristine filter;
|
|
2394
|
+
* a null excluded id resets the layer to that base. It composes with
|
|
2395
|
+
* applyZoneTimeStyling and never replaces it: the time styling drives the opacity PAINT
|
|
2396
|
+
* property and the synthetic stripe layers' filters, while this drives the
|
|
2397
|
+
* geometry layers' FILTER, so the two ride independent properties and the
|
|
2398
|
+
* out-of-window stripes stay intact for every non-edited zone. The synthetic
|
|
2399
|
+
* stripe overlay layers are ALSO re-filtered here (composed with the
|
|
2400
|
+
* out-of-window time predicate via zoneOverlayFilter) so the edited zone hides its
|
|
2401
|
+
* stripes, not just its base geometry; its clock badge goes the same way, through the
|
|
2402
|
+
* filter drawZoneBadges hands the badge engine. Each write is guarded by a getLayer
|
|
2403
|
+
* check because the layers may not be added yet or may be mid-rebuild on a
|
|
2404
|
+
* terrain switch. Non-zone overlays are never touched.
|
|
2405
|
+
*/
|
|
2406
|
+
private applyZoneExclusions(): void {
|
|
2407
|
+
for (const layer of this.manifestLayers()) {
|
|
2408
|
+
if (!isZoneSourceLayer(layer.source_layer)) {
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
|
|
2412
|
+
if (!this.map.getLayer(layer.id)) {
|
|
2413
|
+
continue;
|
|
2414
|
+
}
|
|
2415
|
+
|
|
2416
|
+
// The manifest types a layer's filter as the contract's own expression. The Tile API
|
|
2417
|
+
// writes it for this renderer, so it is asserted to be the renderer's filter where it
|
|
2418
|
+
// is handed over.
|
|
2419
|
+
const base = layer.filter as FilterSpecification | undefined;
|
|
2420
|
+
this.map.setFilter(layer.id, zoneExclusionFilter(base, this.excludedZoneId));
|
|
2421
|
+
|
|
2422
|
+
// The synthetic stripe overlay layers are NOT in source.layers, so
|
|
2423
|
+
// the manifest walk above misses them; re-apply the edited-zone exclusion
|
|
2424
|
+
// (composed with the out-of-window time predicate) here too, or an edited
|
|
2425
|
+
// out-of-window zone keeps painting its stripes under the live draft.
|
|
2426
|
+
const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
|
|
2427
|
+
if (this.map.getLayer(stripeLayerId)) {
|
|
2428
|
+
this.map.setFilter(
|
|
2429
|
+
stripeLayerId,
|
|
2430
|
+
zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
|
|
2431
|
+
);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
/**
|
|
2437
|
+
* applyItinerarySegmentColor rewrites every itinerary tile layer to paint in the
|
|
2438
|
+
* current single segment color, or restores the manifest's own per-segment
|
|
2439
|
+
* expression when the color is null. Line layers take a literal line-color; the
|
|
2440
|
+
* points symbol layer takes an icon-image expression that swaps ONLY the two
|
|
2441
|
+
* synthetic endpoint sprites, so an author's waypoint pins keep the colors they
|
|
2442
|
+
* chose. Both bases are read fresh from the stored manifest layer each call, so
|
|
2443
|
+
* clearing the tint restores the pristine expression rather than a previously
|
|
2444
|
+
* written literal, and a repeated apply is idempotent.
|
|
2445
|
+
*
|
|
2446
|
+
* It composes with the emphasis / edit-styling / exclusion folds by PROPERTY
|
|
2447
|
+
* DISJOINTNESS: those own line-opacity, icon-opacity, circle-opacity, line-width and
|
|
2448
|
+
* the layer filter, this one owns line-color and icon-image, and no fold reads a
|
|
2449
|
+
* property another writes on the manifest layers. So neither clobbers the other and
|
|
2450
|
+
* the order they run in is unconstrained. A future fold that also writes line-color
|
|
2451
|
+
* breaks that guarantee and would have to compose through a shared expression, the
|
|
2452
|
+
* way applyEditStyling already composes with applyItineraryEmphasis. The edit ghost
|
|
2453
|
+
* is the one reader of the tint: {@link setItinerarySegmentColor} draws it again.
|
|
2454
|
+
*/
|
|
2455
|
+
private applyItinerarySegmentColor(): void {
|
|
2456
|
+
const color = this.itinerarySegmentColor;
|
|
2457
|
+
|
|
2458
|
+
// Warm the two endpoint sprites in the tint color before the layout write references them.
|
|
2459
|
+
// Fire-and-forget and idempotent, exactly as prewarmItineraryIcons does for the per-segment
|
|
2460
|
+
// colors; the missing-image resolver stays the net for the one-frame race.
|
|
2461
|
+
if (color !== null) {
|
|
2462
|
+
for (const icon of ITINERARY_ENDPOINT_ICONS) {
|
|
2463
|
+
loadWaypointIcon(this.map, icon, color, this.icons).catch(() => {
|
|
2464
|
+
// Rasterization is best-effort: an environment with no canvas simply gets
|
|
2465
|
+
// no warm sprite, and the missing-image resolver answers the reference instead. A
|
|
2466
|
+
// swallowed failure must never take the tint's paint write down with it.
|
|
2467
|
+
});
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
for (const layer of this.manifestLayers()) {
|
|
2472
|
+
if (!this.map.getLayer(layer.id)) {
|
|
2473
|
+
continue;
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
if (layer.source_layer === ITINERARY_LINE_SOURCE_LAYER && layer.type === "line") {
|
|
2477
|
+
// The casing keeps the manifest's white. Tinting it to the segment color
|
|
2478
|
+
// is the one write that would make it disappear: it exists precisely to
|
|
2479
|
+
// be the color the route is not.
|
|
2480
|
+
if (isItineraryCasingLayer(layer)) {
|
|
2481
|
+
continue;
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
const baseColor = layer.paint?.["line-color"] as
|
|
2485
|
+
| string
|
|
2486
|
+
| ExpressionSpecification
|
|
2487
|
+
| undefined;
|
|
2488
|
+
this.setFoldPaint(layer.id, "line-color", color ?? baseColor);
|
|
2489
|
+
|
|
2490
|
+
continue;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
if (layer.source_layer === ITINERARY_POINT_SOURCE_LAYER && layer.type === "symbol") {
|
|
2494
|
+
const baseImage = layer.layout?.["icon-image"] as
|
|
2495
|
+
| string
|
|
2496
|
+
| ExpressionSpecification
|
|
2497
|
+
| undefined;
|
|
2498
|
+
|
|
2499
|
+
// A layer with no manifest icon-image has nothing to branch off, so leave
|
|
2500
|
+
// it alone rather than writing a fallback-less expression over it.
|
|
2501
|
+
if (baseImage === undefined) {
|
|
2502
|
+
continue;
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
this.map.setLayoutProperty(
|
|
2506
|
+
layer.id,
|
|
2507
|
+
"icon-image",
|
|
2508
|
+
color === null ? baseImage : endpointColorIconImage(color, baseImage),
|
|
2509
|
+
);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
|
|
2514
|
+
/**
|
|
2515
|
+
* applyItineraryEmphasis rebuilds the paint of every itinerary tile layer to
|
|
2516
|
+
* reflect the current emphasis. It walks the tracked tile sources, picks out
|
|
2517
|
+
* the layers bound to the itinerary source-layers (lines + points), and writes
|
|
2518
|
+
* the opacity property that matches each layer kind: line-opacity for line
|
|
2519
|
+
* layers, icon-opacity for symbol layers, circle-opacity for circle layers
|
|
2520
|
+
* (the last for the start/end markers). Line layers additionally get a
|
|
2521
|
+
* line-width override that thickens the focused feature while preserving the
|
|
2522
|
+
* manifest's zoom-interpolated base: the base is read fresh from the manifest
|
|
2523
|
+
* layer each call, so a repeated emphasis change always wraps the pristine
|
|
2524
|
+
* width rather than a previously-multiplied value. Each write is guarded by a
|
|
2525
|
+
* getLayer check because the layers may not be added yet or may be mid-rebuild
|
|
2526
|
+
* on a terrain switch. Non-itinerary overlays are never touched.
|
|
2527
|
+
*/
|
|
2528
|
+
private applyItineraryEmphasis(): void {
|
|
2529
|
+
for (const layer of this.manifestLayers()) {
|
|
2530
|
+
const isLine = layer.source_layer === ITINERARY_LINE_SOURCE_LAYER;
|
|
2531
|
+
const isPoint = layer.source_layer === ITINERARY_POINT_SOURCE_LAYER;
|
|
2532
|
+
if (!isLine && !isPoint) {
|
|
2533
|
+
continue;
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
const property = itineraryOpacityProperty(layer.type);
|
|
2537
|
+
if (!property || !this.map.getLayer(layer.id)) {
|
|
2538
|
+
continue;
|
|
2539
|
+
}
|
|
2540
|
+
|
|
2541
|
+
const expr = itineraryOpacity(this.itineraryEmphasis, isLine);
|
|
2542
|
+
this.setFoldPaint(layer.id, property, expr);
|
|
2543
|
+
|
|
2544
|
+
// Line layers also drive line-width so the focused geometry reads
|
|
2545
|
+
// thicker. The base width is the manifest layer's own line-width (a
|
|
2546
|
+
// number or a zoom interpolation), defaulting to a literal when absent;
|
|
2547
|
+
// reading it fresh keeps the multiplier wrapping the pristine base.
|
|
2548
|
+
if (isLine && layer.type === "line") {
|
|
2549
|
+
// The manifest types a paint value as the contract's own JSON. A line's width is a
|
|
2550
|
+
// number or an expression in it, as the renderer takes one, so it is asserted here.
|
|
2551
|
+
const baseWidth =
|
|
2552
|
+
(layer.paint?.["line-width"] as number | ExpressionSpecification | undefined) ??
|
|
2553
|
+
DEFAULT_LINE_WIDTH;
|
|
2554
|
+
this.setFoldPaint(
|
|
2555
|
+
layer.id,
|
|
2556
|
+
"line-width",
|
|
2557
|
+
itineraryLineWidth(this.itineraryEmphasis, baseWidth),
|
|
2558
|
+
);
|
|
2559
|
+
|
|
2560
|
+
// Dim the companion direction indicator with its line. The chevrons ride the
|
|
2561
|
+
// same itinerary_lines source-layer, so they carry segment_id and itinerary_id
|
|
2562
|
+
// and dim under the SAME line-keyed opacity expression: the arrows fade with
|
|
2563
|
+
// their route under an emphasis. The write is getLayer-guarded.
|
|
2564
|
+
//
|
|
2565
|
+
// The casing takes both writes above (it is the same stroke, so it dims
|
|
2566
|
+
// and thickens with the line it haloes) but owns no direction companion
|
|
2567
|
+
// to dim (addDirectionLayers never made one for it).
|
|
2568
|
+
if (!isItineraryCasingLayer(layer)) {
|
|
2569
|
+
this.applyDirectionOpacity(layer.id, expr);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
|
|
2574
|
+
// The restricted stretches dim and thicken with the segments they mark, under the same
|
|
2575
|
+
// line-keyed expressions: their features carry the segment_id and itinerary_id a line does.
|
|
2576
|
+
this.applyRoadAccessOpacity(itineraryOpacity(this.itineraryEmphasis, true));
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
/**
|
|
2580
|
+
* applyDirectionOpacity writes the opacity (icon-opacity) of the companion chevron layer
|
|
2581
|
+
* of an itinerary line layer, so the indicator dims WITH its route while keeping its own
|
|
2582
|
+
* subtle base opacity. The given `lineOpacity` is the line-keyed expression the base line
|
|
2583
|
+
* carries (the emphasis `case`, or the edit `case` that zeroes the edited segment). The
|
|
2584
|
+
* chevron multiplies it by its base ({@link DIRECTION_CHEVRON_OPACITY}), so a focused
|
|
2585
|
+
* route's indicator reads at the subtle base and not at full opacity, an unfocused route's
|
|
2586
|
+
* dims proportionally from that base, and the edited segment's zeroes out. The write is
|
|
2587
|
+
* guarded by getLayer because the layer may not be added yet or may be mid-rebuild on a
|
|
2588
|
+
* terrain switch.
|
|
2589
|
+
*/
|
|
2590
|
+
private applyDirectionOpacity(
|
|
2591
|
+
lineLayerId: string,
|
|
2592
|
+
lineOpacity: number | ExpressionSpecification,
|
|
2593
|
+
): void {
|
|
2594
|
+
const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
|
|
2595
|
+
if (this.map.getLayer(chevronLayerId)) {
|
|
2596
|
+
const chevronOpacity: ExpressionSpecification = ["*", lineOpacity, DIRECTION_CHEVRON_OPACITY];
|
|
2597
|
+
this.setFoldPaint(chevronLayerId, "icon-opacity", chevronOpacity);
|
|
2598
|
+
}
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
/**
|
|
2602
|
+
* setFoldPaint writes one paint property of a layer this renderer folds (an itinerary or zone
|
|
2603
|
+
* layer, or one of their companions) with no transition ({@link noTransition}), so a fold's
|
|
2604
|
+
* value lands in the frame it is written. Every opacity, width and colour the emphasis, edit,
|
|
2605
|
+
* restriction, tint and zone time folds write goes through it: a write made under the
|
|
2606
|
+
* renderer's default ease leaves a draped line or fill drawn as it was.
|
|
2607
|
+
*
|
|
2608
|
+
* @param layerId The layer the property is written on.
|
|
2609
|
+
* @param property The paint property.
|
|
2610
|
+
* @param value The value the property takes, or undefined for the style's own default.
|
|
2611
|
+
*/
|
|
2612
|
+
private setFoldPaint<Property extends keyof typeof transitionOf>(
|
|
2613
|
+
layerId: string,
|
|
2614
|
+
property: Property,
|
|
2615
|
+
value: AllPaintProperties[Property],
|
|
2616
|
+
): void {
|
|
2617
|
+
this.map.setPaintProperty(layerId, transitionOf[property], noTransition);
|
|
2618
|
+
this.map.setPaintProperty(layerId, property, value);
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
/**
|
|
2622
|
+
* applyItineraryExclusions rebuilds the filter of every itinerary tile layer to
|
|
2623
|
+
* suppress the currently-excluded features. It walks the tracked tile sources,
|
|
2624
|
+
* picks out the layers bound to the itinerary source-layers, and chooses the id
|
|
2625
|
+
* property + excluded id list per kind (segment_id + segmentIds for line
|
|
2626
|
+
* layers, waypoint_id + waypointIds for point layers) then writes a filter that
|
|
2627
|
+
* drops those features while preserving the manifest's own filter. The base
|
|
2628
|
+
* filter is read fresh from the manifest layer each call so a repeated change
|
|
2629
|
+
* always wraps the pristine filter; an empty id list resets the layer to that
|
|
2630
|
+
* base. Each write is guarded by a getLayer check because the layers may not be
|
|
2631
|
+
* added yet or may be mid-rebuild on a terrain switch. Non-itinerary overlays
|
|
2632
|
+
* are never touched.
|
|
2633
|
+
*/
|
|
2634
|
+
private applyItineraryExclusions(): void {
|
|
2635
|
+
for (const layer of this.manifestLayers()) {
|
|
2636
|
+
const isLine = layer.source_layer === ITINERARY_LINE_SOURCE_LAYER;
|
|
2637
|
+
const isPoint = layer.source_layer === ITINERARY_POINT_SOURCE_LAYER;
|
|
2638
|
+
if (!isLine && !isPoint) {
|
|
2639
|
+
continue;
|
|
2640
|
+
}
|
|
2641
|
+
|
|
2642
|
+
if (!this.map.getLayer(layer.id)) {
|
|
2643
|
+
continue;
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
// Lines key off segment_id, points off waypoint_id; each draws from its
|
|
2647
|
+
// own excluded id list so a segment exclusion never touches the points
|
|
2648
|
+
// and a waypoint exclusion never touches the lines. Points are dropped for
|
|
2649
|
+
// BOTH the tool-bus exclusions (waypointIds) AND the in-edit waypoint (its
|
|
2650
|
+
// committed tile copy is hidden while the live DraftWaypointMarker is on
|
|
2651
|
+
// screen); the two sets compose without mutating the tool-bus state.
|
|
2652
|
+
const idProp = isLine ? "segment_id" : "waypoint_id";
|
|
2653
|
+
const ids = isLine
|
|
2654
|
+
? this.itineraryExclusions.segmentIds
|
|
2655
|
+
: this.excludedWaypointId
|
|
2656
|
+
? [...this.itineraryExclusions.waypointIds, this.excludedWaypointId]
|
|
2657
|
+
: this.itineraryExclusions.waypointIds;
|
|
2658
|
+
// Asserted as the zone fold's base filter is: the manifest's filter is the renderer's.
|
|
2659
|
+
const base = layer.filter as FilterSpecification | undefined;
|
|
2660
|
+
this.map.setFilter(layer.id, itineraryExclusionFilter(base, idProp, ids));
|
|
2661
|
+
|
|
2662
|
+
// Exclude the companion direction indicator alongside its line. The chevrons
|
|
2663
|
+
// carry segment_id (they ride the line source-layer), so a segment exclusion
|
|
2664
|
+
// drops the arrows for the same segments. Their base filter is undefined (a
|
|
2665
|
+
// fresh layer with no manifest filter), so the exclusion is built from
|
|
2666
|
+
// undefined. Only the line companions are filtered: the point
|
|
2667
|
+
// walk has no direction layer, and neither does the casing (the filter write
|
|
2668
|
+
// above still lands on it, so an excluded segment loses its halo with it).
|
|
2669
|
+
if (isLine && !isItineraryCasingLayer(layer)) {
|
|
2670
|
+
this.applyDirectionExclusion(layer.id);
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
this.applyRoadAccessExclusion();
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
/**
|
|
2678
|
+
* applyDirectionExclusion writes the segment exclusion filter onto the companion chevron
|
|
2679
|
+
* layer of an itinerary line layer, so the arrows vanish for the same excluded segments as
|
|
2680
|
+
* their line. The companion carries no manifest base filter, so the exclusion is built from
|
|
2681
|
+
* undefined, and an empty excluded list resets it to no filter. The write is guarded by
|
|
2682
|
+
* getLayer because the layer may not be added yet or may be mid-rebuild on a terrain switch.
|
|
2683
|
+
*/
|
|
2684
|
+
private applyDirectionExclusion(lineLayerId: string): void {
|
|
2685
|
+
const filter = itineraryExclusionFilter(
|
|
2686
|
+
undefined,
|
|
2687
|
+
"segment_id",
|
|
2688
|
+
this.itineraryExclusions.segmentIds,
|
|
2689
|
+
);
|
|
2690
|
+
|
|
2691
|
+
const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
|
|
2692
|
+
if (this.map.getLayer(chevronLayerId)) {
|
|
2693
|
+
this.map.setFilter(chevronLayerId, filter);
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|