正在显示
23 个修改的文件
包含
1028 行增加
和
347 行删除
@@ -49,8 +49,7 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) | @@ -49,8 +49,7 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) | ||
49 | extent_ = DmpXmlUtils::readRectangle(pExtent); | 49 | extent_ = DmpXmlUtils::readRectangle(pExtent); |
50 | dataSource_ = layerNode.get<std::string>("datasource"); | 50 | dataSource_ = layerNode.get<std::string>("datasource"); |
51 | 51 | ||
52 | - setDataProvider("postgres"); | ||
53 | - | 52 | + //setDataProvider("postgres"); |
54 | // boost::property_tree::ptree pResourceMetadata = layerNode.get_child("resourcemetadata"); | 53 | // boost::property_tree::ptree pResourceMetadata = layerNode.get_child("resourcemetadata"); |
55 | // schema_ = layerNode.get<std::string>("schema"); | 54 | // schema_ = layerNode.get<std::string>("schema"); |
56 | // geom_ = layerNode.get<std::string>("geom"); | 55 | // geom_ = layerNode.get<std::string>("geom"); |
@@ -186,12 +185,13 @@ DmpWkbTypes::GeometryType DmpVectorLayer::GeometryType() const | @@ -186,12 +185,13 @@ DmpWkbTypes::GeometryType DmpVectorLayer::GeometryType() const | ||
186 | 185 | ||
187 | bool DmpVectorLayer::setDataProvider(std::string const &provider) | 186 | bool DmpVectorLayer::setDataProvider(std::string const &provider) |
188 | { | 187 | { |
188 | + isinit_ = true; | ||
189 | //临时测试使用 | 189 | //临时测试使用 |
190 | - PGconn* pPGconn = PQconnectdb(dataSource_.c_str()); | ||
191 | - ConnStatusType t = PQstatus(pPGconn); | ||
192 | - if (t != CONNECTION_OK) | 190 | + PGconn* pPGconn = PQconnectdb(provider.c_str()); |
191 | + ConnStatusType t = PQstatus(pPGconn); | ||
192 | + if (t != CONNECTION_OK) | ||
193 | return false; | 193 | return false; |
194 | - int re = PQsetClientEncoding(pPGconn, "UTF-8"); | 194 | + int re = PQsetClientEncoding(pPGconn, "UTF-8"); |
195 | 195 | ||
196 | std::string sql = "select t.f_geometry_column, t.type ,f_table_schema,t.srid from public.geometry_columns t where lower( t.f_table_name) = lower('" + name_ + "');"; | 196 | std::string sql = "select t.f_geometry_column, t.type ,f_table_schema,t.srid from public.geometry_columns t where lower( t.f_table_name) = lower('" + name_ + "');"; |
197 | PGresult* pPGresult= PQexec(pPGconn, sql.c_str()); | 197 | PGresult* pPGresult= PQexec(pPGconn, sql.c_str()); |
@@ -211,7 +211,7 @@ bool DmpVectorLayer::setDataProvider(std::string const &provider) | @@ -211,7 +211,7 @@ bool DmpVectorLayer::setDataProvider(std::string const &provider) | ||
211 | const char* geomtype = PQgetvalue(pPGresult, 0, 1); | 211 | const char* geomtype = PQgetvalue(pPGresult, 0, 1); |
212 | schema_ = PQgetvalue(pPGresult, 0, 2); | 212 | schema_ = PQgetvalue(pPGresult, 0, 2); |
213 | //std::string srid = PQgetvalue(pPGresult, 0, 3); | 213 | //std::string srid = PQgetvalue(pPGresult, 0, 3); |
214 | - | 214 | + wkbTypeString_ = geomtype; |
215 | if (!geomtype) | 215 | if (!geomtype) |
216 | return false; | 216 | return false; |
217 | if (!strcmp(geomtype, "POINT")) wkbType_ = DmpWkbTypes::Point; | 217 | if (!strcmp(geomtype, "POINT")) wkbType_ = DmpWkbTypes::Point; |
@@ -60,7 +60,9 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | @@ -60,7 +60,9 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | ||
60 | std::string schema() { return schema_;} | 60 | std::string schema() { return schema_;} |
61 | std::string geom() { return geom_;} | 61 | std::string geom() { return geom_;} |
62 | std::string wherestr() { return wherestr_;} | 62 | std::string wherestr() { return wherestr_;} |
63 | + std::string GeomTypeString(){return wkbTypeString_;} | ||
63 | size_t featurecount(){return featurecount_;} | 64 | size_t featurecount(){return featurecount_;} |
65 | + bool IsInit(){return isinit_;} | ||
64 | private: | 66 | private: |
65 | bool readExtentFromXml_; | 67 | bool readExtentFromXml_; |
66 | DmpWkbTypes::Type wkbType_ = DmpWkbTypes::Unknown; | 68 | DmpWkbTypes::Type wkbType_ = DmpWkbTypes::Unknown; |
@@ -70,10 +72,14 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | @@ -70,10 +72,14 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | ||
70 | std::string schema_; | 72 | std::string schema_; |
71 | std::string geom_; | 73 | std::string geom_; |
72 | size_t featurecount_; | 74 | size_t featurecount_; |
75 | + std::string wkbTypeString_; | ||
73 | 76 | ||
74 | std::string wherestr_; | 77 | std::string wherestr_; |
78 | + bool isinit_ = false; | ||
75 | shared_ptr<DmapCore_30::Renderer> renderer_30_ = nullptr; | 79 | shared_ptr<DmapCore_30::Renderer> renderer_30_ = nullptr; |
76 | vector<shared_ptr<DmpVectorThinLayer>> thinLayers_; | 80 | vector<shared_ptr<DmpVectorThinLayer>> thinLayers_; |
81 | + | ||
82 | + | ||
77 | 83 | ||
78 | }; | 84 | }; |
79 | #endif //__dmpvectorlayer_h__ | 85 | #endif //__dmpvectorlayer_h__ |
@@ -9,15 +9,18 @@ SET (MAPSERVER_SRCS | @@ -9,15 +9,18 @@ SET (MAPSERVER_SRCS | ||
9 | dmppgsqlpool.cpp | 9 | dmppgsqlpool.cpp |
10 | dmppgsqlsourcepools.cpp | 10 | dmppgsqlsourcepools.cpp |
11 | wfs/dmpwfs.cpp | 11 | wfs/dmpwfs.cpp |
12 | + wfs/dmpwfsfilter.cpp | ||
12 | wfs/dmpgmlfilter.cpp | 13 | wfs/dmpgmlfilter.cpp |
13 | wfs/dmpwfsgetcapabilities.cpp | 14 | wfs/dmpwfsgetcapabilities.cpp |
14 | wfs/dmpwfsgetfeature.cpp | 15 | wfs/dmpwfsgetfeature.cpp |
15 | wfs/dmpwfsparameters.cpp | 16 | wfs/dmpwfsparameters.cpp |
17 | + wfs/dmpsqlfactory.cpp | ||
16 | wms/dmpwmsrenderer.cpp | 18 | wms/dmpwmsrenderer.cpp |
17 | wms/dmpwms.cpp | 19 | wms/dmpwms.cpp |
18 | wms/dmpwmsparameters.cpp | 20 | wms/dmpwmsparameters.cpp |
19 | wms/dmpwmsgetcapabilities.cpp | 21 | wms/dmpwmsgetcapabilities.cpp |
20 | wms/dmpwmsgetmap.cpp | 22 | wms/dmpwmsgetmap.cpp |
23 | + wms/dmpwmsserviceinfo.cpp | ||
21 | wms/dmpwmsgetfeatureinfo.cpp | 24 | wms/dmpwmsgetfeatureinfo.cpp |
22 | mapping/dmpmapping.cpp | 25 | mapping/dmpmapping.cpp |
23 | mapping/dmpeditservice.cpp | 26 | mapping/dmpeditservice.cpp |
@@ -32,15 +35,18 @@ SET (MAPSERVER_HDRS | @@ -32,15 +35,18 @@ SET (MAPSERVER_HDRS | ||
32 | dmppgsqlpool.h | 35 | dmppgsqlpool.h |
33 | dmppgsqlsourcepools.h | 36 | dmppgsqlsourcepools.h |
34 | wfs/dmpwfs.h | 37 | wfs/dmpwfs.h |
38 | + wfs/dmpwfsfilter.h | ||
35 | wfs/dmpgmlfilter.h | 39 | wfs/dmpgmlfilter.h |
36 | wfs/dmpwfsgetcapabilities.h | 40 | wfs/dmpwfsgetcapabilities.h |
37 | wfs/dmpwfsgetfeature.h | 41 | wfs/dmpwfsgetfeature.h |
38 | wfs/dmpwfsparameters.h | 42 | wfs/dmpwfsparameters.h |
43 | + wfs/dmpsqlfactory.h | ||
39 | wms/dmpwmsrenderer.h | 44 | wms/dmpwmsrenderer.h |
40 | wms/dmpwms.h | 45 | wms/dmpwms.h |
41 | wms/dmpwmsparameters.h | 46 | wms/dmpwmsparameters.h |
42 | wms/dmpwmsgetcapabilities.h | 47 | wms/dmpwmsgetcapabilities.h |
43 | wms/dmpwmsgetmap.h | 48 | wms/dmpwmsgetmap.h |
49 | + wms/dmpwmsserviceinfo.h | ||
44 | wms/dmpwmsgetfeatureinfo.h | 50 | wms/dmpwmsgetfeatureinfo.h |
45 | mapping/dmpmapping.h | 51 | mapping/dmpmapping.h |
46 | mapping/dmpeditservice.h | 52 | mapping/dmpeditservice.h |
@@ -12,6 +12,97 @@ | @@ -12,6 +12,97 @@ | ||
12 | namespace mapserver | 12 | namespace mapserver |
13 | { | 13 | { |
14 | 14 | ||
15 | +void DmpMapServerUtil::responseGml(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid) | ||
16 | +{ | ||
17 | + | ||
18 | +// rs->PrepareFieldhead(); //获得了结果集的字段类型 | ||
19 | + int shapeType = -1; | ||
20 | + | ||
21 | + double xg1, yg1, xg2, yg2; | ||
22 | + int havegSet = 0; | ||
23 | + int count = 0; | ||
24 | + int pointCountTemp = 0; | ||
25 | + char buff[5000] = {0}; | ||
26 | + | ||
27 | + responseData.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><wfs:FeatureCollection "); | ||
28 | + responseData.append("xmlns:gims=\"http://www.esri.com/esri\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:ogc=\"http://www.opengis.net/ogc\">"); | ||
29 | + | ||
30 | + | ||
31 | + //bool paff = parseString.affine; | ||
32 | + try | ||
33 | + { | ||
34 | + int fieldsCount = pPgsqlConn->GetFieldCount(); | ||
35 | + for (; pPgsqlConn->next();) | ||
36 | + { | ||
37 | + // css++; | ||
38 | + //if(css!=24)continue; | ||
39 | + //break; | ||
40 | + //string geometry = ""; | ||
41 | + //string properties = ""; | ||
42 | + responseData.append("<gims:featureMember>"); | ||
43 | + sprintf(buff, "<gims:%s fid=\"%s.%d\">", layerName.c_str(), layerName.c_str(), count + 1); | ||
44 | + responseData.append(buff); | ||
45 | + //responseData.append("\r\n"); | ||
46 | + | ||
47 | + //columns[md[ i ].getString(MetaData::ATTR_NAME)] = i; | ||
48 | + for (int i = 0; i < fieldsCount; i++) | ||
49 | + { | ||
50 | + const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | ||
51 | + if (sfieldName == 0) | ||
52 | + { | ||
53 | + break; | ||
54 | + } | ||
55 | + if (strncmp(sfieldName, "RN_RN", 5) == 0) | ||
56 | + continue; | ||
57 | + std::string strFieldName = sfieldName; | ||
58 | + //DmapDll::StringHelp::ToXMLString(strFieldName); | ||
59 | + | ||
60 | + if (strFieldName == "geometry_as_gml") | ||
61 | + { | ||
62 | + const char* value = pPgsqlConn->getString(i); | ||
63 | + if(value) | ||
64 | + responseData.append(value); | ||
65 | + continue; | ||
66 | + } | ||
67 | + else | ||
68 | + { | ||
69 | + const char *v = pPgsqlConn->getString(i); | ||
70 | + sprintf(buff, "<gims:%s>%s</gims:%s>", strFieldName.c_str(), v, strFieldName.c_str()); | ||
71 | + //properties += buff; | ||
72 | + responseData.append(buff); | ||
73 | + } | ||
74 | + | ||
75 | + } | ||
76 | + //tickAA=GetTickCount(); | ||
77 | + | ||
78 | + sprintf(buff, "</gims:%s>\r",layerName.c_str()); | ||
79 | + responseData.append(buff); | ||
80 | + responseData.append("</gims:featureMember>"); | ||
81 | + | ||
82 | + count++; | ||
83 | + //if(pointCount>25)break; | ||
84 | + | ||
85 | + if (pointCountTemp > 2000) | ||
86 | + break; | ||
87 | + //Sleep(5000); | ||
88 | + // break; | ||
89 | + } | ||
90 | + } | ||
91 | + catch (...) | ||
92 | + { | ||
93 | + | ||
94 | + } | ||
95 | + | ||
96 | + //sprintf(buff, "numberMatched=\"%ld\" numberReturned=\"%ld\" ", count, count); | ||
97 | + //responseData.append(insertBuf, sql, strlen(sql)); | ||
98 | + | ||
99 | + | ||
100 | + | ||
101 | + responseData.append("</wfs:FeatureCollection>"); | ||
102 | + | ||
103 | + return; | ||
104 | +} | ||
105 | + | ||
15 | //以GeoJson的形式返回 | 106 | //以GeoJson的形式返回 |
16 | void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const string& srid) | 107 | void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const string& srid) |
17 | { | 108 | { |
@@ -28,10 +119,10 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str | @@ -28,10 +119,10 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str | ||
28 | int fieldsCount = pPgsqlConn->GetFieldCount(); | 119 | int fieldsCount = pPgsqlConn->GetFieldCount(); |
29 | for (int featureIndex = 0; pPgsqlConn->next(); featureIndex++) | 120 | for (int featureIndex = 0; pPgsqlConn->next(); featureIndex++) |
30 | { | 121 | { |
31 | - | ||
32 | if (featureIndex > 0) | 122 | if (featureIndex > 0) |
33 | responseData.append(","); | 123 | responseData.append(","); |
34 | - //ab->AppendString(R"({"type":"Feature")"); | 124 | + |
125 | + responseData.append(R"({"type":"Feature")"); | ||
35 | 126 | ||
36 | string geometry = ""; | 127 | string geometry = ""; |
37 | string properties = ""; | 128 | string properties = ""; |
@@ -43,6 +134,7 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str | @@ -43,6 +134,7 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str | ||
43 | { | 134 | { |
44 | break; | 135 | break; |
45 | } | 136 | } |
137 | + | ||
46 | 138 | ||
47 | if (strncmp(sfieldName, "RN_RN", 5) == 0) | 139 | if (strncmp(sfieldName, "RN_RN", 5) == 0) |
48 | continue; | 140 | continue; |
@@ -20,6 +20,7 @@ namespace mapserver | @@ -20,6 +20,7 @@ namespace mapserver | ||
20 | { | 20 | { |
21 | public: | 21 | public: |
22 | static void responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid); | 22 | static void responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid); |
23 | + static void responseGml(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid); | ||
23 | static void toJsonString(std::string &s); | 24 | static void toJsonString(std::string &s); |
24 | static std::string replace(std::string strsrc, std::string strfind, std::string strrep); | 25 | static std::string replace(std::string strsrc, std::string strfind, std::string strrep); |
25 | 26 |
@@ -9,6 +9,8 @@ | @@ -9,6 +9,8 @@ | ||
9 | 9 | ||
10 | #include "dmppgsqlsourcepools.h" | 10 | #include "dmppgsqlsourcepools.h" |
11 | #include <iostream> | 11 | #include <iostream> |
12 | +#include "dmphttpbase.h" | ||
13 | +#include "dmphttputils.h" | ||
12 | //#include "DES.h" | 14 | //#include "DES.h" |
13 | //#include "StringHelp.h" | 15 | //#include "StringHelp.h" |
14 | 16 | ||
@@ -79,9 +81,9 @@ namespace mapserver | @@ -79,9 +81,9 @@ namespace mapserver | ||
79 | } | 81 | } |
80 | 82 | ||
81 | 83 | ||
82 | - AddDatabasePool("postgis", name, name,name, name); | 84 | + AddDatabasePool(name); |
83 | 85 | ||
84 | - map<string, shared_ptr<DmpPgsqlPool>>::iterator poolIter2 = this->pgsqlPool_.find(name); | 86 | + map<string, shared_ptr<DmpPgsqlPool>>::iterator poolIter2 = this->pgsqlPool_.find(name); |
85 | if (poolIter2 != this->pgsqlPool_.end()) | 87 | if (poolIter2 != this->pgsqlPool_.end()) |
86 | { | 88 | { |
87 | shared_ptr<DmpPgsqlPool> pool = poolIter2->second; | 89 | shared_ptr<DmpPgsqlPool> pool = poolIter2->second; |
@@ -166,6 +168,24 @@ namespace mapserver | @@ -166,6 +168,24 @@ namespace mapserver | ||
166 | return ""; | 168 | return ""; |
167 | } | 169 | } |
168 | 170 | ||
171 | + string DmpPgsqlSourcePools::GetDbsource(const string& serviceid) | ||
172 | + { | ||
173 | + string requestUrl = DmpServerConfig::Instance()->getMetaUrl(); | ||
174 | + if(requestUrl.size() >0 && requestUrl[requestUrl.size() -1] !='/') | ||
175 | + { | ||
176 | + requestUrl += "/"; | ||
177 | + } | ||
178 | + requestUrl.append("API/Database/Detail"); | ||
179 | + | ||
180 | + std::string strContent= DmpHttp::post(requestUrl); | ||
181 | + if(strContent.length()==0) | ||
182 | + { | ||
183 | + return ""; | ||
184 | + } | ||
185 | + return requestUrl; | ||
186 | + } | ||
187 | + | ||
188 | + | ||
169 | bool DmpPgsqlSourcePools::UpdateDatabasePool() | 189 | bool DmpPgsqlSourcePools::UpdateDatabasePool() |
170 | { | 190 | { |
171 | printf("InitDatabasePool\r\n"); | 191 | printf("InitDatabasePool\r\n"); |
@@ -447,6 +467,20 @@ namespace mapserver | @@ -447,6 +467,20 @@ namespace mapserver | ||
447 | return true; | 467 | return true; |
448 | } | 468 | } |
449 | 469 | ||
470 | + bool DmpPgsqlSourcePools::AddDatabasePool(string guid) | ||
471 | + { | ||
472 | + | ||
473 | + shared_ptr<DmpPgsqlPool> newPool(new DmpPgsqlPool()); | ||
474 | + // newPool->guid() = guid; | ||
475 | + // newPool->m_name = databaseName; | ||
476 | + // newPool->m_alias = alias; | ||
477 | + std::string connStr = this->GetDbsource(guid); | ||
478 | + newPool->Connect(connStr.c_str()); | ||
479 | + //newPool->Connect("PostgreSQLConn=hostaddr=172.26.99.173 port=5433 dbname='postgres' user='postgres' password='chinadci'"); | ||
480 | + pgsqlPool_[guid] = newPool; | ||
481 | + return true; | ||
482 | + } | ||
483 | + | ||
450 | bool DmpPgsqlSourcePools::AddDatabasePool(string dataType, | 484 | bool DmpPgsqlSourcePools::AddDatabasePool(string dataType, |
451 | string guid, | 485 | string guid, |
452 | string databaseName, | 486 | string databaseName, |
@@ -14,6 +14,8 @@ | @@ -14,6 +14,8 @@ | ||
14 | #include <map> | 14 | #include <map> |
15 | #include "dmppgsqlpool.h" | 15 | #include "dmppgsqlpool.h" |
16 | #include <mutex> | 16 | #include <mutex> |
17 | +#include "dmpserverconfig.h" | ||
18 | + | ||
17 | #define DMAP_DMDMS_DATABASE "dmdms_database" | 19 | #define DMAP_DMDMS_DATABASE "dmdms_database" |
18 | #define DMAP_SCHEMA "public" | 20 | #define DMAP_SCHEMA "public" |
19 | #define MAXCOUNT 200000 | 21 | #define MAXCOUNT 200000 |
@@ -39,6 +41,9 @@ namespace mapserver | @@ -39,6 +41,9 @@ namespace mapserver | ||
39 | 41 | ||
40 | string GetDbSourceID(string name); | 42 | string GetDbSourceID(string name); |
41 | 43 | ||
44 | + string GetDbsource(const string& serviceid); | ||
45 | + | ||
46 | + | ||
42 | bool InitDatabasePool(); | 47 | bool InitDatabasePool(); |
43 | 48 | ||
44 | bool UpdateDatabasePool(); | 49 | bool UpdateDatabasePool(); |
@@ -48,6 +53,8 @@ namespace mapserver | @@ -48,6 +53,8 @@ namespace mapserver | ||
48 | bool AddDatabasePool(string dataType, string guid, string databaseName, string alias, string connStr); | 53 | bool AddDatabasePool(string dataType, string guid, string databaseName, string alias, string connStr); |
49 | // Update 数据库连接池 | 54 | // Update 数据库连接池 |
50 | bool UpdDatabasePool(string dataType, string guid, string databaseName, string alias, string connStr); | 55 | bool UpdDatabasePool(string dataType, string guid, string databaseName, string alias, string connStr); |
56 | + | ||
57 | + bool AddDatabasePool(string guid); | ||
51 | private: | 58 | private: |
52 | shared_ptr<DmpPgsqlPool> defaultPool_; | 59 | shared_ptr<DmpPgsqlPool> defaultPool_; |
53 | map<string, shared_ptr<DmpPgsqlPool>> pgsqlPool_; | 60 | map<string, shared_ptr<DmpPgsqlPool>> pgsqlPool_; |
@@ -187,7 +187,7 @@ namespace DmpMapping | @@ -187,7 +187,7 @@ namespace DmpMapping | ||
187 | else | 187 | else |
188 | { | 188 | { |
189 | LOGGER_ERROR("not find dir " + imagePath); | 189 | LOGGER_ERROR("not find dir " + imagePath); |
190 | - context.response()->writeJson(R"({"value":[]}")"); | 190 | + context.response()->writeJson(R"({"value":[]})"); |
191 | return ; | 191 | return ; |
192 | } | 192 | } |
193 | 193 | ||
@@ -235,7 +235,7 @@ namespace DmpMapping | @@ -235,7 +235,7 @@ namespace DmpMapping | ||
235 | else | 235 | else |
236 | { | 236 | { |
237 | LOGGER_ERROR("not find dir " + imagePath); | 237 | LOGGER_ERROR("not find dir " + imagePath); |
238 | - context.response()->writeJson(R"({"value":[]}")"); | 238 | + context.response()->writeJson(R"({"value":[]})"); |
239 | return ; | 239 | return ; |
240 | } | 240 | } |
241 | 241 |
@@ -13,7 +13,7 @@ | @@ -13,7 +13,7 @@ | ||
13 | #include <boost/function.hpp> | 13 | #include <boost/function.hpp> |
14 | #include <boost/make_shared.hpp> | 14 | #include <boost/make_shared.hpp> |
15 | #include <boost/algorithm/string/predicate.hpp> | 15 | #include <boost/algorithm/string/predicate.hpp> |
16 | - | 16 | +#include <string> |
17 | namespace DmpWfs | 17 | namespace DmpWfs |
18 | { | 18 | { |
19 | 19 | ||
@@ -32,11 +32,23 @@ namespace DmpWfs | @@ -32,11 +32,23 @@ namespace DmpWfs | ||
32 | std::stringstream stream(filter); | 32 | std::stringstream stream(filter); |
33 | boost::property_tree::ptree ptree; | 33 | boost::property_tree::ptree ptree; |
34 | boost::property_tree::read_xml(stream, ptree); | 34 | boost::property_tree::read_xml(stream, ptree); |
35 | - | ||
36 | boost::property_tree::ptree::iterator ptroot = ptree.begin(); | 35 | boost::property_tree::ptree::iterator ptroot = ptree.begin(); |
36 | + | ||
37 | if( ptroot !=ptree.end() && (boost::iequals(ptroot->first,"fes:Filter")|| boost::iequals(ptroot->first,"Filter") || boost::iequals(ptroot->first,"ogc:Filter"))) | 37 | if( ptroot !=ptree.end() && (boost::iequals(ptroot->first,"fes:Filter")|| boost::iequals(ptroot->first,"Filter") || boost::iequals(ptroot->first,"ogc:Filter"))) |
38 | { | 38 | { |
39 | + bool isFirst = true; | ||
39 | 40 | ||
41 | + for (boost::property_tree::ptree::iterator ptchild = ptroot->second.begin(); ptchild != ptroot->second.end(); ++ptchild) | ||
42 | + { | ||
43 | + if (!isFirst) | ||
44 | + { | ||
45 | + sql_ += " or "; | ||
46 | + } | ||
47 | + int k = _All(ptchild->first, ptchild->second); | ||
48 | + //nc++; | ||
49 | + | ||
50 | + printf("%s\r\n", ptchild->first.c_str()); | ||
51 | + } | ||
40 | } | 52 | } |
41 | 53 | ||
42 | /*if(!(strcmp(p,"fes:Filter")==0||strcmp(p,"Filter")==0 || strcmp(p,"ogc:Filter")==0))return Error(-12,"no filter node"); | 54 | /*if(!(strcmp(p,"fes:Filter")==0||strcmp(p,"Filter")==0 || strcmp(p,"ogc:Filter")==0))return Error(-12,"no filter node"); |
@@ -59,4 +71,251 @@ namespace DmpWfs | @@ -59,4 +71,251 @@ namespace DmpWfs | ||
59 | 71 | ||
60 | return false; | 72 | return false; |
61 | } | 73 | } |
74 | + | ||
75 | + int DmpGmlFilter::Error(int errorcode, const char* err) | ||
76 | + { | ||
77 | + return 0; | ||
78 | + } | ||
79 | + | ||
80 | + std::string DmpGmlFilter::GetFieldName(const std::string& name) | ||
81 | + { | ||
82 | + int len = name.size(); | ||
83 | + char p[100]; | ||
84 | + strcpy(p, name.c_str()); | ||
85 | + for (int i = 0; i < len; i++) | ||
86 | + { | ||
87 | + if (name[i] == ':') | ||
88 | + { | ||
89 | + strcpy(p, &name[i + 1]); | ||
90 | + len = strlen(p); | ||
91 | + break; | ||
92 | + } | ||
93 | + } | ||
94 | + std::string str = p; | ||
95 | + return str; | ||
96 | + } | ||
97 | + | ||
98 | + | ||
99 | + | ||
100 | + int DmpGmlFilter::_All(const std::string &ptname,boost::property_tree::ptree& ptree) | ||
101 | + { | ||
102 | + | ||
103 | + std::string name = GetFieldName(ptname); | ||
104 | + const char *p = name.c_str(); | ||
105 | + | ||
106 | + if (0 == strcmp(p, "PropertyIsNotEqualTo")) | ||
107 | + return _PropertyIsNotEqualTo(ptree); | ||
108 | + return 0; | ||
109 | + /* | ||
110 | + switch (name.length()) | ||
111 | + { | ||
112 | + case 2: | ||
113 | + if (0 == strcmp(p, "Or")) | ||
114 | + return _Or(ptree); | ||
115 | + break; | ||
116 | + case 3: | ||
117 | + if (0 == strcmp(p, "Not")) | ||
118 | + return _Not(ptree); | ||
119 | + if (0 == strcmp(p, "And")) | ||
120 | + return _And(ptree); | ||
121 | + break; | ||
122 | + case 4: | ||
123 | + if (0 == strcmp(p, "BBOX")) | ||
124 | + return _BBOX(ptree); | ||
125 | + break; | ||
126 | + case 6: | ||
127 | + if (0 == strcmp(p, "Equals")) | ||
128 | + return _Equals(ptree); | ||
129 | + if (0 == strcmp(p, "Beyond")) | ||
130 | + return _Beyond(ptree); | ||
131 | + if (0 == strcmp(p, "Within")) | ||
132 | + return _Within(ptree); | ||
133 | + break; | ||
134 | + case 7: | ||
135 | + if (0 == strcmp(p, "Crosses")) | ||
136 | + return _Crosses(ptree); | ||
137 | + if (0 == strcmp(p, "Touches")) | ||
138 | + return _Touches(ptree); | ||
139 | + if (0 == strcmp(p, "DWithin")) | ||
140 | + return _DWithin(ptree); | ||
141 | + break; | ||
142 | + case 8: | ||
143 | + if (0 == strcmp(p, "Contains")) | ||
144 | + return _Contains(ptree); | ||
145 | + if (0 == strcmp(p, "Overlaps")) | ||
146 | + return _Overlaps(ptree); | ||
147 | + if (0 == strcmp(p, "Disjoint")) | ||
148 | + return _Disjoint(ptree); | ||
149 | + break; | ||
150 | + case 9: | ||
151 | + if (0 == strcmp(p, "FeatureId")) | ||
152 | + return _FeatureId(ptree); | ||
153 | + break; | ||
154 | + case 10: | ||
155 | + if (0 == strcmp(p, "Intersects")) | ||
156 | + return _Intersects(ptree); | ||
157 | + if (0 == strcmp(p, "ResourceId")) | ||
158 | + return _FeatureId(ptree); | ||
159 | + break; | ||
160 | + case 11: | ||
161 | + if (0 == strcmp(p, "GmlObjectId")) | ||
162 | + return _GmlObjectId(ptree); | ||
163 | + if (0 == strcmp(p, "DIntersects")) | ||
164 | + return _DIntersects(ptree); | ||
165 | + break; | ||
166 | + case 14: | ||
167 | + if (0 == strcmp(p, "PropertyIsLike")) | ||
168 | + return _PropertyIsLike(ptree); | ||
169 | + if (0 == strcmp(p, "PropertyIsNull")) | ||
170 | + return _PropertyIsNull(ptree); | ||
171 | + if (0 == strcmp(p, "fes:ResourceId") || 0 == strcmp(p, "ogc:ResourceId")) | ||
172 | + return _FeatureId(ptree); | ||
173 | + break; | ||
174 | + case 17: | ||
175 | + if (0 == strcmp(p, "PropertyIsBetween")) | ||
176 | + return _PropertyIsBetween(ptree); | ||
177 | + if (0 == strcmp(p, "PropertyIsEqualTo")) | ||
178 | + return _PropertyIsEqualTo(ptree); | ||
179 | + break; | ||
180 | + case 18: | ||
181 | + if (0 == strcmp(p, "PropertyIsLessThan")) | ||
182 | + return _PropertyIsLessThan(ptree); | ||
183 | + break; | ||
184 | + case 20: | ||
185 | + if (0 == strcmp(p, "PropertyIsNotEqualTo")) | ||
186 | + return _PropertyIsNotEqualTo(ptree); | ||
187 | + break; | ||
188 | + case 21: | ||
189 | + if (0 == strcmp(p, "PropertyIsGreaterThan")) | ||
190 | + return _PropertyIsGreaterThan(ptree); | ||
191 | + break; | ||
192 | + case 27: | ||
193 | + if (0 == strcmp(p, "PropertyIsLessThanOrEqualTo")) | ||
194 | + return _PropertyIsLessThanOrEqualTo(ptree); | ||
195 | + break; | ||
196 | + case 30: | ||
197 | + if (0 == strcmp(p, "PropertyIsGreaterThanOrEqualTo")) | ||
198 | + return _PropertyIsGreaterThanOrEqualTo(ptree); | ||
199 | + break; | ||
200 | + default: | ||
201 | + break; | ||
202 | + } | ||
203 | + sql_ += "1=1"; | ||
204 | + error_ = "Filter type error: "; | ||
205 | + error_ += p; | ||
206 | + return -17;*/ | ||
207 | + } | ||
208 | + | ||
209 | + int DmpGmlFilter::_PropertyIsNotEqualTo(boost::property_tree::ptree& ptree) | ||
210 | + { | ||
211 | + return _PropertyOneEqual(ptree, "<>"); | ||
212 | + } | ||
213 | + | ||
214 | + int DmpGmlFilter::_PropertyOneEqual(boost::property_tree::ptree &ptree,const char *type, int isLike) | ||
215 | + { | ||
216 | + int nc = 0, isExpression; | ||
217 | + for (auto ptchild = ptree.begin(); ptchild != ptree.end(); ++ptchild) | ||
218 | + { | ||
219 | + if(ptchild->first == "<xmlattr>") | ||
220 | + continue; | ||
221 | + int r = _PropertyParse(ptchild->first, ptchild->second, isExpression, isLike); //这里IsLike设定的值是1 | ||
222 | + if (r) return r; | ||
223 | + | ||
224 | + if (isExpression) | ||
225 | + { | ||
226 | + if (nc == 0) | ||
227 | + { | ||
228 | + sql_ += type; | ||
229 | + } | ||
230 | + nc++; | ||
231 | + if (nc == 2) | ||
232 | + return 0; | ||
233 | + } | ||
234 | + } | ||
235 | + if (nc < 2) | ||
236 | + return Error(-19, "no enough expression"); | ||
237 | + return 0; | ||
238 | + } | ||
239 | + /* | ||
240 | + //<fes:Filter | ||
241 | + //xmlns:fes="http://www.opengis.net/fes/2.0" | ||
242 | + //xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
243 | + //xsi:schemaLocation="http://www.opengis.net/fes/2.0 | ||
244 | + //http://schemas.opengis.net/filter/2.0.0/filterAll.xsd"> | ||
245 | + //<fes:PropertyIsLike wildCard="*" singleChar="#" escapeChar="!"> | ||
246 | + //<fes:ValueReference>LAST_NAME</fes:ValueReference> | ||
247 | + //<fes:Literal>JOHN*</fes:Literal> | ||
248 | + //</fes:PropertyIsLike> | ||
249 | + //</fes:Filter> | ||
250 | + */ | ||
251 | + | ||
252 | + int DmpGmlFilter::_PropertyParse(const std::string& ptreeName, boost::property_tree::ptree& ptree, int &isExpression, int isLike) | ||
253 | + { | ||
254 | + | ||
255 | + isExpression = 0; | ||
256 | + string name = this->GetFieldName(ptreeName); | ||
257 | + const char *p = name.c_str(); | ||
258 | + std::string value = ptree.get_value<std::string>(); | ||
259 | + if (p == 0 || p[0] == 0) | ||
260 | + { | ||
261 | + sql_ += "('"; | ||
262 | + sql_ += value; | ||
263 | + sql_ += "')"; | ||
264 | + return 0; | ||
265 | + } | ||
266 | + if (0 == strcmp(p, "Literal")) | ||
267 | + { | ||
268 | + isExpression = 1; | ||
269 | + if (isLike) | ||
270 | + { | ||
271 | + sql_ += "('%"; | ||
272 | + sql_ += value; | ||
273 | + sql_ += "%')"; | ||
274 | + } | ||
275 | + else | ||
276 | + { | ||
277 | + sql_ += "('"; | ||
278 | + sql_ += value; | ||
279 | + sql_ += "')"; | ||
280 | + } | ||
281 | + return 0; | ||
282 | + } | ||
283 | + /* if (0 == strcmp(p, "PropertyName") || 0 == strcmp(p, "ValueReference")) | ||
284 | + { | ||
285 | + isExpression = 1; | ||
286 | + //std::string s=n->value(); | ||
287 | + //s=this->td->GetFieldQuery(s); | ||
288 | + _AppendProperty(sql, n->value()); //添加了一个字段? | ||
289 | + | ||
290 | + sql = sql + "::varchar"; | ||
291 | + //sql+=n->value(); | ||
292 | + return 0; | ||
293 | + } | ||
294 | + if (0 == strcmp(p, "Add")) | ||
295 | + { | ||
296 | + isExpression = 1; | ||
297 | + return _PropertyParse4(ptree, "+"); | ||
298 | + } | ||
299 | + if (0 == strcmp(p, "Sub")) | ||
300 | + { | ||
301 | + isExpression = 1; | ||
302 | + return _PropertyParse4(ptree, "-"); | ||
303 | + } | ||
304 | + if (0 == strcmp(p, "Mul")) | ||
305 | + { | ||
306 | + isExpression = 1; | ||
307 | + return _PropertyParse4(ptree, "*"); | ||
308 | + } | ||
309 | + if (0 == strcmp(p, "Div")) | ||
310 | + { | ||
311 | + isExpression = 1; | ||
312 | + return _PropertyParse4(ptree, "/"); | ||
313 | + } | ||
314 | + if (0 == strcmp(p, "Function")) | ||
315 | + { | ||
316 | + isExpression = 1; | ||
317 | + return _PropertyParseFunction(ptree); | ||
318 | + }*/ | ||
319 | + return 0; | ||
320 | + } | ||
62 | } | 321 | } |
@@ -30,6 +30,15 @@ namespace DmpWfs | @@ -30,6 +30,15 @@ namespace DmpWfs | ||
30 | ~DmpGmlFilter(); | 30 | ~DmpGmlFilter(); |
31 | 31 | ||
32 | bool Parse(const std::string &filter); | 32 | bool Parse(const std::string &filter); |
33 | + private: | ||
34 | + int Error(int errorcode, const char* err); | ||
35 | + std::string GetFieldName(const std::string& name); | ||
36 | + int _All(const std::string &name, boost::property_tree::ptree &ptree); | ||
37 | + | ||
38 | + int _PropertyIsNotEqualTo(boost::property_tree::ptree &ptree); | ||
39 | + | ||
40 | + int _PropertyParse(const std::string& ptreeName, boost::property_tree::ptree &ptreeode, int &isExpression, int isLike = 0); | ||
41 | + int _PropertyOneEqual(boost::property_tree::ptree &ptree, const char *type, int isLike = 0); | ||
33 | 42 | ||
34 | private: | 43 | private: |
35 | std::string sql_; | 44 | std::string sql_; |
@@ -35,24 +35,13 @@ namespace DmpWfs | @@ -35,24 +35,13 @@ namespace DmpWfs | ||
35 | this->resultType_ = resultType; | 35 | this->resultType_ = resultType; |
36 | } | 36 | } |
37 | 37 | ||
38 | - void DmpSqlFactory::appendCondition(char *c) | ||
39 | - { | ||
40 | - if (condition_.size() == 0) | ||
41 | - { | ||
42 | - condition_ = c; | ||
43 | - } | ||
44 | - else | ||
45 | - { | ||
46 | - condition_ += " and "; | ||
47 | - condition += c; | ||
48 | - } | ||
49 | - } | ||
50 | 38 | ||
51 | - void DmpSqlFactory::appendCondition(std::string &c) | 39 | + |
40 | + void DmpSqlFactory::appendCondition(const std::string &c) | ||
52 | { | 41 | { |
53 | if (condition_.size() == 0) | 42 | if (condition_.size() == 0) |
54 | { | 43 | { |
55 | - condition = c; | 44 | + condition_ = c; |
56 | } | 45 | } |
57 | else | 46 | else |
58 | { | 47 | { |
@@ -100,7 +89,7 @@ namespace DmpWfs | @@ -100,7 +89,7 @@ namespace DmpWfs | ||
100 | if (count_ > 0 || startIndex_ > 0) | 89 | if (count_ > 0 || startIndex_ > 0) |
101 | { | 90 | { |
102 | char sz[100]; | 91 | char sz[100]; |
103 | - sprintf(sz, " limit %ld offset %ld", count_, startIndex_); | 92 | + sprintf(sz, " limit %d offset %d", count_, startIndex_); |
104 | sql += sz; | 93 | sql += sz; |
105 | } | 94 | } |
106 | return sql; | 95 | return sql; |
@@ -21,7 +21,6 @@ namespace DmpWfs | @@ -21,7 +21,6 @@ namespace DmpWfs | ||
21 | 21 | ||
22 | void setStartIndexCount(int startIndex, int count, const std::string &resultType); | 22 | void setStartIndexCount(int startIndex, int count, const std::string &resultType); |
23 | void appendCondition(const std::string &c); | 23 | void appendCondition(const std::string &c); |
24 | - void appendCondition(char *c); | ||
25 | void setProp(const std::string& prop) { prop_ = prop; } | 24 | void setProp(const std::string& prop) { prop_ = prop; } |
26 | void setTable(const std::string& table){ table_ = table; } | 25 | void setTable(const std::string& table){ table_ = table; } |
27 | void setOrder(const std::string& order){ order_ = order; } | 26 | void setOrder(const std::string& order){ order_ = order; } |
@@ -8,11 +8,10 @@ | @@ -8,11 +8,10 @@ | ||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | #include "dmpwfsfilter.h" | 10 | #include "dmpwfsfilter.h" |
11 | - | 11 | +#include <boost/algorithm/string/predicate.hpp> |
12 | 12 | ||
13 | namespace DmpWfs | 13 | namespace DmpWfs |
14 | { | 14 | { |
15 | - | ||
16 | DmpWfsFilter::DmpWfsFilter(/* args */) | 15 | DmpWfsFilter::DmpWfsFilter(/* args */) |
17 | { | 16 | { |
18 | } | 17 | } |
@@ -23,7 +22,31 @@ namespace DmpWfs | @@ -23,7 +22,31 @@ namespace DmpWfs | ||
23 | 22 | ||
24 | bool DmpWfsFilter::Parse(const std::string& filter) | 23 | bool DmpWfsFilter::Parse(const std::string& filter) |
25 | { | 24 | { |
25 | + try | ||
26 | + { | ||
27 | + std::stringstream stream(filter); | ||
28 | + boost::property_tree::ptree ptree; | ||
29 | + boost::property_tree::read_xml(stream, ptree); | ||
30 | + boost::property_tree::ptree::iterator ptroot = ptree.begin(); | ||
26 | 31 | ||
32 | + if( ptroot !=ptree.end() && (boost::iequals(ptroot->first,"fes:Filter")|| boost::iequals(ptroot->first,"Filter") || boost::iequals(ptroot->first,"ogc:Filter"))) | ||
33 | + { | ||
34 | + bool isFirst = true; | ||
35 | + | ||
36 | + for (boost::property_tree::ptree::iterator ptchild = ptroot->second.begin(); ptchild != ptroot->second.end(); ++ptchild) | ||
37 | + { | ||
38 | + if (!isFirst) | ||
39 | + { | ||
40 | + sql_ += " or "; | ||
41 | + } | ||
42 | + int k = _All(ptchild->first, ptchild->second); | ||
43 | + } | ||
44 | + } | ||
45 | + } | ||
46 | + catch (const std::exception &e) | ||
47 | + { | ||
48 | + | ||
49 | + } | ||
27 | return false; | 50 | return false; |
28 | } | 51 | } |
29 | 52 | ||
@@ -360,7 +383,8 @@ namespace DmpWfs | @@ -360,7 +383,8 @@ namespace DmpWfs | ||
360 | int isExpression; | 383 | int isExpression; |
361 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) | 384 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) |
362 | { | 385 | { |
363 | - int r = _PropertyParse(node, isExpression); | 386 | + if(ptchild->first == "<xmlattr>")continue; |
387 | + int r = _PropertyParse(ptchild->first,ptchild->second, isExpression); | ||
364 | if (r) | 388 | if (r) |
365 | return r; | 389 | return r; |
366 | if (isExpression) | 390 | if (isExpression) |
@@ -378,7 +402,8 @@ namespace DmpWfs | @@ -378,7 +402,8 @@ namespace DmpWfs | ||
378 | //sql+="("; | 402 | //sql+="("; |
379 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) | 403 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) |
380 | { | 404 | { |
381 | - int r = _PropertyParse(node, isExpression); | 405 | + if(ptchild->first == "<xmlattr>")continue; |
406 | + int r = _PropertyParse(ptchild->first, ptchild->second, isExpression); | ||
382 | if (r) | 407 | if (r) |
383 | return r; | 408 | return r; |
384 | if (isExpression) | 409 | if (isExpression) |
@@ -391,7 +416,7 @@ namespace DmpWfs | @@ -391,7 +416,7 @@ namespace DmpWfs | ||
391 | return Error(-23, "no Property node"); | 416 | return Error(-23, "no Property node"); |
392 | 417 | ||
393 | sql_ += " between "; | 418 | sql_ += " between "; |
394 | - { | 419 | + /* { |
395 | xml_node<char> *node = n->first_node("LowerBoundary"); | 420 | xml_node<char> *node = n->first_node("LowerBoundary"); |
396 | if (node == 0 || node->first_node() == 0) | 421 | if (node == 0 || node->first_node() == 0) |
397 | return Error(-22, "no LowerBoundary node"); | 422 | return Error(-22, "no LowerBoundary node"); |
@@ -403,16 +428,17 @@ namespace DmpWfs | @@ -403,16 +428,17 @@ namespace DmpWfs | ||
403 | if (node == 0 || node->first_node() == 0) | 428 | if (node == 0 || node->first_node() == 0) |
404 | return Error(-24, "no UpperBoundary node"); | 429 | return Error(-24, "no UpperBoundary node"); |
405 | int isExpression; | 430 | int isExpression; |
406 | - _PropertyParse(node->first_node(), isExpression); | ||
407 | - } | 431 | + _PropertyParse(ptchild->first, ptchild->second, isExpression); |
432 | + }qingxiongf*/ | ||
408 | //sql+=")"; | 433 | //sql+=")"; |
409 | return 0; | 434 | return 0; |
410 | } | 435 | } |
411 | - int DmpWfsFilter::_PropertyOneEqual(boost::property_tree::ptree& ptree, char *type, int isLike) | 436 | + int DmpWfsFilter::_PropertyOneEqual(boost::property_tree::ptree& ptree,const char *type, int isLike) |
412 | { | 437 | { |
413 | int nc = 0, isExpression; | 438 | int nc = 0, isExpression; |
414 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) | 439 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) |
415 | { | 440 | { |
441 | + if(ptchild->first == "<xmlattr>")continue; | ||
416 | int r = _PropertyParse(ptchild->first,ptchild->second, isExpression, isLike); //这里IsLike设定的值是1 | 442 | int r = _PropertyParse(ptchild->first,ptchild->second, isExpression, isLike); //这里IsLike设定的值是1 |
417 | if (r) | 443 | if (r) |
418 | return r; | 444 | return r; |
@@ -435,12 +461,13 @@ namespace DmpWfs | @@ -435,12 +461,13 @@ namespace DmpWfs | ||
435 | { | 461 | { |
436 | return _PropertyOneEqual(ptree, "="); | 462 | return _PropertyOneEqual(ptree, "="); |
437 | } | 463 | } |
438 | - int DmpWfsFilter::_PropertyParse4(boost::property_tree::ptree& ptree, char *f) | 464 | + int DmpWfsFilter::_PropertyParse4(boost::property_tree::ptree& ptree,const char *f) |
439 | { | 465 | { |
440 | int nc = 0, isExpression; | 466 | int nc = 0, isExpression; |
441 | sql_ += "("; | 467 | sql_ += "("; |
442 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) | 468 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) |
443 | { | 469 | { |
470 | + if(ptchild->first == "<xmlattr>")continue; | ||
444 | int r = _PropertyParse(ptchild->first, ptchild->second, isExpression); | 471 | int r = _PropertyParse(ptchild->first, ptchild->second, isExpression); |
445 | if (r) | 472 | if (r) |
446 | return r; | 473 | return r; |
@@ -466,13 +493,14 @@ namespace DmpWfs | @@ -466,13 +493,14 @@ namespace DmpWfs | ||
466 | int DmpWfsFilter::_PropertyParseFunction(boost::property_tree::ptree& ptree) | 493 | int DmpWfsFilter::_PropertyParseFunction(boost::property_tree::ptree& ptree) |
467 | { | 494 | { |
468 | { | 495 | { |
469 | - xml_attribute<char> *nameNode = n->first_attribute("name"); | ||
470 | - if (nameNode == 0) | ||
471 | - return Error(-20, "no function name node"); | ||
472 | - char *a = nameNode->value(); | ||
473 | - if (a == 0) | 496 | + std::string pattr_name = ptree.get<std::string>("<xmlattr>.name"); |
497 | + // xml_attribute<char> *nameNode = n->first_attribute("name"); | ||
498 | + //if (pattr == ptree.end()) | ||
499 | + // return Error(-20, "no function name node"); | ||
500 | + // char *a = nameNode->value(); | ||
501 | + if (pattr_name == "") | ||
474 | return Error(-21, "no function name"); | 502 | return Error(-21, "no function name"); |
475 | - sql_ += a; | 503 | + sql_ += pattr_name; |
476 | } | 504 | } |
477 | 505 | ||
478 | int isExpression; | 506 | int isExpression; |
@@ -488,7 +516,7 @@ namespace DmpWfs | @@ -488,7 +516,7 @@ namespace DmpWfs | ||
488 | } | 516 | } |
489 | } | 517 | } |
490 | 518 | ||
491 | - sql[sql.size() - 1] = ')'; | 519 | + sql_[sql_.size() - 1] = ')'; |
492 | //sql+=")"; | 520 | //sql+=")"; |
493 | return 0; | 521 | return 0; |
494 | } | 522 | } |
@@ -513,14 +541,14 @@ namespace DmpWfs | @@ -513,14 +541,14 @@ namespace DmpWfs | ||
513 | //我感觉这里应该有一个通配符的转换 | 541 | //我感觉这里应该有一个通配符的转换 |
514 | int DmpWfsFilter::_PropertyParse(const std::string& ptreeName, boost::property_tree::ptree& ptree, int &isExpression, int isLike) | 542 | int DmpWfsFilter::_PropertyParse(const std::string& ptreeName, boost::property_tree::ptree& ptree, int &isExpression, int isLike) |
515 | { | 543 | { |
516 | - | ||
517 | isExpression = 0; | 544 | isExpression = 0; |
518 | string name = this->GetFieldName(ptreeName); | 545 | string name = this->GetFieldName(ptreeName); |
519 | const char *p = name.c_str(); | 546 | const char *p = name.c_str(); |
547 | + std::string value = ptree.get_value<std::string>(); | ||
520 | if (p == 0 || p[0] == 0) | 548 | if (p == 0 || p[0] == 0) |
521 | { | 549 | { |
522 | sql_ += "('"; | 550 | sql_ += "('"; |
523 | - sql_ += n->value(); | 551 | + sql_ += value; |
524 | sql_ += "')"; | 552 | sql_ += "')"; |
525 | return 0; | 553 | return 0; |
526 | } | 554 | } |
@@ -530,13 +558,13 @@ namespace DmpWfs | @@ -530,13 +558,13 @@ namespace DmpWfs | ||
530 | if (isLike) | 558 | if (isLike) |
531 | { | 559 | { |
532 | sql_ += "('%"; | 560 | sql_ += "('%"; |
533 | - sql_ += n->value(); | 561 | + sql_ += value; |
534 | sql_ += "%')"; | 562 | sql_ += "%')"; |
535 | } | 563 | } |
536 | else | 564 | else |
537 | { | 565 | { |
538 | sql_ += "('"; | 566 | sql_ += "('"; |
539 | - sql_ += n->value(); | 567 | + sql_ += value; |
540 | sql_ += "')"; | 568 | sql_ += "')"; |
541 | } | 569 | } |
542 | return 0; | 570 | return 0; |
@@ -546,9 +574,9 @@ namespace DmpWfs | @@ -546,9 +574,9 @@ namespace DmpWfs | ||
546 | isExpression = 1; | 574 | isExpression = 1; |
547 | //std::string s=n->value(); | 575 | //std::string s=n->value(); |
548 | //s=this->td->GetFieldQuery(s); | 576 | //s=this->td->GetFieldQuery(s); |
549 | - _AppendProperty(sql, n->value()); //添加了一个字段? | 577 | + _AppendProperty(sql_,value.c_str()); //添加了一个字段? |
550 | 578 | ||
551 | - sql = sql + "::varchar"; | 579 | + sql_ = sql_ + "::varchar"; |
552 | //sql+=n->value(); | 580 | //sql+=n->value(); |
553 | return 0; | 581 | return 0; |
554 | } | 582 | } |
@@ -602,8 +630,9 @@ namespace DmpWfs | @@ -602,8 +630,9 @@ namespace DmpWfs | ||
602 | 630 | ||
603 | void DmpWfsFilter::pParsesrsName(boost::property_tree::ptree& ptree) | 631 | void DmpWfsFilter::pParsesrsName(boost::property_tree::ptree& ptree) |
604 | { | 632 | { |
605 | - xml_attribute<char> *sr = n->first_attribute("srsName"); | ||
606 | - if (sr) | 633 | + // xml_attribute<char> *sr = n->first_attribute("srsName"); |
634 | + /*std::string atrr = ptree.get<std::string>("srsName"); | ||
635 | + if (!atrr.empty()) | ||
607 | { | 636 | { |
608 | char *s = _strdup(sr->value()); | 637 | char *s = _strdup(sr->value()); |
609 | clsMalloc m(s); | 638 | clsMalloc m(s); |
@@ -622,11 +651,12 @@ namespace DmpWfs | @@ -622,11 +651,12 @@ namespace DmpWfs | ||
622 | //parse epsg:5432 | 651 | //parse epsg:5432 |
623 | sa = ss[n - 1]; | 652 | sa = ss[n - 1]; |
624 | strcpy_s((char *)srs.c_str(), sa); | 653 | strcpy_s((char *)srs.c_str(), sa); |
625 | - } | 654 | + } qingxiongf*/ |
655 | + | ||
626 | } | 656 | } |
627 | int DmpWfsFilter::pEnvelope(boost::property_tree::ptree& ptree, double *x1, double *y1, double *x2, double *y2) | 657 | int DmpWfsFilter::pEnvelope(boost::property_tree::ptree& ptree, double *x1, double *y1, double *x2, double *y2) |
628 | { | 658 | { |
629 | - xml_node<char> *node = n->first_node("lowerCorner"); //,"ogc:PropertyName"); | 659 | + /* xml_node<char> *node = n->first_node("lowerCorner"); //,"ogc:PropertyName"); |
630 | if (node) | 660 | if (node) |
631 | { | 661 | { |
632 | xml_node<char> *node1 = n->first_node("upperCorner"); //,"ogc:PropertyName"); | 662 | xml_node<char> *node1 = n->first_node("upperCorner"); //,"ogc:PropertyName"); |
@@ -652,8 +682,7 @@ namespace DmpWfs | @@ -652,8 +682,7 @@ namespace DmpWfs | ||
652 | *y2 = v[3]; | 682 | *y2 = v[3]; |
653 | return 0; | 683 | return 0; |
654 | } | 684 | } |
655 | - //==0)return -1; | ||
656 | - //char *v=node->value(); | 685 | + qingxiongf*/ |
657 | 686 | ||
658 | return Error(-4214, "envope parse error"); | 687 | return Error(-4214, "envope parse error"); |
659 | } | 688 | } |
@@ -792,7 +821,7 @@ namespace DmpWfs | @@ -792,7 +821,7 @@ namespace DmpWfs | ||
792 | 821 | ||
793 | int DmpWfsFilter::pGeometryPointValuePosList(boost::property_tree::ptree& ptree, std::vector<double> &v) | 822 | int DmpWfsFilter::pGeometryPointValuePosList(boost::property_tree::ptree& ptree, std::vector<double> &v) |
794 | { | 823 | { |
795 | - int dim = 2; | 824 | + /* int dim = 2; |
796 | xml_attribute<char> *pn = n->first_attribute("dimension"); | 825 | xml_attribute<char> *pn = n->first_attribute("dimension"); |
797 | if (pn) | 826 | if (pn) |
798 | { | 827 | { |
@@ -844,13 +873,13 @@ namespace DmpWfs | @@ -844,13 +873,13 @@ namespace DmpWfs | ||
844 | p = poslist + 1; | 873 | p = poslist + 1; |
845 | digit = false; | 874 | digit = false; |
846 | } | 875 | } |
847 | - } | 876 | + }qingxiongf*/ |
848 | return 0; | 877 | return 0; |
849 | } | 878 | } |
850 | 879 | ||
851 | int DmpWfsFilter::pGeometryGetDis(boost::property_tree::ptree& ptree, double &dis) | 880 | int DmpWfsFilter::pGeometryGetDis(boost::property_tree::ptree& ptree, double &dis) |
852 | { | 881 | { |
853 | - //<Distance unit=\"a#meters\">10</Distance> \ | 882 | + /* |
854 | 883 | ||
855 | double ratio = 1; | 884 | double ratio = 1; |
856 | { | 885 | { |
@@ -885,21 +914,14 @@ namespace DmpWfs | @@ -885,21 +914,14 @@ namespace DmpWfs | ||
885 | 914 | ||
886 | dis = f; | 915 | dis = f; |
887 | // rapidxml::xml_node<char> * t=n->first_node("X"); | 916 | // rapidxml::xml_node<char> * t=n->first_node("X"); |
888 | - | 917 | +qingxiongf*/ |
889 | return 0; | 918 | return 0; |
890 | } | 919 | } |
891 | 920 | ||
892 | - /* void DmpWfsFilter::GetQueryField(const char *field) | 921 | + void DmpWfsFilter::GetQueryField(std::string &field) |
893 | { | 922 | { |
894 | - if (td) | ||
895 | - { | ||
896 | - fieldTemp = td->GetFieldQuery(field); | ||
897 | - } | ||
898 | - else | ||
899 | - { | ||
900 | - fieldTemp = field; | ||
901 | - } | ||
902 | - }*/ | 923 | + return ; |
924 | + } | ||
903 | 925 | ||
904 | int DmpWfsFilter::Error(int code, const char *err) | 926 | int DmpWfsFilter::Error(int code, const char *err) |
905 | { | 927 | { |
@@ -908,28 +930,30 @@ namespace DmpWfs | @@ -908,28 +930,30 @@ namespace DmpWfs | ||
908 | return code; | 930 | return code; |
909 | } | 931 | } |
910 | 932 | ||
911 | - int DmpWfsFilter::pGeometrySql(char *function, char *oracle_mask, int isDisjoin, xml_node<char> *n, bool useBuffer) | 933 | + int DmpWfsFilter::pGeometrySql(const char *function,const char *oracle_mask, int isDisjoin, boost::property_tree::ptree &ptree, bool useBuffer) |
912 | { | 934 | { |
913 | { | 935 | { |
914 | - xml_node<char> *nodeP = n->first_node2("PropertyName", "ValueReference"); //,"ogc:PropertyName"); | ||
915 | - if (nodeP == 0 || nodeP->value()[0] == 0) | ||
916 | - return Error(-15, "no PropertyName node"); | ||
917 | - GetQueryField(nodeP->value()); | 936 | + std::string value = ptree.get<std::string>("PropertyName.ValueReference"); |
937 | + // xml_node<char> *nodeP = n->first_node2("PropertyName", "ValueReference"); //,"ogc:PropertyName"); | ||
938 | + //if (nodeP == 0 || nodeP->value()[0] == 0) | ||
939 | + // return Error(-15, "no PropertyName node"); | ||
940 | + GetQueryField(value); | ||
918 | } | 941 | } |
919 | double dis; | 942 | double dis; |
920 | if (useBuffer) | 943 | if (useBuffer) |
921 | { | 944 | { |
922 | - xml_node<char> *nodeD = n->first_node("Distance"); //,"ogc:PropertyName"); | ||
923 | - if (nodeD == 0) | ||
924 | - return Error(-15, "no Distance node"); | ||
925 | - int rt = pGeometryGetDis(nodeD, dis); | 945 | + boost::property_tree::ptree pDistance = ptree.get_child("Distance"); |
946 | + // xml_node<char> *nodeD = n->first_node("Distance"); //,"ogc:PropertyName"); | ||
947 | + // if (nodeD == 0) | ||
948 | + // return Error(-15, "no Distance node"); | ||
949 | + int rt = pGeometryGetDis(pDistance, dis); | ||
926 | if (rt) | 950 | if (rt) |
927 | return Error(-15, "no Distance node"); | 951 | return Error(-15, "no Distance node"); |
928 | } | 952 | } |
929 | 953 | ||
930 | std::string strOut; | 954 | std::string strOut; |
931 | double x1, y1, x2, y2; | 955 | double x1, y1, x2, y2; |
932 | - int ee = GetGeomFromGml(n, strOut, x1, y1, x2, y2); | 956 | + int ee = GetGeomFromGml(ptree, strOut, x1, y1, x2, y2); |
933 | if (ee) | 957 | if (ee) |
934 | return Error(ee, "gml parse error"); | 958 | return Error(ee, "gml parse error"); |
935 | if (useBuffer) | 959 | if (useBuffer) |
@@ -952,7 +976,7 @@ namespace DmpWfs | @@ -952,7 +976,7 @@ namespace DmpWfs | ||
952 | } | 976 | } |
953 | else | 977 | else |
954 | { | 978 | { |
955 | - if (_stricmp(function, "st_intersection") == 0) | 979 | + if (strcmp(function, "st_intersection") == 0) |
956 | { | 980 | { |
957 | function = "st_intersects"; | 981 | function = "st_intersects"; |
958 | } | 982 | } |
@@ -971,7 +995,7 @@ namespace DmpWfs | @@ -971,7 +995,7 @@ namespace DmpWfs | ||
971 | sql_ += "("; | 995 | sql_ += "("; |
972 | { | 996 | { |
973 | std::string nameOut; | 997 | std::string nameOut; |
974 | - ConnClassAll::GetSRIDName(fieldTemp, nameOut, (char *)srs.c_str(), this->DatabaseType); | 998 | + // ConnClassAll::GetSRIDName(fieldTemp, nameOut, (char *)srs.c_str(), this->DatabaseType); |
975 | sql_ += nameOut; | 999 | sql_ += nameOut; |
976 | } | 1000 | } |
977 | sql_ += ","; | 1001 | sql_ += ","; |
@@ -980,6 +1004,8 @@ namespace DmpWfs | @@ -980,6 +1004,8 @@ namespace DmpWfs | ||
980 | 1004 | ||
981 | return 0; | 1005 | return 0; |
982 | } | 1006 | } |
1007 | + | ||
1008 | + /* | ||
983 | int DmpWfsFilter::pGeometryPointValueCoord(boost::property_tree::ptree& ptree, std::vector<double> &v) | 1009 | int DmpWfsFilter::pGeometryPointValueCoord(boost::property_tree::ptree& ptree, std::vector<double> &v) |
984 | { | 1010 | { |
985 | double x, y; | 1011 | double x, y; |
@@ -995,6 +1021,8 @@ namespace DmpWfs | @@ -995,6 +1021,8 @@ namespace DmpWfs | ||
995 | v.push_back(y); | 1021 | v.push_back(y); |
996 | return 0; | 1022 | return 0; |
997 | } | 1023 | } |
1024 | + qingxiongf*/ | ||
1025 | + /* | ||
998 | int DmpWfsFilter::pGeometryPointValuePointRep(boost::property_tree::ptree& ptree, std::vector<double> &v) | 1026 | int DmpWfsFilter::pGeometryPointValuePointRep(boost::property_tree::ptree& ptree, std::vector<double> &v) |
999 | { | 1027 | { |
1000 | double x, y; | 1028 | double x, y; |
@@ -1010,7 +1038,7 @@ namespace DmpWfs | @@ -1010,7 +1038,7 @@ namespace DmpWfs | ||
1010 | v.push_back(y); | 1038 | v.push_back(y); |
1011 | return 0; | 1039 | return 0; |
1012 | } | 1040 | } |
1013 | - | 1041 | +qingxiongf*/ |
1014 | //来看看这个函数 | 1042 | //来看看这个函数 |
1015 | int DmpWfsFilter::pGeometryPointValueCoordinates(char *p, std::vector<double> &v) | 1043 | int DmpWfsFilter::pGeometryPointValueCoordinates(char *p, std::vector<double> &v) |
1016 | { | 1044 | { |
@@ -1100,30 +1128,34 @@ namespace DmpWfs | @@ -1100,30 +1128,34 @@ namespace DmpWfs | ||
1100 | { | 1128 | { |
1101 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) | 1129 | for (auto ptchild =ptree.begin(); ptchild != ptree.end(); ++ptchild) |
1102 | { | 1130 | { |
1103 | - if (!strcmp((char *)node->name(), "pos") || !strcmp((char *)node->name(), "gml:pos")) //以空格分割的坐标数据 | 1131 | + std::string name = ptchild->first; |
1132 | + | ||
1133 | + if (!strcmp((char *)name.c_str(), "pos") || !strcmp((char *)name.c_str(), "gml:pos")) //以空格分割的坐标数据 | ||
1104 | { | 1134 | { |
1105 | - return pGeometryPointValuePos(node->value(), v); | 1135 | + std::string value = ptchild->second.get_value<std::string>(); |
1136 | + return pGeometryPointValuePos((char*)value.c_str(), v); | ||
1106 | } | 1137 | } |
1107 | - else if (!strcmp((char *)node->name(), "posList") || !strcmp((char *)node->name(), "gml:posList")) //有维度,以空格分割的坐标数据 | 1138 | + else if (!strcmp((char *)name.c_str(), "posList") || !strcmp((char *)name.c_str(), "gml:posList")) //有维度,以空格分割的坐标数据 |
1108 | { | 1139 | { |
1109 | - return pGeometryPointValuePosList(node, v); | 1140 | + return pGeometryPointValuePosList( ptchild->second, v); |
1110 | } | 1141 | } |
1111 | - else if (!strcmp((char *)node->name(), "coordinates") || !strcmp((char *)node->name(), "gml:coordinates")) //以空格或者逗号分割的数据 | 1142 | + else if (!strcmp((char *)name.c_str(), "coordinates") || !strcmp((char *)name.c_str(), "gml:coordinates")) //以空格或者逗号分割的数据 |
1112 | { | 1143 | { |
1113 | - return pGeometryPointValueCoordinates(node->value(), v); | 1144 | + std::string value = ptchild->second.get_value<std::string>(); |
1145 | + return pGeometryPointValueCoordinates((char*)value.c_str(), v); | ||
1114 | } | 1146 | } |
1115 | - else if (!strcmp((char *)node->name(), "coord") || !strcmp((char *)node->name(), "gml:coord")) //坐标,似乎只能得到一个点哦。。。 | 1147 | + else if (!strcmp((char *)name.c_str(), "coord") || !strcmp((char *)name.c_str(), "gml:coord")) //坐标,似乎只能得到一个点哦。。。 |
1116 | { | 1148 | { |
1117 | - return pGeometryPointValueCoord(node, v); | 1149 | + return pGeometryPointValueCoord(ptchild->second, v); |
1118 | } | 1150 | } |
1119 | - else if ((!strcmp((char *)node->name(), "pointRep")) || (!strcmp((char *)node->name(), "pointProperty")) || (!strcmp((char *)node->name(), "gml:pointRep")) || (!strcmp((char *)node->name(), "gml:pointProperty"))) | 1151 | + else if ((!strcmp((char *)name.c_str(), "pointRep")) || (!strcmp((char *)name.c_str(), "pointProperty")) || (!strcmp((char *)name.c_str(), "gml:pointRep")) || (!strcmp((char *)name.c_str(), "gml:pointProperty"))) |
1120 | { | 1152 | { |
1121 | - return pGeometryPointValuePointRep(node, v); | 1153 | + return pGeometryPointValuePointRep(ptchild->second, v); |
1122 | } | 1154 | } |
1123 | } | 1155 | } |
1124 | return Error(-10, "point node not exist"); | 1156 | return Error(-10, "point node not exist"); |
1125 | } | 1157 | } |
1126 | - | 1158 | +/* |
1127 | int DmpWfsFilter::pGeometryEnvope(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1159 | int DmpWfsFilter::pGeometryEnvope(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1128 | { | 1160 | { |
1129 | pParsesrsName(n); | 1161 | pParsesrsName(n); |
@@ -1135,7 +1167,8 @@ namespace DmpWfs | @@ -1135,7 +1167,8 @@ namespace DmpWfs | ||
1135 | *g = mp; | 1167 | *g = mp; |
1136 | return 0; | 1168 | return 0; |
1137 | } | 1169 | } |
1138 | - | 1170 | +qingxingf*/ |
1171 | +/* | ||
1139 | int DmpWfsFilter::pGeometryMultiPoint(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1172 | int DmpWfsFilter::pGeometryMultiPoint(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1140 | { | 1173 | { |
1141 | xml_node<char> *node; | 1174 | xml_node<char> *node; |
@@ -1166,7 +1199,8 @@ namespace DmpWfs | @@ -1166,7 +1199,8 @@ namespace DmpWfs | ||
1166 | *g = mp; | 1199 | *g = mp; |
1167 | return 0; | 1200 | return 0; |
1168 | } | 1201 | } |
1169 | - | 1202 | +qingxingf*/ |
1203 | +/* | ||
1170 | int DmpWfsFilter::pGeometryMultiPolyline(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1204 | int DmpWfsFilter::pGeometryMultiPolyline(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1171 | { | 1205 | { |
1172 | xml_node<char> *node; | 1206 | xml_node<char> *node; |
@@ -1193,7 +1227,8 @@ namespace DmpWfs | @@ -1193,7 +1227,8 @@ namespace DmpWfs | ||
1193 | *g = plyg; | 1227 | *g = plyg; |
1194 | return 0; | 1228 | return 0; |
1195 | } | 1229 | } |
1196 | - | 1230 | + qingxiongf*/ |
1231 | +/* | ||
1197 | int DmpWfsFilter::pGeometryMultiPolygon(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1232 | int DmpWfsFilter::pGeometryMultiPolygon(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1198 | { | 1233 | { |
1199 | xml_node<char> *node; | 1234 | xml_node<char> *node; |
@@ -1221,6 +1256,8 @@ namespace DmpWfs | @@ -1221,6 +1256,8 @@ namespace DmpWfs | ||
1221 | *g = plyg; | 1256 | *g = plyg; |
1222 | return 0; | 1257 | return 0; |
1223 | } | 1258 | } |
1259 | + qingxingf*/ | ||
1260 | + /* | ||
1224 | int DmpWfsFilter::pGeometryPolygon(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1261 | int DmpWfsFilter::pGeometryPolygon(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1225 | { | 1262 | { |
1226 | xml_node<char> *node; | 1263 | xml_node<char> *node; |
@@ -1271,7 +1308,8 @@ namespace DmpWfs | @@ -1271,7 +1308,8 @@ namespace DmpWfs | ||
1271 | *g = plyg; | 1308 | *g = plyg; |
1272 | return 0; | 1309 | return 0; |
1273 | } | 1310 | } |
1274 | - | 1311 | +qingxingf*/ |
1312 | +/* | ||
1275 | int DmpWfsFilter::pGeometryPolyline(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1313 | int DmpWfsFilter::pGeometryPolyline(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1276 | { | 1314 | { |
1277 | xml_node<char> *node; | 1315 | xml_node<char> *node; |
@@ -1303,11 +1341,10 @@ namespace DmpWfs | @@ -1303,11 +1341,10 @@ namespace DmpWfs | ||
1303 | *g = plyg; | 1341 | *g = plyg; |
1304 | return 0; | 1342 | return 0; |
1305 | } | 1343 | } |
1306 | - | 1344 | +qingxingf*/ |
1307 | int DmpWfsFilter::pGeometryLineString(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1345 | int DmpWfsFilter::pGeometryLineString(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1308 | { | 1346 | { |
1309 | - //rapidxml::xml_node<char> * t=n->first_node(); | ||
1310 | - //if(t==0)return Error(-3,"point have no children"); | 1347 | + /* |
1311 | std::vector<double> v; | 1348 | std::vector<double> v; |
1312 | int rt = pGeometryPointArray(n, v); | 1349 | int rt = pGeometryPointArray(n, v); |
1313 | if (rt) | 1350 | if (rt) |
@@ -1331,10 +1368,10 @@ namespace DmpWfs | @@ -1331,10 +1368,10 @@ namespace DmpWfs | ||
1331 | j++; | 1368 | j++; |
1332 | } | 1369 | } |
1333 | 1370 | ||
1334 | - *g = l; | 1371 | + *g = l; qingxiongf*/ |
1335 | return 0; | 1372 | return 0; |
1336 | } | 1373 | } |
1337 | - | 1374 | +/* |
1338 | void DmpWfsFilter::parse_gml_srs(boost::property_tree::ptree& ptree, gmlSrs *srs) | 1375 | void DmpWfsFilter::parse_gml_srs(boost::property_tree::ptree& ptree, gmlSrs *srs) |
1339 | { | 1376 | { |
1340 | char *p; | 1377 | char *p; |
@@ -1378,7 +1415,7 @@ namespace DmpWfs | @@ -1378,7 +1415,7 @@ namespace DmpWfs | ||
1378 | return; | 1415 | return; |
1379 | } | 1416 | } |
1380 | 1417 | ||
1381 | - /* retrieve the last ':' or '#' char */ | 1418 | + |
1382 | for (p = (char *)srsname; *p; p++) | 1419 | for (p = (char *)srsname; *p; p++) |
1383 | ; | 1420 | ; |
1384 | for (--p; *p != sep; p--) | 1421 | for (--p; *p != sep; p--) |
@@ -1399,9 +1436,6 @@ namespace DmpWfs | @@ -1399,9 +1436,6 @@ namespace DmpWfs | ||
1399 | 1436 | ||
1400 | int DmpWfsFilter::pGeometryPoint(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) | 1437 | int DmpWfsFilter::pGeometryPoint(boost::property_tree::ptree& ptree, DmpWfsGmlObject **g) |
1401 | { | 1438 | { |
1402 | - //rapidxml::xml_node<char> * t=n->first_node(); | ||
1403 | - //if(t==0)return Error(-3,"point have no children"); | ||
1404 | - | ||
1405 | std::vector<double> v; | 1439 | std::vector<double> v; |
1406 | int rt = pGeometryPointArray(n, v); | 1440 | int rt = pGeometryPointArray(n, v); |
1407 | if (rt) | 1441 | if (rt) |
@@ -1485,10 +1519,11 @@ namespace DmpWfs | @@ -1485,10 +1519,11 @@ namespace DmpWfs | ||
1485 | } | 1519 | } |
1486 | return 0; | 1520 | return 0; |
1487 | } | 1521 | } |
1488 | - | 1522 | + qingxionggf*/ |
1523 | + /* | ||
1489 | int DmpWfsFilter::ParseOrder(char *xml, void *tdp, int dtp) | 1524 | int DmpWfsFilter::ParseOrder(char *xml, void *tdp, int dtp) |
1490 | { | 1525 | { |
1491 | - err[0] = 0; | 1526 | + err[0] = 0; |
1492 | sql = ""; | 1527 | sql = ""; |
1493 | this->td = (TableDesc *)tdp; | 1528 | this->td = (TableDesc *)tdp; |
1494 | this->DatabaseType = dtp; | 1529 | this->DatabaseType = dtp; |
@@ -1546,65 +1581,34 @@ namespace DmpWfs | @@ -1546,65 +1581,34 @@ namespace DmpWfs | ||
1546 | } | 1581 | } |
1547 | return 0; | 1582 | return 0; |
1548 | } | 1583 | } |
1584 | + qingxingf*/ | ||
1549 | 1585 | ||
1550 | - int DmpWfsFilter::GetGeomFromGml(void *nn, std::string &strOut, double &x1, double &y1, double &x2, double &y2, void **geoOut) | 1586 | + int DmpWfsFilter::GetGeomFromGml(boost::property_tree::ptree &ptreeode, std::string &strOut, double &x1, double &y1, double &x2, double &y2, void **geoOut) |
1551 | { | 1587 | { |
1552 | if (geoOut) | 1588 | if (geoOut) |
1553 | { | 1589 | { |
1554 | *geoOut = 0; | 1590 | *geoOut = 0; |
1555 | } | 1591 | } |
1556 | strOut = ""; | 1592 | strOut = ""; |
1557 | - xml_node<char> *node = (xml_node<char> *)nn; | 1593 | + // xml_node<char> *node = (xml_node<char> *)nn; |
1558 | DmpWfsGmlObject *g = 0; | 1594 | DmpWfsGmlObject *g = 0; |
1559 | - int e = pGeometry(node, &g); //很重要的函数 | 1595 | + int e = pGeometry(ptreeode, &g); //很重要的函数 |
1560 | // char sz[100];//int srid=-1; | 1596 | // char sz[100];//int srid=-1; |
1561 | // itoa(srs,sz,10); | 1597 | // itoa(srs,sz,10); |
1598 | + string srs = ""; | ||
1562 | //strcpy(sz,"NULL"); | 1599 | //strcpy(sz,"NULL"); |
1563 | if (g) | 1600 | if (g) |
1564 | { | 1601 | { |
1565 | - g->GetRect(x1, y1, x2, y2); | 1602 | + //g->GetRect(x1, y1, x2, y2); |
1566 | std::string sql; | 1603 | std::string sql; |
1567 | - g->GetString(sql); | ||
1568 | - switch (DatabaseType) | ||
1569 | - { | ||
1570 | - //case DatabaseTypeOracle: | ||
1571 | - // { | ||
1572 | - // if(geoOut) | ||
1573 | - // { | ||
1574 | - // SDOGeometry *sg=new SDOGeometry(); | ||
1575 | - // g->GetObj(sg); | ||
1576 | - // if(strcmp(srs,"NULL")) | ||
1577 | - // { | ||
1578 | - // sg->setSdo_srid(atoi(srs)); //getobj测试, // this->DataType | ||
1579 | - // } | ||
1580 | - // *geoOut=(void *)sg; //构造ORACLE SPATIAL 的SDO_GEOMETRY结构 | ||
1581 | - // } | ||
1582 | - // //else | ||
1583 | - // { | ||
1584 | - // //这里似乎用的是WKT的形式啊。。。 | ||
1585 | - // strOut="SDO_GEOMETRY('"; | ||
1586 | - // strOut=strOut+sql; | ||
1587 | - // strOut=strOut+"',"; | ||
1588 | - // strOut=strOut+srs; | ||
1589 | - // strOut=strOut+")"; | ||
1590 | - // } | ||
1591 | - // } | ||
1592 | - // break; | ||
1593 | - case DatabaseTypePostgreSQL: | ||
1594 | - { | ||
1595 | - strOut = initConfig.geometryfromtext; | 1604 | + // g->GetString(sql); |
1605 | + strOut = "";//initConfig.geometryfromtext; | ||
1596 | strOut += "st_geomfromtext('"; //strOut="geometryfromtext('"; | 1606 | strOut += "st_geomfromtext('"; //strOut="geometryfromtext('"; |
1597 | strOut = strOut + sql; | 1607 | strOut = strOut + sql; |
1598 | strOut = strOut + "',"; | 1608 | strOut = strOut + "',"; |
1599 | //initConfig.DefaultGID; | 1609 | //initConfig.DefaultGID; |
1600 | strOut = strOut + srs; | 1610 | strOut = strOut + srs; |
1601 | strOut = strOut + ")"; | 1611 | strOut = strOut + ")"; |
1602 | - } | ||
1603 | - break; | ||
1604 | - default: | ||
1605 | - return -18741; | ||
1606 | - break; | ||
1607 | - } | ||
1608 | } | 1612 | } |
1609 | else | 1613 | else |
1610 | { | 1614 | { |
@@ -81,15 +81,17 @@ namespace DmpWfs | @@ -81,15 +81,17 @@ namespace DmpWfs | ||
81 | int pGeometryPointValuePointRep(boost::property_tree::ptree &ptree, std::vector<double> &v); | 81 | int pGeometryPointValuePointRep(boost::property_tree::ptree &ptree, std::vector<double> &v); |
82 | int pGeometryPointValueCoord(boost::property_tree::ptree &ptree, std::vector<double> &v); | 82 | int pGeometryPointValueCoord(boost::property_tree::ptree &ptree, std::vector<double> &v); |
83 | int pGeometryGetDis(boost::property_tree::ptree &ptree, double &dis); | 83 | int pGeometryGetDis(boost::property_tree::ptree &ptree, double &dis); |
84 | - int pGeometrySql(char *function, char *oracle_mask, int isDisjoin, boost::property_tree::ptree &ptree, bool useBuffer); //char *function,char *field,DmpWfsGmlObject *g,std::string &str); | 84 | + int pGeometrySql(const char *function,const char *oracle_mask, int isDisjoin, boost::property_tree::ptree &ptree, bool useBuffer); //char *function,char *field,DmpWfsGmlObject *g,std::string &str); |
85 | private: | 85 | private: |
86 | int Error(int code,const char * err); | 86 | int Error(int code,const char * err); |
87 | - // void GetQueryField(const char *field); | 87 | + void GetQueryField(std::string &field); |
88 | void _AppendProperty(std::string &sql, const char *str); | 88 | void _AppendProperty(std::string &sql, const char *str); |
89 | + int GetGeomFromGml(boost::property_tree::ptree &ptreeode,std::string &strOut,double &x1,double &y1,double &x2,double &y2,void **geoOut=0); | ||
89 | int _PropertyParse(const std::string& ptreeName, boost::property_tree::ptree &ptreeode, int &isExpression, int isLike = 0); | 90 | int _PropertyParse(const std::string& ptreeName, boost::property_tree::ptree &ptreeode, int &isExpression, int isLike = 0); |
90 | - int _PropertyParse4(boost::property_tree::ptree &ptreeode, char *f); | 91 | + int _PropertyParse4(boost::property_tree::ptree &ptreeode,const char *f); |
91 | int _PropertyParseFunction(boost::property_tree::ptree &ptree); | 92 | int _PropertyParseFunction(boost::property_tree::ptree &ptree); |
92 | - int _PropertyOneEqual(boost::property_tree::ptree &ptree, char *type, int isLike = 0); | 93 | + int _PropertyOneEqual(boost::property_tree::ptree &ptree,const char *type, int isLike = 0); |
94 | + void pParsesrsName(boost::property_tree::ptree& ptree); | ||
93 | }; | 95 | }; |
94 | 96 | ||
95 | } | 97 | } |
@@ -164,7 +164,7 @@ namespace DmpWfs | @@ -164,7 +164,7 @@ namespace DmpWfs | ||
164 | ptFeatureType.add("Name", layer->name()); | 164 | ptFeatureType.add("Name", layer->name()); |
165 | ptFeatureType.add("Title", layer->title()); | 165 | ptFeatureType.add("Title", layer->title()); |
166 | ptFeatureType.add("DisplayColumn", ""); | 166 | ptFeatureType.add("DisplayColumn", ""); |
167 | - ptFeatureType.add("Geometry", "点"); | 167 | + ptFeatureType.add("Geometry", layer->GeomTypeString()); |
168 | ptFeatureType.add("GeometryColumn", layer->geom()); | 168 | ptFeatureType.add("GeometryColumn", layer->geom()); |
169 | ptFeatureType.add("SRS", srs); | 169 | ptFeatureType.add("SRS", srs); |
170 | 170 | ||
@@ -187,7 +187,12 @@ namespace DmpWfs | @@ -187,7 +187,12 @@ namespace DmpWfs | ||
187 | ptFeatureType.add_child("LatLongBoundingBox", ptBoundingbox); | 187 | ptFeatureType.add_child("LatLongBoundingBox", ptBoundingbox); |
188 | 188 | ||
189 | boost::property_tree::ptree ptFields; | 189 | boost::property_tree::ptree ptFields; |
190 | - for (; pPgsqlConn->next();) | 190 | + char tablesql_buff[300]; |
191 | + sprintf(tablesql_buff, "select column_name,data_type from information_schema.columns where table_schema = '%s' and table_name = '%s'", | ||
192 | + layer->schema().c_str(), | ||
193 | + layer->name().c_str()); | ||
194 | + bool returnResult = pPgsqlConn->ExecWait(tablesql_buff); | ||
195 | + for (;returnResult && pPgsqlConn->next();) | ||
191 | { | 196 | { |
192 | std::string fieldname = pPgsqlConn->getString(0); | 197 | std::string fieldname = pPgsqlConn->getString(0); |
193 | std::string typeString = pPgsqlConn->getString(1); | 198 | std::string typeString = pPgsqlConn->getString(1); |
@@ -9,216 +9,237 @@ | @@ -9,216 +9,237 @@ | ||
9 | #include "dmpwfsgetfeature.h" | 9 | #include "dmpwfsgetfeature.h" |
10 | #include "dmpsqlfactory.h" | 10 | #include "dmpsqlfactory.h" |
11 | #include "dmpmapserverutil.h" | 11 | #include "dmpmapserverutil.h" |
12 | -#include "dmpvectorlayer.h" | ||
13 | #include "dmpgmlfilter.h" | 12 | #include "dmpgmlfilter.h" |
13 | +#include "dmpwfsfilter.h" | ||
14 | +#include "dmpserverresponse.h" | ||
15 | +#include "dmpserverrequest.h" | ||
16 | +#include "dmpserverproject.h" | ||
17 | + | ||
14 | #include <string.h> | 18 | #include <string.h> |
15 | 19 | ||
16 | namespace DmpWfs | 20 | namespace DmpWfs |
17 | { | 21 | { |
18 | - void writeGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
19 | - const DmpProject* project, | ||
20 | - bool projectSettings) | ||
21 | - { | ||
22 | - WfsGetFeature(context, params, project, projectSettings); | ||
23 | - } | ||
24 | - | ||
25 | - std::string WfsGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
26 | - const DmpProject* project, | ||
27 | - bool projectSettings) | ||
28 | - { | ||
29 | - char buff[5000]; | ||
30 | - // DmpSqlFactory sqlFactory; | ||
31 | - | ||
32 | - int maxFeatures = params.MaxFeatures(); | ||
33 | - int startIndex = params.StartIndex(); | ||
34 | - std::string typeName = params.TypeName(); | ||
35 | - std::string featureID = params.FeatureID(); | ||
36 | - std::string propertyName = params.PropertyName(); | ||
37 | - std::string resultType = params.ResultType(); | ||
38 | - std::string filter = params.Filter(); | ||
39 | - | ||
40 | - std::string sortby = params.Sortby(); | ||
41 | - | ||
42 | - DmpGmlFilter gmlFilter; | ||
43 | - gmlFilter.Parse(filter); | ||
44 | -/* | ||
45 | - sqlFactory.setStartIndexCount(startIndex, maxFeatures, resultType); | ||
46 | - | ||
47 | - std::vector<std::string> ids; | ||
48 | - if (!featureID.empty()) | ||
49 | - { | ||
50 | - char *idstring[1000]; | ||
51 | - //将ID值以逗号分开,并返回个数 | ||
52 | - | ||
53 | - vector<string> stringlist = mapserver::DmpMapServerUtil::stringSplit(propertyName, ","); | ||
54 | - for (int i = 0; i < stringlist.size(); i++) | ||
55 | - { | ||
56 | - char *ss[2]; | ||
57 | - //形式:LayerName.ID | ||
58 | - vector<string> stringList1 = mapserver::DmpMapServerUtil::stringSplit(idstring[i], "."); | ||
59 | - // int n = StringHelp::ParseStringTok(idstring[i], '.', ss, 2); | ||
60 | - if (stringList1.size() == 2) | ||
61 | - { | ||
62 | - if (typeName.empty()) | ||
63 | - { | ||
64 | - typeName = stringList1[0]; | ||
65 | - } | ||
66 | - ids.push_back(stringList1[1]); | ||
67 | - } | ||
68 | - else if (stringList1.size() == 1) | ||
69 | - { | ||
70 | - ids.push_back(stringList1[0]); | ||
71 | - } | ||
72 | - } | ||
73 | - } | 22 | + void writeGetFeature(const DmpServerContext &context, const DmpWfsParameters ¶ms, |
23 | + const DmpProject *project, | ||
24 | + bool projectSettings) | ||
25 | + { | ||
26 | + WfsGetFeature(context, params, project, projectSettings); | ||
27 | + } | ||
74 | 28 | ||
75 | - std::vector<std::string> props; | ||
76 | - std::vector<std::string> propsAs; | ||
77 | - if (propertyName.empty()) | ||
78 | - { | ||
79 | - | ||
80 | - vector<string> stringlist = mapserver::DmpMapServerUtil::stringSplit(propertyName, ","); | ||
81 | - for (int i = 0; i < stringlist.size(); i++) | ||
82 | - { | ||
83 | - // char *ss[2]; | ||
84 | - std::string sProp, sPropAs; | ||
85 | - vector<string> layernameSplit = mapserver::DmpMapServerUtil::stringSplit(stringlist[i], "."); | ||
86 | - if (layernameSplit.size() == 2) | ||
87 | - { | ||
88 | - if (typeName.empty()) | ||
89 | - { | ||
90 | - typeName = layernameSplit[0]; | ||
91 | - } | ||
92 | - //又以空格分开 | ||
93 | - // StringHelp::GetAsStringSql(ss[1], sProp, sPropAs); | ||
94 | - props.push_back(sProp); | ||
95 | - propsAs.push_back(sPropAs); | ||
96 | - //sPropOrig=ss[1]; | ||
97 | - } | ||
98 | - else if (layernameSplit.size() == 1) | ||
99 | - { | ||
100 | - // StringHelp::GetAsStringSql(ss[0], sProp, sPropAs); | ||
101 | - props.push_back(sProp); | ||
102 | - propsAs.push_back(sPropAs); //props.push_back(ss[0]); | ||
103 | - } | ||
104 | - } | ||
105 | - } | ||
106 | - | 29 | + std::string WfsGetFeature(const DmpServerContext &context, const DmpWfsParameters ¶ms, |
30 | + const DmpProject *project, | ||
31 | + bool projectSettings) | ||
32 | + { | ||
33 | + char buff[5000]; | ||
34 | + DmpSqlFactory sqlFactory; | ||
107 | 35 | ||
108 | - if (typeName.empty()) | ||
109 | - { | ||
110 | - return "layername not exist"; | ||
111 | - } | 36 | + int maxFeatures = params.MaxFeatures(); |
37 | + int startIndex = params.StartIndex(); | ||
38 | + std::string typeName = params.TypeName(); | ||
39 | + std::string featureID = params.FeatureID(); | ||
40 | + std::string propertyName = params.PropertyName(); | ||
41 | + DmpWfsParameters::Format resultType = params.ResultType(); | ||
42 | + std::string filter = params.Filter(); | ||
112 | 43 | ||
113 | - DmpVectorLayer* mapLayer =(DmpVectorLayer*) project->getLayer(typeName);//GetLayer(parseString.layerName); | ||
114 | - if(mapLayer == nullptr) | ||
115 | - { | ||
116 | - return "layer not find"; | ||
117 | - } | 44 | + std::string sortby = params.Sortby(); |
118 | 45 | ||
119 | - shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(mapLayer->source()); | ||
120 | - if(pPgsqlConn == nullptr) | ||
121 | - { | ||
122 | - return "连接数据库失败"; | ||
123 | - } | ||
124 | - // shared_ptr<dmapFields> fields = pWorkspace->GetFields(mapLayer->m_layerName,""); | 46 | + DmpWfsFilter wfsFilter; |
47 | + wfsFilter.Parse(filter); | ||
48 | + std::string sql0 = wfsFilter.getSql(); | ||
49 | + printf("%s\r\n", sql0.c_str()); | ||
125 | 50 | ||
126 | - //if(fields == nullptr) | ||
127 | - { | ||
128 | - //return Error(buff, ErrorClass::ParaError, "layername not exist", ab); | ||
129 | - } | 51 | + sqlFactory.setStartIndexCount(startIndex, maxFeatures, ""); |
130 | 52 | ||
131 | - // shared_ptr<TableDesc> pTabledesc = this->ToTableDesc(fields,mapLayer->m_layerName); | ||
132 | - | 53 | + std::vector<std::string> ids; |
54 | + if (!featureID.empty()) | ||
55 | + { | ||
56 | + char *idstring[1000]; | ||
57 | + //将ID值以逗号分开,并返回个数 | ||
133 | 58 | ||
134 | - size_t propCount = props.size(); | ||
135 | - if (propCount) | ||
136 | - { | ||
137 | - std::string sF; | ||
138 | - for (int i = 0; i < propCount; i++) | ||
139 | - { | ||
140 | - if (i) | ||
141 | - sF = sF + ","; | ||
142 | - string sleft, sright, s; | ||
143 | - s = props[i]; | ||
144 | - int at1 = s.find("("), at2 = s.find(")"); | ||
145 | - | ||
146 | - if (at1 != string::npos && at2 == s.length() - 1 && at1 < at2) | ||
147 | - { | ||
148 | - sleft = s.substr(0, at1); | ||
149 | - sright = s.substr(at1 + 1, s.length() - 2 - at1); | ||
150 | - if (boost::iequals(sleft, "distinct")) | ||
151 | - { | ||
152 | - // sF = sF + sleft + " " + fields->GetFieldQuery(sright.c_str()); | ||
153 | - } | ||
154 | - else | ||
155 | - { | ||
156 | - // sF = sF + sleft + "(" + fields->GetFieldQuery(sright.c_str()) + ")"; | ||
157 | - } | ||
158 | - } | ||
159 | - else | ||
160 | - { | ||
161 | - // sF = sF + fields->GetFieldQuery(s.c_str()); | ||
162 | - } | ||
163 | - | ||
164 | - } | ||
165 | - | ||
166 | - sqlFactory.setProp(sF); | ||
167 | - } | ||
168 | - else | ||
169 | - { | ||
170 | - // bool isJson = (parseString.format && (strcmpi(parseString.format, "geojson") ==0 || strcmpi(parseString.format, "json") ==0)); | ||
171 | - // this->GetAllField( srsOut, sqlF.prop,mapLayer,pWorkspace,isJson); | ||
172 | - } | 59 | + vector<string> stringlist = mapserver::DmpMapServerUtil::stringSplit(propertyName, ","); |
60 | + for (int i = 0; i < stringlist.size(); i++) | ||
61 | + { | ||
62 | + char *ss[2]; | ||
63 | + //形式:LayerName.ID | ||
64 | + vector<string> stringList1 = mapserver::DmpMapServerUtil::stringSplit(idstring[i], "."); | ||
65 | + // int n = StringHelp::ParseStringTok(idstring[i], '.', ss, 2); | ||
66 | + if (stringList1.size() == 2) | ||
67 | + { | ||
68 | + if (typeName.empty()) | ||
69 | + { | ||
70 | + typeName = stringList1[0]; | ||
71 | + } | ||
72 | + ids.push_back(stringList1[1]); | ||
73 | + } | ||
74 | + else if (stringList1.size() == 1) | ||
75 | + { | ||
76 | + ids.push_back(stringList1[0]); | ||
77 | + } | ||
78 | + } | ||
79 | + } | ||
173 | 80 | ||
174 | - size_t idCount = ids.size(); | 81 | + std::vector<std::string> props; |
82 | + std::vector<std::string> propsAs; | ||
83 | + if (!propertyName.empty()) | ||
84 | + { | ||
175 | 85 | ||
176 | - | ||
177 | - if (!filter.empty()) | ||
178 | - { | ||
179 | - DmpWfsFilter wfsFilter; | ||
180 | - | ||
181 | - if(wfsFilter.Parse(filter)) | ||
182 | - { | ||
183 | - return "解析查询器错误"; | ||
184 | - } | ||
185 | - | ||
186 | - sqlFactory.appendCondition(wfsFilter.getSql()); | ||
187 | - } | 86 | + vector<string> stringlist = mapserver::DmpMapServerUtil::stringSplit(propertyName, ","); |
87 | + for (int i = 0; i < stringlist.size(); i++) | ||
88 | + { | ||
89 | + // char *ss[2]; | ||
90 | + std::string sProp, sPropAs; | ||
91 | + vector<string> layernameSplit = mapserver::DmpMapServerUtil::stringSplit(stringlist[i], "."); | ||
92 | + if (layernameSplit.size() == 2) | ||
93 | + { | ||
94 | + if (typeName.empty()) | ||
95 | + { | ||
96 | + typeName = layernameSplit[0]; | ||
97 | + } | ||
98 | + //又以空格分开 | ||
99 | + // StringHelp::GetAsStringSql(ss[1], sProp, sPropAs); | ||
100 | + props.push_back(sProp); | ||
101 | + propsAs.push_back(sPropAs); | ||
102 | + //sPropOrig=ss[1]; | ||
103 | + } | ||
104 | + else if (layernameSplit.size() == 1) | ||
105 | + { | ||
106 | + // StringHelp::GetAsStringSql(ss[0], sProp, sPropAs); | ||
107 | + props.push_back(sProp); | ||
108 | + propsAs.push_back(sPropAs); //props.push_back(ss[0]); | ||
109 | + } | ||
110 | + } | ||
111 | + } | ||
188 | 112 | ||
189 | - if (!sortby.empty()) | ||
190 | - { | ||
191 | - DmpWfsFilter wfsFilter; | ||
192 | - if (wfsFilter.ParseOrder(sortby)) | ||
193 | - { | ||
194 | - return "参数sortby 解析错误!"; | ||
195 | - } | ||
196 | - sqlFactory.setOrder(wfsFilter.getSql()); | ||
197 | - } | ||
198 | - sqlFactory.setTable(mapLayer->name()); | ||
199 | - std::string sql = sqlFactory.getSql(); | ||
200 | - if (!pPgsqlConn->ExecWaitBinary(sql)) | ||
201 | - { | ||
202 | - return "查询错误:" + pPgsqlConn->error(); | ||
203 | - } */ | ||
204 | - // int ver = ParseString::GetGMLVersion(parseString.version, parseString.outputFormat); | ||
205 | - /* if (parseString.format && (strcmpi(parseString.format, "geojson") ==0|| strcmpi(parseString.format, "json")==0)) | 113 | + if (typeName.empty()) |
114 | + { | ||
115 | + return "layername not exist"; | ||
116 | + } | ||
117 | + | ||
118 | + DmpVectorLayer *mapLayer = (DmpVectorLayer *)project->getLayer(typeName); //GetLayer(parseString.layerName); | ||
119 | + if (mapLayer == nullptr) | ||
120 | + { | ||
121 | + return "layer not find"; | ||
122 | + } | ||
123 | + | ||
124 | + shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(mapLayer->source()); | ||
125 | + if (pPgsqlConn == nullptr) | ||
126 | + { | ||
127 | + return "连接数据库失败"; | ||
128 | + } | ||
129 | + // shared_ptr<dmapFields> fields = pPgsqlConn->GetFields(mapLayer->m_layerName,""); | ||
130 | + | ||
131 | + //if(fields == nullptr) | ||
132 | + { | ||
133 | + //return Error(buff, ErrorClass::ParaError, "layername not exist", ab); | ||
134 | + } | ||
135 | + | ||
136 | + // shared_ptr<TableDesc> pTabledesc = this->ToTableDesc(fields,mapLayer->m_layerName); | ||
137 | + | ||
138 | + size_t propCount = props.size(); | ||
139 | + if (propCount) | ||
140 | + { | ||
141 | + std::string sF; | ||
142 | + for (int i = 0; i < propCount; i++) | ||
143 | + { | ||
144 | + if (i) | ||
145 | + sF = sF + ","; | ||
146 | + string sleft, sright, s; | ||
147 | + s = props[i]; | ||
148 | + int at1 = s.find("("), at2 = s.find(")"); | ||
149 | + | ||
150 | + if (at1 != string::npos && at2 == s.length() - 1 && at1 < at2) | ||
151 | + { | ||
152 | + sleft = s.substr(0, at1); | ||
153 | + sright = s.substr(at1 + 1, s.length() - 2 - at1); | ||
154 | + if (boost::iequals(sleft, "distinct")) | ||
155 | + { | ||
156 | + // sF = sF + sleft + " " + fields->GetFieldQuery(sright.c_str()); | ||
157 | + } | ||
158 | + else | ||
159 | + { | ||
160 | + // sF = sF + sleft + "(" + fields->GetFieldQuery(sright.c_str()) + ")"; | ||
161 | + } | ||
162 | + } | ||
163 | + else | ||
164 | + { | ||
165 | + // sF = sF + fields->GetFieldQuery(s.c_str()); | ||
166 | + } | ||
167 | + } | ||
168 | + | ||
169 | + sqlFactory.setProp(sF); | ||
170 | + } | ||
171 | + else | ||
172 | + { | ||
173 | + std::string prop; | ||
174 | + GetAllField(prop, mapLayer, pPgsqlConn, resultType); | ||
175 | + sqlFactory.setProp(prop); | ||
176 | + } | ||
177 | + | ||
178 | + size_t idCount = ids.size(); | ||
179 | + | ||
180 | + if (!filter.empty()) | ||
181 | + { | ||
182 | + DmpWfsFilter wfsFilter; | ||
183 | + | ||
184 | + if (wfsFilter.Parse(filter)) | ||
185 | + { | ||
186 | + return "解析查询器错误"; | ||
187 | + } | ||
188 | + | ||
189 | + sqlFactory.appendCondition(wfsFilter.getSql()); | ||
190 | + } | ||
191 | + | ||
192 | + if (!sortby.empty()) | ||
193 | + { | ||
194 | + DmpWfsFilter wfsFilter; | ||
195 | + if (wfsFilter.ParseOrder(sortby)) | ||
196 | + { | ||
197 | + return "参数sortby 解析错误!"; | ||
198 | + } | ||
199 | + sqlFactory.setOrder(wfsFilter.getSql()); | ||
200 | + } | ||
201 | + sqlFactory.setTable(mapLayer->name()); | ||
202 | + std::string sql = sqlFactory.getSql(); | ||
203 | + if (!pPgsqlConn->ExecWaitBinary(sql)) | ||
204 | + { | ||
205 | + return "查询错误:" + pPgsqlConn->error(); | ||
206 | + } | ||
207 | + | ||
208 | + if (resultType == DmpWfsParameters::Format::GeoJson) | ||
209 | + { | ||
210 | + std::string responseData; | ||
211 | + std::string srid = std::__cxx11::to_string(mapLayer->crs().srid()); | ||
212 | + DmpMapServerUtil::responseGeojson(pPgsqlConn, responseData, mapLayer->name(), srid); | ||
213 | + context.response()->writeJson(responseData); | ||
214 | + } | ||
215 | + else | ||
216 | + { | ||
217 | + std::string responseData; | ||
218 | + std::string srid = std::__cxx11::to_string(mapLayer->crs().srid()); | ||
219 | + DmpMapServerUtil::responseGml(pPgsqlConn, responseData, mapLayer->name(), srid); | ||
220 | + context.response()->removeHeader("Content-Type"); | ||
221 | + context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); | ||
222 | + context.response()->write(responseData); | ||
223 | + } | ||
224 | + | ||
225 | + // int ver = ParseString::GetGMLVersion(parseString.version, parseString.outputFormat); | ||
226 | + /* if (parseString.format && (strcmpi(parseString.format, "geojson") ==0|| strcmpi(parseString.format, "json")==0)) | ||
206 | { | 227 | { |
207 | isPicture = 10; | 228 | isPicture = 10; |
208 | - return this->FormatWFSJsonCAll(pWorkspace, ab, parseString.layerName, buff, ver); | 229 | + return this->FormatWFSJsonCAll(pPgsqlConn, ab, parseString.layerName, buff, ver); |
209 | } | 230 | } |
210 | else | 231 | else |
211 | { | 232 | { |
212 | isPicture = 0; | 233 | isPicture = 0; |
213 | - return this->FormatWFSXMLCAll(pWorkspace, ab, parseString.layerName, buff, ver); | 234 | + return this->FormatWFSXMLCAll(pPgsqlConn, ab, parseString.layerName, buff, ver); |
214 | }*/ | 235 | }*/ |
215 | - return ""; | ||
216 | - } | 236 | + return ""; |
237 | + } | ||
217 | 238 | ||
218 | - void getAsStringSql(const string& str, std::string &sProp, std::string &sAs) | 239 | + void getAsStringSql(const string &str, std::string &sProp, std::string &sAs) |
219 | { | 240 | { |
220 | //char *ss[2]; | 241 | //char *ss[2]; |
221 | - vector<string> layernameSplit = mapserver::DmpMapServerUtil::stringSplit(str, "."); | 242 | + vector<string> layernameSplit = mapserver::DmpMapServerUtil::stringSplit(str, "."); |
222 | //int n = ParseStringTok(str, ' ', ss, 2); | 243 | //int n = ParseStringTok(str, ' ', ss, 2); |
223 | if (layernameSplit.size() == 1) | 244 | if (layernameSplit.size() == 1) |
224 | { | 245 | { |
@@ -231,4 +252,86 @@ namespace DmpWfs | @@ -231,4 +252,86 @@ namespace DmpWfs | ||
231 | sAs = layernameSplit[1]; | 252 | sAs = layernameSplit[1]; |
232 | } | 253 | } |
233 | } | 254 | } |
255 | + | ||
256 | + bool GetAllField(std::string &strOut, DmpVectorLayer *mapLayer, | ||
257 | + shared_ptr<DmpPgsql> pPgsqlConn, DmpWfsParameters::Format format) | ||
258 | + { | ||
259 | + string fields_str; | ||
260 | + if (pPgsqlConn != nullptr) | ||
261 | + { | ||
262 | + char tablesql_buff[300]; | ||
263 | + std::sprintf(tablesql_buff, "select column_name,data_type from information_schema.columns where table_schema = '%s' and table_name = '%s'", | ||
264 | + mapLayer->schema().c_str(), | ||
265 | + mapLayer->name().c_str()); | ||
266 | + | ||
267 | + int returnResult = pPgsqlConn->ExecWait(tablesql_buff); | ||
268 | + if (!returnResult) | ||
269 | + { | ||
270 | + string fields_str = " * "; | ||
271 | + } | ||
272 | + else | ||
273 | + { | ||
274 | + | ||
275 | + for (int i = 0; pPgsqlConn->next(); i++) | ||
276 | + { | ||
277 | + if (i > 0 && fields_str.length() > 0 && fields_str[fields_str.length() - 1] != ',') | ||
278 | + { | ||
279 | + fields_str += ","; | ||
280 | + } | ||
281 | + string fieldname = pPgsqlConn->getString(0); | ||
282 | + string typeString = pPgsqlConn->getString(1); | ||
283 | + int typeInt = PGFieldType::VarCharFieldType; | ||
284 | + if (mapLayer->geom() == fieldname || typeString == "geometry") | ||
285 | + { | ||
286 | + typeString = "geometry"; | ||
287 | + typeInt = PGFieldType::ShapeFieldType; | ||
288 | + if (format == DmpWfsParameters::Format::GeoJson) | ||
289 | + { | ||
290 | + fields_str += " st_asgeojson(\"" + (fieldname) + "\") as geometry_as_geojson"; | ||
291 | + } | ||
292 | + else | ||
293 | + { | ||
294 | + fields_str += " st_asgml(\"" + (fieldname) + "\") as geometry_as_gml"; | ||
295 | + } | ||
296 | + } | ||
297 | + else if (typeString == "integer") | ||
298 | + { | ||
299 | + typeInt = PGFieldType::BigIntFieldType; | ||
300 | + fields_str += " \"" + (fieldname) + "\"::varchar "; | ||
301 | + } | ||
302 | + else if (typeString == "bigint") | ||
303 | + { | ||
304 | + typeInt = PGFieldType::BigIntFieldType; | ||
305 | + fields_str += " \"" + (fieldname) + "\"::varchar "; | ||
306 | + } | ||
307 | + else if (typeString == "double precision" || typeString == "real" || typeString == "numeric") | ||
308 | + { | ||
309 | + typeInt = PGFieldType::DoubleFieldType; | ||
310 | + fields_str += " \"" + (fieldname) + "\"::varchar "; | ||
311 | + } | ||
312 | + else if (typeString == "character varying" || typeString == "text") | ||
313 | + { | ||
314 | + typeInt = PGFieldType::VarCharFieldType; | ||
315 | + fields_str += " \"" + (fieldname) + "\" "; | ||
316 | + } | ||
317 | + else if (typeString == "bytea") | ||
318 | + { | ||
319 | + continue; | ||
320 | + } | ||
321 | + else if (typeString == "timestamp without time zone") | ||
322 | + { | ||
323 | + fields_str += " \"" + (fieldname) + "\"::varchar "; | ||
324 | + } | ||
325 | + } | ||
326 | + } | ||
327 | + } | ||
328 | + else | ||
329 | + { | ||
330 | + fields_str = " * "; | ||
331 | + } | ||
332 | + | ||
333 | + strOut = fields_str; | ||
334 | + | ||
335 | + return true; | ||
336 | + } | ||
234 | } | 337 | } |
@@ -19,6 +19,7 @@ | @@ -19,6 +19,7 @@ | ||
19 | #include "dmpwfsparameters.h" | 19 | #include "dmpwfsparameters.h" |
20 | #include "dmpservercontext.h" | 20 | #include "dmpservercontext.h" |
21 | #include "dmppgsqlsourcepools.h" | 21 | #include "dmppgsqlsourcepools.h" |
22 | +#include "dmpvectorlayer.h" | ||
22 | #include "dmpgmlfilter.h" | 23 | #include "dmpgmlfilter.h" |
23 | using namespace mapserver; | 24 | using namespace mapserver; |
24 | namespace DmpWfs | 25 | namespace DmpWfs |
@@ -34,6 +35,8 @@ namespace DmpWfs | @@ -34,6 +35,8 @@ namespace DmpWfs | ||
34 | 35 | ||
35 | void getAsStringSql(const string& str,std::string &sProp,std::string &sAs); | 36 | void getAsStringSql(const string& str,std::string &sProp,std::string &sAs); |
36 | 37 | ||
38 | + bool GetAllField(std::string &strOut,DmpVectorLayer* mapLayer,shared_ptr<DmpPgsql> pPgsqlConn, DmpWfsParameters::Format format); | ||
39 | + | ||
37 | } | 40 | } |
38 | 41 | ||
39 | #endif // __dmpwfsgetfeature_h__ | 42 | #endif // __dmpwfsgetfeature_h__ |
@@ -170,11 +170,23 @@ namespace DmpWfs | @@ -170,11 +170,23 @@ namespace DmpWfs | ||
170 | return value; | 170 | return value; |
171 | } | 171 | } |
172 | 172 | ||
173 | - std::string DmpWfsParameters::ResultType() const //要素ID | 173 | + DmpWfsParameters::Format DmpWfsParameters::ResultType() const |
174 | { | 174 | { |
175 | std::string value = ""; | 175 | std::string value = ""; |
176 | GetStringParameter("RESULTTYPE",value); | 176 | GetStringParameter("RESULTTYPE",value); |
177 | - return value; | 177 | + if (value.empty()) { |
178 | + GetStringParameter("FORMAT",value); | ||
179 | + } | ||
180 | + if (value.empty()) { | ||
181 | + return DmpWfsParameters::Format::GML3; | ||
182 | + } | ||
183 | + | ||
184 | + Format f = Format::GML3; | ||
185 | + boost::to_lower(value); | ||
186 | + if (value.compare("geojson") == 0 || value.compare("json") == 0 ) { | ||
187 | + f = DmpWfsParameters::Format::GeoJson; | ||
188 | + } | ||
189 | + return f; | ||
178 | } | 190 | } |
179 | 191 | ||
180 | } | 192 | } |
@@ -51,7 +51,7 @@ namespace DmpWfs | @@ -51,7 +51,7 @@ namespace DmpWfs | ||
51 | std::string PropertyName() const; //指定返回的要素属性,没有指定不返回 | 51 | std::string PropertyName() const; //指定返回的要素属性,没有指定不返回 |
52 | std::string SrsName() const; //空间参考坐标 | 52 | std::string SrsName() const; //空间参考坐标 |
53 | std::string FeatureID() const; //要素ID | 53 | std::string FeatureID() const; //要素ID |
54 | - std::string ResultType() const; | 54 | + DmpWfsParameters::Format ResultType() const; |
55 | 55 | ||
56 | //std::string Expiry(); | 56 | //std::string Expiry(); |
57 | 57 |
@@ -19,6 +19,8 @@ | @@ -19,6 +19,8 @@ | ||
19 | #include "dmplogger.h" | 19 | #include "dmplogger.h" |
20 | #include "dmpwmsgetcapabilities.h" | 20 | #include "dmpwmsgetcapabilities.h" |
21 | #include "dmpwmsgetmap.h" | 21 | #include "dmpwmsgetmap.h" |
22 | +#include "dmpwmsserviceinfo.h" | ||
23 | +#include "dmpwmsgetfeatureinfo.h" | ||
22 | using namespace std; | 24 | using namespace std; |
23 | 25 | ||
24 | namespace DmpWms | 26 | namespace DmpWms |
@@ -56,8 +58,12 @@ namespace DmpWms | @@ -56,8 +58,12 @@ namespace DmpWms | ||
56 | } | 58 | } |
57 | else if(boost::iequals(request, "getfeatureinfo")) | 59 | else if(boost::iequals(request, "getfeatureinfo")) |
58 | { | 60 | { |
59 | - | 61 | + writeFeatureInfo(context,params, project); |
60 | } | 62 | } |
63 | + else if(boost::iequals(request, "getserviceinfo")) | ||
64 | + { | ||
65 | + writeGetServiceInfo(context,params, project); | ||
66 | + } | ||
61 | else if(request == "getlegendgraphic") | 67 | else if(request == "getlegendgraphic") |
62 | { | 68 | { |
63 | 69 |
@@ -63,7 +63,7 @@ namespace DmpWms | @@ -63,7 +63,7 @@ namespace DmpWms | ||
63 | DmpWms::DmpWmsRenderer mapRenderer(height, width); | 63 | DmpWms::DmpWmsRenderer mapRenderer(height, width); |
64 | 64 | ||
65 | std::string layers = params.Layers(); | 65 | std::string layers = params.Layers(); |
66 | - if (layers !="") | 66 | + if (layers =="") |
67 | { | 67 | { |
68 | mapRenderer.AddWmsMapLayers(project); | 68 | mapRenderer.AddWmsMapLayers(project); |
69 | } | 69 | } |
1 | +/************************************************************************** | ||
2 | +* file: dmpwmsserviceinfo.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-11 14:05:33 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpwmsserviceinfo.h" | ||
10 | +#include "dmpserverresponse.h" | ||
11 | +#include "dmpserverrequest.h" | ||
12 | +#include "dmpserverproject.h" | ||
13 | + | ||
14 | +namespace DmpWms | ||
15 | +{ | ||
16 | + void writeGetServiceInfo(const DmpServerContext &context, const DmpWmsParameters ¶ms, | ||
17 | + const DmpProject *project, | ||
18 | + bool projectSettings) | ||
19 | + { | ||
20 | + boost::property_tree::ptree xmlRoot; | ||
21 | + | ||
22 | + std::string name = context.serverProject()->name(); | ||
23 | + std::string title = context.serverProject()->title(); | ||
24 | + | ||
25 | + boost::property_tree::ptree ptRoot; | ||
26 | + | ||
27 | + addServiceInfoLayers(ptRoot,project,name,title); | ||
28 | + | ||
29 | + | ||
30 | + std::stringstream stream; | ||
31 | + write_json(stream, ptRoot); | ||
32 | + std::string json; | ||
33 | + json = stream.str(); | ||
34 | + | ||
35 | + context.response()->writeJson(json); | ||
36 | + } | ||
37 | + | ||
38 | + void addServiceInfoLayers(boost::property_tree::ptree &pt,const DmpProject* project, std::string& name, std::string& title) | ||
39 | + { | ||
40 | + std::string srs = "EPSG:" + std::__cxx11::to_string(project->crs().srid()); | ||
41 | + | ||
42 | + boost::property_tree::ptree ptProject; | ||
43 | + // ptProject.add("<xmlattr>.queryable","1"); | ||
44 | + ptProject.add("Name", name); | ||
45 | + ptProject.add("Title", title); | ||
46 | + ptProject.add("CRS", srs); | ||
47 | + | ||
48 | + double minx,miny,maxx,maxy; | ||
49 | + int i =0; | ||
50 | + std::map<std::string, DmpMapLayer*> mapLayers = project->mapLayers(); | ||
51 | + for (std::map<std::string, DmpMapLayer*>::iterator iter = mapLayers.begin();iter != mapLayers.end(); iter++) | ||
52 | + { | ||
53 | + DmpMapLayer* layer = iter->second; | ||
54 | + if(i ==0) | ||
55 | + { | ||
56 | + minx = layer->extent().xmin(); | ||
57 | + miny = layer->extent().ymin(); | ||
58 | + maxx = layer->extent().xmax(); | ||
59 | + maxy = layer->extent().ymax(); | ||
60 | + } | ||
61 | + else | ||
62 | + { | ||
63 | + if(minx > layer->extent().xmin()) minx = layer->extent().xmin(); | ||
64 | + if(miny > layer->extent().ymin()) miny = layer->extent().ymin(); | ||
65 | + if(maxx < layer->extent().xmax()) maxx = layer->extent().xmax(); | ||
66 | + if(maxy < layer->extent().ymax()) maxy = layer->extent().ymax(); | ||
67 | + } | ||
68 | + i++; | ||
69 | + } | ||
70 | + | ||
71 | + boost::property_tree::ptree ptGeographicBoundingbox; | ||
72 | + ptGeographicBoundingbox.add("westBoundLongitude", minx); | ||
73 | + ptGeographicBoundingbox.add("eastBoundLongitude", maxx); | ||
74 | + ptGeographicBoundingbox.add("southBoundLatitude", miny); | ||
75 | + ptGeographicBoundingbox.add("northBoundLatitude", maxy); | ||
76 | + ptProject.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox); | ||
77 | + | ||
78 | + boost::property_tree::ptree ptLayers; | ||
79 | + for (std::map<std::string, DmpMapLayer*>::iterator iter= mapLayers.begin();iter != mapLayers.end(); iter++) | ||
80 | + { | ||
81 | + DmpMapLayer* layer = iter->second; | ||
82 | + addServiceInfoLayer(ptLayers,(DmpVectorLayer *)layer,srs); | ||
83 | + } | ||
84 | + ptProject.add_child("Layers",ptLayers); | ||
85 | + pt.add_child("Service", ptProject); | ||
86 | + } | ||
87 | + | ||
88 | + void addServiceInfoLayer(boost::property_tree::ptree &pt, DmpVectorLayer* layer, const std::string& srs) | ||
89 | + { | ||
90 | + boost::property_tree::ptree ptLayer; | ||
91 | + ptLayer.add("Name", layer->name()); | ||
92 | + ptLayer.add("Title", layer->title()); | ||
93 | + ptLayer.add("CRS", srs); | ||
94 | + ptLayer.add("Type", layer->GeomTypeString()); | ||
95 | + | ||
96 | + boost::property_tree::ptree ptGeographicBoundingbox; | ||
97 | + ptGeographicBoundingbox.add("westBoundLongitude", layer->extent().xmin()); | ||
98 | + ptGeographicBoundingbox.add("eastBoundLongitude", layer->extent().xmax()); | ||
99 | + ptGeographicBoundingbox.add("southBoundLatitude", layer->extent().ymin()); | ||
100 | + ptGeographicBoundingbox.add("northBoundLatitude", layer->extent().ymax()); | ||
101 | + ptLayer.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox); | ||
102 | + pt.push_back(std::make_pair("", ptLayer)); | ||
103 | + //pt.add_child("Layer", ptLayer); | ||
104 | + } | ||
105 | + | ||
106 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpwmsserviceinfo.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-11 14:05:38 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpwmsserviceinfo_h__ | ||
11 | +#define __dmpwmsserviceinfo_h__ | ||
12 | +#include <boost/property_tree/ptree.hpp> | ||
13 | +#include <boost/property_tree/json_parser.hpp> | ||
14 | +#include <boost/typeof/typeof.hpp> | ||
15 | +#include <memory> | ||
16 | +#include <vector> | ||
17 | +#include "dmpproject.h" | ||
18 | +#include "dmpwmsgetmap.h" | ||
19 | +#include "dmpservercontext.h" | ||
20 | +#include "dmpvectorlayer.h" | ||
21 | +namespace DmpWms | ||
22 | +{ | ||
23 | + | ||
24 | + | ||
25 | + /** | ||
26 | + * Output GetServiceInfo response | ||
27 | + */ | ||
28 | + void writeGetServiceInfo( const DmpServerContext &context,const DmpWmsParameters& params, | ||
29 | + const DmpProject* project, | ||
30 | + bool projectSettings = false); | ||
31 | + | ||
32 | + void addServiceInfoLayers(boost::property_tree::ptree &pt,const DmpProject* project,std::string& name, std::string& title); | ||
33 | + | ||
34 | + void addServiceInfoLayer(boost::property_tree::ptree &pt,DmpVectorLayer* layer,const std::string& srs); | ||
35 | +} | ||
36 | + | ||
37 | + | ||
38 | +#endif // __dmpwmsserviceinfo_h__ |
请
注册
或
登录
后发表评论