leaflet-city-mapper 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +78 -2
- package/cucumber.mjs +9 -0
- package/dist/leaflet-city-mapper.js +2 -0
- package/dist/leaflet-city-mapper.js.map +7 -0
- package/dist/utils/CELL.js +2 -0
- package/dist/utils/CELL.js.map +7 -0
- package/dist/utils/addBridges.js +2 -0
- package/dist/utils/addBridges.js.map +7 -0
- package/dist/utils/addRasterTile.js +2 -0
- package/dist/utils/addRasterTile.js.map +7 -0
- package/dist/utils/along.js +2 -0
- package/dist/utils/along.js.map +7 -0
- package/dist/utils/atmosphere.js +2 -0
- package/dist/utils/atmosphere.js.map +7 -0
- package/dist/utils/attach.js +2 -0
- package/dist/utils/attach.js.map +7 -0
- package/dist/utils/bindSunlight.js +2 -0
- package/dist/utils/bindSunlight.js.map +7 -0
- package/dist/utils/box.js +2 -0
- package/dist/utils/box.js.map +7 -0
- package/dist/utils/bridgeElevation.js +2 -0
- package/dist/utils/bridgeElevation.js.map +7 -0
- package/dist/utils/build.js +2 -0
- package/dist/utils/build.js.map +7 -0
- package/dist/utils/cameraControls.js +2 -0
- package/dist/utils/cameraControls.js.map +7 -0
- package/dist/utils/channel.js +2 -0
- package/dist/utils/channel.js.map +7 -0
- package/dist/utils/collider.js +2 -0
- package/dist/utils/collider.js.map +7 -0
- package/dist/utils/colliders.js +2 -0
- package/dist/utils/colliders.js.map +7 -0
- package/dist/utils/computeBounds.js +2 -0
- package/dist/utils/computeBounds.js.map +7 -0
- package/dist/utils/conformModelToTerrain.js +2 -0
- package/dist/utils/conformModelToTerrain.js.map +7 -0
- package/dist/utils/createMesh.js +2 -0
- package/dist/utils/createMesh.js.map +7 -0
- package/dist/utils/createProgram.js +3 -0
- package/dist/utils/createProgram.js.map +7 -0
- package/dist/utils/decodeDirectory.js +2 -0
- package/dist/utils/decodeDirectory.js.map +7 -0
- package/dist/utils/decodeHeader.js +2 -0
- package/dist/utils/decodeHeader.js.map +7 -0
- package/dist/utils/decodeModel.js +2 -0
- package/dist/utils/decodeModel.js.map +7 -0
- package/dist/utils/decompress.js +2 -0
- package/dist/utils/decompress.js.map +7 -0
- package/dist/utils/destroyTexture.js +2 -0
- package/dist/utils/destroyTexture.js.map +7 -0
- package/dist/utils/disposeMesh.js +2 -0
- package/dist/utils/disposeMesh.js.map +7 -0
- package/dist/utils/drawGeometry.js +2 -0
- package/dist/utils/drawGeometry.js.map +7 -0
- package/dist/utils/elevationWGSL.js +24 -0
- package/dist/utils/elevationWGSL.js.map +7 -0
- package/dist/utils/emptyNode.js +2 -0
- package/dist/utils/emptyNode.js.map +7 -0
- package/dist/utils/endZoom.js +2 -0
- package/dist/utils/endZoom.js.map +7 -0
- package/dist/utils/findFeature.js +2 -0
- package/dist/utils/findFeature.js.map +7 -0
- package/dist/utils/geometry.js +1 -0
- package/dist/utils/geometry.js.map +7 -0
- package/dist/utils/getElevation.js +2 -0
- package/dist/utils/getElevation.js.map +7 -0
- package/dist/utils/getHeader.js +2 -0
- package/dist/utils/getHeader.js.map +7 -0
- package/dist/utils/getZxy.js +2 -0
- package/dist/utils/getZxy.js.map +7 -0
- package/dist/utils/glass.js +2 -0
- package/dist/utils/glass.js.map +7 -0
- package/dist/utils/headlight.js +2 -0
- package/dist/utils/headlight.js.map +7 -0
- package/dist/utils/hit.js +2 -0
- package/dist/utils/hit.js.map +7 -0
- package/dist/utils/horizontalPosition.js +2 -0
- package/dist/utils/horizontalPosition.js.map +7 -0
- package/dist/utils/horizontalRay.js +2 -0
- package/dist/utils/horizontalRay.js.map +7 -0
- package/dist/utils/hull.js +2 -0
- package/dist/utils/hull.js.map +7 -0
- package/dist/utils/initSunlight.js +2 -0
- package/dist/utils/initSunlight.js.map +7 -0
- package/dist/utils/initTerrain.js +2 -0
- package/dist/utils/initTerrain.js.map +7 -0
- package/dist/utils/initTraffic.js +40 -0
- package/dist/utils/initTraffic.js.map +7 -0
- package/dist/utils/initWalk.js +2 -0
- package/dist/utils/initWalk.js.map +7 -0
- package/dist/utils/intersectMeshes.js +2 -0
- package/dist/utils/intersectMeshes.js.map +7 -0
- package/dist/utils/isClockWise.js +2 -0
- package/dist/utils/isClockWise.js.map +7 -0
- package/dist/utils/lampPostGeometry.js +2 -0
- package/dist/utils/lampPostGeometry.js.map +7 -0
- package/dist/utils/lightGeometry.js +2 -0
- package/dist/utils/lightGeometry.js.map +7 -0
- package/dist/utils/lightGrid.js +2 -0
- package/dist/utils/lightGrid.js.map +7 -0
- package/dist/utils/limbs.js +2 -0
- package/dist/utils/limbs.js.map +7 -0
- package/dist/utils/loadModel.js +2 -0
- package/dist/utils/loadModel.js.map +7 -0
- package/dist/utils/loadSource.js +2 -0
- package/dist/utils/loadSource.js.map +7 -0
- package/dist/utils/loadTerrain.js +2 -0
- package/dist/utils/loadTerrain.js.map +7 -0
- package/dist/utils/mapCamera.js +2 -0
- package/dist/utils/mapCamera.js.map +7 -0
- package/dist/utils/materialShaders.js +211 -0
- package/dist/utils/materialShaders.js.map +7 -0
- package/dist/utils/mirror.js +2 -0
- package/dist/utils/mirror.js.map +7 -0
- package/dist/utils/moonPosition.js +2 -0
- package/dist/utils/moonPosition.js.map +7 -0
- package/dist/utils/moves.js +2 -0
- package/dist/utils/moves.js.map +7 -0
- package/dist/utils/nativeEvents.js +2 -0
- package/dist/utils/nativeEvents.js.map +7 -0
- package/dist/utils/nativeGeometry.js +2 -0
- package/dist/utils/nativeGeometry.js.map +7 -0
- package/dist/utils/nativeLayer.js +2 -0
- package/dist/utils/nativeLayer.js.map +7 -0
- package/dist/utils/nodeMatrix.js +2 -0
- package/dist/utils/nodeMatrix.js.map +7 -0
- package/dist/utils/onAdd3DLayer.js +2 -0
- package/dist/utils/onAdd3DLayer.js.map +7 -0
- package/dist/utils/onAddSun.js +2 -0
- package/dist/utils/onAddSun.js.map +7 -0
- package/dist/utils/onClick.js +2 -0
- package/dist/utils/onClick.js.map +7 -0
- package/dist/utils/onMapChange.js +2 -0
- package/dist/utils/onMapChange.js.map +7 -0
- package/dist/utils/onPMTileAdd.js +2 -0
- package/dist/utils/onPMTileAdd.js.map +7 -0
- package/dist/utils/onPMTileRemove.js +2 -0
- package/dist/utils/onPMTileRemove.js.map +7 -0
- package/dist/utils/onPointerLeave.js +2 -0
- package/dist/utils/onPointerLeave.js.map +7 -0
- package/dist/utils/onPointerMove.js +2 -0
- package/dist/utils/onPointerMove.js.map +7 -0
- package/dist/utils/onRemove3DLayer.js +2 -0
- package/dist/utils/onRemove3DLayer.js.map +7 -0
- package/dist/utils/onRemoveSun.js +2 -0
- package/dist/utils/onRemoveSun.js.map +7 -0
- package/dist/utils/onTerrainAdd.js +2 -0
- package/dist/utils/onTerrainAdd.js.map +7 -0
- package/dist/utils/onTerrainChange.js +2 -0
- package/dist/utils/onTerrainChange.js.map +7 -0
- package/dist/utils/onTerrainRemove.js +2 -0
- package/dist/utils/onTerrainRemove.js.map +7 -0
- package/dist/utils/onZoomAnim.js +2 -0
- package/dist/utils/onZoomAnim.js.map +7 -0
- package/dist/utils/paints.js +2 -0
- package/dist/utils/paints.js.map +7 -0
- package/dist/utils/parseColor.js +2 -0
- package/dist/utils/parseColor.js.map +7 -0
- package/dist/utils/parts.js +2 -0
- package/dist/utils/parts.js.map +7 -0
- package/dist/utils/projectCelestialBody.js +2 -0
- package/dist/utils/projectCelestialBody.js.map +7 -0
- package/dist/utils/pump.js +2 -0
- package/dist/utils/pump.js.map +7 -0
- package/dist/utils/rasterTiles.js +2 -0
- package/dist/utils/rasterTiles.js.map +7 -0
- package/dist/utils/raycast.js +2 -0
- package/dist/utils/raycast.js.map +7 -0
- package/dist/utils/read.js +2 -0
- package/dist/utils/read.js.map +7 -0
- package/dist/utils/readAccessor.js +2 -0
- package/dist/utils/readAccessor.js.map +7 -0
- package/dist/utils/releaseArea.js +2 -0
- package/dist/utils/releaseArea.js.map +7 -0
- package/dist/utils/removeRasterTile.js +2 -0
- package/dist/utils/removeRasterTile.js.map +7 -0
- package/dist/utils/render.js +15 -0
- package/dist/utils/render.js.map +7 -0
- package/dist/utils/renderSunlight.js +13 -0
- package/dist/utils/renderSunlight.js.map +7 -0
- package/dist/utils/renderers.js +2 -0
- package/dist/utils/renderers.js.map +7 -0
- package/dist/utils/resizeSunlight.js +2 -0
- package/dist/utils/resizeSunlight.js.map +7 -0
- package/dist/utils/roofCoverage.js +2 -0
- package/dist/utils/roofCoverage.js.map +7 -0
- package/dist/utils/routeGeometry.js +2 -0
- package/dist/utils/routeGeometry.js.map +7 -0
- package/dist/utils/scheduledTrips.js +2 -0
- package/dist/utils/scheduledTrips.js.map +7 -0
- package/dist/utils/setGeoJSONData.js +2 -0
- package/dist/utils/setGeoJSONData.js.map +7 -0
- package/dist/utils/setHighlight.js +2 -0
- package/dist/utils/setHighlight.js.map +7 -0
- package/dist/utils/setPMTileOpacity.js +2 -0
- package/dist/utils/setPMTileOpacity.js.map +7 -0
- package/dist/utils/setPMTileZIndex.js +2 -0
- package/dist/utils/setPMTileZIndex.js.map +7 -0
- package/dist/utils/setParent.js +2 -0
- package/dist/utils/setParent.js.map +7 -0
- package/dist/utils/setTerrainHeight.js +2 -0
- package/dist/utils/setTerrainHeight.js.map +7 -0
- package/dist/utils/setVertexColor.js +2 -0
- package/dist/utils/setVertexColor.js.map +7 -0
- package/dist/utils/showFeature.js +2 -0
- package/dist/utils/showFeature.js.map +7 -0
- package/dist/utils/sizes.js +2 -0
- package/dist/utils/sizes.js.map +7 -0
- package/dist/utils/skin.js +2 -0
- package/dist/utils/skin.js.map +7 -0
- package/dist/utils/solarPosition.js +2 -0
- package/dist/utils/solarPosition.js.map +7 -0
- package/dist/utils/sortMeshes.js +2 -0
- package/dist/utils/sortMeshes.js.map +7 -0
- package/dist/utils/speed.js +2 -0
- package/dist/utils/speed.js.map +7 -0
- package/dist/utils/startZoom.js +2 -0
- package/dist/utils/startZoom.js.map +7 -0
- package/dist/utils/taillight.js +2 -0
- package/dist/utils/taillight.js.map +7 -0
- package/dist/utils/terrainAtlas.js +2 -0
- package/dist/utils/terrainAtlas.js.map +7 -0
- package/dist/utils/terrainElevation.js +2 -0
- package/dist/utils/terrainElevation.js.map +7 -0
- package/dist/utils/terrainGrid.js +2 -0
- package/dist/utils/terrainGrid.js.map +7 -0
- package/dist/utils/textureSampler.js +2 -0
- package/dist/utils/textureSampler.js.map +7 -0
- package/dist/utils/tileId.js +2 -0
- package/dist/utils/tileId.js.map +7 -0
- package/dist/utils/toLanes.js +2 -0
- package/dist/utils/toLanes.js.map +7 -0
- package/dist/utils/toSRGB.js +2 -0
- package/dist/utils/toSRGB.js.map +7 -0
- package/dist/utils/tooltip.js +3 -0
- package/dist/utils/tooltip.js.map +7 -0
- package/dist/utils/traffic.js +2 -0
- package/dist/utils/traffic.js.map +7 -0
- package/dist/utils/traverse.js +2 -0
- package/dist/utils/traverse.js.map +7 -0
- package/dist/utils/treeGeometry.js +2 -0
- package/dist/utils/treeGeometry.js.map +7 -0
- package/dist/utils/triangulate.js +2 -0
- package/dist/utils/triangulate.js.map +7 -0
- package/dist/utils/tripsAt.js +2 -0
- package/dist/utils/tripsAt.js.map +7 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +7 -0
- package/dist/utils/underEntry.js +2 -0
- package/dist/utils/underEntry.js.map +7 -0
- package/dist/utils/update.js +2 -0
- package/dist/utils/update.js.map +7 -0
- package/dist/utils/updateArea.js +2 -0
- package/dist/utils/updateArea.js.map +7 -0
- package/dist/utils/updateCamera.js +2 -0
- package/dist/utils/updateCamera.js.map +7 -0
- package/dist/utils/updatePointLights.js +2 -0
- package/dist/utils/updatePointLights.js.map +7 -0
- package/dist/utils/updateWorldMatrix.js +2 -0
- package/dist/utils/updateWorldMatrix.js.map +7 -0
- package/dist/utils/vehicleOffsets.js +2 -0
- package/dist/utils/vehicleOffsets.js.map +7 -0
- package/dist/utils/vehicles.js +2 -0
- package/dist/utils/vehicles.js.map +7 -0
- package/dist/utils/vertexNormals.js +2 -0
- package/dist/utils/vertexNormals.js.map +7 -0
- package/dist/utils/walk.js +2 -0
- package/dist/utils/walk.js.map +7 -0
- package/dist/utils/white.js +2 -0
- package/dist/utils/white.js.map +7 -0
- package/dist/utils/worldLights.js +2 -0
- package/dist/utils/worldLights.js.map +7 -0
- package/dist/utils/wrap.js +2 -0
- package/dist/utils/wrap.js.map +7 -0
- package/package.json +43 -4
- package/src/index.js +397 -0
- package/src/utils/CELL.js +4 -0
- package/src/utils/addBridges.js +66 -0
- package/src/utils/addRasterTile.js +112 -0
- package/src/utils/along.js +9 -0
- package/src/utils/atmosphere.js +20 -0
- package/src/utils/attach.js +255 -0
- package/src/utils/bindSunlight.js +12 -0
- package/src/utils/box.js +1 -0
- package/src/utils/bridgeElevation.js +18 -0
- package/src/utils/build.js +20 -0
- package/src/utils/cameraControls.js +287 -0
- package/src/utils/channel.js +4 -0
- package/src/utils/collider.js +62 -0
- package/src/utils/colliders.js +2 -0
- package/src/utils/computeBounds.js +17 -0
- package/src/utils/conformModelToTerrain.js +69 -0
- package/src/utils/createMesh.js +31 -0
- package/src/utils/createProgram.js +92 -0
- package/src/utils/decodeDirectory.js +40 -0
- package/src/utils/decodeHeader.js +15 -0
- package/src/utils/decodeModel.js +43 -0
- package/src/utils/decompress.js +5 -0
- package/src/utils/destroyTexture.js +7 -0
- package/src/utils/disposeMesh.js +13 -0
- package/src/utils/drawGeometry.js +122 -0
- package/src/utils/elevationWGSL.js +27 -0
- package/src/utils/emptyNode.js +9 -0
- package/src/utils/endZoom.js +15 -0
- package/src/utils/findFeature.js +49 -0
- package/src/utils/geometry.js +2 -0
- package/src/utils/getElevation.js +10 -0
- package/src/utils/getHeader.js +9 -0
- package/src/utils/getZxy.js +76 -0
- package/src/utils/glass.js +1 -0
- package/src/utils/headlight.js +1 -0
- package/src/utils/hit.js +41 -0
- package/src/utils/horizontalPosition.js +16 -0
- package/src/utils/horizontalRay.js +12 -0
- package/src/utils/hull.js +1 -0
- package/src/utils/initSunlight.js +9 -0
- package/src/utils/initTerrain.js +19 -0
- package/src/utils/initTraffic.js +93 -0
- package/src/utils/initWalk.js +72 -0
- package/src/utils/intersectMeshes.js +121 -0
- package/src/utils/isClockWise.js +12 -0
- package/src/utils/lampPostGeometry.js +26 -0
- package/src/utils/lightGeometry.js +22 -0
- package/src/utils/lightGrid.js +50 -0
- package/src/utils/limbs.js +9 -0
- package/src/utils/loadModel.js +217 -0
- package/src/utils/loadSource.js +17 -0
- package/src/utils/loadTerrain.js +65 -0
- package/src/utils/mapCamera.js +432 -0
- package/src/utils/materialShaders.js +243 -0
- package/src/utils/mirror.js +6 -0
- package/src/utils/moonPosition.js +17 -0
- package/src/utils/moves.js +11 -0
- package/src/utils/nativeEvents.js +77 -0
- package/src/utils/nativeGeometry.js +131 -0
- package/src/utils/nativeLayer.js +317 -0
- package/src/utils/nodeMatrix.js +22 -0
- package/src/utils/onAdd3DLayer.js +31 -0
- package/src/utils/onAddSun.js +147 -0
- package/src/utils/onClick.js +13 -0
- package/src/utils/onMapChange.js +16 -0
- package/src/utils/onPMTileAdd.js +15 -0
- package/src/utils/onPMTileRemove.js +8 -0
- package/src/utils/onPointerLeave.js +11 -0
- package/src/utils/onPointerMove.js +15 -0
- package/src/utils/onRemove3DLayer.js +78 -0
- package/src/utils/onRemoveSun.js +3 -0
- package/src/utils/onTerrainAdd.js +18 -0
- package/src/utils/onTerrainChange.js +13 -0
- package/src/utils/onTerrainRemove.js +40 -0
- package/src/utils/onZoomAnim.js +14 -0
- package/src/utils/paints.js +10 -0
- package/src/utils/parseColor.js +42 -0
- package/src/utils/parts.js +16 -0
- package/src/utils/projectCelestialBody.js +13 -0
- package/src/utils/pump.js +226 -0
- package/src/utils/rasterTiles.js +285 -0
- package/src/utils/raycast.js +60 -0
- package/src/utils/read.js +29 -0
- package/src/utils/readAccessor.js +68 -0
- package/src/utils/releaseArea.js +34 -0
- package/src/utils/removeRasterTile.js +13 -0
- package/src/utils/render.js +406 -0
- package/src/utils/renderSunlight.js +170 -0
- package/src/utils/renderers.js +2 -0
- package/src/utils/resizeSunlight.js +15 -0
- package/src/utils/roofCoverage.js +47 -0
- package/src/utils/routeGeometry.js +22 -0
- package/src/utils/scheduledTrips.js +29 -0
- package/src/utils/setGeoJSONData.js +11 -0
- package/src/utils/setHighlight.js +13 -0
- package/src/utils/setPMTileOpacity.js +7 -0
- package/src/utils/setPMTileZIndex.js +7 -0
- package/src/utils/setParent.js +7 -0
- package/src/utils/setTerrainHeight.js +10 -0
- package/src/utils/setVertexColor.js +14 -0
- package/src/utils/showFeature.js +27 -0
- package/src/utils/sizes.js +1 -0
- package/src/utils/skin.js +2 -0
- package/src/utils/solarPosition.js +17 -0
- package/src/utils/sortMeshes.js +12 -0
- package/src/utils/speed.js +3 -0
- package/src/utils/startZoom.js +5 -0
- package/src/utils/taillight.js +1 -0
- package/src/utils/terrainAtlas.js +21 -0
- package/src/utils/terrainElevation.js +20 -0
- package/src/utils/terrainGrid.js +23 -0
- package/src/utils/textureSampler.js +10 -0
- package/src/utils/tileId.js +18 -0
- package/src/utils/toLanes.js +7 -0
- package/src/utils/toSRGB.js +1 -0
- package/src/utils/tooltip.js +6 -0
- package/src/utils/traffic.js +315 -0
- package/src/utils/traverse.js +6 -0
- package/src/utils/treeGeometry.js +45 -0
- package/src/utils/triangulate.js +100 -0
- package/src/utils/tripsAt.js +16 -0
- package/src/utils/types.js +8 -0
- package/src/utils/underEntry.js +17 -0
- package/src/utils/update.js +18 -0
- package/src/utils/updateArea.js +40 -0
- package/src/utils/updateCamera.js +32 -0
- package/src/utils/updatePointLights.js +38 -0
- package/src/utils/updateWorldMatrix.js +47 -0
- package/src/utils/vehicleOffsets.js +8 -0
- package/src/utils/vehicles.js +65 -0
- package/src/utils/vertexNormals.js +30 -0
- package/src/utils/walk.js +187 -0
- package/src/utils/white.js +1 -0
- package/src/utils/worldLights.js +25 -0
- package/src/utils/wrap.js +1 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** Test the mesh's ground footprint against loaded imagery, including coarse parent tiles. */
|
|
2
|
+
export function roofCoverage(mesh, backend, rasters) {
|
|
3
|
+
const map = backend._map, bounds = mesh.geometry.bounds, world = mesh.worldMatrix;
|
|
4
|
+
let intersectsArchive = false;
|
|
5
|
+
for (const layer of rasters) {
|
|
6
|
+
const zoom = layer._tileZoom, origin = map.project(backend._sceneOrigin, zoom);
|
|
7
|
+
const scale = map.options.crs.scale(zoom) / (40075016.68557849 * Math.cos(backend._sceneOrigin.lat * Math.PI / 180));
|
|
8
|
+
const min = [Infinity, Infinity], max = [-Infinity, -Infinity];
|
|
9
|
+
for (let i = 0; i < 8; i++) {
|
|
10
|
+
const x = i & 1 ? bounds.max[0] : bounds.min[0], y = i & 2 ? bounds.max[1] : bounds.min[1];
|
|
11
|
+
const z = i & 4 ? bounds.max[2] : bounds.min[2];
|
|
12
|
+
const px = origin.x + (world[0] * x + world[4] * y + world[8] * z + world[12]) * scale;
|
|
13
|
+
const py = origin.y + (world[2] * x + world[6] * y + world[10] * z + world[14]) * scale;
|
|
14
|
+
min[0] = Math.min(min[0], px); min[1] = Math.min(min[1], py);
|
|
15
|
+
max[0] = Math.max(max[0], px); max[1] = Math.max(max[1], py);
|
|
16
|
+
}
|
|
17
|
+
if (layer.header.maxLat !== undefined && layer.header.minLon !== undefined &&
|
|
18
|
+
layer.header.minLat !== undefined && layer.header.maxLon !== undefined) {
|
|
19
|
+
const nw = map.project([layer.header.maxLat, layer.header.minLon], zoom);
|
|
20
|
+
const se = map.project([layer.header.minLat, layer.header.maxLon], zoom);
|
|
21
|
+
min[0] = Math.max(min[0], nw.x); min[1] = Math.max(min[1], nw.y);
|
|
22
|
+
max[0] = Math.min(max[0], se.x); max[1] = Math.min(max[1], se.y);
|
|
23
|
+
if (min[0] >= max[0] || min[1] >= max[1]) continue;
|
|
24
|
+
}
|
|
25
|
+
intersectsArchive = true;
|
|
26
|
+
let remaining = [[min[0], min[1], max[0], max[1]]];
|
|
27
|
+
for (const tile of layer._rasterTiles.values()) {
|
|
28
|
+
// Failed imagery already reports an error; do not hide the building indefinitely.
|
|
29
|
+
if (!tile.done && !tile.error) continue;
|
|
30
|
+
const size = 256 * 2 ** (zoom - tile.coords.z);
|
|
31
|
+
const left = tile.coords.x * size, top = tile.coords.y * size;
|
|
32
|
+
remaining = remaining.flatMap(([x0, y0, x1, y1]) => {
|
|
33
|
+
const l = Math.max(x0, left), t = Math.max(y0, top);
|
|
34
|
+
const r = Math.min(x1, left + size), b = Math.min(y1, top + size);
|
|
35
|
+
if (l >= r || t >= b) return [[x0, y0, x1, y1]];
|
|
36
|
+
const pieces = [];
|
|
37
|
+
if (y0 < t) pieces.push([x0, y0, x1, t]);
|
|
38
|
+
if (b < y1) pieces.push([x0, b, x1, y1]);
|
|
39
|
+
if (x0 < l) pieces.push([x0, t, l, b]);
|
|
40
|
+
if (r < x1) pieces.push([r, t, x1, b]);
|
|
41
|
+
return pieces;
|
|
42
|
+
});
|
|
43
|
+
if (!remaining.length) return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return !intersectsArchive;
|
|
47
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Dashed lane outline, in layer-local metres. */
|
|
2
|
+
|
|
3
|
+
export function routeGeometry(lanes) {
|
|
4
|
+
const position = [], normal = [], color = [];
|
|
5
|
+
for (const { points, lengths } of lanes) for (let i = 1; i < points.length; i++) {
|
|
6
|
+
const a = points[i - 1], b = points[i];
|
|
7
|
+
const dx = b[0] - a[0], dz = b[1] - a[1], length = lengths[i] - lengths[i - 1];
|
|
8
|
+
if (!length) continue;
|
|
9
|
+
const x = -dz / length * 2.5, z = dx / length * 2.5;
|
|
10
|
+
for (let distance = Math.floor(lengths[i - 1] / 30) * 30; distance < lengths[i]; distance += 30) {
|
|
11
|
+
const start = Math.max(0, (distance - lengths[i - 1]) / length);
|
|
12
|
+
const end = Math.min(1, (distance + 18 - lengths[i - 1]) / length);
|
|
13
|
+
if (end <= start) continue;
|
|
14
|
+
const p = [a[0] + dx * start, a[1] + dz * start], q = [a[0] + dx * end, a[1] + dz * end], y = a[2] + 0.4;
|
|
15
|
+
for (const point of [[p[0] - x, p[1] - z], [p[0] + x, p[1] + z], [q[0] + x, q[1] + z],
|
|
16
|
+
[p[0] - x, p[1] - z], [q[0] + x, q[1] + z], [q[0] - x, q[1] - z]]) {
|
|
17
|
+
position.push(point[0], y, point[1]); normal.push(0, 1, 0); color.push(0.08, 0.7, 0.85);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return { position, normal, color };
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trips of a frequency-based timetable (like GTFS frequencies.txt) underway at `date`, in the timetable's local time.
|
|
3
|
+
* @param {{timeZone: string, duration: number, services: Array<{from: string, to: string, every?: number, months?: number[], weekdays?: number[]}>}} timetable
|
|
4
|
+
* `duration` and `every` are minutes; `from`/`to` are 'HH:MM' first/last departures; months are 1-12, weekdays 0 (Sunday)-6.
|
|
5
|
+
* @returns {Array<{id: string, departure: string, progress: number}>} `progress` is 0-1 along the lane.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function scheduledTrips(date, { timeZone, duration, services }) {
|
|
9
|
+
const time = new Date(date);
|
|
10
|
+
if (!Number.isFinite(time.getTime())) throw new Error('Invalid date');
|
|
11
|
+
const clock = new Intl.DateTimeFormat('en-GB', {
|
|
12
|
+
timeZone, year: 'numeric', month: '2-digit', day: '2-digit',
|
|
13
|
+
hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23',
|
|
14
|
+
});
|
|
15
|
+
const parts = Object.fromEntries(clock.formatToParts(time).filter(p => p.type !== 'literal').map(p => [p.type, Number(p.value)]));
|
|
16
|
+
const minute = parts.hour * 60 + parts.minute + (parts.second + time.getUTCMilliseconds() / 1000) / 60;
|
|
17
|
+
const weekday = new Date(Date.UTC(parts.year, parts.month - 1, parts.day)).getUTCDay();
|
|
18
|
+
const minutes = clockTime => clockTime.split(':').reduce((hours, value) => hours * 60 + Number(value));
|
|
19
|
+
const departures = [];
|
|
20
|
+
for (const { from, to, every = Infinity, months, weekdays } of services) {
|
|
21
|
+
if (months?.includes(parts.month) === false || weekdays?.includes(weekday) === false) continue;
|
|
22
|
+
for (let departure = minutes(from); departure <= minutes(to); departure += every) departures.push(departure);
|
|
23
|
+
}
|
|
24
|
+
return departures.sort((a, b) => a - b).filter(departure => minute >= departure && minute < departure + duration).map(departure => ({
|
|
25
|
+
id: `${parts.year}-${parts.month}-${parts.day}-${departure}`,
|
|
26
|
+
departure: `${String(Math.floor(departure / 60)).padStart(2, '0')}:${String(departure % 60).padStart(2, '0')}`,
|
|
27
|
+
progress: (minute - departure) / duration,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { releaseArea } from './releaseArea.js';
|
|
2
|
+
import { updateArea } from './updateArea.js';
|
|
3
|
+
|
|
4
|
+
export function setGeoJSONData(layer, data) {
|
|
5
|
+
layer.options.data = data;
|
|
6
|
+
delete layer.options.url;
|
|
7
|
+
for (const area of layer._areas.values()) releaseArea(layer, area);
|
|
8
|
+
layer._areas.clear();
|
|
9
|
+
updateArea(layer);
|
|
10
|
+
return layer;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { update } from './update.js';
|
|
2
|
+
|
|
3
|
+
/** Highlight a source vertex range in the shader; vertex colors stay untouched. */
|
|
4
|
+
|
|
5
|
+
export function setHighlight(backend, feature) {
|
|
6
|
+
if (feature?.model) feature = null;
|
|
7
|
+
if (backend.highlightedFeature?.mesh === feature?.mesh &&
|
|
8
|
+
backend.highlightedFeature?.vertexStart === feature?.vertexStart) return;
|
|
9
|
+
if (backend.highlightedFeature) backend.highlightedFeature.mesh.highlight = null;
|
|
10
|
+
backend.highlightedFeature = feature;
|
|
11
|
+
if (feature) feature.mesh.highlight = [feature.vertexStart, feature.vertexEnd];
|
|
12
|
+
update(backend);
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Reparent/detach scene data without drawing or disposing GPU resources. */
|
|
2
|
+
|
|
3
|
+
export function setParent(node, parent) {
|
|
4
|
+
if (node.parent) node.parent.children.splice(node.parent.children.indexOf(node), 1);
|
|
5
|
+
node.parent = parent;
|
|
6
|
+
if (parent) parent.children.push(node);
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getElevation } from './getElevation.js';
|
|
2
|
+
|
|
3
|
+
export function setTerrainHeight(layer) {
|
|
4
|
+
if (!layer.root || !layer.location) return;
|
|
5
|
+
layer._terrainBaseY ??= layer.root.position[1];
|
|
6
|
+
const terrain = layer._map?._terrain3D;
|
|
7
|
+
const elevation = terrain && getElevation(terrain, layer.location);
|
|
8
|
+
const offset = Number.isFinite(elevation) ? layer.options.terrainOffset ?? 0 : 0;
|
|
9
|
+
layer.root.position[1] = layer._terrainBaseY + (elevation ?? 0) + offset;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paints the vertices `[start, end)` of a mesh and marks its color buffer dirty.
|
|
3
|
+
* @param {Object} mesh Layer-created mesh with a color attribute.
|
|
4
|
+
* @param {number} start Inclusive vertex index, not an offset into the RGB array.
|
|
5
|
+
* @param {number} end Exclusive vertex index.
|
|
6
|
+
* @param {Object} color sRGB {r,g,b}, typically from parseColor().
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function setVertexColor(mesh, start, end, color) {
|
|
10
|
+
for (let i = start; i < end; i++) {
|
|
11
|
+
mesh.geometry.attributes.color.data.set([color.r, color.g, color.b], i * 3);
|
|
12
|
+
}
|
|
13
|
+
mesh.geometry.attributes.color.needsUpdate = true;
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Update tooltip content/position and arbitrate cursor ownership across shared layers. */
|
|
2
|
+
|
|
3
|
+
export function showFeature(backend, feature, event) {
|
|
4
|
+
const tooltip = backend._tooltip;
|
|
5
|
+
if (!tooltip) return;
|
|
6
|
+
if (feature) {
|
|
7
|
+
tooltip.replaceChildren(backend.options.tooltip(feature));
|
|
8
|
+
tooltip.hidden = false;
|
|
9
|
+
const rect = backend.container.getBoundingClientRect();
|
|
10
|
+
const x = event.clientX - rect.left, y = event.clientY - rect.top;
|
|
11
|
+
tooltip.style.left = `${x + tooltip.offsetWidth + 16 > rect.width ? x - tooltip.offsetWidth - 12 : x + 12}px`;
|
|
12
|
+
tooltip.style.top = `${y + tooltip.offsetHeight + 16 > rect.height ? y - tooltip.offsetHeight - 12 : y + 12}px`;
|
|
13
|
+
} else {
|
|
14
|
+
tooltip.hidden = true;
|
|
15
|
+
}
|
|
16
|
+
const shared = backend._shared;
|
|
17
|
+
if (shared) {
|
|
18
|
+
const visible = [...shared._layers].some(layer => layer._tooltip && !layer._tooltip.hidden);
|
|
19
|
+
if (visible) {
|
|
20
|
+
if (shared._cursor === undefined) shared._cursor = backend.container.style.cursor;
|
|
21
|
+
backend.container.style.cursor = 'pointer';
|
|
22
|
+
} else if (shared._cursor !== undefined) {
|
|
23
|
+
backend.container.style.cursor = shared._cursor;
|
|
24
|
+
delete shared._cursor;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const sizes = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4 };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { horizontalPosition } from "./horizontalPosition.js";
|
|
2
|
+
|
|
3
|
+
// Solar centre, without atmospheric refraction.
|
|
4
|
+
|
|
5
|
+
export function solarPosition(date, lat, lng) {
|
|
6
|
+
const time = new Date(date).getTime();
|
|
7
|
+
if (!Number.isFinite(time) || !Number.isFinite(lat) || Math.abs(lat) > 90 ||
|
|
8
|
+
!Number.isFinite(lng) || Math.abs(lng) > 180) throw new Error('Invalid solar date or location');
|
|
9
|
+
const rad = Math.PI / 180, d = time / 86400000 - 10957.5;
|
|
10
|
+
const mean = (357.5291 + 0.98560028 * d) * rad;
|
|
11
|
+
const longitude = mean + (1.9148 * Math.sin(mean) + 0.02 * Math.sin(2 * mean) +
|
|
12
|
+
0.0003 * Math.sin(3 * mean) + 102.9372 + 180) * rad;
|
|
13
|
+
const obliquity = 23.4397 * rad;
|
|
14
|
+
const declination = Math.asin(Math.sin(longitude) * Math.sin(obliquity));
|
|
15
|
+
const ascension = Math.atan2(Math.sin(longitude) * Math.cos(obliquity), Math.cos(longitude));
|
|
16
|
+
return horizontalPosition(d, lat, lng, ascension, declination);
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export function sortMeshes(meshes) {
|
|
3
|
+
return meshes.sort((a, b) => Number(Boolean(b.ground)) - Number(Boolean(a.ground)) ||
|
|
4
|
+
(a.ground && b.ground ? (a.renderOrder || 0) - (b.renderOrder || 0) ||
|
|
5
|
+
a.tile.coords.z - b.tile.coords.z : 0) ||
|
|
6
|
+
Number(a.program.transparent) - Number(b.program.transparent) ||
|
|
7
|
+
(a.program.transparent
|
|
8
|
+
? (a.renderOrder || 0) - (b.renderOrder || 0) ||
|
|
9
|
+
b._sortDepth - a._sortDepth || a.id - b.id
|
|
10
|
+
: (a._sortDepth ?? 0) - (b._sortDepth ?? 0) || a.id - b.id)
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const taillight = [1.7, 0.06, 0.05];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Float32 DEM atlas; missing samples retain the shader no-data sentinel. */
|
|
2
|
+
|
|
3
|
+
export function terrainAtlas(tiles, bounds) {
|
|
4
|
+
const columns = bounds.max.x - bounds.min.x + 1, rows = bounds.max.y - bounds.min.y + 1;
|
|
5
|
+
const elevations = new Float32Array(columns * rows * 65536).fill(-1e9);
|
|
6
|
+
let low = Infinity, high = -Infinity;
|
|
7
|
+
for (const [key, values] of tiles) {
|
|
8
|
+
const [x, y] = key.split('/').map(Number);
|
|
9
|
+
const start = (y - bounds.min.y) * 256 * columns * 256 + (x - bounds.min.x) * 256;
|
|
10
|
+
for (let row = 0; row < 256; row++) {
|
|
11
|
+
for (let column = 0; column < 256; column++) {
|
|
12
|
+
const value = values[row * 256 + column];
|
|
13
|
+
if (!Number.isFinite(value) || value <= -1000) continue;
|
|
14
|
+
elevations[start + row * columns * 256 + column] = value;
|
|
15
|
+
low = Math.min(low, value);
|
|
16
|
+
high = Math.max(high, value);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return { elevations, low, high };
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Bilinear DEM sampling, with the original first-valid-neighbour no-data rule. */
|
|
2
|
+
|
|
3
|
+
export function terrainElevation(point, tiles) {
|
|
4
|
+
const x = point.x - 0.5, y = point.y - 0.5;
|
|
5
|
+
const x0 = Math.floor(x), y0 = Math.floor(y);
|
|
6
|
+
const fx = x - x0, fy = y - y0;
|
|
7
|
+
const sample = (px, py) => {
|
|
8
|
+
const tileX = Math.floor(px / 256), tileY = Math.floor(py / 256);
|
|
9
|
+
const tile = tiles.get(`${tileX}/${tileY}`);
|
|
10
|
+
if (!tile) return null;
|
|
11
|
+
const elevation = tile[(py - tileY * 256) * 256 + px - tileX * 256];
|
|
12
|
+
return Number.isFinite(elevation) && elevation > -1000 ? elevation : null;
|
|
13
|
+
};
|
|
14
|
+
const values = [sample(x0, y0), sample(x0 + 1, y0), sample(x0, y0 + 1), sample(x0 + 1, y0 + 1)];
|
|
15
|
+
const valid = values.map((value, i) => Number.isFinite(value) ? i : -1).filter(i => i >= 0);
|
|
16
|
+
if (!valid.length) return null;
|
|
17
|
+
if (valid.length < 4) return values[valid[0]];
|
|
18
|
+
return (values[0] * (1 - fx) + values[1] * fx) * (1 - fy) +
|
|
19
|
+
(values[2] * (1 - fx) + values[3] * fx) * fy;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Unit tile grid; the vertex shader supplies the elevation. */
|
|
2
|
+
|
|
3
|
+
export function terrainGrid(divisions) {
|
|
4
|
+
const positions = [], normals = [], uvs = [], indices = [];
|
|
5
|
+
for (let row = 0; row <= divisions; row++) {
|
|
6
|
+
for (let column = 0; column <= divisions; column++) {
|
|
7
|
+
positions.push(column / divisions, 0, row / divisions);
|
|
8
|
+
normals.push(0, 1, 0);
|
|
9
|
+
uvs.push(column / divisions, row / divisions);
|
|
10
|
+
if (row < divisions && column < divisions) {
|
|
11
|
+
const a = row * (divisions + 1) + column;
|
|
12
|
+
const b = a + 1, c = a + divisions + 1, d = c + 1;
|
|
13
|
+
indices.push(a, c, b, b, c, d);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
position: { size: 3, data: new Float32Array(positions) },
|
|
19
|
+
normal: { size: 3, data: new Float32Array(normals) },
|
|
20
|
+
uv: { size: 2, data: new Float32Array(uvs) },
|
|
21
|
+
index: { data: new Uint16Array(indices) },
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Translate glTF sampler constants into WebGPU sampler options. */
|
|
2
|
+
|
|
3
|
+
export function textureSampler(sampler) {
|
|
4
|
+
return {
|
|
5
|
+
addressModeU: sampler.wrapS === 33071 ? 'clamp-to-edge' : sampler.wrapS === 33648 ? 'mirror-repeat' : 'repeat',
|
|
6
|
+
addressModeV: sampler.wrapT === 33071 ? 'clamp-to-edge' : sampler.wrapT === 33648 ? 'mirror-repeat' : 'repeat',
|
|
7
|
+
magFilter: sampler.magFilter === 9728 ? 'nearest' : 'linear',
|
|
8
|
+
minFilter: sampler.minFilter === 9728 || sampler.minFilter === 9984 || sampler.minFilter === 9986 ? 'nearest' : 'linear',
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Cumulative Hilbert ID for an archive tile. */
|
|
2
|
+
|
|
3
|
+
export function tileId(z, x, y) {
|
|
4
|
+
if (![z, x, y].every(Number.isInteger) || z < 0 || z > 26 ||
|
|
5
|
+
x < 0 || y < 0 || x >= 2 ** z || y >= 2 ** z) throw new Error('Invalid PMTiles tile coordinates');
|
|
6
|
+
let id = (4 ** z - 1) / 3;
|
|
7
|
+
const n = 2 ** z;
|
|
8
|
+
// Same cumulative Hilbert ordering used by build/pmtiles.js.
|
|
9
|
+
for (let s = n / 2; s >= 1; s /= 2) {
|
|
10
|
+
const rx = (x & s) ? 1 : 0, ry = (y & s) ? 1 : 0;
|
|
11
|
+
id += s * s * ((3 * rx) ^ ry);
|
|
12
|
+
if (!ry) {
|
|
13
|
+
if (rx) { x = n - 1 - x; y = n - 1 - y; }
|
|
14
|
+
[x, y] = [y, x];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return id;
|
|
18
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// GeoJSON (Multi)LineStrings become lanes ({latlngs, properties, elevation?}); prepare() adds `points` ([x, z, ground]),
|
|
2
|
+
// `lengths` and `length` in layer-local metres.
|
|
3
|
+
|
|
4
|
+
export const toLanes = ({ features = [] }) => features.flatMap(({ geometry, properties }) => {
|
|
5
|
+
const lines = geometry?.type === 'LineString' ? [geometry.coordinates] : geometry?.type === 'MultiLineString' ? geometry.coordinates : [];
|
|
6
|
+
return lines.map(line => ({ latlngs: line.map(([lng, lat]) => [lat, lng]), properties: properties ?? {}, elevation: properties?.elevation }));
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const toSRGB = value => value <= 0.0031308 ? value * 12.92 : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const tooltip = ({ properties: p }) => {
|
|
2
|
+
const content = document.createElement('div');
|
|
3
|
+
content.style.whiteSpace = 'pre-line';
|
|
4
|
+
content.textContent = [p.name, p.departure && `Departure ${p.departure} ${p.timetable.timeZone}`, p.description].filter(Boolean).join('\n');
|
|
5
|
+
return content;
|
|
6
|
+
};
|