提交 c9e4981b0c3f2cbf9a3bd784f9f5929875e9e1e5

作者 qingxiongf
1 个父辈 a3e47bd9

金字塔

不能预览此文件类型
... ... @@ -24,7 +24,7 @@ SET(DMAP_CORE_SRCS
24 24 dmptilematrixset.cpp
25 25 dmpvectordataprovider.cpp
26 26 dmpvectorlayer.cpp
27   - dmpvectorthinlayer.cpp
  27 + dmpvectorvacuatelayer.cpp
28 28 dmpvectorlayerrenderer.cpp
29 29 dmpxmlutils.cpp
30 30
... ... @@ -76,7 +76,7 @@ SET(DMAP_CORE_HDRS
76 76 dmptilematrixset.h
77 77 dmpvectordataprovider.h
78 78 dmpvectorlayer.h
79   - dmpvectorthinlayer.h
  79 + dmpvectorvacuatelayer.h
80 80 dmpvectorlayerrenderer.h
81 81 dmpxmlutils.h
82 82
... ...
... ... @@ -223,4 +223,103 @@ DmpMapLayer *DmpProject::getLayer() const
223 223 {
224 224 return nullptr;
225 225 }
  226 +}
  227 +
  228 +bool DmpProject::initVectorLayerVacuate(std::function<std::string(const std::string &)> getVacuateFun)
  229 +{
  230 + try
  231 + {
  232 + std::string tableguids = "";
  233 + for (int i = 0; i < vectorLayers_.size(); i++)
  234 + {
  235 + DmpMapLayer *layer = vectorLayers_.at(i);
  236 + if (layer->type() == DmpMapLayerType::VectorLayer)
  237 + {
  238 + if (!tableguids.empty())
  239 + {
  240 + tableguids += ",";
  241 + }
  242 + tableguids += layer->id();
  243 + }
  244 + }
  245 +
  246 + if (tableguids.empty())
  247 + {
  248 + return false;
  249 + }
  250 +
  251 + std::string vacuateInfo = getVacuateFun(tableguids);
  252 + if (vacuateInfo.empty())
  253 + {
  254 + return false;
  255 + }
  256 +
  257 + std::istringstream stream(vacuateInfo);
  258 + ptree pt;
  259 + read_json(stream, pt);
  260 + bool result = pt.get<bool>("result");
  261 + if (!result)
  262 + {
  263 + return false;
  264 + }
  265 +
  266 + //图层
  267 + ptree pLayers = pt.get_child("data");
  268 + // for (BOOST_AUTO(pos, pLayers.begin()); pos != pLayers.end(); ++pos)
  269 + for (ptree::iterator pos = pLayers.begin(); pos != pLayers.end(); ++pos)
  270 + {
  271 + ptree pLayer = pos->second;
  272 + int vacuateCount = pLayer.get<int>("vacuate_count");
  273 + if (vacuateCount > 0)
  274 + {
  275 + std::string tableGuid = pLayer.get<std::string>("table_guid");
  276 + std::string tableName = pLayer.get<std::string>("table_name");
  277 +
  278 + DmpMapLayer *layer = this->getLayer(tableName);
  279 + if (layer && layer->type() == DmpMapLayerType::VectorLayer)
  280 + {
  281 + DmpVectorLayer *vectorLayer = (DmpVectorLayer *)layer;
  282 + ptree ptableVacuates = pLayer.get_child("table_vacuate");
  283 + for (BOOST_AUTO(pos1, ptableVacuates.begin()); pos1 != ptableVacuates.end(); ++pos1)
  284 + {
  285 + ptree pVacuateLayer = pos1->second;
  286 + shared_ptr<DmpVectorVacuateLayer> vacuateLayer(new DmpVectorVacuateLayer());
  287 + std::string name = pVacuateLayer.get<std::string>("name");
  288 + std::string connectStr = pVacuateLayer.get<std::string>("connectstr");
  289 + double pixel_distance = pVacuateLayer.get<double>("pixel_distance");
  290 + vacuateLayer->Init(pixel_distance, name, connectStr);
  291 + vectorLayer->ApplendCurrentScaleTable(vacuateLayer);
  292 + }
  293 + }
  294 + }
  295 + }//for
  296 + return true;
  297 + }
  298 + catch (const std::exception &e)
  299 + {
  300 + std::cerr << e.what() << '\n';
  301 + return false;
  302 + }
  303 + return false;
  304 +}
  305 +
  306 +bool DmpProject::initVectorLayerVacuate(DmpProject* project)
  307 +{
  308 + if(!project) return false;
  309 + for (size_t i = 0; i < project->vectorLayers().size(); i++)
  310 + {
  311 + DmpMapLayer *layer = project->vectorLayers().at(i);
  312 + if (layer->type() == DmpMapLayerType::VectorLayer)
  313 + {
  314 + DmpVectorLayer *vectorLayer = (DmpVectorLayer *)layer;
  315 + DmpVectorLayer *thisVectorLayer = (DmpVectorLayer*)this->getLayer(layer->name());
  316 + for (size_t i0 = 0; i0 < vectorLayer->vacuateLayers().size(); i0++)
  317 + {
  318 + std::shared_ptr<DmpVectorVacuateLayer> pvectorVacuateLayer = vectorLayer->vacuateLayers().at(i0);
  319 + thisVectorLayer->vacuateLayers().push_back(pvectorVacuateLayer->clone());
  320 + }
  321 +
  322 + }
  323 + }
  324 + return true;
226 325 }
\ No newline at end of file
... ...
... ... @@ -27,6 +27,9 @@ class CORE_EXPORT DmpProject
27 27 bool Read(const std::string &data);
28 28 bool Write(const std::string &filename, const std::string &data);
29 29 bool WritePtree(boost::property_tree::ptree& ptDoc);
  30 + //初始化矢量图层金字塔信息
  31 + bool initVectorLayerVacuate(std::function<std::string(const std::string &)> getVacuateFun);
  32 + bool initVectorLayerVacuate(DmpProject* project);
30 33 std::string WriteXml();
31 34 std::string WriteJson();
32 35 DmpCoordinateReferenceSystem crs() const;
... ...
... ... @@ -293,7 +293,7 @@ bool DmpVectorLayer::setDataProvider(const std::string &provider)
293 293 return true;
294 294 }
295 295
296   -shared_ptr<DmpVectorThinLayer> DmpVectorLayer::GetCurrentScaleTable(double dx)
  296 +shared_ptr<DmpVectorVacuateLayer> DmpVectorLayer::GetCurrentScaleTable(double dx)
297 297 {
298 298
299 299 /*
... ... @@ -319,13 +319,13 @@ shared_ptr<DmpVectorThinLayer> DmpVectorLayer::GetCurrentScaleTable(double dx)
319 319 }
320 320 */
321 321
322   - for (int i = 0; i < this->thinLayers_.size(); i++)
  322 + for (int i = 0; i < this->vacuateLayers_.size(); i++)
323 323 {
324   - shared_ptr<DmpVectorThinLayer> mapLayerThinning = this->thinLayers_[i];
  324 + shared_ptr<DmpVectorVacuateLayer> vacuateLayer = this->vacuateLayers_[i];
325 325
326   - if (mapLayerThinning->IsCurrentLayer(dx))
  326 + if (vacuateLayer->IsCurrentLayer(dx))
327 327 {
328   - return mapLayerThinning;
  328 + return vacuateLayer;
329 329 }
330 330 }
331 331 return nullptr;
... ...
... ... @@ -15,7 +15,7 @@
15 15 #include "dmpmaplayer.h"
16 16 #include "dmpwkbtypes.h"
17 17 #include "dmpvectordataprovider.h"
18   -#include "dmpvectorthinlayer.h"
  18 +#include "dmpvectorvacuatelayer.h"
19 19 #include "Renderer.h"
20 20 #include <vector>
21 21
... ... @@ -54,8 +54,9 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer
54 54
55 55
56 56 shared_ptr<DmapCore_30::Renderer> GetRenderer30() { return renderer_30_; }
57   - vector<shared_ptr<DmpVectorThinLayer>> thinLayers() const { return thinLayers_; }
58   - shared_ptr<DmpVectorThinLayer> GetCurrentScaleTable(double dx);
  57 + vector<shared_ptr<DmpVectorVacuateLayer>> vacuateLayers() const { return vacuateLayers_; }
  58 + shared_ptr<DmpVectorVacuateLayer> GetCurrentScaleTable(double dx);
  59 + void ApplendCurrentScaleTable(shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer){vacuateLayers_.push_back(pVectorVacuateLayer);}
59 60
60 61 std::string schema() { return schema_;}
61 62 std::string geom() { return geom_;}
... ... @@ -79,9 +80,9 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer
79 80 std::string wherestr_;
80 81 bool isinit_ = false;
81 82 shared_ptr<DmapCore_30::Renderer> renderer_30_ = nullptr;
82   - vector<shared_ptr<DmpVectorThinLayer>> thinLayers_;
  83 + vector<shared_ptr<DmpVectorVacuateLayer>> vacuateLayers_;
  84 +
83 85
84   -
85 86
86 87 };
87 88 #endif //__dmpvectorlayer_h__
... ...
1 1 /**************************************************************************
2   -* file: dmpvectorthinlayer.cpp
  2 +* file: dmpvectorvacuatelayer.cpp
3 3
4 4 * Author: qingxiongf
5 5 * Date: 2021-12-13 10:05:35
6 6 * Email: qingxiongf@chinadci.com
7 7 * copyright: 广州城市信息研究所有限公司
8 8 ***************************************************************************/
9   -#include "dmpvectorthinlayer.h"
  9 +#include "dmpvectorvacuatelayer.h"
