#pragma once #include "Xy.h" #include "LayerName.h" #include // forward declarations class CXy; namespace cv { class Mat; } namespace fs = std::filesystem; // --- SQLite #include class AFX_EXT_CLASS MapViewLayer { public: MapViewLayer(void); virtual ~MapViewLayer(void); // 将左上右下投影坐标转换为经纬度 bool MapProjection(CXy *pXy, CRect8 rect); // 并行下载 + 拼接 + 裁剪 + 保存 // - 使用 SQLite 缓存瓦片(MBTiles 风格表结构)。 // - 参数 urls: 默认共享卫星地址 // - 参数 path: SQLite 文件路径,例如:C:\\tiles\\map_cache.sqlite // - 参数 outFile:生成的地图图片路径 // - 参数 threadCount:默认线程数 bool SaveTDTMapCroppedParallel(int zoom, const CString& urls, const CString& path, const CString& outFile, int threadCount = 6); protected: // 经纬度转换辅助 int lon2tileX(double lon, int zoom); int lat2tileY(double lat, int zoom); double lon2pixelX(double lon, int zoom); double lat2pixelY(double lat, int zoom); // SQLite bool InitTileDatabase(const fs::path& dbPath); bool ReadTileFromSQLite(sqlite3* db, int z, int x, int y, const CString& url, cv::Mat& outTile); bool InsertTileToSQLite(sqlite3* db, int z, int x, int y, const CString& url, const unsigned char* data, int size); // 下载到内存(供 SQLite 写入) bool DownloadTileBytes(const CString& url, std::vector& out); protected: double m_dX0, m_dY0; // 左上点经纬度 double m_dX1, m_dY1; // 右下点经纬度 };