提交 b6ba294f80d30ee2830564f2bedb714290118b1f

作者 qingxiongf
2 个父辈 9656e4ba 8a2e4891
@@ -182,7 +182,12 @@ bool DmpServerManager::loadServices() @@ -182,7 +182,12 @@ bool DmpServerManager::loadServices()
182 std::string type = e.second.get<std::string>("type"); 182 std::string type = e.second.get<std::string>("type");
183 int capabilities = e.second.get<int>("capabilities"); 183 int capabilities = e.second.get<int>("capabilities");
184 std::string project = e.second.get<std::string>("project"); 184 std::string project = e.second.get<std::string>("project");
  185 + std::string state = e.second.get<std::string>("state");
185 this->initServices(type, name, title, capabilities, project); 186 this->initServices(type, name, title, capabilities, project);
  187 + if(state=="0")
  188 + {
  189 + serverRegistry_->getServer(type)->stop(name);
  190 + }
186 } 191 }
187 } 192 }
188 } 193 }
@@ -208,7 +213,7 @@ bool DmpServerManager::initServices(const std::string &serverName, const std::st @@ -208,7 +213,7 @@ bool DmpServerManager::initServices(const std::string &serverName, const std::st
208 delete project; 213 delete project;
209 return false; 214 return false;
210 } 215 }
211 - 216 +
212 project->initVectorLayerVacuate([](const std::string &tableguid) 217 project->initVectorLayerVacuate([](const std::string &tableguid)
213 { return DmpHttp::get(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid); }); 218 { return DmpHttp::get(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid); });
214 219
@@ -181,7 +181,21 @@ void DmpManagerApiHandler::startService(const DmpServerApiContext &context) cons @@ -181,7 +181,21 @@ void DmpManagerApiHandler::startService(const DmpServerApiContext &context) cons
181 params.getValue("servername", serverName); 181 params.getValue("servername", serverName);
182 std::string serviceName; 182 std::string serviceName;
183 params.getValue("servicename",serviceName); 183 params.getValue("servicename",serviceName);
184 - context.manager()->startService(serverName, serviceName); 184 + if(serverName.empty()||serviceName.empty())
  185 + {
  186 + context.response()->write("{\"status\":\"false\",\"message\":"+serviceName+"\"服务启动失败\"}");
  187 + return;
  188 + }
  189 +
  190 + bool flag=context.manager()->startService(serverName, serviceName);
  191 + if(flag)
  192 + {
  193 + context.response()->write("{\"status\":\"true\",\"message\":"+serviceName+"\"服务启动\"}");
  194 + }
  195 + else
  196 + {
  197 + context.response()->write("{\"status\":\"false\",\"message\":"+serviceName+"\"服务启动失败\"}");
  198 + }
185 break; 199 break;
186 } 200 }
187 case DmpServerRequest::Method::POST_METHOD: 201 case DmpServerRequest::Method::POST_METHOD:
@@ -206,7 +220,20 @@ void DmpManagerApiHandler::stopService(const DmpServerApiContext &context) const @@ -206,7 +220,20 @@ void DmpManagerApiHandler::stopService(const DmpServerApiContext &context) const
206 params.getValue("servername", serverName); 220 params.getValue("servername", serverName);
207 std::string serviceName; 221 std::string serviceName;
208 params.getValue("servicename",serviceName); 222 params.getValue("servicename",serviceName);
209 - context.manager()->stopService(serverName, serviceName); 223 + if(serverName.empty()||serviceName.empty())
  224 + {
  225 + context.response()->write("{\"status\":\"false\",\"message\":"+serviceName+"\"服务启动失败\"}");
  226 + return;
  227 + }
  228 + bool flag=context.manager()->stopService(serverName, serviceName);
  229 + if(flag)
  230 + {
  231 + context.response()->write("{\"status\":\"true\",\"message\":"+serviceName+"\"服务停止\"}");
  232 + }
  233 + else
  234 + {
  235 + context.response()->write("{\"status\":\"false\",\"message\":"+serviceName+"\"服务停止失败\"}");
  236 + }