10 10
11   -DmpVectorThinLayer::DmpVectorThinLayer(/* args */)
  11 +DmpVectorVacuateLayer::DmpVectorVacuateLayer(/* args */)
12 12 {
13   -
  13 +
14 14 }
15 15
16   -DmpVectorThinLayer::~DmpVectorThinLayer()
  16 +DmpVectorVacuateLayer::~DmpVectorVacuateLayer()
17 17 {
18 18
19 19 }
20 20
21   - bool DmpVectorThinLayer::IsCurrentLayer(double d)
  21 +bool DmpVectorVacuateLayer::IsCurrentLayer(double d)
22 22 {
23 23 if(d > m_ddis)
24 24 {
... ... @@ -27,21 +27,22 @@ DmpVectorThinLayer::~DmpVectorThinLayer()
27 27 return false;
28 28 }
29 29
30   -bool DmpVectorThinLayer::Init(double minX, double minY, double maxX, double maxY, int dxCount, int dyCount,std::string tableName)
31   -{
32   - m_ddis = std::max( (maxX - minX)/ dxCount, (maxY - minY)/ dyCount);
33   - m_tableName = tableName;
34   - return true;
35   -}
  30 + std::shared_ptr<DmpVectorVacuateLayer> DmpVectorVacuateLayer::clone()
  31 + {
  32 + std::shared_ptr<DmpVectorVacuateLayer> vacuateLayer(new DmpVectorVacuateLayer(*this));
  33 + return vacuateLayer;
  34 + }
  35 +
36 36
37   -bool DmpVectorThinLayer::Init(double dis,std::string tableName)
  37 +bool DmpVectorVacuateLayer::Init(double dis, const std::string& tableName, const std::string& connectstr)
38 38 {
39 39 m_ddis =dis;
40 40 m_tableName = tableName;
  41 + connectstr_ = connectstr;
41 42 return true;
42 43 }
43 44
44   -double DmpVectorThinLayer::GeDisPix()
  45 +double DmpVectorVacuateLayer::GeDisPix()
45 46 {
46 47 return this->m_ddis;
47 48 }
\ No newline at end of file
... ...
1 1 /**************************************************************************
2   -* file: dmpvectorthinlayer.h
  2 +* file: dmpvectorvacuatelayer.h
3 3
4 4 * Author: qingxiongf
5 5 * Date: 2021-12-13 10:05:42
... ... @@ -7,33 +7,33 @@
7 7 * copyright: 广州城市信息研究所有限公司
8 8 ***************************************************************************/
9 9
10   -#ifndef __dmpvectorthinlayer_h__
11   -#define __dmpvectorthinlayer_h__
  10 +#ifndef __dmpvectorvacuatelayer_h__
  11 +#define __dmpvectorvacuatelayer_h__
12 12
13 13 #include "dmap_core.h"
14 14 #include <string>
  15 +#include <memory>
15 16
16   -class CORE_EXPORT DmpVectorThinLayer
  17 +class CORE_EXPORT DmpVectorVacuateLayer
17 18 {
18 19 public:
19   - DmpVectorThinLayer(/* args */);
  20 + DmpVectorVacuateLayer(/* args */);
20 21
21   - ~DmpVectorThinLayer();
  22 + ~DmpVectorVacuateLayer();
22 23
23 24 bool IsCurrentLayer(double d);
24 25
25   - bool Init(double minX, double minY,
26   - double maxX, double maxY,
27   - int dxCount, int dyCount,
28   - std::string tableName);
29 26
30   - bool Init(double minX,
31   - std::string tableName);
  27 + bool Init(double dis, const std::string& tableName, const std::string& connectstr);
  28 +
  29 + std::shared_ptr<DmpVectorVacuateLayer> clone();
32 30
33 31 double GeDisPix();
34 32
35 33 std::string tableName()const { return m_tableName;}
36 34
  35 + std::string connectStr() const {return connectstr_;}
  36 +
37 37 private:
38 38 int m_indexLevel;
39 39 int m_dataCount;
... ... @@ -44,6 +44,7 @@ class CORE_EXPORT DmpVectorThinLayer
44 44 double m_ddis;
45 45 std::string m_tableName;
46 46 std::string polygon_area = "geodmap_area";
  47 + std::string connectstr_ = "";
47 48 };
48 49
49   -#endif // __dmpvectorthinlayer_h__
  50 +#endif // __dmpvectorvacuatelayer_h__
... ...
... ... @@ -116,25 +116,24 @@ namespace DmapCore_30
116 116
117 117 clsPtree::PtreeAttrParse("glowing", ptRenderer, m_bGlowing);
118 118 if (m_bGlowing)
119   - clsPtree::PtreeAttrParseColor("glowingcolor", "glowingtransparency", ptRenderer, m_iBGColor);
  119 + clsPtree::PtreeAttrParseColor("glowingcolor", "glowingtransparency", ptRenderer, m_iGlowingColor);
120 120
121 121
122   - clsPtree::PtreeAttrParse("shadow", ptRenderer, m_bGlowing);
123   - if (m_bGlowing)
  122 + clsPtree::PtreeAttrParse("shadow", ptRenderer, m_bShadow);
  123 + if (m_bShadow)
124 124 clsPtree::PtreeAttrParseColor("shadowcolor", "shadowtransparency", ptRenderer, m_iShadowColor);
125 125
126 126 pt.add_child("TEXTSYMBOL",ptRenderer);
127 127 return true;
128 128 }
129 129
130   - void TextSymbol::ToJson(AppendBuffer *ab)
  130 + void TextSymbol::ToJson(AppendBuffer *ab)
