From c06f9ea0f8ef9106a983e0f690f777d76c79c4db Mon Sep 17 00:00:00 2001 From: gaozheng Date: Tue, 16 Jun 2026 22:01:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(vtk):=20GeoLocalFrame=20=E5=B0=B1?= =?UTF-8?q?=E5=9C=B0=20reanchor=20+=20=E5=B8=98=E9=9D=A2=E9=87=8D=E9=94=9A?= =?UTF-8?q?=E6=94=B9=E5=B0=B1=E5=9C=B0(=E5=85=B1=E4=BA=AB=20frame=20?= =?UTF-8?q?=E4=B8=80=E8=87=B4,=E4=BE=9B=E5=BA=95=E5=9B=BE=E7=AD=89?= =?UTF-8?q?=E5=90=8C=E6=BA=90=E5=AF=B9=E9=BD=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/VtkSceneView.cpp | 3 ++- src/core/geo/GeoLocalFrame.cpp | 7 +++++++ src/core/geo/GeoLocalFrame.hpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/VtkSceneView.cpp b/src/app/VtkSceneView.cpp index a10db8a..3988d7b 100644 --- a/src/app/VtkSceneView.cpp +++ b/src/app/VtkSceneView.cpp @@ -88,7 +88,8 @@ void VtkSceneView::addCurtain(const geopro::core::Grid& grid, const geopro::core la0 = std::min(la0, grid.lat[i]); la1 = std::max(la1, grid.lat[i]); lo0 = std::min(lo0, grid.lon[i]); lo1 = std::max(lo1, grid.lon[i]); } - frame_ = std::make_shared((la0 + la1) / 2.0, (lo0 + lo1) / 2.0); + // 就地重锚共享 frame(不换对象)→ 同持此 frame 的底图层等随即一致对齐。 + frame_->reanchor((la0 + la1) / 2.0, (lo0 + lo1) / 2.0); frameAnchoredToData_ = true; } auto curtain = geopro::render::buildCurtain(grid, cs, *frame_); diff --git a/src/core/geo/GeoLocalFrame.cpp b/src/core/geo/GeoLocalFrame.cpp index 0b77b38..62273f1 100644 --- a/src/core/geo/GeoLocalFrame.cpp +++ b/src/core/geo/GeoLocalFrame.cpp @@ -17,6 +17,13 @@ GeoLocalFrame::GeoLocalFrame(double lat0, double lon0) mPerDegLon_(kMetersPerDegLonEquator * std::cos(lat0 * kPi / 180.0)), mPerDegLat_(kMetersPerDegLat) {} +void GeoLocalFrame::reanchor(double lat0, double lon0) { + lat0_ = lat0; + lon0_ = lon0; + mPerDegLon_ = kMetersPerDegLonEquator * std::cos(lat0 * kPi / 180.0); + // mPerDegLat_ 为常数,无需更新。 +} + LocalXY GeoLocalFrame::toLocal(double lat, double lon) const { return LocalXY{(lon - lon0_) * mPerDegLon_, (lat - lat0_) * mPerDegLat_}; } diff --git a/src/core/geo/GeoLocalFrame.hpp b/src/core/geo/GeoLocalFrame.hpp index ceec27b..7a97ce2 100644 --- a/src/core/geo/GeoLocalFrame.hpp +++ b/src/core/geo/GeoLocalFrame.hpp @@ -9,6 +9,8 @@ struct LatLon { double lat, lon; }; class GeoLocalFrame { public: GeoLocalFrame(double lat0, double lon0); + // 就地改原点(不换对象):所有持有此共享 frame 的渲染层(帘面/底图/坐标轴)随即一致重定位。 + void reanchor(double lat0, double lon0); LocalXY toLocal(double lat, double lon) const; // -> (x East m, y North m) // toLocal 的反算:局部米 (x East, y North) -> 经纬度。 // lon = lon0 + x/mPerDegLon,lat = lat0 + y/mPerDegLat(坐标轴经纬度刻度用)。