總體流程:
- 定義天地圖切片資訊、位址資訊、位址域資訊
- 使用WebTiledLayer定義底圖
- 加載天地圖
一、定義天地圖切片資訊
包括天地圖:
//天地圖dpi
static int TDTDpi;
//天地圖圖檔格式
static TileImageFormat TDTImageFormat;
//天地圖空間坐标系
static SpatialReference TDTSR;
//天地圖原點
static Point TDTOrigin;
//天地圖圖檔高
static int TDTPixHeight;
//天地圖圖檔寬
static int TDTPixWidth;
//天地圖切片矩陣
static QList<LevelOfDetail> TDTLevels;
//天地圖電子地圖位址
static QString TDTURLVEC;
//天地圖衛星影像
static QString TDTURLIMG;
//天地圖注記
static QString TDTURLCVA;
//天地圖位址域
static QStringList TDTDOMAINS;
//天地圖全局視圖範圍
static Envelope TDTFullExtent;
void CGIS::componentComplete()
{
qDebug()<<"CGIS::componentComplete():start--------------"<<endl;
QQuickItem::componentComplete();
//std::shared_ptr<QList> levels(tdtlvs);
std::initializer_list<LevelOfDetail> lvItems={
LevelOfDetail(0,1.40625,590995197.141669),
LevelOfDetail(1,0.703125,295497598.570834),
LevelOfDetail(2,0.3515625,147748799.285417),
LevelOfDetail(3,0.17578125,73874399.6427086),
LevelOfDetail(4,0.087890625,36937199.8213543),
LevelOfDetail(5,0.0439453125,18468599.9106771),
LevelOfDetail(6,0.02197265625,9234299.95533857),
LevelOfDetail(7,0.010986328125,4617149.97766928),
LevelOfDetail(8,0.0054931640625,2308574.98883464),
LevelOfDetail(9,0.00274658203125,1154287.49441732),
LevelOfDetail(10,0.001373291015625,577143.747208661),
LevelOfDetail(11,0.0006866455078125,288571.87360433),
LevelOfDetail(12,0.00034332275390625,144285.936802165),
LevelOfDetail(13,0.000171661376953125,72142.9684010826),
LevelOfDetail(14,8.58306884765625E-05,36071.4842005413),
LevelOfDetail(15,4.29153442382812E-05,18035.7421002706),
LevelOfDetail(16,2.14576721191406E-05,9017.87105013533),
LevelOfDetail(17,1.07288360595703E-05,4508.93552506766),
LevelOfDetail(18,5.36441802978515E-06,2254.46776253383),
LevelOfDetail(19,2.68220901489257E-06,1127.23388126691),
LevelOfDetail(20,1.34110450744628E-06,563.616940633458)
};
QList<LevelOfDetail> tdtlevels=lvItems;
m_mapView = findChild<MapQuickView*>("mapView");
m_mapView->setWrapAroundMode(WrapAroundMode::Disabled);
tdtTileInfo=new TileInfo(TDT::TDTDpi,TileImageFormat::Unknown,tdtlevels,
TDT::TDTSR,Point(-180,90,TDT::TDTSR),256,256);
std::shared_ptr<TileInfo> sp_tdtTileInfo(tdtTileInfo);
qDebug()<<"tdt-dpi:"<<sp_tdtTileInfo->dpi();
qDebug()<<"tdt-tileHeight:"<<sp_tdtTileInfo->tileHeight();
tdtWebTiledLayer=new WebTiledLayer(
TDT::TDTURLIMG,TDT::TDTDOMAINS,*sp_tdtTileInfo,TDT::TDTFullExtent,this);
std::shared_ptr<WebTiledLayer> sp_tdtlayer(tdtWebTiledLayer);
qDebug()<<"tdtLayer-url:"<<sp_tdtlayer->templateUrl();
basemap=new Basemap(sp_tdtlayer.get(), this);
m_map = new Map(SpatialReference(4490), this);
m_map->setBasemap(basemap);
Point pt(121.13464303314697, 31.56970212181205,TDT::TDTSR);
Viewpoint vp(pt, 5000.0);
m_map->setInitialViewpoint(vp);
// Set map to map view
m_mapView->setMap(m_map);
qDebug()<<"CGIS::componentComplete():end--------------"<<endl;
}