131 131 {
132 132 char buff[300] = {0};
133 133 char resultbuff[5000] ={0};
134 134 sprintf(resultbuff, R"("TEXTSYMBOL":{"antialiasing":"antialias_default",)");
135 135 clsJson::JsonAttrParse("font", resultbuff, buff, this->m_sFont);
136 136 clsJson::JsonAttrParse("fontsize", resultbuff, buff, this->m_iFontSize);
137   - //
138 137 clsJson::JsonAttrParseColor("fontcolor", "fonttransparency", resultbuff, buff, m_iFontColor);
139 138 clsJson::JsonAttrParse("x_dis", resultbuff, buff, this->m_dXdis);
140 139 clsJson::JsonAttrParse("y_dis", resultbuff, buff, this->m_dYdis);
... ... @@ -147,11 +146,11 @@ namespace DmapCore_30
147 146
148 147 clsJson::JsonAttrParse("glowing", resultbuff, buff, m_bGlowing);
149 148 if (m_bGlowing)
150   - clsJson::JsonAttrParseColor("glowingcolor", "glowingtransparency", resultbuff, buff, m_iBGColor);
  149 + clsJson::JsonAttrParseColor("glowingcolor", "glowingtransparency", resultbuff, buff, m_iGlowingColor);
151 150
152 151
153   - clsJson::JsonAttrParse("shadow", resultbuff, buff, m_bGlowing);
154   - if (m_bGlowing)
  152 + clsJson::JsonAttrParse("shadow", resultbuff, buff, m_bShadow);
  153 + if (m_bShadow)
155 154 clsJson::JsonAttrParseColor("shadowcolor", "shadowtransparency", resultbuff, buff, m_iShadowColor);
156 155
157 156 clsJson::JsonAttrEnd(resultbuff);
... ...
... ... @@ -108,7 +108,7 @@ public:
108 108
109 109 int main(int argc, char *argv[])
110 110 {
111   - int port = 8088, maxThreads = 10;
  111 + int port = 8820, maxThreads = 10;
112 112 const char *serverType = "lf";
113 113 #ifndef WIN32
114 114 extern char *optarg;
... ...
1 1 [MetaData]
2 2 pgsqlConnect="hostaddr=localhost port=5432 dbname='dmap_dms' user='postgres' password='chinadci'"
3   -metaUrl=http://172.26.60.100:8841/
\ No newline at end of file
  3 +metaUrl=http://172.26.60.101:8840/
\ No newline at end of file
... ...
... ... @@ -121,6 +121,11 @@ bool DmpServerManager::publish(const std::string& serverName, const std::string&
121 121 return false;
122 122 }
123 123
  124 + project->initVectorLayerVacuate([](const std::string &tableguid)
  125 + {
  126 + return DmpHttp::get(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid);
  127 + });
  128 +
124 129 if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project))
125 130 {
126 131 delete project;
... ... @@ -183,7 +188,7 @@ bool DmpServerManager::loadServices()
183 188 }
184 189 bool DmpServerManager::initServices(const std::string& serverName, const std::string& serviceName, const std::string& title, int capabilities, const std::string& projectData)
185 190 {
186   - //project
  191 + // project
187 192 std::string projData;
188 193 if (!DmpServerUtils::Base64Decode(projectData, &projData))
189 194 {
... ... @@ -196,12 +201,16 @@ bool DmpServerManager::initServices(const std::string& serverName, const std::st
196 201 return false;
197 202 }
198 203
  204 + project->initVectorLayerVacuate([](const std::string &tableguid)
  205 + {
  206 + return DmpHttp::get(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid);
  207 + });
  208 +
199 209 if (!serverRegistry_->getServer(serverName)->publish(serviceName, title, capabilities, *project))
200 210 {
201 211 delete project;
202 212 return false;
203 213 }
204   - projects_[serviceName] = project;
  214 + projects_[serviceName] = project;
205 215 return true;
206   -
207 216 }
\ No newline at end of file
... ...
... ... @@ -20,7 +20,8 @@
20 20 #include "dmpserverregistry.h"
21 21
22 22
23   -#define URI_RELOAD ("/API/Service/Reload") //加载已注册服务接口
  23 +#define URI_RELOAD ("/API/Service/Reload") //加载已注册服务接口
  24 +#define URL_VACUATE ("/API/Manager/TableVacuateDetail?table_guids=") //加载矢量数据抽稀图层
24 25 class SERVER_EXPORT DmpServerManager
25 26 {
26 27 public:
... ...
... ... @@ -454,9 +454,14 @@ namespace mapserver
454 454
455 455 bool DmpPgsqlSourcePools::AddDatabasePool(string guid)
456 456 {
457   - if (guid.find(" ") != string::npos && guid.size() > 50)
  457 + if (guid.find(" ") != string::npos || guid.size() > 100)
458 458 {
459   - std::string connStr = guid;
  459 + std::string connStr = guid;
  460 + if(connStr.find(" ") == string::npos)
  461 + {
  462 + connStr = DmpServerDes::DesBase64Decrypt(connStr, "Chinadci");
  463 + }
  464 +
460 465 shared_ptr<DmpPgsqlPool> newPool(new DmpPgsqlPool(guid,guid,guid));
461 466 newPool->Connect(connStr.c_str());
462 467 //newPool->Connect("PostgreSQLConn=hostaddr=172.26.99.173 port=5433 dbname='postgres' user='postgres' password='chinadci'");
... ...
... ... @@ -48,8 +48,8 @@ namespace DmpMapping
48 48
49 49 std::string guid = pt.get<std::string>("guid");
50 50
51   - DmpProject* project = (DmpProject*)context.serverProject()->project();
52   - std::string projectData = project->WriteXml();
  51 + DmpProject* projectold = (DmpProject*)context.serverProject()->project();
  52 + std::string projectData = projectold->WriteXml();
53 53 // printf("%s\r\n",projectData.c_str());
54 54 if(!guid.empty() && !projectData.empty())
55 55 {
... ... @@ -60,6 +60,9 @@ namespace DmpMapping
60 60 context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载DMD符号化失败!\"}");
61 61 return false;
62 62 }
  63 +
  64 + project->initVectorLayerVacuate(projectold);
  65 +
63 66 vectorMappingProjects[guid] = project;
64 67
65 68 // int i = 0;
... ... @@ -166,31 +169,36 @@ namespace DmpMapping
166 169 context.response()->writeJson("{\"status\":\"false\",\"message\":\"DMD文档错误\"}");
167 170 return false;
168 171 }
169   - vectorMappingProjects[guid] = project;
170   -
171   - double minx, miny, maxx, maxy;
172   - std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers();
173   - for (size_t i = 0; i < vectorLayers.size(); i++)
174   - {
175   - DmpMapLayer *layer = vectorLayers[i];
176   - if (i == 0)
177   - {
178   - minx = layer->extent().xmin();
179   - miny = layer->extent().ymin();
180   - maxx = layer->extent().xmax();
181   - maxy = layer->extent().ymax();
182   - }
183   - else
  172 + project->initVectorLayerVacuate([](const std::string &tableguid)
  173 + {
  174 + return DmpServerConfig::Instance()->HttpGet( DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid);
  175 + });
  176 +
  177 + vectorMappingProjects[guid] = project;
  178 +
  179 + double minx, miny, maxx, maxy;
  180 + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers();
  181 + for (size_t i = 0; i < vectorLayers.size(); i++)
184 182 {
185   - if (minx > layer->extent().xmin())
  183 + DmpMapLayer *layer = vectorLayers[i];
  184 + if (i == 0)
  185 + {
186 186 minx = layer->extent().xmin();
187   - if (miny > layer->extent().ymin())
188 187 miny = layer->extent().ymin();
189   - if (maxx < layer->extent().xmax())
190 188 maxx = layer->extent().xmax();
191   - if (maxy < layer->extent().ymax())
192 189 maxy = layer->extent().ymax();
193   - }
  190 + }
  191 + else
  192 + {
  193 + if (minx > layer->extent().xmin())
  194 + minx = layer->extent().xmin();
  195 + if (miny > layer->extent().ymin())
  196 + miny = layer->extent().ymin();
  197 + if (maxx < layer->extent().xmax())
  198 + maxx = layer->extent().xmax();
  199 + if (maxy < layer->extent().ymax())
  200 + maxy = layer->extent().ymax();
  201 + }
194 202 }
195 203
196 204 char buff[250];
... ... @@ -271,6 +279,10 @@ namespace DmpMapping
271 279 context.response()->writeJson("{\"status\":\"false\",\"message\":\"DMD文档错误\"}");
272 280 return false;
273 281 }
  282 + project->initVectorLayerVacuate([](const std::string &tableguid)
  283 + {
  284 + return DmpServerConfig::Instance()->HttpGet(DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid);
  285 + });
274 286 vectorMappingProjects[guid] = project;
275 287 context.response()->writeJson("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}");
276 288 return true;
... ...
... ... @@ -15,6 +15,7 @@
15 15 #include "dmpproject.h"
16 16 #include "dmpservercontext.h"
17 17 #include "dmppgsqlsourcepools.h"
  18 +#include "dmpservermanager.h"
18 19
19 20 namespace DmpMapping
20 21 {
... ...
... ... @@ -19,7 +19,6 @@
19 19 #include "../wms/dmpwmsgetmap.h"
20 20 #include "../wms/dmpwmsparameters.h"
21 21 #include "dmpmapping.h"
22   -#include "dmpmappingparameters.h"
23 22 #include "dmpimageinfo.h"
24 23
25 24 using namespace std;
... ... @@ -71,19 +70,33 @@ namespace DmpMapping
71 70 getImage(context);
72 71 }
73 72 else if(boost::iequals(request, "getmaplog")){
74   - const std::string mapGuid = params.MapGuid();
  73 + getmaplog(context,params);
  74 + }
  75 + else if (boost::iequals(request, "getmap"))
  76 + {
  77 + getmap(context,params);
  78 + }
  79 +
  80 + }
  81 +
  82 + bool DmpMappingService::getmaplog(const DmpServerContext &context,const DmpMappingParameters& params)
  83 + {
  84 + const std::string mapGuid = params.MapGuid();
75 85 if (vectorMappingProjects_.find(mapGuid) != vectorMappingProjects_.end())
76 86 {
77 87 shared_ptr<DmpProject> project = vectorMappingProjects_.find(mapGuid)->second;
78 88 const DmpWms::DmpWmsParameters wmsParams(context.request()->serverParameters());
79 89 DmpWms::writeGetMapLog(context, wmsParams, project.get());
  90 + return true;
80 91 }
81 92 else
82 93 {
83 94 context.response()->writeJson("{\"status\":\"false\",\"message\":\"未找到服务\"}");
  95 + return false;
84 96 }
85 97 }
86   - else if (boost::iequals(request, "getmap"))
  98 +
  99 + bool DmpMappingService::getmap(const DmpServerContext &context,const DmpMappingParameters& params)
87 100 {
88 101 const std::string mapGuid = params.MapGuid();
89 102 if (vectorMappingProjects_.find(mapGuid) != vectorMappingProjects_.end())
... ... @@ -91,6 +104,7 @@ namespace DmpMapping
91 104 shared_ptr<DmpProject> project = vectorMappingProjects_.find(mapGuid)->second;
92 105 const DmpWms::DmpWmsParameters wmsParams(context.request()->serverParameters());
93 106 DmpWms::writeGetMap(context, wmsParams, project.get());
  107 + return true;
94 108 }
95 109 else
96 110 {
... ... @@ -114,27 +128,31 @@ namespace DmpMapping
114 128 if (!DmpServerUtils::Base64Decode(mapRenderer, &projData))
115 129 {
116 130 context.response()->writeJson("{\"status\":\"false\",\"message\":\""+ mapRenderer +" base64转码错误\"}");
117   - return;
  131 + return false;
118 132 }
119 133 shared_ptr<DmpProject> project(new DmpProject());
120 134 if (!project->Read(projData))
121 135 {
122 136 context.response()->writeJson("{\"status\":\"false\",\"message\":\"DMD文档错误\"}");
123   - return;
  137 + return false;
124 138 }
  139 + project->initVectorLayerVacuate([](const std::string &tableguid)
  140 + {
  141 + return DmpServerConfig::Instance()->HttpGet( DmpServerConfig::Instance()->getMetaUrl() + URL_VACUATE + tableguid);
  142 + });
125 143 const DmpWms::DmpWmsParameters wmsParams(context.request()->serverParameters());
126 144 DmpWms::writeGetMap(context, wmsParams, project.get());
127 145 if(!mapGuid.empty())
128 146 {
129 147 vectorMappingProjects_[mapGuid] = project;
130 148 }
131   - return;
  149 + return true;
132 150 }
133 151 }
134 152 }
  153 +
  154 + return false;