210 break; 237 break;
211 } 238 }
212 case DmpServerRequest::Method::POST_METHOD: 239 case DmpServerRequest::Method::POST_METHOD:
@@ -310,7 +337,7 @@ void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context @@ -310,7 +337,7 @@ void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context
310 337
311 boost::property_tree::read_json(stream, pt); 338 boost::property_tree::read_json(stream, pt);
312 path= pt.get<std::string>("projectlayers.maplayer.datasource"); 339 path= pt.get<std::string>("projectlayers.maplayer.datasource");
313 - path="/mnt/d/Code/tiles"; 340 + //path="/mnt/d/Code/tiles";
314 confcdipath=path+"/conf.cdi"; 341 confcdipath=path+"/conf.cdi";
315 confxmlpath=path+"/conf.xml"; 342 confxmlpath=path+"/conf.xml";
316 std::ifstream fread(confxmlpath, std::ifstream::binary); 343 std::ifstream fread(confxmlpath, std::ifstream::binary);
@@ -75,7 +75,11 @@ namespace tileserver @@ -75,7 +75,11 @@ namespace tileserver
75 //cairo_surface_write_to_png (surface, "./tms.png"); 75 //cairo_surface_write_to_png (surface, "./tms.png");
76 //LOGGER_DEBUG(filepath); 76 //LOGGER_DEBUG(filepath);
77 } 77 }
78 - } 78 + }
  79 +
  80 +
  81 +
  82 +
79 //cairo_surface_write_to_png (surface, "./tms.png"); 83 //cairo_surface_write_to_png (surface, "./tms.png");
80 std::string responseData; 84 std::string responseData;
81 cairo_surface_write_to_png_stream(surface, cairo_write_func, &responseData); 85 cairo_surface_write_to_png_stream(surface, cairo_write_func, &responseData);
@@ -19,7 +19,7 @@ namespace tileserver @@ -19,7 +19,7 @@ namespace tileserver
19 DmpEsriTileProvider::DmpEsriTileProvider(const std::string& rootPath) 19 DmpEsriTileProvider::DmpEsriTileProvider(const std::string& rootPath)
20 : DmpTileProvider(rootPath) 20 : DmpTileProvider(rootPath)
21 { 21 {
22 - // this->_rootPath ="/mnt/d/Data/tile/ShareMap2014/Layers/_alllayers/"; 22 + //rootPath_ ="/mnt/d/Code/tiles/SD_2014/Layers/_alllayers";
23 } 23 }
24 24
25 std::string DmpEsriTileProvider::IntToHex8Str(const int num) 25 std::string DmpEsriTileProvider::IntToHex8Str(const int num)
@@ -36,7 +36,7 @@ namespace tileserver @@ -36,7 +36,7 @@ namespace tileserver
36 std::string row_str = "R" + IntToHex8Str(row); 36 std::string row_str = "R" + IntToHex8Str(row);
37 std::string col_str = "C" + IntToHex8Str(col); 37 std::string col_str = "C" + IntToHex8Str(col);
38 38
39 - std::string tile_path = rootPath_ + level_str + "/"+ row_str+"/"+ col_str + "." + format; 39 + std::string tile_path = rootPath_ +"/"+ level_str + "/"+ row_str+"/"+ col_str + "." + format;
40 40
41 std::ifstream fread(tile_path, std::ifstream::binary); 41 std::ifstream fread(tile_path, std::ifstream::binary);
42 if(!fread) 42 if(!fread)
@@ -70,8 +70,8 @@ namespace tileserver @@ -70,8 +70,8 @@ namespace tileserver
70 DmpRectangle rectangle=dmpTileLayer->extent(); 70 DmpRectangle rectangle=dmpTileLayer->extent();
71 std::string format=dmpTileLayer->getFormat(); 71 std::string format=dmpTileLayer->getFormat();
72 72
73 - DmpPoint min=DmpPoint(rectangle.xmin(),rectangle.ymin());  
74 - DmpPoint max=DmpPoint(rectangle.xmax(),rectangle.ymax()); 73 + DmpPoint min=DmpPoint(rectangle.xmin(),rectangle.ymax());
  74 + DmpPoint max=DmpPoint(rectangle.xmax(),rectangle.ymin());
