| 1234567 |
- // Runtime DEM sampler for the road-grouped old-town plan. Missing heights fail; no fallback.
- import { readFileSync, writeFileSync } from 'node:fs'
- const BASE=process.env.COCKPIT_BASE||'http://localhost:8001'
- const path='tools/city-massing/city/oldtown/plan.json',plan=JSON.parse(readFileSync(path))
- const puppeteer=(await import('file:///C:/Users/ASUS/.dsh/profiles/desktop/node_modules/puppeteer-core/lib/puppeteer/puppeteer-core.js')).default
- const browser=await puppeteer.launch({executablePath:'C:/Program Files/Google/Chrome/Application/chrome.exe',headless:true,args:['--no-sandbox']})
- try{const page=await browser.newPage();await page.goto(BASE,{waitUntil:'domcontentloaded'});const heights=await page.evaluate(async points=>{window.CESIUM_BASE_URL='/cesium/';const raw=await(await fetch('/src/modules/cockpit/services/cesiumEngine.js')).text();const url=raw.match(/from\s*["']([^"']*\/cesium\.js[^"']*)["']/)?.[1];if(!url)throw Error('Cesium import URL missing');const C=await import(url),provider=await C.CesiumTerrainProvider.fromUrl('/gis/dem',{requestVertexNormals:false});const out=[];for(let i=0;i<points.length;i+=256){const c=points.slice(i,i+256).map(p=>C.Cartographic.fromDegrees(p.lon,p.lat));const s=await C.sampleTerrainMostDetailed(provider,c,true);out.push(...s.map(p=>p.height))}if(out.some(h=>!Number.isFinite(h)||h<=1))throw Error(`Missing or invalid DEM height at ${out.findIndex(h=>!Number.isFinite(h)||h<=1)}`);return out},plan.samples);writeFileSync('tools/city-massing/city/oldtown/terrain-samples.json',JSON.stringify({provider:'/gis/dem',method:'runtime sampleTerrainMostDetailed, no fallback',planPoints:plan.samples,heights},null,2));console.log({points:heights.length,min:Math.min(...heights),max:Math.max(...heights)})}finally{await browser.close()}
|