You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "Xy.h"
#include "LayerName.h"
#include <filesystem>
// forward declarations
class CXy;
namespace cv { class Mat; }
namespace fs = std::filesystem;
// --- SQLite
#include <sqlite3.h>
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<unsigned char>& out);
protected:
double m_dX0, m_dY0; // 左上点经纬度
double m_dX1, m_dY1; // 右下点经纬度
};