正在显示
8 个修改的文件
包含
673 行增加
和
3 行删除
@@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
14 | #include <boost/typeof/typeof.hpp> | 14 | #include <boost/typeof/typeof.hpp> |
15 | #include "dmpproject.h" | 15 | #include "dmpproject.h" |
16 | #include "dmptilelayer.h" | 16 | #include "dmptilelayer.h" |
17 | - | 17 | +#include "dmpvectorlayer.h" |
18 | using namespace boost::property_tree; | 18 | using namespace boost::property_tree; |
19 | DmpProject *DmpProject::project_ = nullptr; | 19 | DmpProject *DmpProject::project_ = nullptr; |
20 | 20 | ||
@@ -84,6 +84,7 @@ bool DmpProject::Read(const std::string &data) | @@ -84,6 +84,7 @@ bool DmpProject::Read(const std::string &data) | ||
84 | else if (layerType == 1) | 84 | else if (layerType == 1) |
85 | { | 85 | { |
86 | //vector | 86 | //vector |
87 | + mapLayer = new DmpVectorLayer(); | ||
87 | } | 88 | } |
88 | else if (layerType == 2) | 89 | else if (layerType == 2) |
89 | { | 90 | { |
@@ -8,6 +8,10 @@ SET (MAPSERVER_SRCS | @@ -8,6 +8,10 @@ SET (MAPSERVER_SRCS | ||
8 | dmppgsql.cpp | 8 | dmppgsql.cpp |
9 | dmppgsqlpool.cpp | 9 | dmppgsqlpool.cpp |
10 | dmppgsqlsourcepools.cpp | 10 | dmppgsqlsourcepools.cpp |
11 | + wfs/dmpwfs.cpp | ||
12 | + wfs/dmpwfsgetcapabilities.cpp | ||
13 | + wfs/dmpwfsgetfeature.cpp | ||
14 | + wfs/dmpwfsparameters.cpp | ||
11 | wms/dmpwmsrenderer.cpp | 15 | wms/dmpwmsrenderer.cpp |
12 | wms/dmpwms.cpp | 16 | wms/dmpwms.cpp |
13 | wms/dmpwmsparameters.cpp | 17 | wms/dmpwmsparameters.cpp |
@@ -22,6 +26,9 @@ SET (MAPSERVER_HDRS | @@ -22,6 +26,9 @@ SET (MAPSERVER_HDRS | ||
22 | dmppgsql.h | 26 | dmppgsql.h |
23 | dmppgsqlpool.h | 27 | dmppgsqlpool.h |
24 | dmppgsqlsourcepools.h | 28 | dmppgsqlsourcepools.h |
29 | + wfs/dmpwfsgetcapabilities.h | ||
30 | + wfs/dmpwfsgetfeature.h | ||
31 | + wfs/dmpwfsparameters.h | ||
25 | wms/dmpwmsrenderer.h | 32 | wms/dmpwmsrenderer.h |
26 | wms/dmpwms.h | 33 | wms/dmpwms.h |
27 | wms/dmpwmsparameters.h | 34 | wms/dmpwmsparameters.h |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | 10 | ||
11 | - #include <string> | 11 | +#include <string> |
12 | #include "dmpmodule.h" | 12 | #include "dmpmodule.h" |
13 | #include <boost/dll/alias.hpp> // for BOOST_DLL_ALIAS | 13 | #include <boost/dll/alias.hpp> // for BOOST_DLL_ALIAS |
14 | #include <boost/filesystem.hpp> | 14 | #include <boost/filesystem.hpp> |
@@ -51,7 +51,11 @@ namespace DmpWfs | @@ -51,7 +51,11 @@ namespace DmpWfs | ||
51 | 51 | ||
52 | }; | 52 | }; |
53 | 53 | ||
54 | - | 54 | + //实际中,WebGIS服务器针对这些功能并不是必须全部实现,而是实现全部或部分。 |
55 | + //因此,根据依据这些功能的支持与否,可以将WFS分为3类: | ||
56 | + //Basic WFS —— 必须支持GetCapabilities、DescribeFeature Type、GetFeature功能 | ||
57 | + //XLink WFS —— 必须在Basic WFS基础上加上GetGmlObject操作 | ||
58 | + //Transaction WFS —— 也称为WFS-T,必须在Basic WFS基础上加上Transaction功能以及支持编辑数据,另外也可以加上GetGmlObject或LockFeature功能 | ||
55 | class DmpWfsModule : public DmpServiceModule | 59 | class DmpWfsModule : public DmpServiceModule |
56 | { | 60 | { |
57 | public: | 61 | public: |
1 | +/************************************************************************** | ||
2 | +* file: dmpwfsgetcapabilities.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-22 14:04:56 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpwfsgetcapabilities.h" | ||
10 | +#include "dmpserverresponse.h" | ||
11 | +#include "dmpserverrequest.h" | ||
12 | +#include "dmpserverproject.h" | ||
13 | +#include "dmpvectorlayer.h" | ||
14 | + | ||
15 | + | ||
16 | +namespace DmpWfs | ||
17 | +{ | ||
18 | + void writeGetCapabilities( const DmpServerContext &context, const DmpWfsParameters& params, | ||
19 | + const DmpProject* project, bool projectSettings) | ||
20 | + { | ||
21 | + std::string serviceName = context.serverProject()->name(); | ||
22 | + std::string serviceTitle = context.serverProject()->title(); | ||
23 | + if(serviceTitle.empty()) serviceTitle = serviceName; | ||
24 | + | ||
25 | + std::string version = params.Version(); | ||
26 | + std::string hrefUrl; | ||
27 | + char char_hrefUrl[1024] = {0}; | ||
28 | + std::string domain = context.request()->domain(); | ||
29 | + std::string port = context.request()->port(); | ||
30 | + if(port == "80" || port =="") | ||
31 | + { | ||
32 | + sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->path().c_str()); | ||
33 | + } | ||
34 | + else | ||
35 | + { | ||
36 | + sprintf(char_hrefUrl, "http://%s:%s%s", domain.c_str(),port.c_str(), context.request()->path().c_str()); | ||
37 | + } | ||
38 | + hrefUrl = char_hrefUrl; | ||
39 | + // hrefUrl = "http://172.26.40.51:8821/?mapService=test"; | ||
40 | + std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, version,hrefUrl,serviceName,serviceTitle,projectSettings); | ||
41 | + | ||
42 | + std::stringstream stream; | ||
43 | + write_xml(stream, *doc.get()); | ||
44 | + std::string xml; | ||
45 | + xml = stream.str(); | ||
46 | + | ||
47 | + // DmpServerResponse* response = context.response(); | ||
48 | + context.response()->removeHeader("Content-Type"); | ||
49 | + context.response()->setHeader("Content-Type", "text/xml;charset=utf-8"); | ||
50 | + context.response()->write(xml); | ||
51 | + } | ||
52 | + | ||
53 | + | ||
54 | + std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, | ||
55 | + const std::string &serviceName, const std::string &serviceTitle, | ||
56 | + const std::string &version, const std::string &hrefUrl, | ||
57 | + bool projectSettings ) | ||
58 | + { | ||
59 | + std::shared_ptr<boost::property_tree::ptree> xmlRootDoc(new boost::property_tree::ptree()); | ||
60 | + boost::property_tree::ptree xmlRoot; | ||
61 | + std::string rootname; | ||
62 | + | ||
63 | + rootname = "WFS_Capabilities"; | ||
64 | + xmlRoot.add("<xmlattr>.xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance"); | ||
65 | + xmlRoot.add("<xmlattr>.xmlns","http://www.opengis.net/wfs"); | ||
66 | + xmlRoot.add("<xmlattr>.xmlns:sld","http://www.opengis.net/sld"); | ||
67 | + xmlRoot.add("<xmlattr>.xsi:schemaLocation","http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd"); | ||
68 | + xmlRoot.add("<xmlattr>.version", version); | ||
69 | + xmlRoot.add("<xmlattr>.updateSequence", "0"); | ||
70 | + | ||
71 | + boost::property_tree::ptree ptService; | ||
72 | + ptService.add("Name", serviceName); | ||
73 | + ptService.add("Title", serviceTitle); | ||
74 | + ptService.add("Abstract", "dmap wfs service"); | ||
75 | + ptService.add("Keywords", "WFS,DMAP,"+ serviceName ); | ||
76 | + ptService.add("OnlineResource", hrefUrl); | ||
77 | + ptService.add("Fees","none"); | ||
78 | + ptService.add("AccessConstraints","none"); | ||
79 | + xmlRoot.add_child("Service",ptService); | ||
80 | + | ||
81 | + boost::property_tree::ptree ptCapability; | ||
82 | + addCapabilitiesRequest(ptCapability,hrefUrl); | ||
83 | + xmlRoot.add_child("Capability",ptCapability); | ||
84 | + | ||
85 | + boost::property_tree::ptree ptFeatureTypeList; | ||
86 | + addFeatureTypeList(ptFeatureTypeList,project); | ||
87 | + xmlRoot.add_child("FeatureTypeList",ptFeatureTypeList); | ||
88 | + | ||
89 | + boost::property_tree::ptree ptFilter; | ||
90 | + addFilterCapabilities(ptFilter,hrefUrl); | ||
91 | + xmlRoot.add_child("ogc:Filter_Capabilities",ptFilter); | ||
92 | + | ||
93 | + xmlRootDoc->add_child(rootname,xmlRoot); | ||
94 | + return xmlRootDoc; | ||
95 | + | ||
96 | + } | ||
97 | + | ||
98 | + void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl) | ||
99 | + { | ||
100 | + boost::property_tree::ptree ptRequest; | ||
101 | + | ||
102 | + boost::property_tree::ptree ptGetCapabilities; | ||
103 | + addCapabilitiesRequest_DCPType(ptGetCapabilities, hrefUrl, "Get"); | ||
104 | + addCapabilitiesRequest_DCPType(ptGetCapabilities, hrefUrl, "Post"); | ||
105 | + ptRequest.add_child("GetCapabilities", ptGetCapabilities); | ||
106 | + | ||
107 | + boost::property_tree::ptree ptDescribeFeatureType; | ||
108 | + boost::property_tree::ptree ptSchemaDescriptionLanguage; | ||
109 | + ptSchemaDescriptionLanguage.add("XMLSCHEMA",""); | ||
110 | + ptDescribeFeatureType.add_child("SchemaDescriptionLanguage",ptSchemaDescriptionLanguage); | ||
111 | + addCapabilitiesRequest_DCPType(ptDescribeFeatureType, hrefUrl, "Get"); | ||
112 | + addCapabilitiesRequest_DCPType(ptDescribeFeatureType, hrefUrl, "Post"); | ||
113 | + ptRequest.add_child("DescribeFeatureType", ptDescribeFeatureType); | ||
114 | + | ||
115 | + boost::property_tree::ptree ptGetFeature; | ||
116 | + boost::property_tree::ptree ptResultFormat; | ||
117 | + ptResultFormat.add("GML2",""); | ||
118 | + ptResultFormat.add("GML3",""); | ||
119 | + ptResultFormat.add("GeoJSON",""); | ||
120 | + ptGetFeature.add_child("ResultFormat",ptResultFormat); | ||
121 | + addCapabilitiesRequest_DCPType(ptGetFeature, hrefUrl, "Get"); | ||
122 | + addCapabilitiesRequest_DCPType(ptGetFeature, hrefUrl, "Post"); | ||
123 | + ptRequest.add_child("GetFeature", ptGetFeature); | ||
124 | + | ||
125 | + boost::property_tree::ptree ptTransaction; | ||
126 | + addCapabilitiesRequest_DCPType(ptTransaction, hrefUrl, "Post"); | ||
127 | + ptRequest.add_child("Transaction", ptTransaction); | ||
128 | + | ||
129 | + pt.add_child("Request", ptRequest); | ||
130 | + return; | ||
131 | + } | ||
132 | + | ||
133 | + void addCapabilitiesRequest_DCPType(boost::property_tree::ptree &pt, const std::string &hrefUrl, std::string method) | ||
134 | + { | ||
135 | + boost::property_tree::ptree pt_dcpType; | ||
136 | + boost::property_tree::ptree pt_http; | ||
137 | + boost::property_tree::ptree pt_method; | ||
138 | + | ||
139 | + pt_method.add("<xmlattr>.onlineResource", hrefUrl); | ||
140 | + | ||
141 | + pt_http.add_child(method, pt_method); | ||
142 | + pt_dcpType.add_child("HTTP", pt_http); | ||
143 | + pt.add_child("DCPType", pt_dcpType); | ||
144 | + } | ||
145 | + | ||
146 | + void addFeatureTypeList(boost::property_tree::ptree &pt,const DmpProject *project) | ||
147 | + { | ||
148 | + boost::property_tree::ptree ptOperations; | ||
149 | + ptOperations.add("Query",""); | ||
150 | + pt.add_child("Operations", ptOperations); | ||
151 | + | ||
152 | + int i = 0; | ||
153 | + std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers(); | ||
154 | + for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++, i++) | ||
155 | + { | ||
156 | + DmpVectorLayer *layer = (DmpVectorLayer *)iter->second; | ||
157 | + std::string source = layer->source(); | ||
158 | + shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source()); | ||
159 | + if (pPgsqlConn != nullptr) | ||
160 | + { | ||
161 | + boost::property_tree::ptree ptFeatureType; | ||
162 | + std::string srs = "EPSG:" + std::__cxx11::to_string(project->crs().srid()); | ||
163 | + ptFeatureType.add("<xmlattr>.id", i); | ||
164 | + ptFeatureType.add("Name", layer->name()); | ||
165 | + ptFeatureType.add("Title", layer->title()); | ||
166 | + ptFeatureType.add("DisplayColumn", ""); | ||
167 | + ptFeatureType.add("Geometry", "点"); | ||
168 | + ptFeatureType.add("GeometryColumn", layer->geom()); | ||
169 | + ptFeatureType.add("SRS", srs); | ||
170 | + | ||
171 | + boost::property_tree::ptree ptBoundingbox; | ||
172 | + ptBoundingbox.add("<xmlattr>.CRS", srs); | ||
173 | + if (boost::iequals(srs, "CRS:84") || boost::iequals(srs, "EPSG:4326")) | ||
174 | + { | ||
175 | + ptBoundingbox.add("<xmlattr>.miny", layer->extent().xmin()); | ||
176 | + ptBoundingbox.add("<xmlattr>.maxy", layer->extent().xmax()); | ||
177 | + ptBoundingbox.add("<xmlattr>.minx", layer->extent().ymin()); | ||
178 | + ptBoundingbox.add("<xmlattr>.maxx", layer->extent().ymax()); | ||
179 | + } | ||
180 | + else | ||
181 | + { | ||
182 | + ptBoundingbox.add("<xmlattr>.minx", layer->extent().xmin()); | ||
183 | + ptBoundingbox.add("<xmlattr>.maxx", layer->extent().xmax()); | ||
184 | + ptBoundingbox.add("<xmlattr>.miny", layer->extent().ymin()); | ||
185 | + ptBoundingbox.add("<xmlattr>.maxy", layer->extent().ymax()); | ||
186 | + } | ||
187 | + ptFeatureType.add_child("LatLongBoundingBox", ptBoundingbox); | ||
188 | + | ||
189 | + boost::property_tree::ptree ptFields; | ||
190 | + for (; pPgsqlConn->next();) | ||
191 | + { | ||
192 | + std::string fieldname = pPgsqlConn->getString(0); | ||
193 | + std::string typeString = pPgsqlConn->getString(1); | ||
194 | + std::string aliasName = ""; | ||
195 | + std::string type = ""; | ||
196 | + int typeInt = PGFieldType::VarCharFieldType; | ||
197 | + if (layer->geom() == fieldname) | ||
198 | + { | ||
199 | + typeString = "geometry"; | ||
200 | + typeInt = PGFieldType::ShapeFieldType; | ||
201 | + } | ||
202 | + else if (typeString == "integer") | ||
203 | + { | ||
204 | + typeInt = PGFieldType::IntFieldType; | ||
205 | + } | ||
206 | + else if (typeString == "bigint") | ||
207 | + { | ||
208 | + typeInt = PGFieldType::BigIntFieldType; | ||
209 | + } | ||
210 | + else if (typeString == "double precision" || typeString == "real" || typeString == "numeric") | ||
211 | + { | ||
212 | + typeInt = PGFieldType::DoubleFieldType; | ||
213 | + } | ||
214 | + else if (typeString == "character varying" || typeString == "text") | ||
215 | + { | ||
216 | + typeInt = PGFieldType::VarCharFieldType; | ||
217 | + } | ||
218 | + else if (typeString == "geometry") | ||
219 | + { | ||
220 | + typeInt = PGFieldType::ShapeFieldType; | ||
221 | + } | ||
222 | + else if (typeString == "bytea") | ||
223 | + { | ||
224 | + typeInt = PGFieldType::ByteaFieldType; | ||
225 | + } | ||
226 | + else if (typeString == "timestamp without time zone") | ||
227 | + { | ||
228 | + typeInt = PGFieldType::TimestampWithoutTimeZone; | ||
229 | + } | ||
230 | + | ||
231 | + switch (typeInt) | ||
232 | + { | ||
233 | + case PGFieldType::IntFieldType: | ||
234 | + typeString = "integer"; | ||
235 | + break; | ||
236 | + case PGFieldType::BigIntFieldType: | ||
237 | + case PGFieldType::DoubleFieldType: | ||
238 | + typeString = "double"; | ||
239 | + break; | ||
240 | + case PGFieldType::VarCharFieldType: | ||
241 | + typeString = "string"; | ||
242 | + break; | ||
243 | + default: | ||
244 | + break; | ||
245 | + } | ||
246 | + boost::property_tree::ptree ptField; | ||
247 | + ptField.add("<xmlattr>.name", fieldname); | ||
248 | + ptField.add("<xmlattr>.aliasName", aliasName); | ||
249 | + ptField.add("<xmlattr>.type", "xsd:" + typeString); | ||
250 | + ptField.add("<xmlattr>.minOccurs", "0"); | ||
251 | + ptField.add("<xmlattr>.maxOccurs", "1"); | ||
252 | + ptFields.add_child("Field", ptField); | ||
253 | + } | ||
254 | + ptFeatureType.add_child("Fields", ptFields); | ||
255 | + pt.add_child("FeatureType", ptFeatureType); | ||
256 | + } | ||
257 | + | ||
258 | + } | ||
259 | + } | ||
260 | + | ||
261 | + | ||
262 | + void addFilterCapabilities(boost::property_tree::ptree &pt,const std::string &hrefUrl) | ||
263 | + { | ||
264 | + boost::property_tree::ptree ptFilterCapabilities; | ||
265 | + | ||
266 | + boost::property_tree::ptree ptSpatialCapabilities; | ||
267 | + boost::property_tree::ptree ptSpatialOperators; | ||
268 | + ptSpatialOperators.add("ogc:BBOX",""); | ||
269 | + ptSpatialCapabilities.add_child("ogc:Spatial_Operators",ptSpatialOperators); | ||
270 | + ptFilterCapabilities.add_child("ogc:Spatial_Capabilities", ptSpatialCapabilities); | ||
271 | + | ||
272 | + | ||
273 | + boost::property_tree::ptree ptScalarCapabilities; | ||
274 | + boost::property_tree::ptree ptComparisonOperators; | ||
275 | + ptComparisonOperators.add("ogc:Simple_Comparisons",""); | ||
276 | + ptScalarCapabilities.add_child("ogc:Comparison_Operators",ptComparisonOperators); | ||
277 | + ptFilterCapabilities.add_child("ogc:Filter_Capabilities", ptScalarCapabilities); | ||
278 | + | ||
279 | + pt.add_child("ogc:Filter_Capabilities", ptFilterCapabilities); | ||
280 | + } | ||
281 | + | ||
282 | + | ||
283 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpwfsgetcapabilities.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-22 13:59:41 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpwfsgetcapabilities_h__ | ||
11 | +#define __dmpwfsgetcapabilities_h__ | ||
12 | + | ||
13 | +#include <boost/property_tree/ptree.hpp> | ||
14 | +#include <boost/property_tree/xml_parser.hpp> | ||
15 | +#include <boost/typeof/typeof.hpp> | ||
16 | +#include <memory> | ||
17 | +#include <vector> | ||
18 | +#include "dmpproject.h" | ||
19 | +#include "dmpwfsparameters.h" | ||
20 | +#include "dmpservercontext.h" | ||
21 | +#include "dmppgsqlsourcepools.h" | ||
22 | + | ||
23 | +using namespace mapserver; | ||
24 | +namespace DmpWfs | ||
25 | +{ | ||
26 | + | ||
27 | + /** | ||
28 | + * Output GetCapabilities response | ||
29 | + */ | ||
30 | + void writeGetCapabilities( const DmpServerContext &context,const DmpWfsParameters& params, | ||
31 | + const DmpProject* project, | ||
32 | + bool projectSettings = false); | ||
33 | + | ||
34 | + /** | ||
35 | + * Creates the WMS GetCapabilities XML document. | ||
36 | + * \param serverIface Interface for plugins | ||
37 | + * \param project Project | ||
38 | + * \param version WMS version | ||
39 | + * \param request WMS request | ||
40 | + * \param projectSettings If TRUE, adds extended project information (does not validate against WMS schema) | ||
41 | + * \returns GetCapabilities XML document | ||
42 | + */ | ||
43 | + std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, | ||
44 | + const std::string &serviceName, const std::string &serviceTitle, | ||
45 | + const std::string &version, const std::string &hrefUrl, | ||
46 | + bool projectSettings ); | ||
47 | + | ||
48 | + void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl); | ||
49 | + | ||
50 | + void addCapabilitiesRequest_DCPType(boost::property_tree::ptree &pt, const std::string &hrefUrl, std::string method); | ||
51 | + | ||
52 | + void addFeatureTypeList(boost::property_tree::ptree &pt,const DmpProject* project); | ||
53 | + | ||
54 | + void addFilterCapabilities(boost::property_tree::ptree &pt,const std::string &hrefUrl); | ||
55 | + | ||
56 | +} | ||
57 | + | ||
58 | + | ||
59 | +#endif // __dmpwfsgetcapabilities_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpwfsgetfeature.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-24 10:57:55 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpwfsgetfeature.h" | ||
10 | +namespace DmpWfs | ||
11 | +{ | ||
12 | + void writeGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
13 | + const DmpProject* project, | ||
14 | + bool projectSettings) | ||
15 | + { | ||
16 | + | ||
17 | + } | ||
18 | + | ||
19 | + std::string WfsGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
20 | + const DmpProject* project, | ||
21 | + bool projectSettings) | ||
22 | + { | ||
23 | + char buff[5000]; | ||
24 | + return ""; | ||
25 | + // SqlFactory sqlF; | ||
26 | + | ||
27 | + /*shared_ptr<WMSServer> service = _dmapWms.GetWmsService(parseString.mapService); | ||
28 | + if(service == nullptr) | ||
29 | + { | ||
30 | + return false; | ||
31 | + } | ||
32 | + | ||
33 | + sqlF.SetStartIndexCount(parseString.startIndex, parseString.maxFeatures, parseString.resulttype); | ||
34 | + std::vector<std::string> ids; | ||
35 | + if (parseString.featureid) | ||
36 | + { | ||
37 | + char *idstring[1000]; | ||
38 | + //将ID值以逗号分开,并返回个数 | ||
39 | + int idn = StringHelp::ParseStringTok(parseString.featureid, ',', idstring, 1000); | ||
40 | + for (int i = 0; i < idn; i++) | ||
41 | + { | ||
42 | + char *ss[2]; | ||
43 | + //形式:LayerName.ID | ||
44 | + int n = StringHelp::ParseStringTok(idstring[i], '.', ss, 2); | ||
45 | + if (n == 2) | ||
46 | + { | ||
47 | + if (parseString.layerName == 0) | ||
48 | + { | ||
49 | + parseString.layerName = ss[0]; | ||
50 | + } | ||
51 | + ids.push_back(ss[1]); | ||
52 | + } | ||
53 | + else if (n == 1) | ||
54 | + { | ||
55 | + ids.push_back(ss[0]); | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + std::vector<std::string> props; | ||
61 | + std::vector<std::string> propsAs; | ||
62 | + if (parseString.propertyname) | ||
63 | + { | ||
64 | + char *idstring[1000]; | ||
65 | + int idn = StringHelp::ParseStringTok(parseString.propertyname, ',', idstring, 1000); | ||
66 | + for (int i = 0; i < idn; i++) | ||
67 | + { | ||
68 | + char *ss[2]; | ||
69 | + std::string sProp, sPropAs; | ||
70 | + int n = StringHelp::ParseStringTok(idstring[i], '.', ss, 2); | ||
71 | + if (n == 2) | ||
72 | + { | ||
73 | + if (parseString.layerName == 0) | ||
74 | + { | ||
75 | + parseString.layerName = ss[0]; | ||
76 | + } | ||
77 | + //又以空格分开 | ||
78 | + StringHelp::GetAsStringSql(ss[1], sProp, sPropAs); | ||
79 | + props.push_back(sProp); | ||
80 | + propsAs.push_back(sPropAs); | ||
81 | + //sPropOrig=ss[1]; | ||
82 | + } | ||
83 | + else if (n == 1) | ||
84 | + { | ||
85 | + StringHelp::GetAsStringSql(ss[0], sProp, sPropAs); | ||
86 | + props.push_back(sProp); | ||
87 | + propsAs.push_back(sPropAs); //props.push_back(ss[0]); | ||
88 | + } | ||
89 | + } | ||
90 | + } | ||
91 | + | ||
92 | + if (parseString.layerName == 0) | ||
93 | + return Error(buff, ErrorClass::ParaError, "layername not exist", ab); | ||
94 | + | ||
95 | + //const char *realLayer=0; | ||
96 | + //GetUpLayerID是干什么的? | ||
97 | + //似乎就是加了些L啊什么的。。 。 | ||
98 | + // if (_GetUperLayerId(parseString.layerName, sLayer) == false) | ||
99 | + // return Error(buff, ErrorClass::ParaError, "layer not exist", ab); | ||
100 | + | ||
101 | + shared_ptr<MapLayer> mapLayer = service->GetLayer(parseString.layerName); | ||
102 | + | ||
103 | + | ||
104 | + if(mapLayer == nullptr) | ||
105 | + { | ||
106 | + return Error(buff, ErrorClass::ParaError, "layer not find", ab); | ||
107 | + } | ||
108 | + | ||
109 | + shared_ptr<Workspace> pWorkspace = DataSourcePools::get_instance()->GetWorkspace(mapLayer->m_dbSource); | ||
110 | + if(pWorkspace == nullptr) | ||
111 | + { | ||
112 | + return Error(buff, ErrorClass::DatabaseDisconnect, "连接数据库失败", ab); | ||
113 | + } | ||
114 | + shared_ptr<dmapFields> fields = pWorkspace->GetFields(mapLayer->m_layerName,""); | ||
115 | + | ||
116 | + if(fields == nullptr) | ||
117 | + { | ||
118 | + return Error(buff, ErrorClass::ParaError, "layername not exist", ab); | ||
119 | + } | ||
120 | + | ||
121 | + | ||
122 | + shared_ptr<TableDesc> pTabledesc = this->ToTableDesc(fields,mapLayer->m_layerName); | ||
123 | + | ||
124 | + | ||
125 | + size_t propCount = props.size(); | ||
126 | + if (propCount) | ||
127 | + { | ||
128 | + std::string sF; | ||
129 | + for (int i = 0; i < propCount; i++) | ||
130 | + { | ||
131 | + if (i) | ||
132 | + sF = sF + ","; | ||
133 | + string sleft, sright, s; | ||
134 | + s = props[i]; | ||
135 | + int at1 = s.find("("), at2 = s.find(")"); | ||
136 | + | ||
137 | + if (at1 != string::npos && at2 == s.length() - 1 && at1 < at2) | ||
138 | + { | ||
139 | + sleft = s.substr(0, at1); | ||
140 | + sright = s.substr(at1 + 1, s.length() - 2 - at1); | ||
141 | + if (_stricmp(sleft.c_str(), "distinct") == 0) | ||
142 | + { | ||
143 | + sF = sF + sleft + " " + fields->GetFieldQuery(sright.c_str()); | ||
144 | + } | ||
145 | + else | ||
146 | + { | ||
147 | + sF = sF + sleft + "(" + fields->GetFieldQuery(sright.c_str()) + ")"; | ||
148 | + } | ||
149 | + } | ||
150 | + else | ||
151 | + { | ||
152 | + sF = sF + fields->GetFieldQuery(s.c_str()); | ||
153 | + } | ||
154 | + | ||
155 | + } | ||
156 | + sqlF.prop = sF; | ||
157 | + } | ||
158 | + else | ||
159 | + { | ||
160 | + bool isJson = (parseString.format && (strcmpi(parseString.format, "geojson") ==0 || strcmpi(parseString.format, "json") ==0)); | ||
161 | + this->GetAllField( srsOut, sqlF.prop,mapLayer,pWorkspace,isJson); | ||
162 | + } | ||
163 | + | ||
164 | + size_t idCount = ids.size(); | ||
165 | + | ||
166 | + | ||
167 | + | ||
168 | + if (parseString.filter) | ||
169 | + { | ||
170 | + clsFilter filter(mapLayer->m_srid); | ||
171 | + | ||
172 | + if (filter.Parse(parseString.filter, pTabledesc.get(),DatabaseTypePostgreSQL)) | ||
173 | + { | ||
174 | + return Error(buff, ErrorClass::FilterError, filter.err, ab); | ||
175 | + } | ||
176 | + | ||
177 | + sqlF.AppendCondition(filter.sql); | ||
178 | + } | ||
179 | + if (parseString.sortby) | ||
180 | + { | ||
181 | + clsFilter filter(mapLayer->m_srid); | ||
182 | + if (filter.ParseOrder(parseString.sortby, pTabledesc.get(), DatabaseTypePostgreSQL)) | ||
183 | + { | ||
184 | + return Error(buff, ErrorClass::SortError, filter.err, ab); | ||
185 | + } | ||
186 | + sqlF.order = filter.sql; | ||
187 | + } | ||
188 | + sqlF.table = mapLayer->m_layerName; | ||
189 | + std::string sq = sqlF.GetSql(DatabaseTypePostgreSQL); | ||
190 | + | ||
191 | + bool returnResult = pWorkspace->ExecWaitBinary(sq); | ||
192 | + if (!returnResult) | ||
193 | + { | ||
194 | + return Error(buff, ErrorClass::QueryError, pWorkspace->m_sError.c_str(), ab); | ||
195 | + } | ||
196 | + int ver = ParseString::GetGMLVersion(parseString.version, parseString.outputFormat); | ||
197 | + if (parseString.format && (strcmpi(parseString.format, "geojson") ==0|| strcmpi(parseString.format, "json")==0)) | ||
198 | + { | ||
199 | + isPicture = 10; | ||
200 | + return this->FormatWFSJsonCAll(pWorkspace, ab, parseString.layerName, buff, ver); | ||
201 | + } | ||
202 | + else | ||
203 | + { | ||
204 | + isPicture = 0; | ||
205 | + return this->FormatWFSXMLCAll(pWorkspace, ab, parseString.layerName, buff, ver); | ||
206 | + }*/ | ||
207 | + } | ||
208 | + | ||
209 | + | ||
210 | + | ||
211 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpwfsgetfeature.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2021-12-24 10:57:45 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpwfsgetfeature_h__ | ||
11 | +#define __dmpwfsgetfeature_h__ | ||
12 | +#include <boost/property_tree/ptree.hpp> | ||
13 | +#include <boost/property_tree/xml_parser.hpp> | ||
14 | +#include <boost/typeof/typeof.hpp> | ||
15 | +#include <memory> | ||
16 | +#include <vector> | ||
17 | +#include "dmpproject.h" | ||
18 | +#include "dmpwfsparameters.h" | ||
19 | +#include "dmpservercontext.h" | ||
20 | +#include "dmppgsqlsourcepools.h" | ||
21 | + | ||
22 | +namespace DmpWfs | ||
23 | +{ | ||
24 | + void writeGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
25 | + const DmpProject* project, | ||
26 | + bool projectSettings = false); | ||
27 | + | ||
28 | + // std::string WfsGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, | ||
29 | + // const DmpProject* project, | ||
30 | + // bool projectSettings = false); | ||
31 | + | ||
32 | + | ||
33 | +} | ||
34 | + | ||
35 | +#endif // __dmpwfsgetfeature_h__ |
1 | + | ||
2 | +/************************************************************************** | ||
3 | +* file: dmpwfsparameters.h | ||
4 | + | ||
5 | +* Author: qingxiongf | ||
6 | +* Date: 2021-12-22 20:46:29 | ||
7 | +* Email: qingxiongf@chinadci.com | ||
8 | +* copyright: 广州城市信息研究所有限公司 | ||
9 | +***************************************************************************/ | ||
10 | + | ||
11 | +#ifndef __dmpwfsparameters_h__ | ||
12 | +#define __dmpwfsparameters_h__ | ||
13 | + | ||
14 | + | ||
15 | +#include "dmpserverparameters.h" | ||
16 | + | ||
17 | +namespace DmpWfs | ||
18 | +{ | ||
19 | + class DmpWfsParameters : public DmpServerParameters | ||
20 | + { | ||
21 | + public: | ||
22 | + enum class Format | ||
23 | + { | ||
24 | + NONE, | ||
25 | + JPG, | ||
26 | + PNG, | ||
27 | + TEXT, | ||
28 | + XML, | ||
29 | + HTML, | ||
30 | + GML2, | ||
31 | + GML3, | ||
32 | + GeoJson | ||
33 | + }; | ||
34 | + DmpWfsParameters(const DmpServerParameters ¶meters); | ||
35 | + DmpWfsParameters(); | ||
36 | + virtual ~DmpWfsParameters() = default; | ||
37 | + //GetCapabilities | ||
38 | + std::string Service() const; //必须 值为WFS | ||
39 | + std::string Request() const; //必须 值为 GetCapabilities GetFeature DescribeFeatureType GetGmlObject Transaction LockFeature | ||
40 | + std::string Version() const; //必须 服务版本, 值为 1.0.0, 1.1.0, 1.1.1, 1.3 | ||
41 | + | ||
42 | + //DescribeFeatureType | ||
43 | + //GetFeature | ||
44 | + std::string TypeName() const; //必须 坐标系 | ||
45 | + std::string OutputFormat() const; //必须 | ||
46 | + std::string BBox() const; //必须 | ||
47 | + std::string Filter() const; | ||
48 | + std::string Sortby() const; | ||
49 | + int MaxFeatures() const; //指定返回最多要素 | ||
50 | + std::string PropertyName() const; //指定返回的要素属性,没有指定不返回 | ||
51 | + std::string SrsName() const; //空间参考坐标 | ||
52 | + std::string FeatureID() const; //要素ID | ||
53 | + //std::string Expiry(); | ||
54 | + //std::string ResultType(); | ||
55 | + //std::string FeatureVsrsion(); | ||
56 | + | ||
57 | + //Transaction(对要素数据增、删、改) | ||
58 | + //暂时不实现 | ||
59 | + | ||
60 | + | ||
61 | + | ||
62 | + private: | ||
63 | + bool GetStringParameter(const char* key, std::string &value) const; | ||
64 | + bool GetIntParameter(const char* key, int& value) const; | ||
65 | + | ||
66 | + }; | ||
67 | +} | ||
68 | + | ||
69 | +#endif // __dmpwfsparameters_h__ | ||
70 | + |
请
注册
或
登录
后发表评论