正在显示
2 个修改的文件
包含
132 行增加
和
4 行删除
| @@ -45,9 +45,12 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | @@ -45,9 +45,12 @@ void DmpManagerApiHandler::HandleRequest(const DmpServerApiContext &context) con | ||
| 45 | else if(OperationId().compare("deleteservice") == 0) { | 45 | else if(OperationId().compare("deleteservice") == 0) { |
| 46 | deleteService(context); | 46 | deleteService(context); |
| 47 | } | 47 | } |
| 48 | - else if(OperationId().compare("reloadservices") == 0) { | 48 | + else if(OperationId().compare("reloadservices") == 0) { |
| 49 | reloadServices(context); | 49 | reloadServices(context); |
| 50 | } | 50 | } |
| 51 | + else if(OperationId().compare("gettileserviceinfo") == 0) { | ||
| 52 | + GetTileServiceInfo(context); | ||
| 53 | + } | ||
| 51 | else { | 54 | else { |
| 52 | context.response()->write("not find oparation: " + OperationId()); | 55 | context.response()->write("not find oparation: " + OperationId()); |
| 53 | } | 56 | } |
| @@ -56,6 +59,7 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -56,6 +59,7 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
| 56 | { | 59 | { |
| 57 | switch (context.request()->method()) | 60 | switch (context.request()->method()) |
| 58 | { | 61 | { |
| 62 | + | ||
| 59 | case DmpServerRequest::Method::GET_METHOD: | 63 | case DmpServerRequest::Method::GET_METHOD: |
| 60 | { | 64 | { |
| 61 | context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); | 65 | context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}"); |
| @@ -93,9 +97,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -93,9 +97,12 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
| 93 | context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); | 97 | context.response()->write("{\"status\":\"false\",\"message\":\"服务发布失败\"}"); |
| 94 | return; | 98 | return; |
| 95 | } | 99 | } |
| 96 | - if(context.manager()->publish(serverType, name, title, capabilities, project)) { | 100 | + int flag=context.manager()->publish(serverType, name, title, capabilities, project); |
| 101 | + if(flag==1) { | ||
| 97 | LOGGER_INFO("服务发布成功"); | 102 | LOGGER_INFO("服务发布成功"); |
| 98 | - context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}"); | 103 | + std::string http="http://"+context.request()->domain()+":"+context.request()->port(); |
| 104 | + std::string url=http+"/DMap/Services/"+name+"/TileServer/tmsService?REQUEST=GetThumbnail"; | ||
| 105 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"url\":\""+url+"\",\"message\":\"Pulish service successful!\"}"); | ||
| 99 | // std::string projData; | 106 | // std::string projData; |
| 100 | // DmpServerUtils::Base64Decode(project, &projData); | 107 | // DmpServerUtils::Base64Decode(project, &projData); |
| 101 | // context.response()->removeHeader("Content-Type"); | 108 | // context.response()->removeHeader("Content-Type"); |
| @@ -105,7 +112,14 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | @@ -105,7 +112,14 @@ void DmpManagerApiHandler::regService(const DmpServerApiContext &context) const | ||
| 105 | else | 112 | else |
| 106 | { | 113 | { |
| 107 | LOGGER_ERROR("服务发布失败"); | 114 | LOGGER_ERROR("服务发布失败"); |
| 108 | - context.response()->write("{\"status\":\"false\",\"message\":\"Pulish service fail!\"}"); | 115 | + if(flag==0) |
| 116 | + { | ||
| 117 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"message\":\"Pulish service thumbnail fail!\"}"); | ||
| 118 | + } | ||
| 119 | + else | ||
| 120 | + { | ||
| 121 | + context.response()->write("{\"status\":\""+std::to_string(flag)+"\",\"message\":\"Pulish service fail!\"}"); | ||
| 122 | + } | ||
| 109 | } | 123 | } |
| 110 | } | 124 | } |
| 111 | else | 125 | else |
| @@ -236,4 +250,117 @@ void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) co | @@ -236,4 +250,117 @@ void DmpManagerApiHandler::reloadServices(const DmpServerApiContext &context) co | ||
| 236 | 250 | ||
| 237 | } | 251 | } |
| 238 | } | 252 | } |
| 253 | +} | ||
| 254 | +//获取配置文件切片信息 | ||
| 255 | +void DmpManagerApiHandler::GetTileServiceInfo(const DmpServerApiContext &context) const | ||
| 256 | +{ | ||
| 257 | + switch (context.request()->method()) | ||
| 258 | + { | ||
| 259 | + case DmpServerRequest::Method::GET_METHOD: | ||
| 260 | + { | ||
| 261 | + context.response()->write("{\"status\":\"true\",\"message\":\"获取切片配置信息——————GET\"}"); | ||
| 262 | + break; | ||
| 263 | + } | ||
| 264 | + case DmpServerRequest::Method::POST_METHOD: | ||
| 265 | + { | ||
| 266 | + std::string path; | ||
| 267 | + std::string strExtent; | ||
| 268 | + const char* data = (char*)(context.request()->GetData()); | ||
| 269 | + if(data && *data != '\0') | ||
| 270 | + { | ||
| 271 | + try | ||
| 272 | + { | ||
| 273 | + std::stringstream stream(data); | ||
| 274 | + boost::property_tree::ptree pt; | ||
| 275 | + boost::property_tree::ptree pt_json; | ||
| 276 | + std::string confcdipath; | ||
| 277 | + std::string confxmlpath; | ||
| 278 | + | ||
| 279 | + boost::property_tree::read_json(stream, pt); | ||
| 280 | + path= pt.get<std::string>("projectlayers.maplayer.datasource"); | ||
| 281 | + confcdipath=path+"/conf.cdi"; | ||
| 282 | + confxmlpath=path+"/conf.xml"; | ||
| 283 | + //读取切片配置文件conf.cdi | ||
| 284 | + boost::property_tree::ptree pt_confcdi; | ||
| 285 | + boost::property_tree::read_xml(confcdipath,pt_confcdi); | ||
| 286 | + //boost::property_tree::ptree pt_base=pt.get_child("base"); | ||
| 287 | + std::string xmin=pt_confcdi.get<std::string>("EnvelopeN.XMin"); | ||
| 288 | + std::string ymin=pt_confcdi.get<std::string>("EnvelopeN.YMin"); | ||
| 289 | + std::string xmax=pt_confcdi.get<std::string>("EnvelopeN.XMax"); | ||
| 290 | + std::string ymax=pt_confcdi.get<std::string>("EnvelopeN.YMax"); | ||
| 291 | + pt.put("projectlayers.maplayer.extent.xmin",xmin); | ||
| 292 | + pt.put("projectlayers.maplayer.extent.ymin",ymin); | ||
| 293 | + pt.put("projectlayers.maplayer.extent.xmax",xmax); | ||
| 294 | + pt.put("projectlayers.maplayer.extent.ymax",ymax); | ||
| 295 | + //读取配置文件conf.xml | ||
| 296 | + boost::property_tree::ptree pt_confxml; | ||
| 297 | + boost::property_tree::read_xml(confxmlpath,pt_confxml); | ||
| 298 | + std::string strWKT=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKT"); | ||
| 299 | + std::string wkid=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.SpatialReference.WKID"); | ||
| 300 | + std::string top=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.X"); | ||
| 301 | + std::string left=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileOrigin.Y"); | ||
| 302 | + std::string tileCols=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileCols"); | ||
| 303 | + std::string tileRows=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.TileRows"); | ||
| 304 | + std::string dpi=pt_confxml.get<std::string>("CacheInfo.TileCacheInfo.DPI"); | ||
| 305 | + pt.put("projectCrs.spatialrefsys.wkt",strWKT); | ||
| 306 | + pt.put("projectCrs.spatialrefsys.srid",wkid); | ||
| 307 | + | ||
| 308 | + boost::property_tree::ptree pt_tileMatrixSets=pt.get_child("tileMatrixSets"); | ||
| 309 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v1,pt_tileMatrixSets) | ||
| 310 | + { | ||
| 311 | + //conf.xml中读取tileinfo | ||
| 312 | + boost::property_tree::ptree pt_levels,pt_tileMatrixSet; | ||
| 313 | + boost::property_tree::ptree pt_tileArry=pt_confxml.get_child("CacheInfo.TileCacheInfo.LODInfos"); | ||
| 314 | + BOOST_FOREACH(boost::property_tree::ptree::value_type &v2,pt_tileArry) | ||
| 315 | + { | ||
| 316 | + boost::property_tree::ptree pt_level; | ||
| 317 | + if(v2.first=="LODInfo") | ||
| 318 | + { | ||
| 319 | + std::string level=v2.second.get<std::string>("LevelID"); | ||
| 320 | + std::string scale=v2.second.get<std::string>("Scale"); | ||
| 321 | + std::string resolution=v2.second.get<std::string>("Resolution"); | ||
| 322 | + pt_level.add("level.id",level); | ||
| 323 | + pt_level.add("level.scaleDenominator",scale); | ||
| 324 | + pt_level.add("level.resolution",resolution); | ||
| 325 | + pt_levels.push_back(std::make_pair("", pt_level)); | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + std::string id_=v1.second.get<std::string>("tileMatrixSet.id"); | ||
| 329 | + pt_tileMatrixSet.add("id",id_); | ||
| 330 | + pt_tileMatrixSet.add("crs","EPSG::"+wkid); | ||
| 331 | + pt_tileMatrixSet.add("tileCols",tileCols); | ||
| 332 | + pt_tileMatrixSet.add("tileRows",tileRows); | ||
| 333 | + pt_tileMatrixSet.add("dpi",dpi); | ||
| 334 | + pt_tileMatrixSet.add("tileOrigin.X",top); | ||
| 335 | + pt_tileMatrixSet.add("tileOrigin.Y",left); | ||
| 336 | + pt_tileMatrixSet.add_child("levels",pt_levels); | ||
| 337 | + //pt_tilelist.add_child("tileMatrixList",pt_tiles); | ||
| 338 | + v1.second.put_child("tileMatrixSet",pt_tileMatrixSet); | ||
| 339 | + //v1.second.put("id","EPSG::"+wkid); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + pt.put_child("tileMatrixSets",pt_tileMatrixSets); | ||
| 343 | + std::stringstream ss; | ||
| 344 | + boost::property_tree::write_json(ss,pt); | ||
| 345 | + strExtent=ss.str(); | ||
| 346 | + } | ||
| 347 | + catch (boost::property_tree::ptree_bad_path& e) { | ||
| 348 | + LOGGER_ERROR(e.what()); | ||
| 349 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
| 350 | + return; | ||
| 351 | + } | ||
| 352 | + catch (boost::property_tree::ptree_bad_data& e) { | ||
| 353 | + LOGGER_ERROR(e.what()); | ||
| 354 | + context.response()->write("{\"status\":\"false\",\"message\":\"获取切片配置信息失败\"}"); | ||
| 355 | + return; | ||
| 356 | + } | ||
| 357 | + context.response()->write(strExtent); | ||
| 358 | + } | ||
| 359 | + break; | ||
| 360 | + } | ||
| 361 | + default: | ||
| 362 | + { | ||
| 363 | + | ||
| 364 | + } | ||
| 365 | + } | ||
| 239 | } | 366 | } |
| @@ -27,6 +27,7 @@ public: | @@ -27,6 +27,7 @@ public: | ||
| 27 | void deleteService(const DmpServerApiContext &context) const; | 27 | void deleteService(const DmpServerApiContext &context) const; |
| 28 | void getCapabilities(const DmpServerApiContext &context)const; | 28 | void getCapabilities(const DmpServerApiContext &context)const; |
| 29 | void reloadServices(const DmpServerApiContext &context)const; | 29 | void reloadServices(const DmpServerApiContext &context)const; |
| 30 | + void GetTileServiceInfo(const DmpServerApiContext &context) const; | ||
| 30 | 31 | ||
| 31 | }; | 32 | }; |
| 32 | 33 |
请
注册
或
登录
后发表评论