正在显示
14 个修改的文件
包含
277 行增加
和
48 行删除
@@ -14,4 +14,14 @@ bool DmpCoordinateReferenceSystem::readXml(const boost::property_tree::ptree pNo | @@ -14,4 +14,14 @@ bool DmpCoordinateReferenceSystem::readXml(const boost::property_tree::ptree pNo | ||
14 | proj4_ = pNode.get<std::string>("proj4"); | 14 | proj4_ = pNode.get<std::string>("proj4"); |
15 | srid_ = pNode.get<long>("srid"); | 15 | srid_ = pNode.get<long>("srid"); |
16 | return true; | 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 | } |
@@ -17,6 +17,7 @@ class CORE_EXPORT DmpCoordinateReferenceSystem | @@ -17,6 +17,7 @@ class CORE_EXPORT DmpCoordinateReferenceSystem | ||
17 | { | 17 | { |
18 | public: | 18 | public: |
19 | bool readXml(const boost::property_tree::ptree pNode); | 19 | bool readXml(const boost::property_tree::ptree pNode); |
20 | + bool write(boost::property_tree::ptree& pNode); | ||
20 | long srid(){return srid_;} | 21 | long srid(){return srid_;} |
21 | private: | 22 | private: |
22 | long srid_; | 23 | long srid_; |
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | #include <boost/algorithm/string/case_conv.hpp> | 11 | #include <boost/algorithm/string/case_conv.hpp> |
12 | #include <boost/property_tree/ptree.hpp> | 12 | #include <boost/property_tree/ptree.hpp> |
13 | #include <boost/property_tree/xml_parser.hpp> | 13 | #include <boost/property_tree/xml_parser.hpp> |
14 | +#include <boost/property_tree/json_parser.hpp> | ||
14 | #include <boost/typeof/typeof.hpp> | 15 | #include <boost/typeof/typeof.hpp> |
15 | #include "dmpproject.h" | 16 | #include "dmpproject.h" |
16 | #include "dmptilelayer.h" | 17 | #include "dmptilelayer.h" |
@@ -124,6 +125,60 @@ bool DmpProject::Write(const std::string &filename, const std::string &data) | @@ -124,6 +125,60 @@ bool DmpProject::Write(const std::string &filename, const std::string &data) | ||
124 | return true; | 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 | DmpCoordinateReferenceSystem DmpProject::crs() const | 182 | DmpCoordinateReferenceSystem DmpProject::crs() const |
128 | { | 183 | { |
129 | return crs_; | 184 | return crs_; |
@@ -26,6 +26,9 @@ class CORE_EXPORT DmpProject | @@ -26,6 +26,9 @@ class CORE_EXPORT DmpProject | ||
26 | ~DmpProject(); | 26 | ~DmpProject(); |
27 | bool Read(const std::string &data); | 27 | bool Read(const std::string &data); |
28 | bool Write(const std::string &filename, const std::string &data); | 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 | DmpCoordinateReferenceSystem crs() const; | 32 | DmpCoordinateReferenceSystem crs() const; |
30 | std::map<std::string, DmpMapLayer*> mapLayers() const; | 33 | std::map<std::string, DmpMapLayer*> mapLayers() const; |
31 | DmpMapLayer* getLayer(const std::string &layerName) const; | 34 | DmpMapLayer* getLayer(const std::string &layerName) const; |
@@ -75,6 +75,7 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) | @@ -75,6 +75,7 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) | ||
75 | layerNode.add("<xmlattr>.name", name_); | 75 | layerNode.add("<xmlattr>.name", name_); |
76 | layerNode.add("<xmlattr>.alias", title_); | 76 | layerNode.add("<xmlattr>.alias", title_); |
77 | 77 | ||
78 | + | ||
78 | boost::property_tree::ptree ptExtent; | 79 | boost::property_tree::ptree ptExtent; |
79 | ptExtent.add("xmin", extent_.xmin()); | 80 | ptExtent.add("xmin", extent_.xmin()); |
80 | ptExtent.add("ymin", extent_.ymin()); | 81 | ptExtent.add("ymin", extent_.ymin()); |
@@ -83,12 +84,12 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) | @@ -83,12 +84,12 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) | ||
83 | layerNode.add_child("extent", ptExtent); | 84 | layerNode.add_child("extent", ptExtent); |
84 | 85 | ||
85 | layerNode.add("datasource", dataSource_); | 86 | layerNode.add("datasource", dataSource_); |
86 | - | 87 | + boost::property_tree::ptree ptRenderer; |
87 | if(this->renderer_30_) | 88 | if(this->renderer_30_) |
88 | { | 89 | { |
89 | - boost::property_tree::ptree ptRenderer; | ||
90 | this->renderer_30_->ParsePtree(ptRenderer); | 90 | this->renderer_30_->ParsePtree(ptRenderer); |
91 | } | 91 | } |
92 | + layerNode.add_child("renderer",ptRenderer); | ||
92 | 93 | ||
93 | return true; | 94 | return true; |
94 | } | 95 | } |
@@ -117,15 +117,15 @@ namespace DmapCore_30 | @@ -117,15 +117,15 @@ namespace DmapCore_30 | ||
117 | sprintf(buff_minscale,"%.0f", this->m_dLower); | 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 | if(this->m_pRen) | 124 | if(this->m_pRen) |
125 | { | 125 | { |
126 | this->m_pRen->ParsePtree(ptRenderer); | 126 | this->m_pRen->ParsePtree(ptRenderer); |
127 | } | 127 | } |
128 | - pt.add_child("TEXTSYMBOL",ptRenderer); | 128 | + pt.add_child("SIMPLERENDERER",ptRenderer); |
129 | return true; | 129 | return true; |
130 | } | 130 | } |
131 | 131 |
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | #include "clsJson.h" | 3 | #include "clsJson.h" |
4 | #include <stdarg.h> | 4 | #include <stdarg.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | - | 6 | +#include "clsUtil.h" |
7 | namespace DmapCore_30 | 7 | namespace DmapCore_30 |
8 | { | 8 | { |
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) | 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,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 | string sColor = "", sTransparency = ""; | 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 | sprintf(buff, "\"%s\":\"%s\",\"%s\":\"%s\",", name, sColor.c_str(),name2,sTransparency.c_str()); | 95 | sprintf(buff, "\"%s\":\"%s\",\"%s\":\"%s\",", name, sColor.c_str(),name2,sTransparency.c_str()); |
87 | strcat(resultbuff, buff); | 96 | strcat(resultbuff, buff); |
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | #include "clsPtree.h" | 11 | #include "clsPtree.h" |
12 | #include <stdarg.h> | 12 | #include <stdarg.h> |
13 | #include <string.h> | 13 | #include <string.h> |
14 | +#include "clsUtil.h" | ||
14 | 15 | ||
15 | namespace DmapCore_30 | 16 | namespace DmapCore_30 |
16 | { | 17 | { |
@@ -78,16 +79,22 @@ namespace DmapCore_30 | @@ -78,16 +79,22 @@ namespace DmapCore_30 | ||
78 | pt.add(ptname, v); | 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 | pt.add(ptname + name, sColor); | 96 | pt.add(ptname + name, sColor); |
89 | pt.add(ptname + name2, sTransparency); | 97 | pt.add(ptname + name2, sTransparency); |
90 | - | ||
91 | - } | 98 | + } |
92 | 99 | ||
93 | } // namespace DmapDll | 100 | } // namespace DmapDll |
@@ -20,6 +20,7 @@ SET (MAPSERVER_SRCS | @@ -20,6 +20,7 @@ SET (MAPSERVER_SRCS | ||
20 | wms/dmpwmsgetfeatureinfo.cpp | 20 | wms/dmpwmsgetfeatureinfo.cpp |
21 | mapping/dmpmapping.cpp | 21 | mapping/dmpmapping.cpp |
22 | mapping/dmpeditservice.cpp | 22 | mapping/dmpeditservice.cpp |
23 | + mapping/dmpmappingparameters.cpp | ||
23 | ) | 24 | ) |
24 | 25 | ||
25 | SET (MAPSERVER_HDRS | 26 | SET (MAPSERVER_HDRS |
@@ -40,6 +41,7 @@ SET (MAPSERVER_HDRS | @@ -40,6 +41,7 @@ SET (MAPSERVER_HDRS | ||
40 | wms/dmpwmsgetfeatureinfo.h | 41 | wms/dmpwmsgetfeatureinfo.h |
41 | mapping/dmpmapping.h | 42 | mapping/dmpmapping.h |
42 | mapping/dmpeditservice.h | 43 | mapping/dmpeditservice.h |
44 | + mapping/dmpmappingparameters.h | ||
43 | ) | 45 | ) |
44 | 46 | ||
45 | ######################################################## | 47 | ######################################################## |
@@ -10,25 +10,28 @@ | @@ -10,25 +10,28 @@ | ||
10 | #include "dmplogger.h" | 10 | #include "dmplogger.h" |
11 | #include "dmpserverresponse.h" | 11 | #include "dmpserverresponse.h" |
12 | #include "dmpserverrequest.h" | 12 | #include "dmpserverrequest.h" |
13 | +#include "dmpproject.h" | ||
14 | +#include "dmpserverproject.h" | ||
13 | #include <boost/property_tree/ptree.hpp> | 15 | #include <boost/property_tree/ptree.hpp> |
14 | #include <boost/property_tree/json_parser.hpp> | 16 | #include <boost/property_tree/json_parser.hpp> |
15 | #include <boost/typeof/typeof.hpp> | 17 | #include <boost/typeof/typeof.hpp> |
16 | 18 | ||
17 | namespace DmpMapping | 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 | if(data== nullptr || *data == '\0') | 24 | if(data== nullptr || *data == '\0') |
22 | { | 25 | { |
23 | LOGGER_ERROR("post 参数错误"); | 26 | LOGGER_ERROR("post 参数错误"); |
24 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | 27 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
25 | return false; | 28 | return false; |
26 | } | 29 | } |
27 | 30 | ||
28 | if(!context.serverProject()) | 31 | if(!context.serverProject()) |
29 | { | 32 | { |
30 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); | 33 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); |
31 | - context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | 34 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); |
32 | return false; | 35 | return false; |
33 | } | 36 | } |
34 | 37 | ||
@@ -39,26 +42,27 @@ namespace DmpMapping | @@ -39,26 +42,27 @@ namespace DmpMapping | ||
39 | boost::property_tree::read_json(stream, pt); | 42 | boost::property_tree::read_json(stream, pt); |
40 | 43 | ||
41 | std::string guid = pt.get<std::string>("guid"); | 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 | shared_ptr<DmpProject> project(new DmpProject()); | 51 | shared_ptr<DmpProject> project(new DmpProject()); |
51 | - if (!project->Read(projData)) | 52 | + if (!project->Read(projectData)) |
52 | { | 53 | { |
53 | return false; | 54 | return false; |
54 | } | 55 | } |
55 | vectorMappingProjects[guid] = project; | 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 | else | 62 | else |
59 | { | 63 | { |
60 | LOGGER_ERROR("post 参数错误"); | 64 | LOGGER_ERROR("post 参数错误"); |
61 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | 65 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
62 | return false; | 66 | return false; |
63 | } | 67 | } |
64 | 68 | ||
@@ -66,31 +70,32 @@ namespace DmpMapping | @@ -66,31 +70,32 @@ namespace DmpMapping | ||
66 | catch (boost::property_tree::ptree_bad_path &e) | 70 | catch (boost::property_tree::ptree_bad_path &e) |
67 | { | 71 | { |
68 | LOGGER_ERROR(e.what()); | 72 | LOGGER_ERROR(e.what()); |
69 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | 73 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); |
70 | return false; | 74 | return false; |
71 | } | 75 | } |
72 | catch (boost::property_tree::ptree_bad_data &e) | 76 | catch (boost::property_tree::ptree_bad_data &e) |
73 | { | 77 | { |
74 | LOGGER_ERROR(e.what()); | 78 | LOGGER_ERROR(e.what()); |
75 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | 79 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); |
76 | return false; | 80 | return false; |
77 | } | 81 | } |
78 | return false; | 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 | if(data== nullptr || *data == '\0') | 88 | if(data== nullptr || *data == '\0') |
84 | { | 89 | { |
85 | LOGGER_ERROR("post 参数错误"); | 90 | LOGGER_ERROR("post 参数错误"); |
86 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | 91 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
87 | return false; | 92 | return false; |
88 | } | 93 | } |
89 | 94 | ||
90 | if(!context.serverProject()) | 95 | if(!context.serverProject()) |
91 | { | 96 | { |
92 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); | 97 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); |
93 | - context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | 98 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); |
94 | return false; | 99 | return false; |
95 | } | 100 | } |
96 | 101 | ||
@@ -115,12 +120,12 @@ namespace DmpMapping | @@ -115,12 +120,12 @@ namespace DmpMapping | ||
115 | return false; | 120 | return false; |
116 | } | 121 | } |
117 | vectorMappingProjects[guid] = project; | 122 | vectorMappingProjects[guid] = project; |
118 | - context.response()->write("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}"); | 123 | + context.response()->writeJson("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}"); |
119 | } | 124 | } |
120 | else | 125 | else |
121 | { | 126 | { |
122 | LOGGER_ERROR("post 参数错误"); | 127 | LOGGER_ERROR("post 参数错误"); |
123 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | 128 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
124 | return false; | 129 | return false; |
125 | } | 130 | } |
126 | 131 | ||
@@ -128,13 +133,13 @@ namespace DmpMapping | @@ -128,13 +133,13 @@ namespace DmpMapping | ||
128 | catch (boost::property_tree::ptree_bad_path &e) | 133 | catch (boost::property_tree::ptree_bad_path &e) |
129 | { | 134 | { |
130 | LOGGER_ERROR(e.what()); | 135 | LOGGER_ERROR(e.what()); |
131 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | 136 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); |
132 | return false; | 137 | return false; |
133 | } | 138 | } |
134 | catch (boost::property_tree::ptree_bad_data &e) | 139 | catch (boost::property_tree::ptree_bad_data &e) |
135 | { | 140 | { |
136 | LOGGER_ERROR(e.what()); | 141 | LOGGER_ERROR(e.what()); |
137 | - context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); | 142 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误\"}"); |
138 | return false; | 143 | return false; |
139 | } | 144 | } |
140 | return false; | 145 | return false; |
@@ -20,10 +20,10 @@ namespace DmpMapping | @@ -20,10 +20,10 @@ namespace DmpMapping | ||
20 | { | 20 | { |
21 | typedef std::map<std::string, std::shared_ptr<DmpProject>> ProjectMap; | 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,6 +18,7 @@ | ||
18 | #include "dmplogger.h" | 18 | #include "dmplogger.h" |
19 | #include "../wms/dmpwmsgetmap.h" | 19 | #include "../wms/dmpwmsgetmap.h" |
20 | #include "dmpmapping.h" | 20 | #include "dmpmapping.h" |
21 | +#include "dmpmappingparameters.h" | ||
21 | using namespace std; | 22 | using namespace std; |
22 | 23 | ||
23 | namespace DmpMapping | 24 | namespace DmpMapping |
@@ -32,14 +33,24 @@ namespace DmpMapping | @@ -32,14 +33,24 @@ namespace DmpMapping | ||
32 | LOGGER_DEBUG("Destructing WmsService"); | 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 |
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__ |
请
注册
或
登录
后发表评论