正在显示
1 个修改的文件
包含
115 行增加
和
0 行删除
src/server/services/wmts/dmpwmts.cpp
0 → 100644
1 | +/* | ||
2 | + * @Author: your name | ||
3 | + * @Date: 2021-04-26 15:02:56 | ||
4 | + * @LastEditTime: 2021-04-26 17:17:33 | ||
5 | + * @LastEditors: Please set LastEditors | ||
6 | + * @Description: In User Settings Edit | ||
7 | + * @FilePath: /dmapserver/src/server/services/wmts/dmpwmts.cpp | ||
8 | + */ | ||
9 | +/************************************************************************** | ||
10 | +* file: dmpwmts.cpp | ||
11 | + | ||
12 | +* Author: wanzhongping | ||
13 | +* Date: 2020-12-31 22:20:16 | ||
14 | +* Email: zhongpingw@chinadci.com | ||
15 | +* copyright: 广州城市信息研究所有限公司 | ||
16 | +***************************************************************************/ | ||
17 | +#include <string> | ||
18 | +#include "dmpmodule.h" | ||
19 | +#include <boost/dll/alias.hpp> // for BOOST_DLL_ALIAS | ||
20 | +#include <boost/filesystem.hpp> | ||
21 | +#include <boost/function.hpp> | ||
22 | +#include <memory> | ||
23 | +#include "dmpwmtsparameters.h" | ||
24 | +#include "dmplogger.h" | ||
25 | +#include "dmpcapabilitiesoperation.h" | ||
26 | +#include "dmptileproviderfactory.h" | ||
27 | +using namespace std; | ||
28 | + | ||
29 | +namespace DmpWmts | ||
30 | +{ | ||
31 | + class Service : public DmpService | ||
32 | + { | ||
33 | + public: | ||
34 | + Service() | ||
35 | + { | ||
36 | + std::cout << "Constructing WmtsService" << std::endl; | ||
37 | + LOGGER_DEBUG("Constructing WmtsService"); | ||
38 | + } | ||
39 | + | ||
40 | + ~Service() | ||
41 | + { | ||
42 | + std::cout << "Destructing WmtsService" << std::endl; | ||
43 | + LOGGER_DEBUG("Destructing WmtsService"); | ||
44 | + } | ||
45 | + | ||
46 | + string Name() const override { return string("WMTS"); } | ||
47 | + string Version() const override { return string("1.0.0"); } | ||
48 | + | ||
49 | + bool AllowMethod() const override | ||
50 | + { | ||
51 | + return true; | ||
52 | + } | ||
53 | + | ||
54 | + void ExecuteRequest(const DmpServerRequest &request, DmpServerResponse &response) override | ||
55 | + { | ||
56 | + const DmpWmtsParameters params(request.ServerParameters()); | ||
57 | + int tile_col = params.TileCol(); | ||
58 | + int tile_row = params.TileRow(); | ||
59 | + int tile_matrix = params.TileMatrix(); | ||
60 | + string req = params.Request(); | ||
61 | + DmpWmtsParameters::Format format = params.ImageFormat(); | ||
62 | + if (req.empty()) | ||
63 | + { | ||
64 | + } | ||
65 | + if (boost::iequals(req, "GetTile")) | ||
66 | + { | ||
67 | + string f = (format == DmpWmtsParameters::Format::JPG) ? "jpg" : "png"; | ||
68 | + std::shared_ptr<DmpTileProvider> provider = TileProviderFactory::GetProvider(Vector::ESRI_V2); | ||
69 | + provider->WriteTile(tile_row, tile_col, tile_matrix, f, response); | ||
70 | + } | ||
71 | + else if (boost::iequals(req, "GetCapabilities")) | ||
72 | + { | ||
73 | + /* | ||
74 | + dmpcapabilitilesoperation cap; | ||
75 | + string strfile=cap.GetCapabilitiesDocument(); | ||
76 | + const char *p = strfile.c_str(); | ||
77 | + int len=strfile.length(); | ||
78 | + response.RemoveHeader("Content-Type"); | ||
79 | + response.SetHeader("Content-Type", "application/xml"); | ||
80 | + | ||
81 | + response.WriteContent(p,len); | ||
82 | + */ | ||
83 | + std::shared_ptr<DmpCapabiliTilesProvider> provider = CapabiliTileProviderFactory::GetProvider(); | ||
84 | + provider->WriteCapabilities(response); | ||
85 | + //response.Write("wmts, GetCapabilities"); | ||
86 | + } | ||
87 | + else if (boost::iequals(req, "GetFeatureInfo")) | ||
88 | + { | ||
89 | + response.Write("wmts, GetFeatureInfo"); | ||
90 | + } | ||
91 | + else | ||
92 | + { | ||
93 | + response.Write("wmts,Operation not supported"); | ||
94 | + response.Write("chinadci"); | ||
95 | + } | ||
96 | + } | ||
97 | + }; | ||
98 | + | ||
99 | + class DmpWmtsModule : public DmpServiceModule | ||
100 | + { | ||
101 | + public: | ||
102 | + void RegisterSelf(DmpServiceRegistry ®istry) override | ||
103 | + { | ||
104 | + cout << "WMTSModule::registerSelf called" << endl; | ||
105 | + registry.RegisterService(make_shared<DmpWmts::Service>()); | ||
106 | + } | ||
107 | + }; | ||
108 | + | ||
109 | + shared_ptr<DmpServiceModule> Create() | ||
110 | + { | ||
111 | + return make_shared<DmpWmtsModule>(); | ||
112 | + } | ||
113 | +} // namespace DmpWmts | ||
114 | + | ||
115 | +BOOST_DLL_ALIAS(DmpWmts::Create, service_module) |
请
注册
或
登录
后发表评论