提交 81f7e1d2abb5ba90ea7a223dca54214d13a9cfeb

作者 LJH 李佳桓
1 个父辈 5b4fbc2e

ljh

@@ -312,6 +312,12 @@ void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context @@ -312,6 +312,12 @@ void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context
312 path= pt.get<std::string>("projectlayers.maplayer.datasource"); 312 path= pt.get<std::string>("projectlayers.maplayer.datasource");
313 confcdipath=path+"/conf.cdi"; 313 confcdipath=path+"/conf.cdi";
314 confxmlpath=path+"/conf.xml"; 314 confxmlpath=path+"/conf.xml";
  315 + std::ifstream fread(confxmlpath, std::ifstream::binary);
  316 + if(!fread)
  317 + {
  318 + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}");
  319 + return;
  320 + }
315 //读取切片配置文件conf.cdi 321 //读取切片配置文件conf.cdi
316 boost::property_tree::ptree pt_confcdi; 322 boost::property_tree::ptree pt_confcdi;
317 boost::property_tree::read_xml(confcdipath,pt_confcdi); 323 boost::property_tree::read_xml(confcdipath,pt_confcdi);
@@ -76,7 +76,7 @@ namespace DmpWmts @@ -76,7 +76,7 @@ namespace DmpWmts
76 dmpTileLayer->getTileMatrixSets(tileMatrixSets); 76 dmpTileLayer->getTileMatrixSets(tileMatrixSets);
77 double resolution; 77 double resolution;
78 DmpPoint origin; 78 DmpPoint origin;
79 - int iLevel,xMinTile,yMinTile, xMaxTile, yMaxTile,buffLen; 79 + int iLevel,xMinTile,yMinTile, xMaxTile, yMaxTile;
80 if(!TileProviderFactory::GetTileScale(dmpTileLayer,iLevel,xMinTile,yMinTile, xMaxTile, yMaxTile)) 80 if(!TileProviderFactory::GetTileScale(dmpTileLayer,iLevel,xMinTile,yMinTile, xMaxTile, yMaxTile))
81 { 81 {
82 response.sendError(500, "缩略图范围错误:("); 82 response.sendError(500, "缩略图范围错误:(");
@@ -90,9 +90,12 @@ namespace DmpWmts @@ -90,9 +90,12 @@ namespace DmpWmts
90 { 90 {
91 for(int j=0;j<=heigth;j++) 91 for(int j=0;j<=heigth;j++)
92 { 92 {
93 - std::string strBuff;  
94 - GetTile(yMaxTile+j,xMinTile+i,iLevel,strBuff,buffLen);  
95 - 93 + std::string filepath;
  94 + if(GetTile(yMaxTile+j,xMinTile+i,iLevel,format,filepath))
  95 + {
  96 + cairo_surface_t* image = cairo_image_surface_create_from_png( filepath.c_str());
  97 + TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
  98 + }
96 //TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256); 99 //TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
97 //cairo_surface_write_to_png (surface, "./wmts.png"); 100 //cairo_surface_write_to_png (surface, "./wmts.png");
98 } 101 }
@@ -107,8 +110,19 @@ namespace DmpWmts @@ -107,8 +110,19 @@ namespace DmpWmts
107 cairo_destroy (cr); 110 cairo_destroy (cr);
108 cairo_surface_destroy (surface); 111 cairo_surface_destroy (surface);
109 } 112 }
110 - bool DmpEsriTileProvider::GetTile(int row, int col, int level,std::string& refbuff,int& length ) 113 + bool DmpEsriTileProvider::GetTile(const int row,const int col,const int level,const std::string& format,std::string& reTilePath)
111 { 114 {
  115 + std::string level_str = "L" + DmpWmtsUtils::IntToFormatStr(level);
  116 + std::string row_str = "R" + IntToHex8Str(row);
  117 + std::string col_str = "C" + IntToHex8Str(col);
  118 +
  119 + reTilePath = rootPath_ + level_str + "/"+ row_str+"/"+ col_str + "." + format;
112 120
  121 + std::ifstream fread(reTilePath, std::ifstream::binary);
  122 + if(!fread)
  123 + {
  124 + return false;
  125 + }
  126 +
113 } 127 }
114 } 128 }
@@ -21,7 +21,7 @@ namespace DmpWmts @@ -21,7 +21,7 @@ namespace DmpWmts
21 DmpEsriTileProvider(const std::string& rootPath); 21 DmpEsriTileProvider(const std::string& rootPath);
22 void WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) override; 22 void WriteTile(const int row, const int col, const int level, const std::string& format, DmpServerResponse& response) override;
23 void GetTileThumbnail(DmpTileLayer* dmpTileLayer,DmpServerResponse& response) override; 23 void GetTileThumbnail(DmpTileLayer* dmpTileLayer,DmpServerResponse& response) override;
24 - bool GetTile(const int row,const int col,const int level,std::string& rebuff,int& length); 24 + bool GetTile(const int row,const int col,const int level,const std::string& format,std::string& reTilePath);
25 private: 25 private:
26 std::string IntToHex8Str(const int num); 26 std::string IntToHex8Str(const int num);
27 }; 27 };
@@ -105,6 +105,12 @@ namespace DmpWmts @@ -105,6 +105,12 @@ namespace DmpWmts
105 iLevel=id; 105 iLevel=id;
106 resolution=relus; 106 resolution=relus;
107 break; 107 break;
  108 + }
  109 + else if(leviter==tileLevels.cbegin()&&(heigth+1)*(width+1)>=9)
  110 + {
  111 + iLevel=id;
  112 + resolution=relus;
  113 + break;
108 } 114 }
109 } 115 }
110 } 116 }
@@ -145,7 +151,7 @@ namespace DmpWmts @@ -145,7 +151,7 @@ namespace DmpWmts
145 } 151 }
146 if(cr==NULL) 152 if(cr==NULL)
147 { 153 {
148 - cr = cairo_create (pClsCSTo); 154 + cr = cairo_create (pClsCSTo);
149 } 155 }
150 cairo_set_source_surface(cr, pClsCSFrom, x, y); 156 cairo_set_source_surface(cr, pClsCSFrom, x, y);
151 cairo_paint(cr); 157 cairo_paint(cr);
注册登录 后发表评论