75 std::vector<DmpTileMatrixSet*> tileMatrixSets; 75 std::vector<DmpTileMatrixSet*> tileMatrixSets;
76 dmpTileLayer->getTileMatrixSets(tileMatrixSets); 76 dmpTileLayer->getTileMatrixSets(tileMatrixSets);
77 double resolution; 77 double resolution;
@@ -97,16 +97,41 @@ namespace tileserver @@ -97,16 +97,41 @@ namespace tileserver
97 TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256); 97 TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
98 } 98 }
99 //TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256); 99 //TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256);
100 - //cairo_surface_write_to_png (surface, "./wmts.png"); 100 +
101 } 101 }
102 } 102 }
  103 + cairo_surface_write_to_png (surface, "./wmts.png");
  104 + cairo_surface_t* newimage=surface;
  105 +
  106 + int w,h;
  107 + w = cairo_image_surface_get_width (newimage);
  108 + h = cairo_image_surface_get_height (newimage);
  109 + DmpPoint topLeft;
  110 + TileProviderFactory::RowColToPoint(origin,xMinTile,yMaxTile,resolution,topLeft);
  111 +
  112 + DmpPoint clipPoint;
  113 + int wClip,hClip;
  114 + TileProviderFactory::GetClipBox(topLeft,min,max,resolution,clipPoint,wClip,hClip);
  115 +
  116 + cairo_surface_t *surface0 = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,wClip, hClip);
  117 + cairo_t *cr0 =cairo_create (surface0);
  118 +
  119 + //cairo_rectangle(cr0,clipPoint.x(),clipPoint.y(),wClip,hClip);
  120 + cairo_rectangle(cr0,0,0,wClip,hClip);
  121 + cairo_set_source_surface (cr0, surface,-clipPoint.x(), -clipPoint.y());
  122 + cairo_clip(cr0);
  123 + cairo_paint(cr0);
  124 +
  125 +
103 std::string responseData; 126 std::string responseData;
104 - cairo_surface_write_to_png_stream(surface, TileProviderFactory::cairo_write_func, &responseData); 127 + cairo_surface_write_to_png_stream(surface0, TileProviderFactory::cairo_write_func, &responseData);
105 128
106 response.removeHeader("Content-Type"); 129 response.removeHeader("Content-Type");
107 std::string f = (format == "jpg") ? "image/jpg" : "image/png"; 130 std::string f = (format == "jpg") ? "image/jpg" : "image/png";
108 response.setHeader("Content-Type", f); 131 response.setHeader("Content-Type", f);
109 - response.write(responseData); 132 + response.write(responseData);
  133 + // cairo_destroy (cr0);
  134 + // cairo_surface_destroy (surface0);
110 cairo_destroy (cr); 135 cairo_destroy (cr);
111 cairo_surface_destroy (surface); 136 cairo_surface_destroy (surface);
112 } 137 }
@@ -115,14 +140,13 @@ namespace tileserver @@ -115,14 +140,13 @@ namespace tileserver
115 std::string level_str = "L" + DmpWmtsUtils::IntToFormatStr(level); 140 std::string level_str = "L" + DmpWmtsUtils::IntToFormatStr(level);
116 std::string row_str = "R" + IntToHex8Str(row); 141 std::string row_str = "R" + IntToHex8Str(row);
117 std::string col_str = "C" + IntToHex8Str(col); 142 std::string col_str = "C" + IntToHex8Str(col);
118 -  
119 - reTilePath = rootPath_ + level_str + "/"+ row_str+"/"+ col_str + "." + format; 143 + std::string f = (format == "image/jpg") ? "jpg" : "png";
  144 + reTilePath = rootPath_ + "/"+level_str + "/"+ row_str+"/"+ col_str + "." + f;
120 145
121 - std::ifstream fread(reTilePath, std::ifstream::binary); 146 + std::ifstream fread(reTilePath, std::ifstream::binary);
122 if(!fread) 147 if(!fread)
123 { 148 {
124 return false; 149 return false;
125 } 150 }
126 -  
127 } 151 }
128 } 152 }
注册登录 后发表评论