135 155 }
136   -
137   - }
138 156
139 157
140 158
... ...
... ... @@ -10,11 +10,13 @@
10 10 #define __dmpmapping_h__
11 11 #include <string>
12 12 #include <string>
13   -#include "dmpeditservice.h"
14   -#include "dmpservice.h"
15 13 #include <boost/thread/shared_mutex.hpp>
16 14 #include <boost/thread.hpp>
17 15
  16 +#include "dmpeditservice.h"
  17 +#include "dmpservice.h"
  18 +#include "dmpmappingparameters.h"
  19 +
18 20 typedef boost::shared_mutex rwmutex;
19 21 typedef boost::shared_lock<rwmutex> readLock;
20 22 typedef boost::unique_lock<rwmutex> writeLock;
... ... @@ -31,6 +33,9 @@ namespace DmpMapping
31 33 bool allowMethod(DmpServerRequest::Method method) const override { return method == DmpServerRequest::GET_METHOD; }
32 34 void executeRequest(const DmpServerContext &context) override;
33 35 private:
  36 + bool getmaplog(const DmpServerContext &context,const DmpMappingParameters& params);
  37 + bool getmap(const DmpServerContext &context, const DmpMappingParameters& params);
  38 + private:
34 39
35 40 //存储工程文档实例
36 41 ProjectMap vectorMappingProjects_;
... ...
... ... @@ -7,4 +7,722 @@
7 7 * copyright: 广州城市信息研究所有限公司
8 8 ***************************************************************************/
9 9 #include "dmpprint.h"
  10 +#include <unistd.h>
  11 +#include <algorithm>
  12 +#include <cairo/cairo-svg.h>
