- 서버 위성 메타 응답에 그림 상자 9×9 TM 격자(tm_grid · pyproj · 응답 때 셈 · 귀퉁이 1 cm 넘게 다르면 안 줌) - 공용 createTmNormalizer(고를 칸 toNorm · 격자 쌍선형) · normOfLonLat · imageScreenMatrix · placeMapImage - B04 하단 지도 · B05 배수유역도 · B05 평면 노선 편집이 TM 자리로 · 위성 그림 = 화면 가운데 1차 행렬(contain 뺌) - Watershed 손 베낌 식 넷 · 줌아웃 한계 = 공용 식 · D03 길(createNormalizer) 바뀜 없음 · TM 길 손 안 댐 - 지킴 시험 test_589_tm_grid(Bessel · GRS80 · 격자 = pyproj 0.02 m · 그림 행렬 0.5 px · 옛 꼴 어긋남) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
34 lines
1.7 KiB
JavaScript
34 lines
1.7 KiB
JavaScript
/* 589-1 경위도 겹 → TM 자리 헬퍼 — `B04_PreProcess_UI_MapRender(_Prepare).ts` 의 `createTmNormalizer` ·
|
|
* `normOfLonLat` · `imageScreenMatrix` 를 stdin 입력으로 돌려 JSON 으로 냄.
|
|
* 입력 { meta, lonlat: [[lon, lat]], image: [w, h], views: [[w, h, scale, ox, oy]] }
|
|
*/
|
|
const path = require("path");
|
|
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const { load } = makeLoader({ root: ROOT, ui: () => ({ themeColor: () => "" }) });
|
|
const render = load("B04_PreProcess", "B04_PreProcess_UI_MapRender.ts");
|
|
const prep = load("B04_PreProcess", "logic", "B04_PreProcess_UI_MapRender_Prepare.ts");
|
|
|
|
const input = JSON.parse(require("fs").readFileSync(0, "utf-8"));
|
|
const { meta } = input;
|
|
const tmNorm = render.createTmNormalizer(meta);
|
|
const oldNorm = render.createNormalizer(meta);
|
|
const unit = { width: 1, height: 1, scale: 1, offsetX: 0, offsetY: 0 };
|
|
unit.mapRect = { x: 0, y: 0, width: 1, height: 1 };
|
|
const out = {
|
|
hasToNorm: typeof tmNorm.toNorm === "function",
|
|
tm: input.lonlat.map(([lon, lat]) => prep.normOfLonLat(tmNorm, lon, lat)),
|
|
old: input.lonlat.map(([lon, lat]) => prep.normOfLonLat(oldNorm, lon, lat)),
|
|
oldScreen: input.lonlat.map(([lon, lat]) => render.lonLatToScreen(oldNorm, unit, lon, lat)),
|
|
views: input.views.map(([w, h, scale, ox, oy]) => {
|
|
const mapRect = render.computeMapRect(meta, w, h);
|
|
const view = { width: w, height: h, scale, offsetX: ox, offsetY: oy, mapRect };
|
|
const [iw, ih] = input.image;
|
|
const toScreen = (nx, ny) => render.normalizedToScreen(view, nx, ny);
|
|
const matrix = prep.imageScreenMatrix(meta, tmNorm, iw, ih, toScreen, w / 2, h / 2);
|
|
return { mapRect, matrix };
|
|
}),
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|