提交 b6ba294f80d30ee2830564f2bedb714290118b1f
Merge branch 'master' of http://gitlab.ctune.cn/DMapServer/DMapServer4.1
正在显示
4 个修改的文件
包含
76 行增加
和
16 行删除
... | ... | @@ -182,7 +182,12 @@ bool DmpServerManager::loadServices() |
182 | 182 | std::string type = e.second.get<std::string>("type"); |
183 | 183 | int capabilities = e.second.get<int>("capabilities"); |
184 | 184 | std::string project = e.second.get<std::string>("project"); |
185 | + std::string state = e.second.get<std::string>("state"); | |
185 | 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 | 213 | delete project; |
209 | 214 | return false; |
210 | 215 | } |
211 | - | |
216 | + | |
212 | 217 | project->initVectorLayerVacuate([](const std::string &tableguid) |
213 | 218 | { return DmpHttp::get(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid); }); |
214 | 219 | ... | ... |
... | ... | @@ -181,7 +181,21 @@ void DmpManagerApiHandler::startService(const DmpServerApiContext &context) cons |
181 | 181 | params.getValue("servername", serverName); |
182 | 182 | std::string serviceName; |
183 | 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 | 199 | break; |
186 | 200 | } |
187 | 201 | case DmpServerRequest::Method::POST_METHOD: |
... | ... | @@ -206,7 +220,20 @@ void DmpManagerApiHandler::stopService(const DmpServerApiContext &context) const |
206 | 220 | params.getValue("servername", serverName); |
207 | 221 | std::string serviceName; |
208 | 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 | 237 | break; |
211 | 238 | } |
212 | 239 | case DmpServerRequest::Method::POST_METHOD: |
... | ... | @@ -310,7 +337,7 @@ void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context |
310 | 337 | |
311 | 338 | boost::property_tree::read_json(stream, pt); |
312 | 339 | path= pt.get<std::string>("projectlayers.maplayer.datasource"); |
313 | - path="/mnt/d/Code/tiles"; | |
340 | + //path="/mnt/d/Code/tiles"; | |
314 | 341 | confcdipath=path+"/conf.cdi"; |
315 | 342 | confxmlpath=path+"/conf.xml"; |
316 | 343 | std::ifstream fread(confxmlpath, std::ifstream::binary); | ... | ... |
... | ... | @@ -75,7 +75,11 @@ namespace tileserver |
75 | 75 | //cairo_surface_write_to_png (surface, "./tms.png"); |
76 | 76 | //LOGGER_DEBUG(filepath); |
77 | 77 | } |
78 | - } | |
78 | + } | |
79 | + | |
80 | + | |
81 | + | |
82 | + | |
79 | 83 | //cairo_surface_write_to_png (surface, "./tms.png"); |
80 | 84 | std::string responseData; |
81 | 85 | cairo_surface_write_to_png_stream(surface, cairo_write_func, &responseData); | ... | ... |
... | ... | @@ -19,7 +19,7 @@ namespace tileserver |
19 | 19 | DmpEsriTileProvider::DmpEsriTileProvider(const std::string& rootPath) |
20 | 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 | 25 | std::string DmpEsriTileProvider::IntToHex8Str(const int num) |
... | ... | @@ -36,7 +36,7 @@ namespace tileserver |
36 | 36 | std::string row_str = "R" + IntToHex8Str(row); |
37 | 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 | 41 | std::ifstream fread(tile_path, std::ifstream::binary); |
42 | 42 | if(!fread) |
... | ... | @@ -70,8 +70,8 @@ namespace tileserver |
70 | 70 | DmpRectangle rectangle=dmpTileLayer->extent(); |
71 | 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 | 75 | std::vector<DmpTileMatrixSet*> tileMatrixSets; |
76 | 76 | dmpTileLayer->getTileMatrixSets(tileMatrixSets); |
77 | 77 | double resolution; |
... | ... | @@ -97,16 +97,41 @@ namespace tileserver |
97 | 97 | TileProviderFactory::BufferCopy(image,surface,cr,i*256,j*256); |
98 | 98 | } |
99 | 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 | 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 | 129 | response.removeHeader("Content-Type"); |
107 | 130 | std::string f = (format == "jpg") ? "image/jpg" : "image/png"; |
108 | 131 | response.setHeader("Content-Type", f); |
109 | - response.write(responseData); | |
132 | + response.write(responseData); | |
133 | + // cairo_destroy (cr0); | |
134 | + // cairo_surface_destroy (surface0); | |
110 | 135 | cairo_destroy (cr); |
111 | 136 | cairo_surface_destroy (surface); |
112 | 137 | } |
... | ... | @@ -115,14 +140,13 @@ namespace tileserver |
115 | 140 | std::string level_str = "L" + DmpWmtsUtils::IntToFormatStr(level); |
116 | 141 | std::string row_str = "R" + IntToHex8Str(row); |
117 | 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 | 147 | if(!fread) |
123 | 148 | { |
124 | 149 | return false; |
125 | 150 | } |
126 | - | |
127 | 151 | } |
128 | 152 | } |
\ No newline at end of file | ... | ... |
请
注册
或
登录
后发表评论