10 13
  14 +namespace DmpWms
  15 +{
  16 + static cairo_status_t cairo_write_func_print(void *pbuff, const unsigned char *data, unsigned int length)
  17 + {
  18 + //vector<unsigned char>& vecData = *((vector<unsigned char>*)closure);
  19 + string *pResponseData = (string *)pbuff;
  20 + pResponseData->append((char *)data,length);
  21 + return CAIRO_STATUS_SUCCESS;
  22 + }
  23 +
  24 + DmpPrint::DmpPrint()
  25 + {
  26 + }
  27 +/*
  28 + bool DmpPrint::getPrint(std::string &responseData, DmpProject *project,const char* xml,string servername)
  29 + {
  30 + string result_msg;
  31 +
  32 + xml_document<> doc; // character type defaults to char
  33 + try
  34 + {
  35 + doc.parse<0>((char *)xml);
  36 + }
  37 + catch (...)
  38 + {
  39 + result_msg = "error:Post参数是XML格式";
  40 + }
  41 +
  42 + xml_node<char> *node = doc.first_node();
  43 + if(!node)
  44 + {
  45 + return false;
  46 + }
  47 +
  48 + m_height = 1122;
  49 + m_width = 793;
  50 +
  51 + xml_node<char> *template_node = node->first_node("template");
  52 + if(template_node != nullptr)
  53 + {
  54 + InitTemplateValue(template_node->value());
  55 + }
  56 +
  57 +
  58 + xml_node<char> *extent_node = node->first_node("extent");
  59 +
  60 + if(extent_node)
  61 + {// xmin="" ymin="" xmax="" ymax=""
  62 + xml_attribute<char> *attr_xmin = node->first_attribute("xmin");
  63 + xml_attribute<char> *attr_ymin = node->first_attribute("ymin");
  64 + xml_attribute<char> *attr_xmax = node->first_attribute("xmax");
  65 + xml_attribute<char> *attr_ymax = node->first_attribute("ymax");
  66 +
  67 + if(attr_xmin == nullptr || attr_ymin == nullptr ||
  68 + attr_xmax == nullptr || attr_ymax == nullptr)
  69 + {
  70 + return 0;
  71 + }
  72 +
  73 + xmin = atof( attr_xmax->value());
  74 + ymin = atof( attr_ymin->value());
  75 + xmax = atof( attr_xmax->value());
  76 + ymax = atof( attr_ymax->value());
  77 + }
  78 +
  79 + shared_ptr<MapParameter> pMapParameter(new MapParameter());
  80 +
  81 +
  82 + shared_ptr<OperationalDmapLayer> dmapLayer(new OperationalDmapLayer());
  83 + dmapLayer->serviceName = servername;
  84 +
  85 + map<string, shared_ptr<WMSServer>>::iterator iter = mapWmsServer.find(dmapLayer->serviceName);
  86 + if(iter !=mapWmsServer.end())
  87 + {
  88 + dmapLayer->m_wmsServer = iter->second;
  89 + Rect *rect = dmapLayer->m_wmsServer->GetExtent();
  90 + pMapParameter->InitParameter(xmin,xmax,ymax,ymin,m_width -100,m_height -120);
  91 + //double scaleDenominator = this->RecalculateScale(rect->m_dRight,rect->m_dLeft,rect->m_dTop,rect->m_dBottom,1022,693);
  92 + }
  93 + else
  94 + {
  95 + return false;
  96 + }
  97 +
  98 +
  99 + //dmapLayer->serviceName = "土地利用现状";
  100 + //dmapLayer->m_id = "土地利用现状";
  101 + //dmapLayer->boxX1 = 683497;
  102 + //dmapLayer->boxX2 = 695357;
  103 + //dmapLayer->boxY1 = 2534922;
  104 + //dmapLayer->boxY2 = 2543053;
  105 +
  106 + Rect* rect = dmapLayer->m_wmsServer->GetExtent();
  107 +
  108 + dmapLayer->boxX1 = xmin;
  109 + dmapLayer->boxX2 = xmax;
  110 + dmapLayer->boxY1 = ymin;
  111 + dmapLayer->boxY2 = ymax;
  112 +
  113 + shared_ptr<DmapPrintLayout> dmapLayout(new DmapPrintLayout());
  114 + this->vector_dmapPrintLayout.push_back(dmapLayout);
  115 +
  116 +
  117 + dmapLayout->data.push_back(dmapLayer);
  118 + dmapLayout->localtion_x = 50;
  119 + dmapLayout->localtion_y = 70;
  120 +
  121 + dmapLayout->height = m_height -70;
  122 + dmapLayout->width = m_width -50;
  123 +
  124 + this->m_height = m_height;
  125 + this->m_width = m_width;
  126 +
  127 +
  128 + shared_ptr<OperationalGeom> geomLayer_scale(new OperationalGeom());
  129 + geomLayer_scale->pMapParameter = pMapParameter;
  130 + geomLayer_scale->type = "scale";
  131 + shared_ptr<DmapPrintLayout> dmapLayout_scale(new DmapPrintLayout());
  132 + this->vector_dmapPrintLayout.push_back(dmapLayout_scale);
  133 + geomLayer_scale->localtion_x = 150;
  134 + geomLayer_scale->localtion_y = m_height - 50;
  135 + dmapLayout_scale->data.push_back(geomLayer_scale);
  136 +
  137 +
  138 + shared_ptr<OperationalGeom> geomLayer_compass(new OperationalGeom());
  139 + geomLayer_compass->pMapParameter = pMapParameter;
  140 + geomLayer_compass->type = "compass";
  141 + shared_ptr<DmapPrintLayout> dmapLayout_compass(new DmapPrintLayout());
  142 + this->vector_dmapPrintLayout.push_back(dmapLayout_compass);
  143 + geomLayer_compass->localtion_x = 80;
  144 + geomLayer_compass->localtion_y = m_height - 80;
  145 + dmapLayout_compass->data.push_back(geomLayer_compass);
  146 +
  147 +
  148 + ToPrint(ab);
  149 + return true;
  150 + }
  151 +
  152 + bool DmpPrint::getPrint( std::string &responseData, DmpProject* project,
  153 + string servername,const char* printTemp,const char *bbox)
  154 + {
  155 + string result_msg;
  156 +
  157 + if(printTemp == nullptr || bbox == nullptr)
  158 + return false;
  159 +
  160 + m_height = 1122;
  161 + m_width = 793;
  162 +
  163 +
  164 + double boxX1, boxY1, boxX2, boxY2;
  165 + sscanf(bbox, "%lf,%lf,%lf,%lf", &boxY1, &boxX1, &boxY2, &boxX2); // &x1,&y1,&x2,&y2);
  166 +
  167 +
  168 + InitTemplateValue(printTemp);
  169 +
  170 +
  171 + shared_ptr<MapParameter> pMapParameter(new MapParameter());
  172 +
  173 +
  174 + shared_ptr<OperationalDmapLayer> dmapLayer(new OperationalDmapLayer());
  175 + dmapLayer->serviceName = servername;
  176 +
  177 + map<string, shared_ptr<WMSServer>>::iterator iter = mapWmsServer.find(dmapLayer->serviceName);
  178 + if(iter !=mapWmsServer.end())
  179 + {
  180 +
  181 +
  182 +
  183 +
  184 + if (rect_service)
  185 + {
  186 + if (rect_service->m_dBottom > 0 && rect_service->m_dRight > 0 && rect_service->m_dLeft > 0 && rect_service->m_dTop > 0)
  187 + {
  188 + if (min(boxX1, boxX2) > rect_service->m_dRight || max(boxX1, boxX2) < rect_service->m_dLeft ||
  189 + min(boxY1, boxY2) > rect_service->m_dTop || max(boxY1, boxY2) < rect_service->m_dBottom)
  190 + {
  191 + if (!(min(boxY1, boxY2) > rect_service->m_dRight || max(boxY1, boxY2) < rect_service->m_dLeft ||
  192 + min(boxX1, boxX2) > rect_service->m_dTop || max(boxX1, boxX2) < rect_service->m_dBottom))
  193 + {
  194 + double x1 = boxX1;
  195 + boxX1 = boxY1;
  196 + boxY1 = x1;
  197 + double x2 = boxX2;
  198 + boxX2 = boxY2;
  199 + boxY2 = x2;
  200 + }
  201 + }
  202 + }
  203 + }
  204 + xmin = min(boxX1, boxX2);
  205 + ymin = min(boxY1, boxY2);
  206 + xmax = max(boxX1, boxX2);
  207 + ymax = max(boxY1, boxY2);
  208 + pMapParameter->InitParameter(xmin,xmax,ymax,ymin,m_width -100,m_height -120);
  209 + //double scaleDenominator = this->RecalculateScale(rect->m_dRight,rect->m_dLeft,rect->m_dTop,rect->m_dBottom,1022,693);
  210 + }
  211 + else
  212 + {
  213 + return false;
  214 + }
  215 +
  216 +
  217 + //dmapLayer->serviceName = "土地利用现状";
  218 + //dmapLayer->m_id = "土地利用现状";
  219 + //dmapLayer->boxX1 = 683497;
  220 + //dmapLayer->boxX2 = 695357;
  221 + //dmapLayer->boxY1 = 2534922;
  222 + //dmapLayer->boxY2 = 2543053;
  223 +
  224 + Rect* rect = dmapLayer->m_wmsServer->GetExtent();
  225 +
  226 + dmapLayer->boxX1 = xmin;
  227 + dmapLayer->boxX2 = xmax;
  228 + dmapLayer->boxY1 = ymin;
  229 + dmapLayer->boxY2 = ymax;
  230 +
  231 + shared_ptr<DmapPrintLayout> dmapLayout(new DmapPrintLayout());
  232 + this->vector_dmapPrintLayout.push_back(dmapLayout);
  233 +
  234 +
  235 + dmapLayout->data.push_back(dmapLayer);
  236 + dmapLayout->localtion_x = 50;
  237 + dmapLayout->localtion_y = 70;
  238 +
  239 + dmapLayout->height = m_height -120;
  240 + dmapLayout->width = m_width -100;
  241 +
  242 + this->m_height = m_height;
  243 + this->m_width = m_width;
  244 +
  245 +
  246 + shared_ptr<OperationalGeom> geomLayer_scale(new OperationalGeom());
  247 + geomLayer_scale->pMapParameter = pMapParameter;
  248 + geomLayer_scale->type = "scale";
  249 + shared_ptr<DmapPrintLayout> dmapLayout_scale(new DmapPrintLayout());
  250 + this->vector_dmapPrintLayout.push_back(dmapLayout_scale);
  251 + geomLayer_scale->localtion_x = 150;
  252 + geomLayer_scale->localtion_y = m_height - 110;
  253 + dmapLayout_scale->data.push_back(geomLayer_scale);
  254 +
  255 +
  256 + shared_ptr<OperationalGeom> geomLayer_compass(new OperationalGeom());
  257 + geomLayer_compass->pMapParameter = pMapParameter;
  258 + geomLayer_compass->type = "compass";
  259 + shared_ptr<DmapPrintLayout> dmapLayout_compass(new DmapPrintLayout());
  260 + this->vector_dmapPrintLayout.push_back(dmapLayout_compass);
  261 + geomLayer_compass->localtion_x = 80;
  262 + geomLayer_compass->localtion_y = m_height - 140;
  263 + dmapLayout_compass->data.push_back(geomLayer_compass);
  264 +
  265 +
  266 + ToPrint(ab);
  267 + return true;
  268 +
  269 + }
  270 +
  271 +
  272 + bool DmpPrint::getPrintTempFile(string &responseData,,const char* tempName, const char* bbox)
  273 + {
  274 + string path = "./template/";path += tempName; path += ".xml";
  275 +
  276 +
  277 + ifstream fin(path.c_str(), ios::binary);
  278 +
  279 + if (!fin)
  280 + {
  281 + string result_msg = "<Error>打印模板未找到</Error>";
  282 + ab->AppendString(result_msg.c_str());
  283 + return false;
  284 + }
  285 +
  286 + stringstream buffer;
  287 + buffer << fin.rdbuf();
  288 + string content(buffer.str());
  289 + fin.close();
  290 + return getPrintLayout(ab, pWmsServer,content.c_str(), bbox);
  291 + //return true;
  292 + }
  293 +
  294 +
  295 + bool DmpPrint::getPrintLayout(AppendBuffer *ab,shared_ptr<WMSServer> pWmsServer,
  296 + const char* xml,const char *bbox)
  297 + {
  298 + string result_msg;
  299 + if(xml == nullptr || bbox == nullptr)
  300 + return false;
  301 +
  302 + m_height = 1122;
  303 + m_width = 793;
  304 +
  305 + xml_document<> doc; // character type defaults to char
  306 + try
  307 + {
  308 + doc.parse<0>((char *)xml);
  309 + xml_node<char> *node = doc.first_node();
  310 + if (!node)
  311 + {
  312 + result_msg = "<Error>打印模板无法解析</Error>";
  313 + ab->AppendString(result_msg.c_str());
  314 + return false;
  315 + }
  316 +
  317 + m_height = 1122;
  318 + m_width = 793;
  319 +
  320 + xml_node<char> *template_node = node->first_node("template");
  321 + if (template_node != nullptr)
  322 + {
  323 + InitTemplateValue(template_node->value());
  324 + }
  325 +
  326 + double boxX1, boxY1, boxX2, boxY2;
  327 + sscanf(bbox, "%lf,%lf,%lf,%lf", &boxX1, &boxY1, &boxX2, &boxY2); // &x1,&y1,&x2,&y2);
  328 + shared_ptr<MapParameter> pMapParameter(new MapParameter());
  329 + //Rect *rect_service = pWmsServer->GetExtent();
  330 + //if (rect_service)
  331 + //{
  332 + // rect_service->GetExtent(boxX1, boxX2, boxY1, boxY2);
  333 + //}
  334 +
  335 + xmin = min(boxX1, boxX2);
  336 + ymin = min(boxY1, boxY2);
  337 + xmax = max(boxX1, boxX2);
  338 + ymax = max(boxY1, boxY2);
  339 + pMapParameter->pWmsService = pWmsServer;
  340 + pMapParameter->InitParameter(xmin,xmax,ymax,ymin,m_width -100,m_height -120);
  341 +
  342 + shared_ptr<DmapPrintLayout> printLayout(new DmapPrintLayout());
  343 +
  344 + if(printLayout->ReadXML(node,pMapParameter,result_msg))
  345 + {
  346 + this->vector_dmapPrintLayout.push_back(printLayout);
  347 + ToPrint(ab);
  348 + return true;
  349 + }
  350 + }
  351 + catch (...)
  352 + {
  353 + result_msg = "<Error>error:Post参数是XML格式</Error>";
  354 + }
  355 +
  356 + ab->AppendString(result_msg.c_str());
  357 + return false;
  358 +
  359 + }
  360 +
  361 + bool DmpPrint::ToPrint(AppendBuffer *ab)
  362 + {
  363 + if(isPicture == PrintOutputFormat::SVG)
  364 + {
  365 + //string path = this->GetFilePath("mapPrint.pdf");
  366 + cairo_surface_t *surface = cairo_svg_surface_create_for_stream(cairo_write_func_print,ab,
  367 + (int)m_width,
  368 + (int)m_height);
  369 +
  370 + //cairo_surface_set_fallback_resolution(surface,900,900);
  371 + clsCrSurf mClsSurfDC(surface,(int)m_width,(int)m_height,false);
  372 + cairo_set_antialias(mClsSurfDC.m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST);
  373 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  374 +
  375 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  376 + {
  377 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  378 + layout->DrawData(&mClsSurfDC,PrintOutputFormat::SVG);
  379 + }
  380 + }
  381 + else if(isPicture == PrintOutputFormat::PDF)
  382 + {
  383 + //string path = this->GetFilePath("mapPrint.pdf");
  384 + cairo_surface_t *surface = cairo_pdf_surface_create_for_stream(cairo_write_func_print,ab,
  385 + (int)m_width,
  386 + (int)m_height);
  387 +
  388 + //cairo_surface_set_fallback_resolution(surface,900,900);
  389 + clsCrSurf mClsSurfDC(surface,(int)m_width,(int)m_height,false);
  390 + cairo_set_antialias(mClsSurfDC.m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST);
  391 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  392 +
  393 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  394 + {
  395 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  396 + layout->DrawData(&mClsSurfDC,PrintOutputFormat::PDF);
  397 + }
  398 + }
  399 + else
  400 + {
  401 + cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
  402 + (int)m_width,
  403 + (int)m_height);
  404 +
  405 +
  406 +
  407 + //cairo_surface_set_fallback_resolution(surface);
  408 + //double dpix, dpiy;
  409 + //cairo_surface_get_fallback_resolution(surface,&dpix, &dpiy);
  410 + //printf("%f,%f",dpix,dpiy);
  411 +
  412 + clsCrSurf mClsSurfDC(surface);
  413 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  414 +
  415 +
  416 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  417 + {
  418 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  419 + layout->DrawData(&mClsSurfDC,PrintOutputFormat::PNG);
  420 + }
  421 +
  422 + cairo_surface_write_to_png_stream(surface, cairo_write_func_print, ab);
  423 + }
  424 + return true;
  425 + }
  426 +
  427 +
  428 + bool DmpPrint::InitTemplateValue(string templateValue)
  429 + {
  430 +
  431 + if (templateValue == "A4竖" || templateValue == "A4-hoch")
  432 + {
  433 + m_height = 1122;
  434 + m_width = 793;
  435 + }
  436 + else if (templateValue == "A4横" || templateValue == "A4-quer")
  437 + {
  438 + m_height = 793;
  439 + m_width = 1122;
  440 + }
  441 + else if (templateValue == "A3竖" || templateValue == "A3-hoch")
  442 + {
  443 + m_height = 1122 * 2;
  444 + m_width = 793 * 2;
  445 + }
  446 + else if (templateValue == "A3横" || templateValue == "A3-quer")
  447 + {
  448 + m_height = 793 * 2;
  449 + m_width = 1122 * 2;
  450 + }
  451 + else if (templateValue == "A5竖" || templateValue == "A5-hoch")
  452 + {
  453 + m_height = 1122 / 2;
  454 + m_width = 793 / 2;
  455 + }
  456 + else if (templateValue == "A5横" || templateValue == "A5-quer")
  457 + {
  458 + m_height = 793 / 2;
  459 + m_width = 1122 / 2;
  460 + }
  461 + return true;
  462 + }
  463 +
  464 +
  465 + bool DmpPrint::Test(AppendBuffer *ab,map<string, shared_ptr<WMSServer>> &mapWmsServer,string servername)
  466 + {
  467 + //double scaleDenominator = 0;
  468 +
  469 + shared_ptr<MapParameter> pMapParameter(new MapParameter());
  470 +
  471 +
  472 + shared_ptr<OperationalDmapLayer> dmapLayer(new OperationalDmapLayer());
  473 + dmapLayer->serviceName = servername;
  474 +
  475 + map<string, shared_ptr<WMSServer>>::iterator iter = mapWmsServer.find(dmapLayer->serviceName);
  476 + if(iter !=mapWmsServer.end())
  477 + {
  478 + dmapLayer->m_wmsServer = iter->second;
  479 + Rect *rect = dmapLayer->m_wmsServer->GetExtent();
  480 + pMapParameter->InitParameter(rect->m_dLeft,rect->m_dRight,rect->m_dTop,rect->m_dBottom,693,1022);
  481 + double scaleDenominator = this->RecalculateScale(rect->m_dRight,rect->m_dLeft,rect->m_dTop,rect->m_dBottom,1022,693);
  482 + }
  483 + else
  484 + {
  485 + return false;
  486 + }
  487 +
  488 +
  489 + //dmapLayer->serviceName = "土地利用现状";
  490 + //dmapLayer->m_id = "土地利用现状";
  491 + //dmapLayer->boxX1 = 683497;
  492 + //dmapLayer->boxX2 = 695357;
  493 + //dmapLayer->boxY1 = 2534922;
  494 + //dmapLayer->boxY2 = 2543053;
  495 +
  496 + Rect* rect = dmapLayer->m_wmsServer->GetExtent();
  497 +
  498 + dmapLayer->boxX1 = rect->m_dLeft;
  499 + dmapLayer->boxX2 = rect->m_dRight;
  500 + dmapLayer->boxY1 = rect->m_dBottom;
  501 + dmapLayer->boxY2 = rect->m_dTop;
  502 +
  503 + shared_ptr<DmapPrintLayout> dmapLayout(new DmapPrintLayout());
  504 + this->vector_dmapPrintLayout.push_back(dmapLayout);
  505 +
  506 +
  507 + dmapLayout->data.push_back(dmapLayer);
  508 + dmapLayout->localtion_x = 50;
  509 + dmapLayout->localtion_y = 70;
  510 +
  511 + dmapLayout->height = 1022;
  512 + dmapLayout->width = 693;
  513 +
  514 + this->m_height = 1122;
  515 + this->m_width = 793;
  516 +
  517 +
  518 + shared_ptr<OperationalGeom> geomLayer_scale(new OperationalGeom());
  519 + geomLayer_scale->pMapParameter = pMapParameter;
  520 + geomLayer_scale->type = "scale";
  521 + shared_ptr<DmapPrintLayout> dmapLayout_scale(new DmapPrintLayout());
  522 + this->vector_dmapPrintLayout.push_back(dmapLayout_scale);
  523 + dmapLayout_scale->localtion_x = 150;
  524 + dmapLayout_scale->localtion_y = 1022+20;
  525 + dmapLayout_scale->data.push_back(geomLayer_scale);
  526 +
  527 +
  528 + shared_ptr<OperationalGeom> geomLayer_compass(new OperationalGeom());
  529 + geomLayer_compass->pMapParameter = pMapParameter;
  530 + geomLayer_compass->type = "compass";
  531 + shared_ptr<DmapPrintLayout> dmapLayout_compass(new DmapPrintLayout());
  532 + this->vector_dmapPrintLayout.push_back(dmapLayout_compass);
  533 + dmapLayout_compass->localtion_x = 80;
  534 + dmapLayout_compass->localtion_y = 1022-10;
  535 + dmapLayout_compass->data.push_back(geomLayer_compass);
  536 +
  537 +
  538 + if(isPicture == DmpWmsParameters::Format::SVG)
  539 + {
  540 + //string path = this->GetFilePath("mapPrint.pdf");
  541 + cairo_surface_t *surface = cairo_svg_surface_create_for_stream(cairo_write_func_print,ab,
  542 + (int)m_width,
  543 + (int)m_height);
  544 +
  545 + //cairo_surface_set_fallback_resolution(surface,900,900);
  546 + clsCrSurf mClsSurfDC(surface,(int)m_width,(int)m_height,false);
  547 + cairo_set_antialias(mClsSurfDC.m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST);
  548 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  549 +
  550 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  551 + {
  552 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  553 + layout->DrawData(&mClsSurfDC,DmpWmsParameters::Format::SVG);
  554 + }
  555 + }
  556 + else if(isPicture == DmpWmsParameters::Format::PDF)
  557 + {
  558 + //string path = this->GetFilePath("mapPrint.pdf");
  559 + cairo_surface_t *surface = cairo_pdf_surface_create_for_stream(cairo_write_func_print,ab,
  560 + (int)m_width,
  561 + (int)m_height);
  562 +
  563 + //cairo_surface_set_fallback_resolution(surface,900,900);
  564 + clsCrSurf mClsSurfDC(surface,(int)m_width,(int)m_height,false);
  565 + cairo_set_antialias(mClsSurfDC.m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST);
  566 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  567 +
  568 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  569 + {
  570 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  571 + layout->DrawData(&mClsSurfDC,DmpWmsParameters::Format::PDF);
  572 + }
  573 + }
  574 + else
  575 + {
  576 + cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
  577 + (int)m_width,
  578 + (int)m_height);
  579 +
  580 +
  581 +
  582 + //cairo_surface_set_fallback_resolution(surface);
  583 + //double dpix, dpiy;
  584 + //cairo_surface_get_fallback_resolution(surface,&dpix, &dpiy);
  585 + //printf("%f,%f",dpix,dpiy);
  586 +
  587 + clsCrSurf mClsSurfDC(surface);
  588 + DoSetBackGround(&mClsSurfDC, 0xffffffff);
  589 +
  590 +
  591 + for (size_t i = 0; i < vector_dmapPrintLayout.size(); i++)
  592 + {
  593 + shared_ptr<DmapPrintLayout> layout = vector_dmapPrintLayout.at(i);
  594 + layout->DrawData(&mClsSurfDC, DmpWmsParameters::Format::PNG);
  595 + }
  596 +
  597 + cairo_surface_write_to_png_stream(surface, cairo_write_func_print, ab);
  598 + }
  599 +
  600 +
  601 + }
  602 +
  603 +
  604 +double DmpPrint::RecalculateScale(double right, double left, double top, double bottom, double width, double height )
  605 +{
  606 + double w = right - left;
  607 + double h = top - bottom;
  608 + double oneInchInLayoutUnits = 0.0254;
  609 + double resolution = 96;
  610 + if ((w > std::pow(10, 12)) || (w < std::pow(10, -12)))
  611 + return false;
  612 + if ((h > std::pow(10, 12)) || (h < std::pow(10, -12)))
  613 + return false;
  614 +
  615 + long double R1 = width / w;
  616 + long double R2 = height / h;
  617 + double r = R1 < R2 ? R1 : R2;
  618 + if ((r > std::pow(10, 12)) || (r < std::pow(10, -12)))
  619 + return false;
  620 +
  621 + //m_dR = R1 < R2 ? R1 : R2;
  622 + double m_dR = r;
  623 + double m_dXdis = width / 2.0 - m_dR * (right + left) / 2.0;
  624 + double m_dYdis = height / 2.0 + m_dR * (top + bottom) / 2.0;
  625 +
  626 +
  627 +
  628 +
  629 + bool isWGS84 = left <=180 && right <180 &&
  630 + left >= -180 && right >=-180 &&
  631 + top < 90 && bottom <90;
  632 +
  633 + double scaleDenominator = 0;
  634 + if(isWGS84)
  635 + {
  636 + scaleDenominator = (resolution / oneInchInLayoutUnits)*(1/r)*111000;
  637 + //m_dR = r *(96 / 0.0254) *111000 ;//111000 为赤道1经度等于 111000米
  638 + }
  639 + else
  640 + {
  641 + scaleDenominator= (resolution / oneInchInLayoutUnits) * 1/r;
  642 + }
  643 +
  644 + return scaleDenominator;
  645 +}
  646 +
  647 + string DmpPrint::GetFilePath(string path)
  648 + {
  649 + char sz[200] = {0};
  650 + if(GetCurrentFolderPath(sz, sizeof(sz)) > 0)
  651 + {
  652 + std::string s;
  653 + s = sz;
  654 + size_t t = s.rfind('/');
  655 + sz[t] = 0;
  656 + if(path[0]=='/')
  657 + {
  658 + return path;
  659 + }
  660 + int i=0;
  661 + if(path[0]=='.')
  662 + {
  663 + if(path[1]=='.')
  664 + {
  665 + i++;
  666 + s= sz;
  667 + t = s.rfind('/');
  668 + sz[t] = 0;
  669 + }
  670 + i++;
  671 + }
  672 + if((sz[t]=='/' || sz[t]=='\\')&& (path[i]=='/' || path[i]=='\\'))
  673 + {
  674 + i++;
  675 + }
  676 +
  677 + int j= t;
  678 + for(j=t;i<path.length(); i++,j++)
  679 + {
  680 + if(path[i]=='\\')
  681 + {
  682 + sz[j] = '/';
  683 + }
  684 + else
  685 + {
  686 + sz[j] = path[i];
  687 + }
  688 +
  689 + }
  690 + sz[j] =0;
  691 + //strcat(sz, path.c_str());
  692 + return sz;
  693 + }
  694 + else return 0;
  695 +
  696 + }
  697 +
  698 + int DmpPrint::GetCurrentFolderPath(char* processdir, size_t len)
  699 + {
  700 + char* path_end;
  701 + if (readlink("/proc/self/exe", processdir, len) <= 0)
  702 + return -1;
  703 + path_end = strrchr(processdir, '/');
  704 + if (path_end == NULL)
  705 + return -1;
  706 + ++path_end;
  707 + //strcpy(processname, path_end);
  708 + *path_end = '\0';
  709 + return (size_t)(path_end - processdir);
  710 + }
  711 +
  712 +
  713 +
  714 + bool DmpPrint::DoSetBackGround(clsCrSurf *pClsCS, int iColor)
  715 + {
  716 + cairo_surface_t *surface = pClsCS->m_pSurf;
  717 + cairo_t *cr = pClsCS->m_pCr;
  718 + int surf_w = cairo_image_surface_get_width(surface);
  719 + int surf_h = cairo_image_surface_get_height(surface);
  720 + //画一个矩形背景
  721 + cairo_rectangle(cr, 0, 0, surf_w, surf_h);
  722 + double r, g, b, a;
  723 + MyUtil::ToCairoColor(iColor, r, g, b, a);
  724 + cairo_set_source_rgb(cr, r, g, b);
  725 + cairo_fill(cr);
  726 + return true;
  727 + }*/
  728 +}
