正在显示
9 个修改的文件
包含
463 行增加
和
24 行删除
@@ -52,7 +52,7 @@ namespace DmpWms | @@ -52,7 +52,7 @@ namespace DmpWms | ||
52 | } | 52 | } |
53 | else if(boost::iequals(request,"thumbnail")) | 53 | else if(boost::iequals(request,"thumbnail")) |
54 | { | 54 | { |
55 | - // writeThumbnail(context,params, project); | 55 | + writeThumbnail(context,params, project); |
56 | } | 56 | } |
57 | else if(boost::iequals(request, "getfeatureinfo")) | 57 | else if(boost::iequals(request, "getfeatureinfo")) |
58 | { | 58 | { |
1 | +/************************************************************************** | ||
2 | +* file: dmpwmsgetfeatureinfo.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-17 16:20:04 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpwmsgetcapabilities.h" | ||
10 | +#include "dmpwmsrenderer.h" | ||
11 | +#include "dmpserverresponse.h" | ||
12 | +#include "dmpserverrequest.h" | ||
13 | +#include <map> | ||
14 | +#include <memory> | ||
15 | +namespace DmpWms | ||
16 | +{ | ||
17 | + void writeFeatureInfo(const DmpServerContext &context,const DmpWmsParameters& params, | ||
18 | + const DmpProject* project, | ||
19 | + bool projectSettings ) | ||
20 | + { | ||
21 | + string exception = WmsGetMap(context,params, project,projectSettings); | ||
22 | + if(exception.length() >0) | ||
23 | + { | ||
24 | + | ||
25 | + } | ||
26 | + } | ||
27 | + | ||
28 | + | ||
29 | + std::string WmsGetFeatureInfo(const DmpServerContext &context, const DmpWmsParameters& params, | ||
30 | + const DmpProject* project, bool projectSettings) | ||
31 | + { | ||
32 | + try | ||
33 | + { | ||
34 | + | ||
35 | + double boxX1, boxY1, boxX2, boxY2; | ||
36 | + std::string srs = params.Srs(); | ||
37 | + std::string recbox = params.BBox(); | ||
38 | + | ||
39 | + int width = params.Width(); | ||
40 | + int height = params.Height(); | ||
41 | + | ||
42 | + if (boost::iequals(srs, "CRS:84")|| boost::iequals(srs, "EPSG:4326")) | ||
43 | + { | ||
44 | + sscanf(recbox.c_str(), "%lf,%lf,%lf,%lf", &boxY1, &boxX1, &boxY2, &boxX2); | ||
45 | + } | ||
46 | + else | ||
47 | + { | ||
48 | + sscanf(recbox.c_str(), "%lf,%lf,%lf,%lf", &boxX1, &boxY1, &boxX2, &boxY2); | ||
49 | + } | ||
50 | + | ||
51 | + //stbstb:应该检查大量地方的 width和height不为零 ,char* regionDefs | ||
52 | + if (width <= 0 || height <= 0) return "width和height 参数错误"; | ||
53 | + | ||
54 | + DmpWms::DmpWmsRenderer mapRenderer(height, width); | ||
55 | + | ||
56 | + std::string layers = params.QueryLayers(); | ||
57 | + if (layers !="") | ||
58 | + { | ||
59 | + mapRenderer.AddWmsMapLayers(project); | ||
60 | + } | ||
61 | + else | ||
62 | + { | ||
63 | + char strlayers[1000] = {0}; | ||
64 | + strcpy(strlayers,(char *)layers.c_str()); | ||
65 | + mapRenderer.AddWmsMapLayers(project, strlayers); | ||
66 | + } | ||
67 | + | ||
68 | + int x = params.X(); | ||
69 | + int y = params.Y(); | ||
70 | + int featureCount = params.FeatureCount(); | ||
71 | + | ||
72 | + shared_ptr<Rect> rect (new Rect(boxY2, boxX2, boxY1, boxX1)); | ||
73 | + mapRenderer.SetExtent(rect); | ||
74 | + string responseData; | ||
75 | + mapRenderer.GetFeatureInfo(responseData, "", x, y,featureCount); | ||
76 | + context.response()->removeHeader("Content-Type"); | ||
77 | + context.response()->setHeader("Content-Type", "image/png"); | ||
78 | + context.response()->write(responseData); | ||
79 | + return ""; | ||
80 | + } | ||
81 | + catch (const std::exception &e) | ||
82 | + { | ||
83 | + std::cerr << " GetMap " << e.what() << '\n'; | ||
84 | + return e.what(); | ||
85 | + } | ||
86 | + } | ||
87 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpwmsgetfeatureinfo.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-17 16:19:56 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpwmsgetfeatureinfo_h__ | ||
11 | +#define __dmpwmsgetfeatureinfo_h__ | ||
12 | +#include <boost/property_tree/ptree.hpp> | ||
13 | +#include <boost/property_tree/xml_parser.hpp> | ||
14 | +#include <boost/typeof/typeof.hpp> | ||
15 | +#include <memory> | ||
16 | +#include <vector> | ||
17 | +#include "dmpproject.h" | ||
18 | +#include "dmpwmsparameters.h" | ||
19 | +#include "dmpservercontext.h" | ||
20 | + | ||
21 | +namespace DmpWms | ||
22 | +{ | ||
23 | + void writeFeatureInfo(const DmpServerContext &context,const DmpWmsParameters& params, | ||
24 | + const DmpProject* project, | ||
25 | + bool projectSettings = false ); | ||
26 | + | ||
27 | + std::string WmsGetFeatureInfo(const DmpServerContext &context, const DmpWmsParameters& params, | ||
28 | + const DmpProject* project, | ||
29 | + bool projectSettings); | ||
30 | +} | ||
31 | + | ||
32 | +#endif // __dmpwmsgetfeatureinfo_h__ |
@@ -91,42 +91,53 @@ namespace DmpWms | @@ -91,42 +91,53 @@ namespace DmpWms | ||
91 | return e.what(); | 91 | return e.what(); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | -/* | 94 | + |
95 | void writeThumbnail(const DmpServerContext &context,const DmpWmsParameters& params, | 95 | void writeThumbnail(const DmpServerContext &context,const DmpWmsParameters& params, |
96 | - const DmpProject* project,bool projectSettings = false) | 96 | + const DmpProject* project,bool projectSettings) |
97 | { | 97 | { |
98 | try | 98 | try |
99 | { | 99 | { |
100 | - | ||
101 | - double boxX1, boxY1, boxX2, boxY2; | ||
102 | - // int width = params.Width(); | ||
103 | - // int height = params.Height(); | ||
104 | DmpWms::DmpWmsRenderer mapRenderer(231,256); | 100 | DmpWms::DmpWmsRenderer mapRenderer(231,256); |
105 | - double boxX1 = rect_service->m_dLeft; | ||
106 | - double boxY1 = rect_service->m_dBottom; | ||
107 | - double boxX2 = rect_service->m_dRight; | ||
108 | - double boxY2 = rect_service->m_dTop; | 101 | + double minx,miny,maxx,maxy; |
102 | + int i =0; | ||
103 | + std::map<std::string, DmpMapLayer*> mapLayers = project->mapLayers(); | ||
104 | + for (std::map<std::string, DmpMapLayer*>::iterator iter = mapLayers.begin();iter != mapLayers.end(); iter++) | ||
105 | + { | ||
106 | + DmpMapLayer* layer = iter->second; | ||
107 | + if(i ==0) | ||
108 | + { | ||
109 | + minx = layer->extent().xmin(); | ||
110 | + miny = layer->extent().ymin(); | ||
111 | + maxx = layer->extent().xmax(); | ||
112 | + maxy = layer->extent().ymax(); | ||
113 | + } | ||
114 | + else | ||
115 | + { | ||
116 | + if(minx > layer->extent().xmin()) minx = layer->extent().xmin(); | ||
117 | + if(miny > layer->extent().ymin()) miny = layer->extent().ymin(); | ||
118 | + if(maxx < layer->extent().xmax()) maxx = layer->extent().xmax(); | ||
119 | + if(maxy < layer->extent().ymax()) maxy = layer->extent().ymax(); | ||
120 | + } | ||
121 | + } | ||
109 | 122 | ||
110 | - double dx = (boxX2 - boxX1) *0.1; | ||
111 | - double dy = (boxY2 - boxY1) *0.1; | 123 | + double dx = (maxx - minx) *0.1; |
124 | + double dy = (maxy - miny) *0.1; | ||
112 | 125 | ||
113 | - shared_ptr<Rect> rect (new Rect(boxY2, boxX2, boxY1, boxX1)); | 126 | + shared_ptr<Rect> rect (new Rect(maxy, maxx, miny, minx)); |
114 | mapRenderer.SetExtent(rect); | 127 | mapRenderer.SetExtent(rect); |
115 | - mapRenderer.GetMap(&mapLayerDefs,&mapRegionDefs); | 128 | + mapRenderer.GetMap(nullptr, nullptr, nullptr, true); |
116 | string responseData; | 129 | string responseData; |
117 | mapRenderer.ToStream(responseData); | 130 | mapRenderer.ToStream(responseData); |
118 | context.response()->removeHeader("Content-Type"); | 131 | context.response()->removeHeader("Content-Type"); |
119 | context.response()->setHeader("Content-Type", "image/png"); | 132 | context.response()->setHeader("Content-Type", "image/png"); |
120 | context.response()->write(responseData); | 133 | context.response()->write(responseData); |
121 | - return ""; | ||
122 | } | 134 | } |
123 | catch (const std::exception &e) | 135 | catch (const std::exception &e) |
124 | { | 136 | { |
125 | std::cerr << " GetMap " << e.what() << '\n'; | 137 | std::cerr << " GetMap " << e.what() << '\n'; |
126 | - return e.what(); | ||
127 | } | 138 | } |
128 | } | 139 | } |
129 | -*/ | 140 | + |
130 | 141 | ||
131 | 142 | ||
132 | int StrDefs2Map(std::map<std::string,std::string>& mapDefs,std::string& strDefs) | 143 | int StrDefs2Map(std::map<std::string,std::string>& mapDefs,std::string& strDefs) |
@@ -28,8 +28,8 @@ namespace DmpWms | @@ -28,8 +28,8 @@ namespace DmpWms | ||
28 | const DmpProject* project, | 28 | const DmpProject* project, |
29 | bool projectSettings = false ); | 29 | bool projectSettings = false ); |
30 | 30 | ||
31 | - // void writeThumbnail(const DmpServerContext &context,const DmpWmsParameters& params, | ||
32 | - // const DmpProject* project,bool projectSettings = false); | 31 | + void writeThumbnail(const DmpServerContext &context,const DmpWmsParameters& params, |
32 | + const DmpProject* project,bool projectSettings = false); | ||
33 | 33 | ||
34 | int StrDefs2Map(std::map<std::string,std::string>& mapDefs,std::string& strDefs); | 34 | int StrDefs2Map(std::map<std::string,std::string>& mapDefs,std::string& strDefs); |
35 | 35 |
@@ -169,7 +169,61 @@ namespace DmpWms | @@ -169,7 +169,61 @@ namespace DmpWms | ||
169 | return value; | 169 | return value; |
170 | } | 170 | } |
171 | 171 | ||
172 | + DmpWmsParameters::Format DmpWmsParameters::InfoFormat() const | ||
173 | + { | ||
174 | + std::string value = ""; | ||
175 | + if(!GetStringParameter("INFO_FORMAT",value)) | ||
176 | + { | ||
177 | + GetStringParameter("FORMAT",value); | ||
178 | + } | ||
179 | + | ||
180 | + Format outformat = Format::GML; | ||
181 | + boost::to_lower(value); | ||
182 | + if (value.compare("jpg") == 0 || value.compare("jpeg") == 0 || value.compare("image/jpeg") == 0 ) | ||
183 | + { | ||
184 | + outformat = DmpWmsParameters::Format::JPG; | ||
185 | + } | ||
186 | + else if(value.compare("gml") == 0 || value.compare("application/vnd.ogc.wms_xml") == 0) | ||
187 | + { | ||
188 | + outformat = DmpWmsParameters::Format::XML; | ||
189 | + } | ||
190 | + return outformat; | ||
191 | + } | ||
192 | + | ||
193 | + | ||
194 | + std::string DmpWmsParameters::QueryLayers() const //查询图层 | ||
195 | + { | ||
196 | + std::string value = ""; | ||
197 | + GetStringParameter("QUERY_LAYERS",value); | ||
198 | + return value; | ||
199 | + } | ||
200 | + | ||
201 | + int DmpWmsParameters::FeatureCount() const //查询记录数量 | ||
202 | + { | ||
203 | + int value = 100; | ||
204 | + GetIntParameter("FEATURE_COUNT",value); | ||
205 | + return value; | ||
206 | + } | ||
172 | 207 | ||
208 | + int DmpWmsParameters::X() const //地图上查询点的X坐标,以像素为单位。0是左侧。i是WMS 1.3.0中使用的参数键。 | ||
209 | + { | ||
210 | + int value = -1; | ||
211 | + if(!GetIntParameter("X",value)) | ||
212 | + { | ||
213 | + GetIntParameter("I",value); | ||
214 | + } | ||
215 | + return value; | ||
216 | + } | ||
217 | + | ||
218 | + int DmpWmsParameters::Y() const //地图上查询点的Y坐标,以像素为单位。0是左侧。j是WMS 1.3.0中使用的参数键。 | ||
219 | + { | ||
220 | + int value = -1; | ||
221 | + if(!GetIntParameter("Y",value)) | ||
222 | + { | ||
223 | + GetIntParameter("J",value); | ||
224 | + } | ||
225 | + return value; | ||
226 | + } | ||
173 | 227 | ||
174 | DmpWmsParameters::Format DmpWmsParameters::ResFormat() const | 228 | DmpWmsParameters::Format DmpWmsParameters::ResFormat() const |
175 | { | 229 | { |
@@ -52,8 +52,9 @@ namespace DmpWms | @@ -52,8 +52,9 @@ namespace DmpWms | ||
52 | std::string regionDefs() const; | 52 | std::string regionDefs() const; |
53 | 53 | ||
54 | // GetFeatureInfo | 54 | // GetFeatureInfo |
55 | + DmpWmsParameters::Format InfoFormat() const; | ||
55 | std::string QueryLayers() const; //查询图层 | 56 | std::string QueryLayers() const; //查询图层 |
56 | - std::string FeatureCount() const; //查询记录数量 | 57 | + int FeatureCount() const; //查询记录数量 |
57 | int X() const; //地图上查询点的X坐标,以像素为单位。0是左侧。i是WMS 1.3.0中使用的参数键。 | 58 | int X() const; //地图上查询点的X坐标,以像素为单位。0是左侧。i是WMS 1.3.0中使用的参数键。 |
58 | int Y() const; //地图上查询点的Y坐标,以像素为单位。0是左侧。j是WMS 1.3.0中使用的参数键。 | 59 | int Y() const; //地图上查询点的Y坐标,以像素为单位。0是左侧。j是WMS 1.3.0中使用的参数键。 |
59 | 60 |
@@ -590,6 +590,65 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ | @@ -590,6 +590,65 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ | ||
590 | return sql; | 590 | return sql; |
591 | } | 591 | } |
592 | 592 | ||
593 | + | ||
594 | + bool DmpWmsRenderer::GetFeatureInfo(std::string &responseData, int gmlVersion, int x, int y, int feature_count) | ||
595 | + { | ||
596 | + if(m_dR == 0) | ||
597 | + return false; | ||
598 | + //double x0 = m_dR * x + m_dXdis; | ||
599 | + //double y0 = -m_dR * y + m_dYdis; | ||
600 | + | ||
601 | + double x0 =(x - m_dXdis)/ m_dR ; | ||
602 | + double y0 = (m_dYdis -y )/m_dR ; | ||
603 | + double dis = 1/m_dR; | ||
604 | + | ||
605 | + | ||
606 | + | ||
607 | + for (int i = (int)(m_vLayers.size()) -1; i >=0; i--) | ||
608 | + { | ||
609 | + DmpVectorLayer* layer = (DmpVectorLayer*)m_vLayers[i]; | ||
610 | + | ||
611 | + //double r1 = layer->m_dUpperScale; // * | ||
612 | + //double r2 = layer->m_dLowerScale; // * | ||
613 | + | ||
614 | + | ||
615 | + ///if ((this->m_dScaleDenominator > r1 || this->m_dScaleDenominator < r2 || ml->m_pRenderer == 0)) | ||
616 | + // continue; | ||
617 | + | ||
618 | + double start = clock(); | ||
619 | + double cost, cost2; | ||
620 | + | ||
621 | + string sql = this->GetFeatureInfoSQL(layer, x0, y0, dis,feature_count); //sql语句中使用 ::box | ||
622 | + if (sql == "") | ||
623 | + continue; | ||
624 | + | ||
625 | + string layerName = layer->name(); | ||
626 | + //const char *ss__ = ""; | ||
627 | + //const char **pmsg = &ss__; | ||
628 | + try | ||
629 | + { | ||
630 | + shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source()); | ||
631 | + if (pPgsqlConn == nullptr) | ||
632 | + break; | ||
633 | + if (pPgsqlConn->ExecWaitBinary(sql) ) | ||
634 | + { | ||
635 | + | ||
636 | + //PGresult *res = pPgsqlConn->GetPGresult(); | ||
637 | + string srid = std::__cxx11::to_string(layer->crs().srid()); | ||
638 | + this->FormatWFSJsonCAll(pPgsqlConn, responseData, layerName, gmlVersion,srid); | ||
639 | + return true; | ||
640 | + | ||
641 | + } | ||
642 | + } | ||
643 | + catch (const std::exception &e) | ||
644 | + { | ||
645 | + std::cerr << "#DrawSimpleData " << e.what() << '\n'; | ||
646 | + } | ||
647 | + } | ||
648 | + return true; | ||
649 | + } | ||
650 | + | ||
651 | + | ||
593 | 652 | ||
594 | bool DmpWmsRenderer::AddWmsMapLayers(const DmpProject* project) //插入型加入 | 653 | bool DmpWmsRenderer::AddWmsMapLayers(const DmpProject* project) //插入型加入 |
595 | { | 654 | { |
@@ -1228,4 +1287,199 @@ bool DmpWmsRenderer::ToPngStream(rasterBufferObj *rb,std::string& responseData) | @@ -1228,4 +1287,199 @@ bool DmpWmsRenderer::ToPngStream(rasterBufferObj *rb,std::string& responseData) | ||
1228 | } | 1287 | } |
1229 | 1288 | ||
1230 | 1289 | ||
1290 | +//以GeoJson的形式返回 | ||
1291 | +void DmpWmsRenderer::FormatWFSJsonCAll(shared_ptr<DmpPgsql> pPgsqlConn, AppendBuffer *ab, char *layerNAMEc,int gmlVersion,char *srsOut) | ||
1292 | +{ | ||
1293 | + double xg1, yg1, xg2, yg2; | ||
1294 | + int havegSet = 0; | ||
1295 | + int count = 0; | ||
1296 | + int pointCountTemp = 0; | ||
1297 | + | ||
1298 | + std::string stringTime; | ||
1299 | + char buff[5000] = {0}; | ||
1300 | + | ||
1301 | + ab->AppendString(R"({"type":"FeatureCollection","features":[)"); | ||
1302 | + | ||
1303 | + try | ||
1304 | + { | ||
1305 | + int fieldsCount = pPgsqlConn->GetFieldCount(); | ||
1306 | + for (int featureIndex = 0; pPgsqlConn->next(); featureIndex++) | ||
1307 | + { | ||
1308 | + if (featureIndex > 0) | ||
1309 | + ab->AppendString(","); | ||
1310 | + ab->AppendString(R"({"type":"Feature")"); | ||
1311 | + | ||
1312 | + | ||
1313 | + string geometry = ""; | ||
1314 | + string properties = ""; | ||
1315 | + | ||
1316 | + for (int i = 0; i < fieldsCount; i++) | ||
1317 | + { | ||
1318 | + const char *str = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | ||
1319 | + //printf("%s\r\n",str); | ||
1320 | + if(str == 0) | ||
1321 | + { | ||
1322 | + break; | ||
1323 | + } | ||
1324 | + | ||
1325 | + if (strncmp(str, "RN_RN", 5) == 0) | ||
1326 | + continue; | ||
1327 | + std::string sT = str; | ||
1328 | + //XML转义 | ||
1329 | + DmapDll::StringHelp::ToJSONString(sT); | ||
1330 | + str = sT.c_str(); | ||
1331 | + | ||
1332 | + if( sT == "geometry_as_geojson") | ||
1333 | + { | ||
1334 | + geometry = pPgsqlConn->getString(i); | ||
1335 | + continue; | ||
1336 | + } | ||
1337 | + // str="a"; | ||
1338 | + switch (pPgsqlConn->GetPGFieldType(i)) | ||
1339 | + { | ||
1340 | + case PGFieldType::ByteaFieldType: | ||
1341 | + { | ||
1342 | + const char *s = pPgsqlConn->getBlob2(i); | ||
1343 | + sprintf(buff, R"(,"%s":"%s")", str, s); | ||
1344 | + properties += buff; | ||
1345 | + } | ||
1346 | + break; | ||
1347 | + case PGFieldType::ClobFieldType: | ||
1348 | + { | ||
1349 | + const char *s = pPgsqlConn->getClob2(i); | ||
1350 | + sprintf(buff, R"(,"%s":"%s")", str, s); | ||
1351 | + properties += buff; | ||
1352 | + } | ||
1353 | + break; | ||
1354 | + case PGFieldType::BigIntFieldType: | ||
1355 | + { | ||
1356 | + long v; | ||
1357 | + const char *str1 = pPgsqlConn->getString(i); | ||
1358 | + ((char *)&v)[7] = str1[0]; | ||
1359 | + ((char *)&v)[6] = str1[1]; | ||
1360 | + ((char *)&v)[5] = str1[2]; | ||
1361 | + ((char *)&v)[4] = str1[3]; | ||
1362 | + ((char *)&v)[3] = str1[4]; | ||
1363 | + ((char *)&v)[2] = str1[5]; | ||
1364 | + ((char *)&v)[1] = str1[6]; | ||
1365 | + ((char *)&v)[0] = str1[7]; | ||
1366 | + sprintf(buff, R"(,"%s":%ld)", str, v); | ||
1367 | + properties += buff; | ||
1368 | + //sprintf(sql, "<%s:%s>%llu</%s:%s>", "dmp", str, v, "dmp", str); | ||
1369 | + //ab->AppendString(sql); | ||
1370 | + } | ||
1371 | + break; | ||
1372 | + case PGFieldType::DateFieldType: | ||
1373 | + { | ||
1374 | + int v; | ||
1375 | + const char *str1 = pPgsqlConn->getString(i); | ||
1376 | + ((char *)&v)[3] = str1[0]; | ||
1377 | + ((char *)&v)[2] = str1[1]; | ||
1378 | + ((char *)&v)[1] = str1[2]; | ||
1379 | + ((char *)&v)[0] = str1[3]; | ||
1380 | + sprintf(buff, R"(,"%s":%d)", str, v); | ||
1381 | + properties += buff; | ||
1382 | + //sprintf(sql, "<%s:%s>%ld</%s:%s>", "dmp", str, v, "dmp", str); | ||
1383 | + //ab->AppendString(sql); | ||
1384 | + } | ||
1385 | + break; | ||
1386 | + case PGFieldType::IntFieldType: | ||
1387 | + { | ||
1388 | + int v; | ||
1389 | + const char *str1 = pPgsqlConn->getString(i); | ||
1390 | + ((char *)&v)[3] = str1[0]; | ||
1391 | + ((char *)&v)[2] = str1[1]; | ||
1392 | + ((char *)&v)[1] = str1[2]; | ||
1393 | + ((char *)&v)[0] = str1[3]; | ||
1394 | + sprintf(buff, R"(,"%s":%d)", str, v); | ||
1395 | + properties += buff; | ||
1396 | + //sprintf(sql, "<%s:%s>%ld</%s:%s>", "dmp", str, v, "dmp", str); | ||
1397 | + //ab->AppendString(sql); | ||
1398 | + } | ||
1399 | + break; | ||
1400 | + case PGFieldType::DoubleFieldType: | ||
1401 | + { | ||
1402 | + double v; | ||
1403 | + const char *str1 = pPgsqlConn->getString(i); | ||
1404 | + //int vs=PQgetlength(((PgConn *)rs->conn)->res,0,0); | ||
1405 | + //memcpy(&v,str1,sizeof(v)); | ||
1406 | + ((char *)&v)[7] = str1[0]; | ||
1407 | + ((char *)&v)[6] = str1[1]; | ||
1408 | + ((char *)&v)[5] = str1[2]; | ||
1409 | + ((char *)&v)[4] = str1[3]; | ||
1410 | + ((char *)&v)[3] = str1[4]; | ||
1411 | + ((char *)&v)[2] = str1[5]; | ||
1412 | + ((char *)&v)[1] = str1[6]; | ||
1413 | + ((char *)&v)[0] = str1[7]; | ||
1414 | + //number 有问题。 | ||
1415 | + | ||
1416 | + { | ||
1417 | + char sz1[100]; | ||
1418 | + StringHelp::modp_dtoa2(v, sz1, 5); | ||
1419 | + sprintf(buff, R"(,"%s":"%s")", str, sz1); | ||
1420 | + properties += buff; | ||
1421 | + //sprintf(sql, "<%s:%s>%s</%s:%s>", "dmp", str, sz1, "dmp", str); | ||
1422 | + } | ||
1423 | + //sprintf(sql,"<%s:%s>%lf</%s:%s>","dmp",str,v,"dmp",str); | ||
1424 | + //ab->AppendString(sql); | ||
1425 | + } | ||
1426 | + break; | ||
1427 | + case PGFieldType::TimestampWithoutTimeZone: | ||
1428 | + { | ||
1429 | + std::string s = pPgsqlConn->getString(i); | ||
1430 | + StringHelp::ToJSONString(s); | ||
1431 | + sprintf(buff, R"(,"%s":"%s")", str, s.c_str()); | ||
1432 | + properties += buff; | ||
1433 | + //sprintf(sql, "<%s:%s>%s</%s:%s>", "dmp", str, s.c_str(), "dmp", str); | ||
1434 | + //ab->AppendString(sql); | ||
1435 | + } | ||
1436 | + case PGFieldType::VarCharFieldType: | ||
1437 | + { | ||
1438 | + | ||
1439 | + std::string s = pPgsqlConn->getString(i); | ||
1440 | + StringHelp::ToJSONString(s); | ||
1441 | + sprintf(buff, R"(,"%s":"%s")", str, s.c_str()); | ||
1442 | + properties += buff; | ||
1443 | + //sprintf(sql, "<%s:%s>%s</%s:%s>", "dmp", str, s.c_str(), "dmp", str); | ||
1444 | + ///ab->AppendString(sql); | ||
1445 | + } | ||
1446 | + } | ||
1447 | + } | ||
1448 | + | ||
1449 | + if(geometry != "") | ||
1450 | + { | ||
1451 | + ab->AppendString(R"(,"geometry":)"); | ||
1452 | + ab->AppendString(geometry.c_str()); | ||
1453 | + } | ||
1454 | + | ||
1455 | + if (properties != "") | ||
1456 | + { | ||
1457 | + ab->AppendString(R"(,"properties":)"); | ||
1458 | + properties[0] = '{'; | ||
1459 | + ab->AppendString(properties.c_str()); | ||
1460 | + ab->AppendString("}"); | ||
1461 | + } | ||
1462 | + ab->AppendString("}"); | ||
1463 | + //tickAA=GetTickCount(); | ||
1464 | + | ||
1465 | + //sprintf(sql, "</%s:%s>\r", "dmp", layerName); | ||
1466 | + //ab->AppendString(sql); | ||
1467 | + //ab->AppendString("</gml:featureMember>"); | ||
1468 | + | ||
1469 | + count++; | ||
1470 | + //if(pointCount>25)break; | ||
1471 | + } | ||
1472 | + } | ||
1473 | + catch (...) | ||
1474 | + { | ||
1475 | + return; | ||
1476 | + } | ||
1477 | + | ||
1478 | + ab->AppendString("]}"); | ||
1479 | + | ||
1480 | + return ; | ||
1481 | +} | ||
1482 | + | ||
1483 | + | ||
1484 | + | ||
1231 | } | 1485 | } |
@@ -44,7 +44,7 @@ namespace DmpWms | @@ -44,7 +44,7 @@ namespace DmpWms | ||
44 | 44 | ||
45 | bool GetMapLog(std::stringstream& outputStream, map<string,string>* map_layerDefs = NULL,map<string,string>* map_regionDefs = NULL, shared_ptr<Rect> pRect = nullptr, double r__ = -1, double x_dis__ = 0, double y_dis__ = 0); | 45 | bool GetMapLog(std::stringstream& outputStream, map<string,string>* map_layerDefs = NULL,map<string,string>* map_regionDefs = NULL, shared_ptr<Rect> pRect = nullptr, double r__ = -1, double x_dis__ = 0, double y_dis__ = 0); |
46 | bool GetMap(map<string,string>* map_layerDefs = NULL,map<string,string>* map_regionDefs = NULL, clsCrSurf* pClsSurf = NULL,bool isThumbnail = false, shared_ptr<Rect> pRect = nullptr, double r__ = -1, double x_dis__ = 0, double y_dis__ = 0); | 46 | bool GetMap(map<string,string>* map_layerDefs = NULL,map<string,string>* map_regionDefs = NULL, clsCrSurf* pClsSurf = NULL,bool isThumbnail = false, shared_ptr<Rect> pRect = nullptr, double r__ = -1, double x_dis__ = 0, double y_dis__ = 0); |
47 | - bool GetFeatureInfo(std::stringstream& ab, int gmlVersion, int x, int y, int feature_count); | 47 | + bool GetFeatureInfo(string &responseData, int gmlVersion, int x, int y, int feature_count); |
48 | 48 | ||
49 | bool GetMapLegend( std::stringstream& ab, shared_ptr<legendParamater> pLegendParamater); | 49 | bool GetMapLegend( std::stringstream& ab, shared_ptr<legendParamater> pLegendParamater); |
50 | bool GetMapLegend( shared_ptr<legendParamater> pLegendParamater, clsCrSurf* pClsSurf); | 50 | bool GetMapLegend( shared_ptr<legendParamater> pLegendParamater, clsCrSurf* pClsSurf); |
@@ -143,8 +143,8 @@ namespace DmpWms | @@ -143,8 +143,8 @@ namespace DmpWms | ||
143 | bool CollectRules(const char* sRules); | 143 | bool CollectRules(const char* sRules); |
144 | bool CollectRules2(const char* sRules); | 144 | bool CollectRules2(const char* sRules); |
145 | 145 | ||
146 | - //void FormatWFSJsonCAll(shared_ptr<Workspace> pWorkspace, AppendBuffer *ab, char *layerNAMEc,int gmlVersion,char *srsOut); | ||
147 | - //void FormatWFSXMLCAll(shared_ptr<Workspace> pWorkspace, AppendBuffer *ab, char *layerNAMEc, int gmlVersion,char *srsOut); | 146 | + void FormatWFSJsonCAll(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,int gmlVersion,const char *srid); |
147 | + void FormatWFSXMLCAll(shared_ptr<DmpPgsql> pPgsqlConn,std::string &responseData, const string& layerName, int gmlVersion,const char *srid); | ||
148 | }; | 148 | }; |
149 | } | 149 | } |
150 | 150 |
请
注册
或
登录
后发表评论