提交 688016608f10bc7fddd6efabea57d792d61a7b27

作者 qingxiongf
1 个父辈 13347aa6

wfs

... ... @@ -106,6 +106,7 @@ namespace DmapCore_30
106 106 {
107 107 return c - '0';
108 108 }
  109 + return c;
109 110 }
110 111
111 112 bool clsUtil::ToCairoColor(string color, double &r, double & g, double& b, double&a)
... ... @@ -119,7 +120,9 @@ namespace DmapCore_30
119 120 r = Hex2int(color.at(index)* 16 + Hex2int(color.at(index+1))) / 255.0; index += 2;
120 121 g = Hex2int(color.at(index)* 16 + Hex2int(color.at(index+1))) / 255.0; index += 2;
121 122 b = Hex2int(color.at(index)* 16 + Hex2int(color.at(index+1))) / 255.0; index += 2;
  123 + return true;
122 124 }
  125 + return false;
123 126 }
124 127
125 128 bool clsUtil::ReadHead(unsigned char* & here, int& not_big1, int & shapetype)
... ... @@ -176,7 +179,7 @@ namespace DmapCore_30
176 179 return num;
177 180 }
178 181
179   - char * clsUtil::ConvertEnc(char *encFrom, char *encTo, const char * in, char *bufout, size_t lenout)
  182 + char * clsUtil::ConvertEnc(const char *encFrom,const char *encTo, const char * in, char *bufout, size_t lenout)
180 183 {
181 184 char *sin, *sout;
182 185 int lenin, ret;
... ...
... ... @@ -56,7 +56,7 @@ else { to[index]->Release(); to[index] = from; }\
56 56 static double ReadDouble(unsigned char*& here, int not_big);
57 57 static bool DoSetLineType(int LineType, cairo_t* cr);
58 58 static bool DoSetAntialias(int iAntialias, cairo_t* cr);
59   - static char * ConvertEnc(char *encFrom, char *encTo, const char * in, char *bufout, size_t lenout);
  59 + static char * ConvertEnc(const char *encFrom,const char *encTo, const char * in, char *bufout, size_t lenout);
60 60 static bool ConvertEncUTF8_GB18030(const char *from, clsMalloc &m);
61 61 static bool ConvertEncGB18030_UTF8(const char* from, clsMalloc &m);
62 62
... ...
1   -ADD_SUBDIRECTORY(postgres)
  1 +#ADD_SUBDIRECTORY(postgres)
... ...
... ... @@ -8,10 +8,10 @@ SET (MAPSERVER_SRCS
8 8 dmppgsql.cpp
9 9 dmppgsqlpool.cpp
10 10 dmppgsqlsourcepools.cpp
11   - wfs/dmpwfs.cpp
12   - wfs/dmpwfsgetcapabilities.cpp
13   - wfs/dmpwfsgetfeature.cpp
14   - wfs/dmpwfsparameters.cpp
  11 + #wfs/dmpwfs.cpp
  12 + #wfs/dmpwfsgetcapabilities.cpp
  13 + #wfs/dmpwfsgetfeature.cpp
  14 + #wfs/dmpwfsparameters.cpp
15 15 wms/dmpwmsrenderer.cpp
16 16 wms/dmpwms.cpp
17 17 wms/dmpwmsparameters.cpp
... ... @@ -26,9 +26,10 @@ SET (MAPSERVER_HDRS
26 26 dmppgsql.h
27 27 dmppgsqlpool.h
28 28 dmppgsqlsourcepools.h
29   - wfs/dmpwfsgetcapabilities.h
30   - wfs/dmpwfsgetfeature.h
31   - wfs/dmpwfsparameters.h
  29 + #wfs/dmpwfs.h
  30 + #wfs/dmpwfsgetcapabilities.h
  31 + #wfs/dmpwfsgetfeature.h
  32 + #wfs/dmpwfsparameters.h
32 33 wms/dmpwmsrenderer.h
33 34 wms/dmpwms.h
34 35 wms/dmpwmsparameters.h
... ...
  1 +/**************************************************************************
  2 +* file: dmpwfs.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-24 10:57:45
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpwfs_h__
  11 +#define __dmpwm]fs_h__
  12 +#include <string>
  13 +#include "dmpservice.h"
  14 +#include "dmpwfsparameters.h"
  15 +
  16 +namespace DmpWms
  17 +{
  18 + class DmpWFSService : public DmpService
  19 + {
  20 + public:
  21 + DmpWFSService();
  22 + ~DmpWFSService();
  23 + std::string name() const override { return std::string("WFSService"); }
  24 + std::string version() const override { return std::string("1.3.0"); }
  25 + std::string description() const override { return std::string("WMS服务"); }
  26 + bool allowMethod(DmpServerRequest::Method method) const override { return method == DmpServerRequest::GET_METHOD;}
  27 + void executeRequest(const DmpServerContext &context) override;
  28 + };
  29 +}
  30 +
  31 +#endif // __dmpwfs_h__
... ...
  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 +}
\ No newline at end of file
... ...
  1 +/**************************************************************************
  2 +* file: dmpwfsparameters.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-27 10:08:07
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpwfsparameters.h"
  10 +
  11 +namespace DmpWfs
  12 +{
  13 +
  14 +}
\ No newline at end of file
... ...
... ... @@ -21,7 +21,7 @@ namespace DmpWms
21 21 DmpWMSService();
22 22 ~DmpWMSService();
23 23 std::string name() const override { return std::string("WMSService"); }
24   - std::string version() const override { return std::string("1.0.0"); }
  24 + std::string version() const override { return std::string("1.3.0"); }
25 25 std::string description() const override { return std::string("WMS服务"); }
26 26 bool allowMethod(DmpServerRequest::Method method) const override { return method == DmpServerRequest::GET_METHOD;}
27 27 void executeRequest(const DmpServerContext &context) override;
... ...
注册登录 后发表评论