\ No newline at end of file
... ...
... ... @@ -14,6 +14,9 @@
14 14 #include <string.h>
15 15 #include <vector>
16 16 #include <map>
  17 +#include <math.h>
  18 +#include "dmpproject.h"
  19 +#include "dmpwmsrenderer.h"
17 20
18 21 #include "clsCrSurf.h"
19 22 #include "clsRect.h"
... ... @@ -48,27 +51,26 @@ namespace DmpWms
48 51 bool ToPrint(std::string &responseData);
49 52
50 53 public:
51   - DmpPrint(int isPicture);
52   -/*
53   - bool getPrint(AppendBuffer *ab, map<string, shared_ptr<WMSServer>> &mapWmsServer, const char *xml, string servername);
54   - bool getPrint(AppendBuffer *ab, map<string, shared_ptr<WMSServer>> &mapWmsServer, string servername, const char *printTemp, const char *bbox);
  54 + DmpPrint();
  55 +
  56 + bool getPrint(std::string &responseData, DmpProject* project, const char *xml, string servername);
  57 + bool getPrint(std::string &responseData, DmpProject* project, const char *printTemp, const char *bbox);
55 58
56   - bool getPrintLayout(AppendBuffer *ab,
57   - shared_ptr<WMSServer> pWmsServer,
  59 + bool getPrintLayout(std::string &responseData,
  60 + DmpProject* project,
58 61 const char *xml,
59 62 const char *bbox);
60 63
61   - bool getPrintTempFile(AppendBuffer *ab,
62   - shared_ptr<WMSServer> pWmsServer,
  64 + bool getPrintTempFile(std::string &responseData,
  65 + DmpProject* project,
63 66 const char *tempName,
64 67 const char *bbox);
65 68
66   - bool Test(AppendBuffer *ab, map<string, shared_ptr<WMSServer>> &mapWmsServer, string servername);
  69 + bool Test(std::string &responseData, DmpProject* project, string servername);
67 70
68   - vector<shared_ptr<DmapPrintLayout>> vector_dmapPrintLayout;
69   -
70   - vector<shared_ptr<OperationalLayer>> vector_operationalLayer;
71   - */
  71 + // vector<shared_ptr<DmapPrintLayout>> vector_dmapPrintLayout;
  72 + // vector<shared_ptr<OperationalLayer>> vector_operationalLayer;
  73 +
