正在显示
14 个修改的文件
包含
277 行增加
和
48 行删除
... | ... | @@ -14,4 +14,14 @@ bool DmpCoordinateReferenceSystem::readXml(const boost::property_tree::ptree pNo |
14 | 14 | proj4_ = pNode.get<std::string>("proj4"); |
15 | 15 | srid_ = pNode.get<long>("srid"); |
16 | 16 | return true; |
17 | +} | |
18 | + | |
19 | +bool DmpCoordinateReferenceSystem::write( boost::property_tree::ptree& pNode) | |
20 | +{ | |
21 | + boost::property_tree::ptree ptSpatialrefsys; | |
22 | + ptSpatialrefsys.add("wkt", wkt_); | |
23 | + ptSpatialrefsys.add("proj4", proj4_); | |
24 | + ptSpatialrefsys.add("srid", srid_); | |
25 | + pNode.add_child("spatialrefsys",ptSpatialrefsys); | |
26 | + return true; | |
17 | 27 | } |
\ No newline at end of file | ... | ... |
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | #include <boost/algorithm/string/case_conv.hpp> |
12 | 12 | #include <boost/property_tree/ptree.hpp> |
13 | 13 | #include <boost/property_tree/xml_parser.hpp> |
14 | +#include <boost/property_tree/json_parser.hpp> | |
14 | 15 | #include <boost/typeof/typeof.hpp> |
15 | 16 | #include "dmpproject.h" |
16 | 17 | #include "dmptilelayer.h" |
... | ... | @@ -124,6 +125,60 @@ bool DmpProject::Write(const std::string &filename, const std::string &data) |
124 | 125 | return true; |
125 | 126 | } |
126 | 127 | |
128 | +bool DmpProject::WritePtree(boost::property_tree::ptree& ptDoc) | |
129 | +{ | |
130 | + //目前还未完善 只支持 矢量图层 | |
131 | + boost::property_tree::ptree ptDmap; | |
132 | + | |
133 | + ptDmap.add("<xmlattr>.projectname",projectName_); | |
134 | + ptDmap.add("<xmlattr>.version",version_); | |
135 | + | |
136 | + boost::property_tree::ptree ptProjectCrs; | |
137 | + crs_.write(ptProjectCrs); | |
138 | + ptDmap.add_child("projectCrs",ptProjectCrs); | |
139 | + | |
140 | + boost::property_tree::ptree ptProjectlayers; | |
141 | + | |
142 | + std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers_.begin(); | |
143 | + for (; iter != mapLayers_.end(); ++iter) | |
144 | + { | |
145 | + DmpMapLayer *mapLayer = iter->second; | |
146 | + if (mapLayer && mapLayer->type() == DmpMapLayerType::VectorLayer) | |
147 | + { | |
148 | + boost::property_tree::ptree ptlayer; | |
149 | + ptlayer.add("<xmlattr>.type", "1"); | |
150 | + DmpVectorLayer *vectorMapLayer =(DmpVectorLayer *) mapLayer; | |
151 | + vectorMapLayer->writeXml(ptlayer); | |
152 | + ptProjectlayers.add_child("maplayer",ptlayer); | |
153 | + } | |
154 | + } | |
155 | + | |
156 | + ptDmap.add_child("projectlayers", ptProjectlayers); | |
157 | + ptDoc.add_child("dmap",ptDmap); | |
158 | + | |
159 | + return true; | |
160 | +} | |
161 | + | |
162 | +std::string DmpProject::WriteJson() | |
163 | +{ | |
164 | + boost::property_tree::ptree ptDoc; | |
165 | + WritePtree(ptDoc); | |
166 | + std::stringstream stream; | |
167 | + write_json(stream, ptDoc); | |
168 | + std::string data = stream.str(); | |
169 | + return data; | |
170 | +} | |
171 | + | |
172 | +std::string DmpProject::WriteXml() | |
173 | +{ | |
174 | + boost::property_tree::ptree ptDoc; | |
175 | + WritePtree(ptDoc); | |
176 | + std::stringstream stream; | |
177 | + write_xml(stream, ptDoc); | |
178 | + std::string data = stream.str(); | |
179 | + return data; | |
180 | +} | |
181 | + | |
127 | 182 | DmpCoordinateReferenceSystem DmpProject::crs() const |
128 | 183 | { |
129 | 184 | return crs_; | ... | ... |
... | ... | @@ -26,6 +26,9 @@ class CORE_EXPORT DmpProject |
26 | 26 | ~DmpProject(); |
27 | 27 | bool Read(const std::string &data); |
28 | 28 | bool Write(const std::string &filename, const std::string &data); |
29 | + bool WritePtree(boost::property_tree::ptree& ptDoc); | |
30 | + std::string WriteXml(); | |
31 | + std::string WriteJson(); | |
29 | 32 | DmpCoordinateReferenceSystem crs() const; |
30 | 33 | std::map<std::string, DmpMapLayer*> mapLayers() const; |
31 | 34 | DmpMapLayer* getLayer(const std::string &layerName) const; | ... | ... |
... | ... | @@ -75,6 +75,7 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) |
75 | 75 | layerNode.add("<xmlattr>.name", name_); |
76 | 76 | layerNode.add("<xmlattr>.alias", title_); |
77 | 77 | |
78 | + | |
78 | 79 | boost::property_tree::ptree ptExtent; |
79 | 80 | ptExtent.add("xmin", extent_.xmin()); |
80 | 81 | ptExtent.add("ymin", extent_.ymin()); |
... | ... | @@ -83,12 +84,12 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) |
83 | 84 | layerNode.add_child("extent", ptExtent); |
84 | 85 | |
85 | 86 | layerNode.add("datasource", dataSource_); |
86 | - | |
87 | + boost::property_tree::ptree ptRenderer; | |
87 | 88 | if(this->renderer_30_) |
88 | 89 | { |
89 | - boost::property_tree::ptree ptRenderer; | |
90 | 90 | this->renderer_30_->ParsePtree(ptRenderer); |
91 | 91 | } |
92 | + layerNode.add_child("renderer",ptRenderer); | |
92 | 93 | |
93 | 94 | return true; |
94 | 95 | } | ... | ... |
... | ... | @@ -117,15 +117,15 @@ namespace DmapCore_30 |
117 | 117 | sprintf(buff_minscale,"%.0f", this->m_dLower); |
118 | 118 | } |
119 | 119 | |
120 | - ptRenderer.add("maxscale",buff_maxscale); | |
121 | - ptRenderer.add("minscale",buff_minscale); | |
122 | - ptRenderer.add("alwaysShow", m_alwaysShow?"true":"false"); | |
120 | + ptRenderer.add("<xmlattr>.maxscale",buff_maxscale); | |
121 | + ptRenderer.add("<xmlattr>.minscale",buff_minscale); | |
122 | + ptRenderer.add("<xmlattr>.alwaysShow", m_alwaysShow?"true":"false"); | |
123 | 123 | |
124 | 124 | if(this->m_pRen) |
125 | 125 | { |
126 | 126 | this->m_pRen->ParsePtree(ptRenderer); |
127 | 127 | } |
128 | - pt.add_child("TEXTSYMBOL",ptRenderer); | |
128 | + pt.add_child("SIMPLERENDERER",ptRenderer); | |
129 | 129 | return true; |
130 | 130 | } |
131 | 131 | ... | ... |
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | #include "clsJson.h" |
4 | 4 | #include <stdarg.h> |
5 | 5 | #include <string.h> |
6 | - | |
6 | +#include "clsUtil.h" | |
7 | 7 | namespace DmapCore_30 |
8 | 8 | { |
9 | 9 | void clsJson::ParseEnum(const char *name, char *resultbuff, char* buff, int v, string a1, string a2 , string a3, string a4, string a5, string a6, string a7, string a8, string a9, string a10, string a11, string a12, string a13, string a14, string a15, string a16) |
... | ... | @@ -78,10 +78,19 @@ namespace DmapCore_30 |
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | - void clsJson::JsonAttrParseColor(const char* name,const char*name2,char* resultbuff,char* buff,unsigned int& value) | |
81 | + void clsJson::JsonAttrParseColor(const char* name,const char*name2,char* resultbuff,char* buff,unsigned int& iColor) | |
82 | 82 | { |
83 | 83 | string sColor = "", sTransparency = ""; |
84 | - //StringHelp::ColorToString(value, sColor, sTransparency); | |
84 | + int a = (int)(((unsigned char*)(&iColor))[3]); | |
85 | + int r = (int)(((unsigned char*)(&iColor))[2]); | |
86 | + int g = (int)(((unsigned char*)(&iColor))[1]); | |
87 | + int b = (int)(((unsigned char*)(&iColor))[0]); | |
88 | + //char s1[500], s2[500]; | |
89 | + //StringHelp::fmt(s1, "%d,%d,%d", r, g, b); | |
90 | + //StringHelp::fmt(s2, "%lf", a / 255.0); | |
91 | + sColor = clsUtil::fmt("%d,%d,%d", r, g, b); | |
92 | + sTransparency = clsUtil::fmt("%.2f", a / 255.0); | |
93 | + | |
85 | 94 | |
86 | 95 | sprintf(buff, "\"%s\":\"%s\",\"%s\":\"%s\",", name, sColor.c_str(),name2,sTransparency.c_str()); |
87 | 96 | strcat(resultbuff, buff); | ... | ... |
... | ... | @@ -11,6 +11,7 @@ |
11 | 11 | #include "clsPtree.h" |
12 | 12 | #include <stdarg.h> |
13 | 13 | #include <string.h> |
14 | +#include "clsUtil.h" | |
14 | 15 | |
15 | 16 | namespace DmapCore_30 |
16 | 17 | { |
... | ... | @@ -78,16 +79,22 @@ namespace DmapCore_30 |
78 | 79 | pt.add(ptname, v); |
79 | 80 | } |
80 | 81 | |
81 | - | |
82 | - | |
82 | + void clsPtree::PtreeAttrParseColor(const char *name, const char *name2, boost::property_tree::ptree &pt, unsigned int &iColor) | |
83 | + { | |
84 | + string sColor = "", sTransparency = ""; | |
85 | + int a = (int)(((unsigned char *)(&iColor))[3]); | |
86 | + int r = (int)(((unsigned char *)(&iColor))[2]); | |
87 | + int g = (int)(((unsigned char *)(&iColor))[1]); | |
88 | + int b = (int)(((unsigned char *)(&iColor))[0]); | |
89 | + //char s1[500], s2[500]; | |
90 | + //StringHelp::fmt(s1, "%d,%d,%d", r, g, b); | |
91 | + //StringHelp::fmt(s2, "%lf", a / 255.0); | |
92 | + sColor = clsUtil::fmt("%d,%d,%d", r, g, b); | |
93 | + sTransparency = clsUtil::fmt("%.2f", a / 255.0); | |
83 | 94 | |
84 | - void clsPtree::PtreeAttrParseColor(const char* name,const char*name2, boost::property_tree::ptree& pt,unsigned int& value) | |
85 | - { | |
86 | - string sColor = "", sTransparency = ""; | |
87 | - std::string ptname = "<xmlattr>."; | |
95 | + std::string ptname = "<xmlattr>."; | |
88 | 96 | pt.add(ptname + name, sColor); |
89 | 97 | pt.add(ptname + name2, sTransparency); |
90 | - | |
91 | - } | |
98 | + } | |
92 | 99 | |
93 | 100 | } // namespace DmapDll |
\ No newline at end of file | ... | ... |
... | ... | @@ -20,6 +20,7 @@ SET (MAPSERVER_SRCS |
20 | 20 | wms/dmpwmsgetfeatureinfo.cpp |
21 | 21 | mapping/dmpmapping.cpp |
22 | 22 | mapping/dmpeditservice.cpp |
23 | + mapping/dmpmappingparameters.cpp | |
23 | 24 | ) |
24 | 25 | |
25 | 26 | SET (MAPSERVER_HDRS |
... | ... | @@ -40,6 +41,7 @@ SET (MAPSERVER_HDRS |
40 | 41 | wms/dmpwmsgetfeatureinfo.h |
41 | 42 | mapping/dmpmapping.h |
42 | 43 | mapping/dmpeditservice.h |
44 | + mapping/dmpmappingparameters.h | |
43 | 45 | ) |
44 | 46 | |
45 | 47 | ######################################################## | ... | ... |
... | ... | @@ -10,25 +10,28 @@ |
10 | 10 | #include "dmplogger.h" |
11 | 11 | #include "dmpserverresponse.h" |
12 | 12 | #include "dmpserverrequest.h" |
13 | +#include "dmpproject.h" | |
14 | +#include "dmpserverproject.h" | |
13 | 15 | #include <boost/property_tree/ptree.hpp> |
14 | 16 | #include <boost/property_tree/json_parser.hpp> |
15 | 17 | #include <boost/typeof/typeof.hpp> |
16 | 18 | |
17 | 19 | namespace DmpMapping |
18 | 20 | { |
19 | - bool loadService(const DmpServerContext &context, ProjectMap& vectorMappingProjects, const char* data) | |
21 | + bool loadService(const DmpServerContext &context, ProjectMap& vectorMappingProjects) | |
20 | 22 | { |
23 | + const char *data = (char *)(context.request()->GetData()); | |
21 | 24 | if(data== nullptr || *data == '\0') |
22 | 25 | { |
23 | 26 | LOGGER_ERROR("post 参数错误"); |
24 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
27 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
25 | 28 | return false; |
26 | 29 | } |
27 | 30 | |
28 | 31 | if(!context.serverProject()) |
29 | 32 | { |
30 | 33 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); |
31 | - context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | |
34 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | |
32 | 35 | return false; |
33 | 36 | } |
34 | 37 | |
... | ... | @@ -39,26 +42,27 @@ namespace DmpMapping |
39 | 42 | boost::property_tree::read_json(stream, pt); |
40 | 43 | |
41 | 44 | std::string guid = pt.get<std::string>("guid"); |
42 | - std::string project = pt.get<std::string>("project"); | |
43 | - if(!guid.empty() && !project.empty()) | |
45 | + | |
46 | + DmpProject* project = (DmpProject*)context.serverProject()->project(); | |
47 | + std::string projectData = project->WriteXml(); | |
48 | + if(!guid.empty() && !projectData.empty()) | |
44 | 49 | { |
45 | - std::string projData; | |
46 | - if (!DmpServerUtils::Base64Decode(project, &projData)) | |
47 | - { | |
48 | - return false; | |
49 | - } | |
50 | + | |
50 | 51 | shared_ptr<DmpProject> project(new DmpProject()); |
51 | - if (!project->Read(projData)) | |
52 | + if (!project->Read(projectData)) | |
52 | 53 | { |
53 | 54 | return false; |
54 | 55 | } |
55 | 56 | vectorMappingProjects[guid] = project; |
56 | - context.response()->write("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}"); | |
57 | + context.response()->removeHeader("Content-Type"); | |
58 | + context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); | |
59 | + context.response()->write(projectData); | |
60 | + return true; | |
57 | 61 | } |
58 | 62 | else |
59 | 63 | { |
60 | 64 | LOGGER_ERROR("post 参数错误"); |
61 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
65 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
62 | 66 | return false; |
63 | 67 | } |
64 | 68 | |
... | ... | @@ -66,31 +70,32 @@ namespace DmpMapping |
66 | 70 | catch (boost::property_tree::ptree_bad_path &e) |
67 | 71 | { |
68 | 72 | LOGGER_ERROR(e.what()); |
69 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
73 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
70 | 74 | return false; |
71 | 75 | } |
72 | 76 | catch (boost::property_tree::ptree_bad_data &e) |
73 | 77 | { |
74 | 78 | LOGGER_ERROR(e.what()); |
75 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
79 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
76 | 80 | return false; |
77 | 81 | } |
78 | 82 | return false; |
79 | 83 | } |
80 | 84 | |
81 | - bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data) | |
85 | + bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects) | |
82 | 86 | { |
87 | + const char *data = (char *)(context.request()->GetData()); | |
83 | 88 | if(data== nullptr || *data == '\0') |
84 | 89 | { |
85 | 90 | LOGGER_ERROR("post 参数错误"); |
86 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
91 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
87 | 92 | return false; |
88 | 93 | } |
89 | 94 | |
90 | 95 | if(!context.serverProject()) |
91 | 96 | { |
92 | 97 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); |
93 | - context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | |
98 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | |
94 | 99 | return false; |
95 | 100 | } |
96 | 101 | |
... | ... | @@ -115,12 +120,12 @@ namespace DmpMapping |
115 | 120 | return false; |
116 | 121 | } |
117 | 122 | vectorMappingProjects[guid] = project; |
118 | - context.response()->write("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}"); | |
123 | + context.response()->writeJson("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}"); | |
119 | 124 | } |
120 | 125 | else |
121 | 126 | { |
122 | 127 | LOGGER_ERROR("post 参数错误"); |
123 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
128 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | |
124 | 129 | return false; |
125 | 130 | } |
126 | 131 | |
... | ... | @@ -128,13 +133,13 @@ namespace DmpMapping |
128 | 133 | catch (boost::property_tree::ptree_bad_path &e) |
129 | 134 | { |
130 | 135 | LOGGER_ERROR(e.what()); |
131 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
136 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
132 | 137 | return false; |
133 | 138 | } |
134 | 139 | catch (boost::property_tree::ptree_bad_data &e) |
135 | 140 | { |
136 | 141 | LOGGER_ERROR(e.what()); |
137 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
142 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | |
138 | 143 | return false; |
139 | 144 | } |
140 | 145 | return false; | ... | ... |
... | ... | @@ -20,10 +20,10 @@ namespace DmpMapping |
20 | 20 | { |
21 | 21 | typedef std::map<std::string, std::shared_ptr<DmpProject>> ProjectMap; |
22 | 22 | |
23 | - bool loadService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data); | |
23 | + bool loadService(const DmpServerContext &context,ProjectMap& vectorMappingProjects); | |
24 | 24 | |
25 | 25 | |
26 | - bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data); | |
26 | + bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects); | |
27 | 27 | |
28 | 28 | } |
29 | 29 | ... | ... |
... | ... | @@ -18,6 +18,7 @@ |
18 | 18 | #include "dmplogger.h" |
19 | 19 | #include "../wms/dmpwmsgetmap.h" |
20 | 20 | #include "dmpmapping.h" |
21 | +#include "dmpmappingparameters.h" | |
21 | 22 | using namespace std; |
22 | 23 | |
23 | 24 | namespace DmpMapping |
... | ... | @@ -32,14 +33,24 @@ namespace DmpMapping |
32 | 33 | LOGGER_DEBUG("Destructing WmsService"); |
33 | 34 | } |
34 | 35 | |
35 | - void DmpMappingService::executeRequest(const DmpServerContext &context) | |
36 | + void DmpMappingService::executeRequest(const DmpServerContext &context) | |
36 | 37 | { |
37 | - LOGGER_DEBUG("Destructing WmsService"); | |
38 | - | |
39 | - const char* data = (char*)(context.request()->GetData()); | |
40 | - | |
41 | - | |
42 | - | |
38 | + const DmpMappingParameters params(context.request()->serverParameters()); | |
39 | + //const DmpProject *project = context.serverProject()->project(); | |
40 | + // | |
41 | + const std::string request = params.Request(); | |
42 | + if (request.empty()) | |
43 | + { | |
44 | + context.response()->writeHtml("wms,Operation is null"); | |
45 | + } | |
46 | + else if (boost::iequals(request, "loadService")) | |
47 | + { | |
48 | + loadService(context, vectorMappingProjects_); | |
49 | + } | |
50 | + else if (boost::iequals(request, "getmap")) | |
51 | + { | |
52 | + DmpWms::writeGetMap(context, params, nullptr); | |
53 | + } | |
43 | 54 | } |
44 | 55 | } |
45 | 56 | ... | ... |
1 | +/************************************************************************** | |
2 | +* file: dmpmappingparameters.cpp | |
3 | + | |
4 | +* Author: qingxiongf | |
5 | +* Date: 2021-12-30 15:58:05 | |
6 | +* Email: qingxiongf@chinadci.com | |
7 | +* copyright: 广州城市信息研究所有限公司 | |
8 | +***************************************************************************/ | |
9 | +#include <iostream> | |
10 | +#include "dmpmappingparameters.h" | |
11 | +#include <boost/lexical_cast.hpp> | |
12 | +#include <boost/algorithm/string.hpp> | |
13 | +#include "dmplogger.h" | |
14 | +#include "dmpserverutils.h" | |
15 | + | |
16 | +namespace DmpMapping | |
17 | +{ | |
18 | + DmpMappingParameters::DmpMappingParameters() | |
19 | + : DmpServerParameters() | |
20 | + { | |
21 | + } | |
22 | + | |
23 | + DmpMappingParameters::DmpMappingParameters(const DmpServerParameters ¶ms) | |
24 | + { | |
25 | + params_ = params.parameters(); | |
26 | + } | |
27 | + | |
28 | + bool DmpMappingParameters::GetStringParameter(const char* key, std::string &value) const | |
29 | + { | |
30 | + std::map<std::string, std::string>::const_iterator iter; | |
31 | + iter = params_.find(key); | |
32 | + if (iter != params_.end()) | |
33 | + { | |
34 | + try | |
35 | + { | |
36 | + value = boost::lexical_cast<std::string>(iter->second); | |
37 | + return true; | |
38 | + } | |
39 | + catch (boost::bad_lexical_cast &e) | |
40 | + { | |
41 | + LOGGER_ERROR(e.what()); | |
42 | + } | |
43 | + } | |
44 | + return false; | |
45 | + } | |
46 | + | |
47 | + bool DmpMappingParameters::GetIntParameter(const char* key, int& value) const | |
48 | + { | |
49 | + std::map<std::string, std::string>::const_iterator iter; | |
50 | + iter = params_.find(key); | |
51 | + if (iter != params_.end()) | |
52 | + { | |
53 | + try | |
54 | + { | |
55 | + value= boost::lexical_cast<int>(iter->second); | |
56 | + return true; | |
57 | + } | |
58 | + catch (boost::bad_lexical_cast &e) | |
59 | + { | |
60 | + LOGGER_ERROR(e.what()); | |
61 | + } | |
62 | + } | |
63 | + return false; | |
64 | + } | |
65 | + | |
66 | + | |
67 | + std::string DmpMappingParameters::Service() const | |
68 | + { | |
69 | + std::string value = "WMS"; | |
70 | + this->GetStringParameter("SERVICE", value); | |
71 | + return value; | |
72 | + } | |
73 | + | |
74 | + //必须 值为GetMap GetCapabilities GetFeatureInfo GetFeatureInfo GetLegendGraphic | |
75 | + std::string DmpMappingParameters::Request() const | |
76 | + { | |
77 | + std::string value = ""; | |
78 | + GetStringParameter("REQUEST",value); | |
79 | + return value; | |
80 | + } | |
81 | + | |
82 | + | |
83 | + std::string DmpMappingParameters::Version() const | |
84 | + { | |
85 | + std::string value = ""; | |
86 | + GetStringParameter("VERSION",value); | |
87 | + return value; | |
88 | + } | |
89 | + | |
90 | +} // namespace DmpWms | |
\ No newline at end of file | ... | ... |
1 | +/************************************************************************** | |
2 | +* file: dmpmappingparameters.h | |
3 | + | |
4 | +* Author: qingxiongf | |
5 | +* Date: 2021-12-30 15:58:01 | |
6 | +* Email: qingxiongf@chinadci.com | |
7 | +* copyright: 广州城市信息研究所有限公司 | |
8 | +***************************************************************************/ | |
9 | + | |
10 | +#ifndef __dmpmappingparameters_h__ | |
11 | +#define __dmpmappingparameters_h__ | |
12 | +#include "dmpserverparameters.h" | |
13 | + | |
14 | +namespace DmpMapping | |
15 | +{ | |
16 | + class DmpMappingParameters : public DmpServerParameters | |
17 | + { | |
18 | + public: | |
19 | + DmpMappingParameters(const DmpServerParameters ¶meters); | |
20 | + DmpMappingParameters(); | |
21 | + virtual ~DmpMappingParameters() = default; | |
22 | + std::string Service() const; //必须 值为WMS | |
23 | + std::string Request() const; //必须 值为GetMap GetCapabilities GetFeatureInfo GetFeatureInfo GetLegendGraphic | |
24 | + std::string Version() const; //必须 服务版本, 值为 1.0.0, 1.1.0, 1.1.1, 1.3 | |
25 | + | |
26 | + private: | |
27 | + bool GetStringParameter(const char* key, std::string &value) const; | |
28 | + bool GetIntParameter(const char* key, int& value) const; | |
29 | + | |
30 | + | |
31 | + | |
32 | + }; | |
33 | +} | |
34 | + | |
35 | +#endif // __dmpmappingparameters_h__ | ... | ... |
请
注册
或
登录
后发表评论