72 74 };
73 75 }
74 76
... ...
  1 +/**************************************************************************
  2 +* file: dmpprintlayout.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-01-25 15:12:38
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpprintlayout.h"
  10 +
  11 +namespace DmpWms
  12 +{
  13 +
  14 +}
\ No newline at end of file
... ...
  1 +/**************************************************************************
  2 +* file: dmpprintlayout.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-01-25 15:12:34
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpprintlayout_h__
  11 +#define __dmpprintlayout_h__
  12 +
  13 +namespace DmpWms
  14 +{
  15 +
  16 +}
  17 +
  18 +#endif // __dmpprintlayout_h__
  19 +
  20 +
... ...
... ... @@ -25,7 +25,9 @@ namespace DmpWms
25 25 XML,
26 26 HTML,
27 27 GML,
28   - GeoJson
  28 + GeoJson,
  29 + PDF,
  30 + SVG
29 31 };
30 32 DmpWmsParameters(const DmpServerParameters &parameters);
31 33 DmpWmsParameters();
... ...
... ... @@ -149,11 +149,11 @@ namespace DmpWms
149 149
150 150 string tableName = layer->name(); //layer->name();
151 151 string shapeName = layer->geom();
152   - shared_ptr<DmpVectorThinLayer> pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
  152 + shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
153 153
154   - if (pVectorThinLayer != nullptr)
  154 + if (pVectorVacuateLayer != nullptr)
155 155 {
156   - tableName = pVectorThinLayer->tableName();
  156 + tableName = pVectorVacuateLayer->tableName();
157 157 }
158 158
159 159 ss += " FROM \"%s\".\"%s\" "; // 这个 %s 是tableName
... ... @@ -207,11 +207,11 @@ namespace DmpWms
207 207
208 208 string tableName = layer->name(); //layer->name();
209 209 string shapeName = layer->geom();
210   - shared_ptr<DmpVectorThinLayer> pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
  210 + shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
211 211
212   - if (pVectorThinLayer != nullptr)
  212 + if (pVectorVacuateLayer != nullptr)
213 213 {
214   - tableName = pVectorThinLayer->tableName();
  214 + tableName = pVectorVacuateLayer->tableName();
215 215 }
216 216
217 217 ss += " FROM \"%s\".\"%s\" "; // 这个 %s 是tableName
... ... @@ -294,11 +294,11 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
294 294
295 295 string tableName = layer->name(); //layer->name();
296 296 string shapeName = layer->geom();
297   - shared_ptr<DmpVectorThinLayer> pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
  297 + shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
298 298
299   - if (pVectorThinLayer != nullptr)
  299 + if (pVectorVacuateLayer != nullptr)
300 300 {
301   - tableName = pVectorThinLayer->tableName();
  301 + tableName = pVectorVacuateLayer->tableName();
302 302 }
303 303
304 304 ss += " FROM \"%s\".\"%s\" "; // 这个 %s 是tableName
... ... @@ -332,7 +332,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
332 332 return "";
333 333 }
334 334
335   - string DmpWmsRenderer::GetDrawSQLAll_Catch(DmpVectorLayer *layer, shared_ptr<DmpVectorThinLayer> pVectorThinLayer)
  335 + string DmpWmsRenderer::GetDrawSQLAll_Catch(DmpVectorLayer *layer, shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer)
336 336 {
337 337 if (layer == 0 || layer->geom().size() == 0)
338 338 return "";
... ... @@ -363,9 +363,9 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
363 363 }
364 364
365 365 string tableName = layer->name();
366   - if (pVectorThinLayer != nullptr)
  366 + if (pVectorVacuateLayer != nullptr)
367 367 {
368   - tableName = pVectorThinLayer->tableName();
  368 + tableName = pVectorVacuateLayer->tableName();
369 369 }
370 370
371 371 string shapeName = layer->geom();
... ... @@ -470,9 +470,9 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
470 470 string tableName = layer->name();
471 471 string shapeName = layer->geom();
472 472
473   - if (layer->thinLayers().size() > 0)
  473 + if (layer->vacuateLayers().size() > 0)
474 474 {
475   - tableName = layer->thinLayers()[0]->tableName();
  475 + tableName = layer->vacuateLayers()[0]->tableName();
476 476 }
477 477
478 478 std::string sql = format(ss.c_str(), layer->schema().c_str(), tableName.c_str());
... ... @@ -1038,7 +1038,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1038 1038 outputStream << buff;
1039 1039
1040 1040 string sql = "";
1041   - shared_ptr<DmpVectorThinLayer> pVectorThinLayer = nullptr;
  1041 + shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer = nullptr;
1042 1042
1043 1043 shared_ptr<DataCollection> data(new DataCollection());
1044 1044
... ... @@ -1051,7 +1051,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1051 1051 sql = GetRegionQuerySQL(layer, pExtent.get(), format("%d", layer->crs().srid()), strRegionLayerNameDefs, strRegionColDefs, strLayerDef);
1052 1052 }
1053 1053
1054   - pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
  1054 + pVectorVacuateLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
1055 1055
1056 1056 string sqlLog = sql;
1057 1057 DmpMapServerUtil::toXmlString(sqlLog);
... ... @@ -1064,9 +1064,9 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1064 1064
1065 1065 string tableName = layer->name();
1066 1066
1067   - if (pVectorThinLayer != nullptr)
  1067 + if (pVectorVacuateLayer != nullptr)
1068 1068 {
1069   - tableName = pVectorThinLayer->tableName();
  1069 + tableName = pVectorVacuateLayer->tableName();
1070 1070 }
1071 1071
1072 1072 if (tableName.length() > 32)
... ... @@ -1080,13 +1080,13 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1080 1080 {
1081 1081
1082 1082 shared_ptr<DmpPgsql> pPgsqlConn = nullptr;
1083   - if (pVectorThinLayer == nullptr)
  1083 + if (pVectorVacuateLayer == nullptr)
1084 1084 {
1085 1085 pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source());
1086 1086 }
1087 1087 else
1088 1088 {
1089   - pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetDefaultPgsqlConn();
  1089 + pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(pVectorVacuateLayer->connectStr());
1090 1090 }
1091 1091
1092 1092 if (pPgsqlConn == nullptr)
... ... @@ -1106,7 +1106,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1106 1106 sprintf(buff,"<log>draw success</log>");
1107 1107 outputStream << buff;
1108 1108 }
1109   - else if (pVectorThinLayer != nullptr)
  1109 + else if (pVectorVacuateLayer != nullptr)
1110 1110 {
1111 1111 /*shared_ptr<DmpPgsql> pPgsqlConn1 = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source());
1112 1112 sprintf(buff,"<log>从抽稀图层获取数据%s</log>", pMapLayerThinning->m_tableName.c_str());
... ... @@ -1231,7 +1231,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1231 1231 double cost, cost2;
1232 1232
1233 1233 string sql = "";
1234   - shared_ptr<DmpVectorThinLayer> pVectorThinLayer = nullptr;
  1234 + shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer = nullptr;
1235 1235
1236 1236 bool renderHeat = false;
1237 1237 shared_ptr<DataCollection> data(new DataCollection());
... ... @@ -1245,7 +1245,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1245 1245 sql = GetRegionQuerySQL(layer, pExtent.get(), format("%d", layer->crs().srid()), strRegionLayerNameDefs, strRegionColDefs, strLayerDef);
1246 1246 }
1247 1247
1248   - pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
  1248 + pVectorVacuateLayer = layer->GetCurrentScaleTable(1 / this->m_dR);
1249 1249
1250 1250 // printf( "%s\r\n", sql.c_str());
1251 1251 // this->GetDrawSQL(layer, pExtent.get(), strLayerDef); //sql语句中使用 ::box
... ... @@ -1254,9 +1254,9 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1254 1254
1255 1255 string tableName = layer->name();
1256 1256
1257   - if (pVectorThinLayer != nullptr)
  1257 + if (pVectorVacuateLayer != nullptr)
1258 1258 {
1259   - tableName = pVectorThinLayer->tableName();
  1259 + tableName = pVectorVacuateLayer->tableName();
1260 1260 }
1261 1261
1262 1262 if (tableName.length() > 32)
... ... @@ -1270,13 +1270,13 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1270 1270 {
1271 1271
1272 1272 shared_ptr<DmpPgsql> pPgsqlConn = nullptr;
1273   - if (pVectorThinLayer == nullptr)
  1273 + if (pVectorVacuateLayer == nullptr)
1274 1274 {
1275 1275 pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source());
1276 1276 }
1277 1277 else
1278 1278 {
1279   - pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetDefaultPgsqlConn();
  1279 + pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(pVectorVacuateLayer->connectStr());
1280 1280 }
1281 1281
1282 1282 if (pPgsqlConn == nullptr)
... ... @@ -1300,7 +1300,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1300 1300 this->DrawSimpleData(data.get(), layer->GetRenderer30().get(), pClsSurfThis);
1301 1301
1302 1302 }
1303   - else if (pVectorThinLayer != nullptr)
  1303 + else if (pVectorVacuateLayer != nullptr)
1304 1304 {
1305 1305 shared_ptr<DmpPgsql> pPgsqlConn1 = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source());
1306 1306
... ...
... ... @@ -22,7 +22,7 @@
22 22 #include "clsUtil.h"
23 23 #include "DataCollection.h"
24 24 #include "dmpvectorlayer.h"
25   -#include "dmpvectorthinlayer.h"
  25 +#include "dmpvectorvacuatelayer.h"
26 26 #include "dmprasterbuffer.h"
27 27 #include "dmpproject.h"
28 28 #include "dmppgsqlsourcepools.h"
... ... @@ -32,8 +32,6 @@ using namespace DmapCore_30;
32 32 using namespace mapserver;
33 33 namespace DmpWms
34 34 {
35   -
36   -
37 35 class DmpWmsRenderer
38 36 {
39 37 public:
... ... @@ -49,7 +47,7 @@ namespace DmpWms
49 47 bool GetMapLegend( std::stringstream& ab, shared_ptr<legendParamater> pLegendParamater);
50 48 bool GetMapLegend( shared_ptr<legendParamater> pLegendParamater, clsCrSurf* pClsSurf);
51 49
52   - string GetDrawSQLAll_Catch(DmpVectorLayer* layer,shared_ptr<DmpVectorThinLayer> pMapLayerThinning);
  50 + string GetDrawSQLAll_Catch(DmpVectorLayer* layer,shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer);
53 51 string GetDrawSQL(DmpVectorLayer* layer, Rect* pRect,const char* layerdef = nullptr);
54 52 string GetDrawSQLAll(DmpVectorLayer* layer);
55 53 string GetDrawSQLAllOrderby(DmpVectorLayer* layer);
... ...
注册登录 后发表评论