正在显示
25 个修改的文件
包含
1282 行增加
和
59 行删除
@@ -293,32 +293,22 @@ bool DmpVectorLayer::setDataProvider(const std::string &provider) | @@ -293,32 +293,22 @@ bool DmpVectorLayer::setDataProvider(const std::string &provider) | ||
293 | return true; | 293 | return true; |
294 | } | 294 | } |
295 | 295 | ||
296 | -shared_ptr<DmpVectorVacuateLayer> DmpVectorLayer::GetCurrentScaleTable(double dx) | 296 | +bool sortVacuateLayers(shared_ptr<DmpVectorVacuateLayer> p1,shared_ptr<DmpVectorVacuateLayer> p2) |
297 | { | 297 | { |
298 | + return p1->dis() > p2->dis(); | ||
299 | +} | ||
298 | 300 | ||
299 | - /* | ||
300 | - int outTime = 600; | ||
301 | - if(this->dataCount >500000 && this->m_pDataset->m_MapLayerThinning.size() ==0) | ||
302 | - { | ||
303 | - outTime = 20; | ||
304 | - } | ||
305 | - | ||
306 | - clsLockClass lock(_wlock); | ||
307 | - time_t now = time(0); | ||
308 | - //shared_ptr<WMSServer> wmsServer = this->m_mapWmsServer[servicename]; | ||
309 | - if(now - this->m_pDataset->m_loadMapLayerThinning > outTime) | ||
310 | - { | ||
311 | - this->m_pDataset->m_loadMapLayerThinning = now; | ||
312 | - shared_ptr<Workspace> pWorkspaceDef = DataSourcePools::get_instance()->GetDefaultWorkspace(); | 301 | +void DmpVectorLayer::ApplendCurrentScaleTable(shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer) |
302 | +{ | ||
303 | + this->vacuateLayers_.push_back(pVectorVacuateLayer); | ||
304 | + sort(this->vacuateLayers_.begin(), this->vacuateLayers_.end(),sortVacuateLayers); | ||
305 | + return; | ||
306 | +} | ||
313 | 307 | ||
314 | - this->m_pDataset->InitMapLayerThinning(pWorkspaceDef.get(),this->m_layerName, this->m_dbSource); | ||
315 | - } | ||
316 | - else | ||
317 | - { | ||
318 | - this->m_pDataset->m_loadMapLayerThinning = now; | ||
319 | - } | ||
320 | -*/ | ||
321 | 308 | ||
309 | +shared_ptr<DmpVectorVacuateLayer> DmpVectorLayer::GetCurrentScaleTable(double dx) | ||
310 | +{ | ||
311 | + dx *= 2; | ||
322 | for (int i = 0; i < this->vacuateLayers_.size(); i++) | 312 | for (int i = 0; i < this->vacuateLayers_.size(); i++) |
323 | { | 313 | { |
324 | shared_ptr<DmpVectorVacuateLayer> vacuateLayer = this->vacuateLayers_[i]; | 314 | shared_ptr<DmpVectorVacuateLayer> vacuateLayer = this->vacuateLayers_[i]; |
@@ -56,7 +56,7 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | @@ -56,7 +56,7 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer | ||
56 | shared_ptr<DmapCore_30::Renderer> GetRenderer30() { return renderer_30_; } | 56 | shared_ptr<DmapCore_30::Renderer> GetRenderer30() { return renderer_30_; } |
57 | vector<shared_ptr<DmpVectorVacuateLayer>> vacuateLayers() const { return vacuateLayers_; } | 57 | vector<shared_ptr<DmpVectorVacuateLayer>> vacuateLayers() const { return vacuateLayers_; } |
58 | shared_ptr<DmpVectorVacuateLayer> GetCurrentScaleTable(double dx); | 58 | shared_ptr<DmpVectorVacuateLayer> GetCurrentScaleTable(double dx); |
59 | - void ApplendCurrentScaleTable(shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer){vacuateLayers_.push_back(pVectorVacuateLayer);} | 59 | + void ApplendCurrentScaleTable(shared_ptr<DmpVectorVacuateLayer> pVectorVacuateLayer); |
60 | 60 | ||
61 | std::string schema() { return schema_;} | 61 | std::string schema() { return schema_;} |
62 | std::string geom() { return geom_;} | 62 | std::string geom() { return geom_;} |
@@ -30,6 +30,8 @@ class CORE_EXPORT DmpVectorVacuateLayer | @@ -30,6 +30,8 @@ class CORE_EXPORT DmpVectorVacuateLayer | ||
30 | 30 | ||
31 | double GeDisPix(); | 31 | double GeDisPix(); |
32 | 32 | ||
33 | + double dis() const { return m_ddis; } | ||
34 | + | ||
33 | std::string tableName()const { return m_tableName;} | 35 | std::string tableName()const { return m_tableName;} |
34 | 36 | ||
35 | std::string connectStr() const {return connectstr_;} | 37 | std::string connectStr() const {return connectstr_;} |
@@ -22,7 +22,15 @@ SET (MAPSERVER_SRCS | @@ -22,7 +22,15 @@ SET (MAPSERVER_SRCS | ||
22 | wms/dmpwmsgetmap.cpp | 22 | wms/dmpwmsgetmap.cpp |
23 | wms/dmpwmsserviceinfo.cpp | 23 | wms/dmpwmsserviceinfo.cpp |
24 | wms/dmpwmsgetfeatureinfo.cpp | 24 | wms/dmpwmsgetfeatureinfo.cpp |
25 | - wms/dmpprint.cpp | 25 | + wms/print/dmpmapprint.cpp |
26 | + wms/print/dmpprintlayer.cpp | ||
27 | + wms/print/dmpprinttext.cpp | ||
28 | + wms/print/dmpprintrect.cpp | ||
29 | + wms/print/dmpprintscale.cpp | ||
30 | + wms/print/dmpprintcompass.cpp | ||
31 | + wms/print/dmpprintlayout.cpp | ||
32 | + wms/print/dmpprintparameter.cpp | ||
33 | + wms/print/dmpprintwmsservice.cpp | ||
26 | mapping/dmpmapping.cpp | 34 | mapping/dmpmapping.cpp |
27 | mapping/dmpeditservice.cpp | 35 | mapping/dmpeditservice.cpp |
28 | mapping/dmpmappingparameters.cpp | 36 | mapping/dmpmappingparameters.cpp |
@@ -49,7 +57,15 @@ SET (MAPSERVER_HDRS | @@ -49,7 +57,15 @@ SET (MAPSERVER_HDRS | ||
49 | wms/dmpwmsgetmap.h | 57 | wms/dmpwmsgetmap.h |
50 | wms/dmpwmsserviceinfo.h | 58 | wms/dmpwmsserviceinfo.h |
51 | wms/dmpwmsgetfeatureinfo.h | 59 | wms/dmpwmsgetfeatureinfo.h |
52 | - wms/dmpprint.h | 60 | + wms/print/dmpmapprint.h |
61 | + wms/print/dmpprintlayer.h | ||
62 | + wms/print/dmpprinttext.h | ||
63 | + wms/print/dmpprintrect.h | ||
64 | + wms/print/dmpprintscale.h | ||
65 | + wms/print/dmpprintcompass.h | ||
66 | + wms/print/dmpprintlayout.h | ||
67 | + wms/print/dmpprintparameter.h | ||
68 | + wms/print/dmpprintwmsservice.h | ||
53 | mapping/dmpmapping.h | 69 | mapping/dmpmapping.h |
54 | mapping/dmpeditservice.h | 70 | mapping/dmpeditservice.h |
55 | mapping/dmpmappingparameters.h | 71 | mapping/dmpmappingparameters.h |
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 | -} |
@@ -753,6 +753,11 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ | @@ -753,6 +753,11 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ | ||
753 | return true; | 753 | return true; |
754 | } | 754 | } |
755 | 755 | ||
756 | + shared_ptr<Rect> DmpWmsRenderer::GetExtent() | ||
757 | + { | ||
758 | + return m_pExtent; | ||
759 | + } | ||
760 | + | ||
756 | bool DmpWmsRenderer::SetExtent(shared_ptr<Rect> rect) | 761 | bool DmpWmsRenderer::SetExtent(shared_ptr<Rect> rect) |
757 | { | 762 | { |
758 | m_pExtent = rect; | 763 | m_pExtent = rect; |
@@ -69,7 +69,7 @@ namespace DmpWms | @@ -69,7 +69,7 @@ namespace DmpWms | ||
69 | bool DrawSimpleData(DataCollection* data, Renderer* renderer, clsCrSurf* pClsSurf); | 69 | bool DrawSimpleData(DataCollection* data, Renderer* renderer, clsCrSurf* pClsSurf); |
70 | 70 | ||
71 | //shared_ptr<Rect> GetFullExtent(bool bRecalculate); //加一个bool值,如果为false , 无需计算 | 71 | //shared_ptr<Rect> GetFullExtent(bool bRecalculate); //加一个bool值,如果为false , 无需计算 |
72 | - //shared_ptr<Rect> GetExtent(); | 72 | + shared_ptr<Rect> GetExtent(); |
73 | bool SetExtent(shared_ptr<Rect> rect); | 73 | bool SetExtent(shared_ptr<Rect> rect); |
74 | bool GetParameters(double* pR, double* pXdis, double* pYdis); | 74 | bool GetParameters(double* pR, double* pXdis, double* pYdis); |
75 | bool SetParameters(double r = -1, double xdis = 0, double ydis = 0); | 75 | bool SetParameters(double r = -1, double xdis = 0, double ydis = 0); |
1 | /************************************************************************** | 1 | /************************************************************************** |
2 | -* file: dmpprint.cpp | 2 | +* file: dmpmapprint.cpp |
3 | 3 | ||
4 | * Author: qingxiongf | 4 | * Author: qingxiongf |
5 | * Date: 2022-01-20 18:50:40 | 5 | * Date: 2022-01-20 18:50:40 |
6 | * Email: qingxiongf@chinadci.com | 6 | * Email: qingxiongf@chinadci.com |
7 | * copyright: 广州城市信息研究所有限公司 | 7 | * copyright: 广州城市信息研究所有限公司 |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | -#include "dmpprint.h" | 9 | +#include "dmpmapprint.h" |
10 | #include <unistd.h> | 10 | #include <unistd.h> |
11 | #include <algorithm> | 11 | #include <algorithm> |
12 | #include <cairo/cairo-svg.h> | 12 | #include <cairo/cairo-svg.h> |
@@ -21,11 +21,12 @@ namespace DmpWms | @@ -21,11 +21,12 @@ namespace DmpWms | ||
21 | return CAIRO_STATUS_SUCCESS; | 21 | return CAIRO_STATUS_SUCCESS; |
22 | } | 22 | } |
23 | 23 | ||
24 | - DmpPrint::DmpPrint() | 24 | + DmpMapPrint::DmpMapPrint() |
25 | { | 25 | { |
26 | + | ||
26 | } | 27 | } |
27 | /* | 28 | /* |
28 | - bool DmpPrint::getPrint(std::string &responseData, DmpProject *project,const char* xml,string servername) | 29 | + bool DmpMapPrint::getPrint(std::string &responseData, DmpProject *project,const char* xml,string servername) |
29 | { | 30 | { |
30 | string result_msg; | 31 | string result_msg; |
31 | 32 | ||
@@ -149,7 +150,7 @@ namespace DmpWms | @@ -149,7 +150,7 @@ namespace DmpWms | ||
149 | return true; | 150 | return true; |
150 | } | 151 | } |
151 | 152 | ||
152 | - bool DmpPrint::getPrint( std::string &responseData, DmpProject* project, | 153 | + bool DmpMapPrint::getPrint( std::string &responseData, DmpProject* project, |
153 | string servername,const char* printTemp,const char *bbox) | 154 | string servername,const char* printTemp,const char *bbox) |
154 | { | 155 | { |
155 | string result_msg; | 156 | string result_msg; |
@@ -269,7 +270,7 @@ namespace DmpWms | @@ -269,7 +270,7 @@ namespace DmpWms | ||
269 | } | 270 | } |
270 | 271 | ||
271 | 272 | ||
272 | - bool DmpPrint::getPrintTempFile(string &responseData,,const char* tempName, const char* bbox) | 273 | + bool DmpMapPrint::getPrintTempFile(string &responseData,,const char* tempName, const char* bbox) |
273 | { | 274 | { |
274 | string path = "./template/";path += tempName; path += ".xml"; | 275 | string path = "./template/";path += tempName; path += ".xml"; |
275 | 276 | ||
@@ -292,7 +293,7 @@ namespace DmpWms | @@ -292,7 +293,7 @@ namespace DmpWms | ||
292 | } | 293 | } |
293 | 294 | ||
294 | 295 | ||
295 | - bool DmpPrint::getPrintLayout(AppendBuffer *ab,shared_ptr<WMSServer> pWmsServer, | 296 | + bool DmpMapPrint::getPrintLayout(AppendBuffer *ab,shared_ptr<WMSServer> pWmsServer, |
296 | const char* xml,const char *bbox) | 297 | const char* xml,const char *bbox) |
297 | { | 298 | { |
298 | string result_msg; | 299 | string result_msg; |
@@ -358,7 +359,7 @@ namespace DmpWms | @@ -358,7 +359,7 @@ namespace DmpWms | ||
358 | 359 | ||
359 | } | 360 | } |
360 | 361 | ||
361 | - bool DmpPrint::ToPrint(AppendBuffer *ab) | 362 | + bool DmpMapPrint::ToPrint(AppendBuffer *ab) |
362 | { | 363 | { |
363 | if(isPicture == PrintOutputFormat::SVG) | 364 | if(isPicture == PrintOutputFormat::SVG) |
364 | { | 365 | { |
@@ -425,7 +426,7 @@ namespace DmpWms | @@ -425,7 +426,7 @@ namespace DmpWms | ||
425 | } | 426 | } |
426 | 427 | ||
427 | 428 | ||
428 | - bool DmpPrint::InitTemplateValue(string templateValue) | 429 | + bool DmpMapPrint::InitTemplateValue(string templateValue) |
429 | { | 430 | { |
430 | 431 | ||
431 | if (templateValue == "A4竖" || templateValue == "A4-hoch") | 432 | if (templateValue == "A4竖" || templateValue == "A4-hoch") |
@@ -462,7 +463,7 @@ namespace DmpWms | @@ -462,7 +463,7 @@ namespace DmpWms | ||
462 | } | 463 | } |
463 | 464 | ||
464 | 465 | ||
465 | - bool DmpPrint::Test(AppendBuffer *ab,map<string, shared_ptr<WMSServer>> &mapWmsServer,string servername) | 466 | + bool DmpMapPrint::Test(AppendBuffer *ab,map<string, shared_ptr<WMSServer>> &mapWmsServer,string servername) |
466 | { | 467 | { |
467 | //double scaleDenominator = 0; | 468 | //double scaleDenominator = 0; |
468 | 469 | ||
@@ -601,7 +602,7 @@ namespace DmpWms | @@ -601,7 +602,7 @@ namespace DmpWms | ||
601 | } | 602 | } |
602 | 603 | ||
603 | 604 | ||
604 | -double DmpPrint::RecalculateScale(double right, double left, double top, double bottom, double width, double height ) | 605 | +double DmpMapPrint::RecalculateScale(double right, double left, double top, double bottom, double width, double height ) |
605 | { | 606 | { |
606 | double w = right - left; | 607 | double w = right - left; |
607 | double h = top - bottom; | 608 | double h = top - bottom; |
@@ -644,7 +645,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | @@ -644,7 +645,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | ||
644 | return scaleDenominator; | 645 | return scaleDenominator; |
645 | } | 646 | } |
646 | 647 | ||
647 | - string DmpPrint::GetFilePath(string path) | 648 | + string DmpMapPrint::GetFilePath(string path) |
648 | { | 649 | { |
649 | char sz[200] = {0}; | 650 | char sz[200] = {0}; |
650 | if(GetCurrentFolderPath(sz, sizeof(sz)) > 0) | 651 | if(GetCurrentFolderPath(sz, sizeof(sz)) > 0) |
@@ -695,7 +696,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | @@ -695,7 +696,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | ||
695 | 696 | ||
696 | } | 697 | } |
697 | 698 | ||
698 | - int DmpPrint::GetCurrentFolderPath(char* processdir, size_t len) | 699 | + int DmpMapPrint::GetCurrentFolderPath(char* processdir, size_t len) |
699 | { | 700 | { |
700 | char* path_end; | 701 | char* path_end; |
701 | if (readlink("/proc/self/exe", processdir, len) <= 0) | 702 | if (readlink("/proc/self/exe", processdir, len) <= 0) |
@@ -711,7 +712,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | @@ -711,7 +712,7 @@ double DmpPrint::RecalculateScale(double right, double left, double top, double | ||
711 | 712 | ||
712 | 713 | ||
713 | 714 | ||
714 | - bool DmpPrint::DoSetBackGround(clsCrSurf *pClsCS, int iColor) | 715 | + bool DmpMapPrint::DoSetBackGround(clsCrSurf *pClsCS, int iColor) |
715 | { | 716 | { |
716 | cairo_surface_t *surface = pClsCS->m_pSurf; | 717 | cairo_surface_t *surface = pClsCS->m_pSurf; |
717 | cairo_t *cr = pClsCS->m_pCr; | 718 | cairo_t *cr = pClsCS->m_pCr; |
src/server/services/mapserver/wms/dmpprint.h
→
src/server/services/mapserver/wms/print/dmpmapprint.h
1 | /************************************************************************** | 1 | /************************************************************************** |
2 | -* file: dmpprint.h | 2 | +* file: dmpmapprint.h |
3 | 3 | ||
4 | * Author: qingxiongf | 4 | * Author: qingxiongf |
5 | * Date: 2022-01-20 18:50:30 | 5 | * Date: 2022-01-20 18:50:30 |
@@ -16,16 +16,17 @@ | @@ -16,16 +16,17 @@ | ||
16 | #include <map> | 16 | #include <map> |
17 | #include <math.h> | 17 | #include <math.h> |
18 | #include "dmpproject.h" | 18 | #include "dmpproject.h" |
19 | -#include "dmpwmsrenderer.h" | 19 | +#include "../dmpwmsrenderer.h" |
20 | 20 | ||
21 | #include "clsCrSurf.h" | 21 | #include "clsCrSurf.h" |
22 | #include "clsRect.h" | 22 | #include "clsRect.h" |
23 | #include "clsUtil.h" | 23 | #include "clsUtil.h" |
24 | using namespace std; | 24 | using namespace std; |
25 | using namespace DmapCore_30; | 25 | using namespace DmapCore_30; |
26 | + | ||
26 | namespace DmpWms | 27 | namespace DmpWms |
27 | { | 28 | { |
28 | - class DmpPrint | 29 | + class DmpMapPrint |
29 | { | 30 | { |
30 | private: | 31 | private: |
31 | std::string m_name; | 32 | std::string m_name; |
@@ -51,7 +52,7 @@ namespace DmpWms | @@ -51,7 +52,7 @@ namespace DmpWms | ||
51 | bool ToPrint(std::string &responseData); | 52 | bool ToPrint(std::string &responseData); |
52 | 53 | ||
53 | public: | 54 | public: |
54 | - DmpPrint(); | 55 | + DmpMapPrint(); |
55 | 56 | ||
56 | bool getPrint(std::string &responseData, DmpProject* project, const char *xml, string servername); | 57 | 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); | 58 | bool getPrint(std::string &responseData, DmpProject* project, const char *printTemp, const char *bbox); |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintcompass.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:51:01 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintcompass.h" | ||
10 | + | ||
11 | +namespace DmpWms | ||
12 | +{ | ||
13 | + bool DmpPrintCompass::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
14 | + { | ||
15 | + | ||
16 | + return false; | ||
17 | + } | ||
18 | + | ||
19 | + bool DmpPrintCompass::ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr) | ||
20 | + { | ||
21 | + this->ReadXmlAttribute(pt,localtionX_,"localtion_x"); | ||
22 | + this->ReadXmlAttribute(pt,localtionY_,"localtion_y"); | ||
23 | + //this->ReadXmlAttribute(pt,type,"type"); | ||
24 | + | ||
25 | + this->ReadXmlAttribute(pt, boundSize_, "bound_size"); | ||
26 | + this->ReadXmlAttribute(pt, showbound_, "showBound"); | ||
27 | + | ||
28 | + this->pPrintParameter_ = pPrintParameter; | ||
29 | + | ||
30 | + return true; | ||
31 | + } | ||
32 | + | ||
33 | + | ||
34 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintcompass.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:50:56 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmpprintcompass_h__ | ||
10 | +#define __dmpprintcompass_h__ | ||
11 | + | ||
12 | +#include "dmpprintlayer.h" | ||
13 | +namespace DmpWms | ||
14 | +{ | ||
15 | + class DmpPrintCompass :public DmpPrintLayer | ||
16 | + { | ||
17 | + private: | ||
18 | + string serviceName; | ||
19 | + | ||
20 | + shared_ptr<DmpPrintParameter> pPrintParameter_ = nullptr; | ||
21 | + | ||
22 | + string type = "undefine"; | ||
23 | + | ||
24 | + public: | ||
25 | + //bool DrawImage(); | ||
26 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
27 | + bool ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr); | ||
28 | + }; | ||
29 | +} | ||
30 | + | ||
31 | +#endif // __dmpprintcompass_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintlayer.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 15:21:31 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintlayer.h" | ||
10 | + | ||
11 | +namespace DmpWms | ||
12 | +{ | ||
13 | + | ||
14 | + bool DmpPrintLayer::DrawBound(clsCrSurf* pClsCS,double width, double height) | ||
15 | + { | ||
16 | + if(this->showbound_) | ||
17 | + { | ||
18 | + cairo_t *cr = pClsCS->m_pCr; | ||
19 | + cairo_set_source_rgb (cr, 0, 0, 0); | ||
20 | + cairo_set_line_width (cr, this->boundSize_); | ||
21 | + | ||
22 | + cairo_rectangle (cr, localtionX_, localtionY_, width, height); | ||
23 | + cairo_stroke_preserve (cr); | ||
24 | + return false; | ||
25 | + } | ||
26 | + | ||
27 | + return true; | ||
28 | + } | ||
29 | + | ||
30 | + shared_ptr<clsCrSurf> DmpPrintLayer::CreateSurface(int width, int height, DmpWmsParameters::Format format) | ||
31 | + { | ||
32 | + cairo_surface_t *surface = nullptr; | ||
33 | + | ||
34 | + bool isImage = true; | ||
35 | + | ||
36 | + if (format == DmpWmsParameters::Format::PDF) | ||
37 | + { | ||
38 | + surface = cairo_pdf_surface_create_for_stream(nullptr, nullptr, (int)width, (int)height); | ||
39 | + isImage = false; | ||
40 | + } | ||
41 | + else if (format == DmpWmsParameters::Format::SVG) | ||
42 | + { | ||
43 | + surface = cairo_svg_surface_create_for_stream(nullptr, nullptr, (int)width, (int)height); | ||
44 | + isImage = false; | ||
45 | + } | ||
46 | + else | ||
47 | + { | ||
48 | + surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (int)width, (int)height); | ||
49 | + isImage = true; | ||
50 | + } | ||
51 | + shared_ptr<clsCrSurf> mClsSurfDC(new clsCrSurf(surface, (int)width, (int)height, isImage)); | ||
52 | + return mClsSurfDC; | ||
53 | + } | ||
54 | + | ||
55 | + bool DmpPrintLayer::ReadXmlAttribute(boost::property_tree::ptree &pt,double& v, const char* key) | ||
56 | + { | ||
57 | + try | ||
58 | + { | ||
59 | + string xmlattrkey = "<xmlattr>."; | ||
60 | + xmlattrkey += key; | ||
61 | + string value = pt.get<std::string>(xmlattrkey,"0"); | ||
62 | + v = atof(value.c_str()); | ||
63 | + return true; | ||
64 | + } | ||
65 | + catch(...) | ||
66 | + { | ||
67 | + return false; | ||
68 | + } | ||
69 | + } | ||
70 | + | ||
71 | + bool DmpPrintLayer::ReadXmlAttribute(boost::property_tree::ptree &pt,int& v, const char* key) | ||
72 | + { | ||
73 | + try | ||
74 | + { | ||
75 | + string xmlattrkey = "<xmlattr>."; | ||
76 | + xmlattrkey += key; | ||
77 | + string value = pt.get<std::string>(xmlattrkey,"0"); | ||
78 | + v = atoi(value.c_str()); | ||
79 | + return true; | ||
80 | + } | ||
81 | + catch(...) | ||
82 | + { | ||
83 | + return false; | ||
84 | + } | ||
85 | + } | ||
86 | + | ||
87 | + bool DmpPrintLayer::ReadXmlAttribute(boost::property_tree::ptree &pt,bool& v, const char* key) | ||
88 | + { | ||
89 | + try | ||
90 | + { | ||
91 | + string xmlattrkey = "<xmlattr>."; | ||
92 | + xmlattrkey += key; | ||
93 | + string value = pt.get<std::string>(xmlattrkey,"false"); | ||
94 | + if(value == "false")v = false; | ||
95 | + if(value == "true") v= true; | ||
96 | + | ||
97 | + return true; | ||
98 | + } | ||
99 | + catch(...) | ||
100 | + { | ||
101 | + return false; | ||
102 | + } | ||
103 | + } | ||
104 | + | ||
105 | + | ||
106 | + bool DmpPrintLayer::ReadXmlColorAttribute(boost::property_tree::ptree &pt,int& r, int& g, int& b, const char* key) | ||
107 | + { | ||
108 | + string color; | ||
109 | + if(this->ReadXmlAttribute(pt, color, key)) | ||
110 | + { | ||
111 | + string str_red; | ||
112 | + string str_greed; | ||
113 | + string str_blue; | ||
114 | + int i = color.find_first_of(','); | ||
115 | + if(i != string::npos) | ||
116 | + { | ||
117 | + str_red = color.substr(0,i); | ||
118 | + color = color.substr(i+1); | ||
119 | + } | ||
120 | + else | ||
121 | + { | ||
122 | + return false; | ||
123 | + } | ||
124 | + | ||
125 | + i = color.find_first_of(','); | ||
126 | + if(i != string::npos) | ||
127 | + { | ||
128 | + str_greed = color.substr(0,i); | ||
129 | + str_blue = color.substr(i+1); | ||
130 | + } | ||
131 | + else | ||
132 | + { | ||
133 | + return false; | ||
134 | + } | ||
135 | + | ||
136 | + r = atoi(str_red.c_str()); | ||
137 | + g = atoi(str_greed.c_str()); | ||
138 | + b = atoi(str_blue.c_str()); | ||
139 | + return true; | ||
140 | + } | ||
141 | + return false; | ||
142 | + } | ||
143 | + | ||
144 | + bool DmpPrintLayer::ReadXmlAttribute(boost::property_tree::ptree &pt,std::string& v, const char* key) | ||
145 | + { | ||
146 | + try | ||
147 | + { | ||
148 | + string xmlattrkey = "<xmlattr>."; | ||
149 | + xmlattrkey += key; | ||
150 | + v = pt.get<std::string>(xmlattrkey,""); | ||
151 | + return true; | ||
152 | + } | ||
153 | + catch(...) | ||
154 | + { | ||
155 | + return false; | ||
156 | + } | ||
157 | + } | ||
158 | + | ||
159 | + bool DmpPrintLayer::ReadXmlValue(boost::property_tree::ptree &pt,std::string& v, const char* key) | ||
160 | + { | ||
161 | + try | ||
162 | + { | ||
163 | + string xmlattrkey = key; | ||
164 | + v = pt.get<std::string>(xmlattrkey,""); | ||
165 | + return true; | ||
166 | + } | ||
167 | + catch(...) | ||
168 | + { | ||
169 | + return false; | ||
170 | + } | ||
171 | + } | ||
172 | + | ||
173 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintlayer.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 15:21:25 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpprintlayer_h__ | ||
11 | +#define __dmpprintlayer_h__ | ||
12 | +#include <string> | ||
13 | +#include <memory.h> | ||
14 | +#include <cairo/cairo-pdf.h> | ||
15 | +#include <cairo/cairo-svg.h> | ||
16 | +#include <boost/property_tree/ptree.hpp> | ||
17 | +#include <boost/property_tree/xml_parser.hpp> | ||
18 | +#include <boost/typeof/typeof.hpp> | ||
19 | +#include "clsCrSurf.h" | ||
20 | +#include "dmpprintparameter.h" | ||
21 | +#include "../dmpwmsparameters.h" | ||
22 | +using namespace DmapCore_30; | ||
23 | +using namespace std; | ||
24 | +namespace DmpWms | ||
25 | +{ | ||
26 | + class DmpPrintLayer | ||
27 | + { | ||
28 | + protected: | ||
29 | + std::string id_; | ||
30 | + | ||
31 | + std::string title_; | ||
32 | + | ||
33 | + std::string layerType_; | ||
34 | + | ||
35 | + //背景颜色 | ||
36 | + int backColor_; | ||
37 | + | ||
38 | + //边框颜色 | ||
39 | + int frameColor_; | ||
40 | + //边框类型 | ||
41 | + int frameType_; | ||
42 | + | ||
43 | + int localtionX_; | ||
44 | + | ||
45 | + int localtionY_; | ||
46 | + | ||
47 | + bool showbound_ = false; | ||
48 | + | ||
49 | + double boundSize_ = 0; | ||
50 | + | ||
51 | + public: | ||
52 | + // virtual bool InitNodeClass(); | ||
53 | + virtual bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) = 0; | ||
54 | + | ||
55 | + virtual bool ReadXML(boost::property_tree::ptree &pt, shared_ptr<DmpPrintParameter> pPrintParameter, std::string& errorstr)= 0; | ||
56 | + | ||
57 | + bool DrawBound(clsCrSurf* pClsCS,double width, double height); | ||
58 | + | ||
59 | + bool ReadXmlAttribute(boost::property_tree::ptree &pt,double& v, const char* key); | ||
60 | + | ||
61 | + bool ReadXmlAttribute(boost::property_tree::ptree &pt,int& v, const char* key); | ||
62 | + | ||
63 | + bool ReadXmlAttribute(boost::property_tree::ptree &pt,std::string& v, const char* key); | ||
64 | + | ||
65 | + bool ReadXmlAttribute(boost::property_tree::ptree &pt,bool& v, const char* key); | ||
66 | + | ||
67 | + bool ReadXmlColorAttribute(boost::property_tree::ptree &pt,int& r, int& g, int& b, const char* key); | ||
68 | + | ||
69 | + bool ReadXmlValue(boost::property_tree::ptree &pt,std::string& v, const char* key); | ||
70 | + | ||
71 | + shared_ptr<clsCrSurf> CreateSurface(int width, int height, DmpWmsParameters::Format format); | ||
72 | + }; | ||
73 | +} | ||
74 | + | ||
75 | +#endif // __dmpprintlayer_h__ |
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 | +#include "dmpprintrect.h" | ||
11 | +#include "dmpprintscale.h" | ||
12 | +#include "dmpprinttext.h" | ||
13 | +#include "dmpprintcompass.h" | ||
14 | +#include "dmpprintwmsservice.h" | ||
15 | +namespace DmpWms | ||
16 | +{ | ||
17 | + bool DmpPrintLayout::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
18 | + { | ||
19 | + for(size_t i =0; i< this->data.size(); i++) | ||
20 | + { | ||
21 | + shared_ptr<DmpPrintLayer> printlayer = this->data.at(i); | ||
22 | + printlayer->DrawData(pClsCS,format); | ||
23 | + } | ||
24 | + | ||
25 | + DrawBound(pClsCS); | ||
26 | + return true; | ||
27 | + } | ||
28 | + | ||
29 | + bool DmpPrintLayout::ReadXML(boost::property_tree::ptree &pt, shared_ptr<DmpPrintParameter> pPrintParameter,string& errorstr) | ||
30 | + { | ||
31 | + try | ||
32 | + { | ||
33 | + boost::property_tree::ptree ptbound = pt.get_child("bound"); | ||
34 | + this->ReadXmlAttribute(ptbound, showbound_, "show"); | ||
35 | + this->ReadXmlAttribute(ptbound, localtionX_, "localtion_x"); | ||
36 | + this->ReadXmlAttribute(ptbound, localtionY_, "localtion_y"); | ||
37 | + | ||
38 | + this->ReadXmlAttribute(ptbound, width_, "width"); | ||
39 | + this->ReadXmlAttribute(ptbound, height_, "height"); | ||
40 | + | ||
41 | + this->ReadXmlAttribute(ptbound, boundSize_, "bound_size"); | ||
42 | + } | ||
43 | + catch(const std::exception& e) | ||
44 | + { | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + try | ||
49 | + { | ||
50 | + boost::property_tree::ptree ptlayouts = pt.get_child("layouts"); | ||
51 | + // for (rapidxml::xml_node<char> *layout_node = layouts_node->first_node("layout"); | ||
52 | + // layout_node != nullptr; | ||
53 | + // layout_node = layout_node->next_sibling()) | ||
54 | + for (boost::property_tree::ptree::iterator pos = ptlayouts.begin(); pos != ptlayouts.end(); ++pos) | ||
55 | + { | ||
56 | + string type; | ||
57 | + boost::property_tree::ptree ptlayout = pos->second; | ||
58 | + this->ReadXmlAttribute(ptlayout, type, "type"); | ||
59 | + bool result = true; | ||
60 | + if (type == "text") | ||
61 | + { | ||
62 | + shared_ptr<DmpPrintLayer> layer(new DmpPrintText()); | ||
63 | + result = layer->ReadXML(ptlayout, pPrintParameter, errorstr); | ||
64 | + this->data.push_back(layer); | ||
65 | + } | ||
66 | + else if (type == "dmapservice") | ||
67 | + { | ||
68 | + shared_ptr<DmpPrintLayer> layer(new DmpPrintWMSService()); | ||
69 | + result = layer->ReadXML(ptlayout, pPrintParameter, errorstr); | ||
70 | + this->data.push_back(layer); | ||
71 | + } | ||
72 | + else if (type == "scale") | ||
73 | + { | ||
74 | + shared_ptr<DmpPrintLayer> layer(new DmpPrintScale()); | ||
75 | + result = layer->ReadXML(ptlayout, pPrintParameter, errorstr); | ||
76 | + this->data.push_back(layer); | ||
77 | + } | ||
78 | + else if (type == "compass") | ||
79 | + { | ||
80 | + shared_ptr<DmpPrintLayer> layer(new DmpPrintCompass()); | ||
81 | + result = layer->ReadXML(ptlayout, pPrintParameter, errorstr); | ||
82 | + this->data.push_back(layer); | ||
83 | + } | ||
84 | + else if (type == "rectangle" || type == "rect") | ||
85 | + { | ||
86 | + shared_ptr<DmpPrintLayer> layer(new DmpPrintRect()); | ||
87 | + result = layer->ReadXML(ptlayout, pPrintParameter, errorstr); | ||
88 | + this->data.push_back(layer); | ||
89 | + } | ||
90 | + else | ||
91 | + { | ||
92 | + errorstr = "布局元素错误,layout 值为(text,dmapservice,scale,compass)"; | ||
93 | + result = false; | ||
94 | + } | ||
95 | + } | ||
96 | + } | ||
97 | + catch (const std::exception &e) | ||
98 | + { | ||
99 | + } | ||
100 | + | ||
101 | + return true; | ||
102 | + } | ||
103 | + | ||
104 | + bool DmpPrintLayout::DrawBound(clsCrSurf* pClsCS) | ||
105 | + { | ||
106 | + cairo_t *cr = pClsCS->m_pCr; | ||
107 | + //cairo_set_antialias(pClsCS->m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST); | ||
108 | + cairo_set_source_rgb (cr, 0, 0, 0); | ||
109 | + cairo_set_line_width (cr, 1); | ||
110 | + | ||
111 | + cairo_rectangle (cr, localtionX_, localtionY_, width_, height_); | ||
112 | + cairo_stroke_preserve (cr); | ||
113 | + return true; | ||
114 | + } | ||
115 | +} |
@@ -9,10 +9,31 @@ | @@ -9,10 +9,31 @@ | ||
9 | 9 | ||
10 | #ifndef __dmpprintlayout_h__ | 10 | #ifndef __dmpprintlayout_h__ |
11 | #define __dmpprintlayout_h__ | 11 | #define __dmpprintlayout_h__ |
12 | - | 12 | +#include "dmpprintlayer.h" |
13 | +#include <vector> | ||
13 | namespace DmpWms | 14 | namespace DmpWms |
14 | { | 15 | { |
16 | + | ||
17 | + class DmpPrintLayout :public DmpPrintLayer | ||
18 | + { | ||
19 | + public: | ||
20 | + | ||
21 | + int width_; | ||
22 | + int height_; | ||
23 | + bool showbound_; | ||
24 | + int bound_size_ =1; | ||
25 | + | ||
26 | + | ||
27 | + vector<shared_ptr<DmpPrintLayer>> data; | ||
28 | + | ||
29 | + public: | ||
15 | 30 | ||
31 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
32 | + bool ReadXML(boost::property_tree::ptree &pt, shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr); | ||
33 | + private: | ||
34 | + bool DrawBound(clsCrSurf* pClsCS); | ||
35 | + | ||
36 | + }; | ||
16 | } | 37 | } |
17 | 38 | ||
18 | #endif // __dmpprintlayout_h__ | 39 | #endif // __dmpprintlayout_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintparameter.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:22:44 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintparameter.h" | ||
10 | + | ||
11 | +namespace DmpWms | ||
12 | +{ | ||
13 | + void DmpPrintParameter::InitParameter(double l0, double r0, double t0, double b0, int w0, int h0) | ||
14 | + { | ||
15 | + // if(rect) | ||
16 | + { | ||
17 | + right = r0; | ||
18 | + left = l0; | ||
19 | + top = t0; | ||
20 | + bottom = b0; | ||
21 | + width = w0; | ||
22 | + height = h0; | ||
23 | + | ||
24 | + double w = right - left; | ||
25 | + double h = top - bottom; | ||
26 | + | ||
27 | + if ((w > pow(10, 12)) || (w < pow(10, -12))) | ||
28 | + return; | ||
29 | + if ((h > pow(10, 12)) || (h < pow(10, -12))) | ||
30 | + return; | ||
31 | + | ||
32 | + long double R1 = width / w; | ||
33 | + long double R2 = height / h; | ||
34 | + double r = R1 < R2 ? R1 : R2; | ||
35 | + if ((r > pow(10, 12)) || (r < pow(10, -12))) | ||
36 | + return; | ||
37 | + | ||
38 | + // m_dR = R1 < R2 ? R1 : R2; | ||
39 | + m_dR = r; | ||
40 | + m_dXdis = width / 2.0 - m_dR * (right + left) / 2.0; | ||
41 | + m_dYdis = height / 2.0 + m_dR * (top + bottom) / 2.0; | ||
42 | + | ||
43 | + isWGS84 = left <= 180 && right < 180 && | ||
44 | + left >= -180 && right >= -180 && | ||
45 | + top < 90 && bottom < 90; | ||
46 | + | ||
47 | + double scaleDenominator = 0; | ||
48 | + if (isWGS84) | ||
49 | + { | ||
50 | + scaleDenominator = (resolution / oneInchInLayoutUnits) * (1 / r) * 111000; | ||
51 | + // m_dR = r *(96 / 0.0254) *111000 ;//111000 为赤道1经度等于 111000米 | ||
52 | + } | ||
53 | + else | ||
54 | + { | ||
55 | + scaleDenominator = (resolution / oneInchInLayoutUnits) * 1 / r; | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintparameter.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:22:41 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpprintparameter_h__ | ||
11 | +#define __dmpprintparameter_h__ | ||
12 | +#include <math.h> | ||
13 | +#include "dmpproject.h" | ||
14 | +#include <memory> | ||
15 | +using namespace std; | ||
16 | +namespace DmpWms | ||
17 | +{ | ||
18 | + class DmpPrintParameter | ||
19 | + { | ||
20 | + public: | ||
21 | + DmpProject* pWmsService = nullptr; | ||
22 | + | ||
23 | + bool isWGS84 = false; | ||
24 | + double dWgs = 111000; | ||
25 | + double scaleDenominator = 0; | ||
26 | + int width =0; | ||
27 | + int height =0; | ||
28 | + | ||
29 | + double left = 0; | ||
30 | + double right = 0; | ||
31 | + double top =0; | ||
32 | + double bottom =0; | ||
33 | + | ||
34 | + double oneInchInLayoutUnits = 0.0254; | ||
35 | + double resolution = 96; | ||
36 | + | ||
37 | + double m_dR = 0; | ||
38 | + double m_dXdis = 0;//width / 2.0 - m_dR * (right + left) / 2.0; | ||
39 | + double m_dYdis = 0;//height / 2.0 + m_dR * (top + bottom) / 2.0; | ||
40 | + public: | ||
41 | + void InitParameter(double l0,double r0,double t0,double b0, int w0,int h0); | ||
42 | + | ||
43 | + }; | ||
44 | +} | ||
45 | + | ||
46 | +#endif // __dmpprintparameter_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintrect.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 15:46:35 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintrect.h" | ||
10 | + | ||
11 | +namespace DmpWms | ||
12 | +{ | ||
13 | + bool DmpPrintRect::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
14 | + { | ||
15 | + cairo_t *cr = pClsCS->m_pCr; | ||
16 | + //cairo_set_antialias(pClsCS->m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST); | ||
17 | + cairo_set_source_rgb (cr, 0, 0, 0); | ||
18 | + cairo_set_line_width (cr, boundSize_); | ||
19 | + | ||
20 | + cairo_rectangle (cr, localtionX_, localtionY_, width_, height_); | ||
21 | + cairo_stroke_preserve (cr); | ||
22 | + return true; | ||
23 | + } | ||
24 | + | ||
25 | + bool DmpPrintRect::ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr) | ||
26 | + { | ||
27 | + //this->ReadXmlAttribute(bound_node, showbound, "show"); | ||
28 | + this->ReadXmlAttribute(pt, localtionX_, "localtion_x"); | ||
29 | + this->ReadXmlAttribute(pt, localtionY_, "localtion_y"); | ||
30 | + | ||
31 | + this->ReadXmlAttribute(pt, width_, "width"); | ||
32 | + this->ReadXmlAttribute(pt, height_, "height"); | ||
33 | + | ||
34 | + this->ReadXmlAttribute(pt, boundSize_, "bound_size"); | ||
35 | + this->pPrintParameter_ = pPrintParameter; | ||
36 | + | ||
37 | + return true; | ||
38 | + } | ||
39 | + | ||
40 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintrect.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 15:46:31 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpprintrect_h__ | ||
11 | +#define __dmpprintrect_h__ | ||
12 | +#include "dmpprintlayer.h" | ||
13 | +namespace DmpWms | ||
14 | +{ | ||
15 | + class DmpPrintRect :public DmpPrintLayer | ||
16 | + { | ||
17 | + public: | ||
18 | + shared_ptr<DmpPrintParameter> pPrintParameter_ = nullptr; | ||
19 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
20 | + bool ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr); | ||
21 | + | ||
22 | + private: | ||
23 | + int width_ =0; | ||
24 | + int height_ =0; | ||
25 | + | ||
26 | + }; | ||
27 | +} | ||
28 | + | ||
29 | +#endif // __dmpprintrect_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintscale.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 17:24:56 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintscale.h" | ||
10 | + | ||
11 | + | ||
12 | +namespace DmpWms | ||
13 | +{ | ||
14 | + bool DmpPrintScale::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
15 | + { | ||
16 | + bool isImage = true; | ||
17 | + int width = 1000; | ||
18 | + int height = 30; | ||
19 | + double xdis = 0; | ||
20 | + | ||
21 | + if(this->pPrintParameter_->isWGS84) | ||
22 | + { | ||
23 | + xdis = this->pPrintParameter_->dWgs/this->pPrintParameter_->m_dR ; | ||
24 | + } | ||
25 | + else | ||
26 | + { | ||
27 | + xdis = 1/this->pPrintParameter_->m_dR; | ||
28 | + } | ||
29 | + // double d = (resolution / oneInchInLayoutUnits)*(1/this->scaleDenominator); | ||
30 | + double xdis_100 = xdis*100; | ||
31 | + int ld = (int)log10(xdis_100); | ||
32 | + double hd = xdis_100/pow(10,ld); | ||
33 | + | ||
34 | + double hh = 100; | ||
35 | + if(hd>=1 && hd<2) | ||
36 | + { | ||
37 | + hh = 100; | ||
38 | + } | ||
39 | + else if(hd>=2 && hd<3.5) | ||
40 | + { | ||
41 | + hh = 200; | ||
42 | + } | ||
43 | + else if(hd>=3.5 && hd<7.5) | ||
44 | + { | ||
45 | + hh = 500; | ||
46 | + } | ||
47 | + else | ||
48 | + { | ||
49 | + hh = 1000; | ||
50 | + } | ||
51 | + | ||
52 | + double px_width = (hh/hd); | ||
53 | + | ||
54 | + string dw = "M"; | ||
55 | + string dw2 = "M"; | ||
56 | + int v =hh*pow(10,ld - 2); | ||
57 | + | ||
58 | + if(v >= 1000) | ||
59 | + { | ||
60 | + char buff[100] = {0}; | ||
61 | + v = v/1000; | ||
62 | + sprintf(buff,"%d KM",v); | ||
63 | + dw = buff; | ||
64 | + v = v*2; | ||
65 | + sprintf(buff,"%d KM",v); | ||
66 | + dw2 = buff; | ||
67 | + } | ||
68 | + else | ||
69 | + { | ||
70 | + char buff[100] = {0}; | ||
71 | + sprintf(buff,"%d M",v); | ||
72 | + dw = buff; | ||
73 | + | ||
74 | + | ||
75 | + sprintf(buff,"%d M",v*2); | ||
76 | + dw2 = buff; | ||
77 | + } | ||
78 | + | ||
79 | + shared_ptr<clsCrSurf> mClsSurfDC = this->CreateSurface((int)width, (int)height, format); | ||
80 | + | ||
81 | + cairo_t *cr = mClsSurfDC->m_pCr; //创建画笔 | ||
82 | + int startPix = 10; | ||
83 | + for(int i =0; i<2; i++) | ||
84 | + { | ||
85 | + cairo_set_source_rgb(cr, 0, 0, 0); //设置画笔颜色,也就是红,绿,蓝,这里设置成绿色。 | ||
86 | + cairo_move_to(cr, startPix + px_width*i, 20); //三角形第一个顶点 | ||
87 | + cairo_line_to(cr, startPix + px_width*i, 25); //三角形第二个顶点 | ||
88 | + cairo_line_to(cr, startPix + px_width*(i+1), 25); //三角形第三个顶点 | ||
89 | + cairo_line_to(cr, startPix + px_width*(i+1), 20); //三角形第三个顶点 | ||
90 | + cairo_set_line_width(cr, 1); | ||
91 | + cairo_stroke(cr); | ||
92 | + | ||
93 | + // const char *str = "N"; | ||
94 | + cairo_select_font_face(cr, "宋体", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
95 | + cairo_set_font_size(cr, 10); | ||
96 | + //cairo_move_to(cr, 8, 15); | ||
97 | + | ||
98 | + cairo_move_to(cr, startPix + px_width*(i+1) - 15, 15); | ||
99 | + if(i ==0) | ||
100 | + { | ||
101 | + cairo_show_text(cr, dw.c_str()); | ||
102 | + } | ||
103 | + else | ||
104 | + { | ||
105 | + cairo_show_text(cr, dw2.c_str()); | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + //const char *str = "0"; | ||
110 | + cairo_move_to(cr, startPix -3 , 15); | ||
111 | + cairo_show_text(cr, "0"); | ||
112 | + | ||
113 | + cairo_set_source_surface(pClsCS->m_pCr, mClsSurfDC->m_pSurf, localtionX_, localtionY_); | ||
114 | + cairo_paint(pClsCS->m_pCr); | ||
115 | + return true; | ||
116 | + } | ||
117 | + | ||
118 | + bool DmpPrintScale::ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr) | ||
119 | + { | ||
120 | + this->ReadXmlAttribute(pt,localtionX_,"localtion_x"); | ||
121 | + this->ReadXmlAttribute(pt,localtionY_,"localtion_y"); | ||
122 | + // this->ReadXmlAttribute(pt,type,"type"); | ||
123 | + | ||
124 | + this->ReadXmlAttribute(pt, boundSize_, "bound_size"); | ||
125 | + this->ReadXmlAttribute(pt, showbound_, "showBound"); | ||
126 | + | ||
127 | + this->pPrintParameter_ = pPrintParameter; | ||
128 | + | ||
129 | + return true; | ||
130 | + } | ||
131 | + | ||
132 | + | ||
133 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintscale.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 17:24:52 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpprintscale_h__ | ||
11 | +#define __dmpprintscale_h__ | ||
12 | + | ||
13 | +#include "dmpprintlayer.h" | ||
14 | +namespace DmpWms | ||
15 | +{ | ||
16 | + class DmpPrintScale :public DmpPrintLayer | ||
17 | + { | ||
18 | + private: | ||
19 | + string serviceName; | ||
20 | + shared_ptr<DmpPrintParameter> pPrintParameter_ = nullptr; | ||
21 | + public: | ||
22 | + //bool DrawImage(); | ||
23 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
24 | + bool ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr); | ||
25 | + }; | ||
26 | +} | ||
27 | +#endif // __dmpprintscale_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprinttext.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:36:43 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprinttext.h" | ||
10 | +namespace DmpWms | ||
11 | +{ | ||
12 | + bool DmpPrintText::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
13 | + { | ||
14 | + cairo_set_antialias(pClsCS->m_pCr,cairo_antialias_t::CAIRO_ANTIALIAS_BEST); | ||
15 | + cairo_set_source_rgb(pClsCS->m_pCr, r_, g_, b_); | ||
16 | + cairo_select_font_face(pClsCS->m_pCr, font_.c_str(), CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
17 | + cairo_set_font_size(pClsCS->m_pCr,fontSize_); | ||
18 | + | ||
19 | + cairo_move_to(pClsCS->m_pCr,localtionX_, localtionY_); | ||
20 | + | ||
21 | + cairo_show_text(pClsCS->m_pCr, text_.c_str()); | ||
22 | + | ||
23 | + return true; | ||
24 | + } | ||
25 | + | ||
26 | + bool DmpPrintText::ReadXML(boost::property_tree::ptree &pt, shared_ptr<DmpPrintParameter> pMapParameter,string& errorstr) | ||
27 | + { | ||
28 | + try | ||
29 | + { | ||
30 | + this->ReadXmlAttribute(pt, localtionX_, "localtion_x"); | ||
31 | + this->ReadXmlAttribute(pt, localtionY_, "localtion_y"); | ||
32 | + | ||
33 | + this->ReadXmlAttribute(pt, boundSize_, "bound_size"); | ||
34 | + this->ReadXmlAttribute(pt, showbound_, "showBound"); | ||
35 | + boost::property_tree::ptree pttext = pt.get_child("text"); | ||
36 | + this->ReadXmlColorAttribute(pttext, r_, g_, b_, "fontcolor"); | ||
37 | + this->ReadXmlAttribute(pttext, text_, "title"); | ||
38 | + this->ReadXmlAttribute(pttext, fontSize_, "fontsize"); | ||
39 | + this->ReadXmlAttribute(pttext, font_, "font"); | ||
40 | + this->ReadXmlAttribute(pttext, isBold_, "bold"); | ||
41 | + return true; | ||
42 | + } | ||
43 | + catch(const std::exception& e) | ||
44 | + { | ||
45 | + return false; | ||
46 | + } | ||
47 | + return false; | ||
48 | + } | ||
49 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprinttext.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-27 16:36:39 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#ifndef __dmpprinttext_h__ | ||
10 | +#define __dmpprinttext_h__ | ||
11 | + | ||
12 | +#include "dmpprintlayer.h" | ||
13 | +namespace DmpWms | ||
14 | +{ | ||
15 | + class DmpPrintText : public DmpPrintLayer | ||
16 | + { | ||
17 | + private: | ||
18 | + | ||
19 | + int r_,g_,b_; | ||
20 | + std::string text_; | ||
21 | + std::string font_; | ||
22 | + int fontSize_; | ||
23 | + bool isBold_; | ||
24 | + | ||
25 | + public: | ||
26 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
27 | + bool ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pMapParameter, string& errorstr); | ||
28 | + }; | ||
29 | +} | ||
30 | + | ||
31 | +#endif // __dmpprinttext_h__ |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintwmsservice.cpp | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-28 15:31:15 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | +#include "dmpprintwmsservice.h" | ||
10 | + | ||
11 | +namespace DmpWms | ||
12 | +{ | ||
13 | + bool DmpPrintWMSService::DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format) | ||
14 | + { | ||
15 | + try | ||
16 | + { | ||
17 | + shared_ptr<DmpWmsRenderer> _WmsRenderer(new DmpWmsRenderer( height_, width_)); | ||
18 | + | ||
19 | + shared_ptr<clsCrSurf> mClsSurfDC = this->CreateSurface((int)width_, (int)height_, format); | ||
20 | + | ||
21 | + | ||
22 | + // cairo_surface_set_fallback_resolution( _map->GetSurfDC()->m_pSurf,900,900); | ||
23 | + | ||
24 | + // if (this->m_mapWmsServer.find(serviceName) != this->m_mapWmsServer.end()) | ||
25 | + { | ||
26 | + //shared_ptr<WMSServer> wmsServer = this->m_mapWmsServer[serviceName]; | ||
27 | + _WmsRenderer->AddWmsMapLayers(project_); | ||
28 | + | ||
29 | + //Rect *rect_service = project_->GetExtent(); | ||
30 | + | ||
31 | + shared_ptr<Rect> rect(new Rect(boxY2_, boxX2_, boxY1_, boxX1_)); | ||
32 | + _WmsRenderer->SetExtent(rect); | ||
33 | + _WmsRenderer->GetMap(nullptr, nullptr, mClsSurfDC.get()); | ||
34 | + | ||
35 | + if (this->showMapLegend_) | ||
36 | + { | ||
37 | + DrawLegend(mClsSurfDC.get(), _WmsRenderer, format, localtionX_, localtionY_, this->width_, this->height_); | ||
38 | + } | ||
39 | + | ||
40 | + cairo_set_source_surface(pClsCS->m_pCr, mClsSurfDC->m_pSurf, localtionX_, localtionY_); | ||
41 | + cairo_paint(pClsCS->m_pCr); | ||
42 | + if(this->showCoord_) | ||
43 | + { | ||
44 | + DrawCoord(pClsCS, _WmsRenderer, format, localtionX_, localtionY_, this->width_, this->height_); | ||
45 | + } | ||
46 | + | ||
47 | + DrawBound(pClsCS, width_, height_); | ||
48 | + } | ||
49 | + | ||
50 | + | ||
51 | + return true; | ||
52 | + } | ||
53 | + catch (const std::exception &e) | ||
54 | + { | ||
55 | + | ||
56 | + std::cerr << " Refresh " << e.what() << '\n'; | ||
57 | + return false; | ||
58 | + } | ||
59 | + return false; | ||
60 | + } | ||
61 | + | ||
62 | + /*bool DmpPrintWMSService::DrawCoord(clsCrSurf* pClsCS,PrintOutputFormat format) | ||
63 | + { | ||
64 | + format. | ||
65 | + }*/ | ||
66 | + bool DmpPrintWMSService::DrawCoord(clsCrSurf* pClsCS, shared_ptr<DmpWmsRenderer> _map,DmpWmsParameters::Format format, | ||
67 | + int locationX,int locationY,int width,int height) | ||
68 | + { | ||
69 | + if(pLegendParamater_ == nullptr) | ||
70 | + return false; | ||
71 | + shared_ptr<Rect> rect = _map->GetExtent(); | ||
72 | + if(rect == nullptr) | ||
73 | + return false; | ||
74 | + | ||
75 | + //double x0 =(x - m_dXdis)/ m_dR ; | ||
76 | + //double y0 = ( y + m_dYdis)/m_dR ; | ||
77 | + double x_width = rect->m_dRight - rect->m_dLeft; | ||
78 | + double dx = 100/ _map->m_dR; | ||
79 | + | ||
80 | + | ||
81 | + int ld = (int)log10(dx); | ||
82 | + double hd = dx/pow(10,ld); | ||
83 | + | ||
84 | + double hh = 1; | ||
85 | + | ||
86 | + if(hd>=1 && hd<2) hh = 1; | ||
87 | + else if(hd>=2 && hd<3.5) hh = 2; | ||
88 | + else if(hd>=3.5 && hd<7.5) hh = 5; | ||
89 | + else hh = 10; | ||
90 | + | ||
91 | + dx = hh * pow(10,ld); | ||
92 | + double xbegin = ((int) (rect->m_dLeft/dx) +1) * dx; | ||
93 | + cairo_t *cr = pClsCS->m_pCr; //创建画笔 | ||
94 | + | ||
95 | + cairo_set_source_rgb(cr, 0, 0, 0); | ||
96 | + char drawText[100]= {0}; | ||
97 | + shared_ptr<cairo_text_extents_t> pCrExtents(new cairo_text_extents_t()); | ||
98 | + for(double pos_x = xbegin; pos_x <= rect->m_dRight; pos_x += dx ) | ||
99 | + { | ||
100 | + double x0 = _map->m_dR * pos_x + _map->m_dXdis + locationX; | ||
101 | + sprintf(drawText, "%.4f", pos_x); | ||
102 | + DoubleRemoveZero(drawText); | ||
103 | + // double y0 = -m_dR * y + m_dYdis; | ||
104 | + //设置画笔颜色,也就是红,绿,蓝,这里设置成绿色。 | ||
105 | + | ||
106 | + cairo_move_to(cr, x0, locationY); | ||
107 | + cairo_line_to(cr, x0, locationY -5); | ||
108 | + cairo_set_line_width(cr, 1.5); | ||
109 | + cairo_stroke(cr); | ||
110 | + | ||
111 | + cairo_move_to(cr, x0, locationY + height); | ||
112 | + cairo_line_to(cr, x0, locationY+ height +5); | ||
113 | + cairo_set_line_width(cr, 1.5); | ||
114 | + cairo_stroke(cr); | ||
115 | + | ||
116 | + | ||
117 | + cairo_select_font_face(cr, "宋体", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
118 | + cairo_set_font_size(cr, 10); | ||
119 | + //cairo_move_to(cr, 8, 15); | ||
120 | + | ||
121 | + cairo_text_extents(cr, drawText, pCrExtents.get()); | ||
122 | + | ||
123 | + cairo_move_to(cr, x0 - pCrExtents->width/2 ,locationY - 3 - pCrExtents->height); | ||
124 | + cairo_show_text(cr, drawText); | ||
125 | + | ||
126 | + cairo_move_to(cr, x0 - pCrExtents->width/2 ,locationY + height + 3 + 1.5* pCrExtents->height); | ||
127 | + cairo_show_text(cr, drawText); | ||
128 | + } | ||
129 | + | ||
130 | + | ||
131 | + /// 画Y轴 | ||
132 | + | ||
133 | + //double y_height = rect->m_dTop - rect->m_dBottom; | ||
134 | + | ||
135 | + double ybegin = ((int) (rect->m_dBottom/dx) +1) * dx; | ||
136 | + | ||
137 | + | ||
138 | + for(double pos_y = ybegin; pos_y <= rect->m_dTop; pos_y += dx ) | ||
139 | + { | ||
140 | + double y0 = - _map->m_dR * pos_y + _map->m_dYdis + locationY; | ||
141 | + sprintf(drawText, "%.4f", pos_y); | ||
142 | + DoubleRemoveZero(drawText); | ||
143 | + // double y0 = -m_dR * y + m_dYdis; | ||
144 | + //设置画笔颜色,也就是红,绿,蓝,这里设置成绿色。 | ||
145 | + cairo_move_to(cr,locationX -6, y0); | ||
146 | + cairo_line_to(cr,locationX, y0); | ||
147 | + cairo_set_line_width(cr, 1.5); | ||
148 | + cairo_stroke(cr); | ||
149 | + | ||
150 | + cairo_move_to(cr, locationX + width, y0); | ||
151 | + cairo_line_to(cr, locationX+ width +6,y0); | ||
152 | + cairo_set_line_width(cr, 1.5); | ||
153 | + cairo_stroke(cr); | ||
154 | + | ||
155 | + | ||
156 | + cairo_select_font_face(cr, "宋体", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); | ||
157 | + cairo_set_font_size(cr, 10); | ||
158 | + | ||
159 | + | ||
160 | + cairo_text_extents(cr, drawText, pCrExtents.get()); | ||
161 | + | ||
162 | + cairo_move_to(cr, locationX - pCrExtents->height -3 ,y0 + pCrExtents->width/2); | ||
163 | + cairo_rotate(cr, -3.141592/2); | ||
164 | + cairo_show_text(cr, drawText); | ||
165 | + cairo_rotate(cr, 3.141592/2); | ||
166 | + | ||
167 | + cairo_move_to(cr, locationX + width + 3 + 1.5*pCrExtents->height ,y0 + pCrExtents->width/2); | ||
168 | + cairo_rotate(cr, -3.141592/2); | ||
169 | + cairo_show_text(cr, drawText); | ||
170 | + cairo_rotate(cr, 3.141592/2); | ||
171 | + } | ||
172 | + return true; | ||
173 | + } | ||
174 | + | ||
175 | + void DmpPrintWMSService::DoubleRemoveZero(char* str) | ||
176 | + { | ||
177 | + int len = strlen(str); | ||
178 | + for(int i=0; i< len; i++) | ||
179 | + { | ||
180 | + if(str[i] == '.') | ||
181 | + break; | ||
182 | + if(i ==len -1) | ||
183 | + return; | ||
184 | + } | ||
185 | + | ||
186 | + for(int i=len -1; i>0; i--) | ||
187 | + { | ||
188 | + if(str[i] == '0') | ||
189 | + { | ||
190 | + str[i] = 0; | ||
191 | + } | ||
192 | + else if(str[i] == '.') | ||
193 | + { | ||
194 | + str[i] = 0; | ||
195 | + break; | ||
196 | + } | ||
197 | + else | ||
198 | + { | ||
199 | + break; | ||
200 | + } | ||
201 | + } | ||
202 | + } | ||
203 | + | ||
204 | + bool DmpPrintWMSService::DrawLegend(clsCrSurf* pClsCS, shared_ptr<DmpWmsRenderer> _map, DmpWmsParameters::Format format, | ||
205 | + int locationX,int locationY,int _width,int _height) | ||
206 | + { | ||
207 | + | ||
208 | + int height = 1000; | ||
209 | + int width = 1800; | ||
210 | + | ||
211 | + shared_ptr<clsCrSurf> mClsSurfDC = this->CreateSurface(width_, height_, format); | ||
212 | + // shared_ptr<legendParamater> pLegendParamater_(new legendParamater() ); | ||
213 | + pLegendParamater_->m_dScaleDenominator = _map->m_dScaleDenominator; | ||
214 | + | ||
215 | + _map->GetMapLegend(pLegendParamater_,mClsSurfDC.get()); | ||
216 | + | ||
217 | + pLegendParamater_->next(nullptr); | ||
218 | + | ||
219 | + shared_ptr<clsCrSurf> mClsSurfDC2 = this->CreateSurface(pLegendParamater_->max_pixXIndex+100, (int)pLegendParamater_->max_pixYIndex+15, format); | ||
220 | + | ||
221 | + | ||
222 | + cairo_set_source_rgba (mClsSurfDC2->m_pCr, pLegendParamater_->back_r/255.0, | ||
223 | + pLegendParamater_->back_g/255.0, pLegendParamater_->back_b/255.0, pLegendParamater_->back_a/255.0); | ||
224 | + | ||
225 | + cairo_rectangle (mClsSurfDC2->m_pCr, 3, 3, pLegendParamater_->max_pixXIndex + 100 -6, pLegendParamater_->max_pixYIndex + 10 ); | ||
226 | + cairo_fill_preserve(mClsSurfDC2->m_pCr); | ||
227 | + | ||
228 | + cairo_set_source_rgb (mClsSurfDC2->m_pCr, 0, 0, 0); | ||
229 | + cairo_set_line_width (mClsSurfDC2->m_pCr, 1); | ||
230 | + cairo_stroke(mClsSurfDC2->m_pCr); | ||
231 | + | ||
232 | + | ||
233 | + cairo_set_source_surface(mClsSurfDC2->m_pCr, mClsSurfDC->m_pSurf,0, 0); | ||
234 | + cairo_paint(mClsSurfDC2->m_pCr); | ||
235 | + | ||
236 | + cairo_set_source_surface(pClsCS->m_pCr, mClsSurfDC2->m_pSurf,_width - pLegendParamater_->max_pixXIndex - 100- 10, | ||
237 | + _height - pLegendParamater_->max_pixYIndex -20); | ||
238 | + cairo_paint(pClsCS->m_pCr); | ||
239 | + | ||
240 | + return true; | ||
241 | + | ||
242 | + } | ||
243 | + | ||
244 | + | ||
245 | + bool DmpPrintWMSService::ReadXML(boost::property_tree::ptree &pt,shared_ptr<DmpPrintParameter> pPrintParameter, string& errorstr) | ||
246 | + { | ||
247 | + try | ||
248 | + { | ||
249 | + this->ReadXmlAttribute(pt, localtionX_, "localtion_x"); | ||
250 | + this->ReadXmlAttribute(pt, localtionY_, "localtion_y"); | ||
251 | + this->ReadXmlAttribute(pt, width_, "width"); | ||
252 | + this->ReadXmlAttribute(pt, height_, "height"); | ||
253 | + this->ReadXmlAttribute(pt, showCoord_, "showCoord"); | ||
254 | + this->ReadXmlAttribute(pt, boundSize_, "bound_size"); | ||
255 | + this->ReadXmlAttribute(pt, showbound_, "showBound"); | ||
256 | + | ||
257 | + // rapidxml::xml_node<char> *text_node = node->first_node("legend"); | ||
258 | + | ||
259 | + try | ||
260 | + { | ||
261 | + boost::property_tree::ptree ptlegend = pt.get_child("legend"); | ||
262 | + shared_ptr<legendParamater> pLegendParamater_0(new legendParamater()); | ||
263 | + pLegendParamater_ = pLegendParamater_0; | ||
264 | + | ||
265 | + this->ReadXmlColorAttribute(ptlegend, pLegendParamater_->r, pLegendParamater_->g, pLegendParamater_->b, "fontcolor"); | ||
266 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->title, "title"); | ||
267 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->fontSize, "fontsize"); | ||
268 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->font, "font"); | ||
269 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->isbold, "bold"); | ||
270 | + this->ReadXmlColorAttribute(ptlegend, pLegendParamater_->back_r, pLegendParamater_->back_g, pLegendParamater_->back_b, "backgroundcolor"); | ||
271 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->back_a, "backgroundalpha"); | ||
272 | + | ||
273 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->showclassification, "showclassification"); | ||
274 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->rowspacing, "rowspacing"); | ||
275 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->size_x, "size_x"); | ||
276 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->size_y, "size_y"); | ||
277 | + this->ReadXmlAttribute(ptlegend, pLegendParamater_->row_maxsize, "row_maxsize"); | ||
278 | + showMapLegend_ = true; | ||
279 | + } | ||
280 | + catch(...) | ||
281 | + { | ||
282 | + showMapLegend_ = false; | ||
283 | + } | ||
284 | + | ||
285 | + this->boxX1_ = pPrintParameter->left; | ||
286 | + this->boxX2_ = pPrintParameter->right; | ||
287 | + this->boxY1_ = pPrintParameter->bottom; | ||
288 | + this->boxY2_ = pPrintParameter->top; | ||
289 | + | ||
290 | + this->project_ = pPrintParameter->pWmsService; | ||
291 | + | ||
292 | + pPrintParameter->InitParameter(this->boxX1_, this->boxX2_, this->boxY1_, this->boxY2_, this->width_, this->height_); | ||
293 | + } | ||
294 | + catch(const std::exception& e) | ||
295 | + { | ||
296 | + showMapLegend_ = false; | ||
297 | + return false; | ||
298 | + } | ||
299 | + return true; | ||
300 | + } | ||
301 | +} |
1 | +/************************************************************************** | ||
2 | +* file: dmpprintwmsservice.h | ||
3 | + | ||
4 | +* Author: qingxiongf | ||
5 | +* Date: 2022-01-28 15:31:10 | ||
6 | +* Email: qingxiongf@chinadci.com | ||
7 | +* copyright: 广州城市信息研究所有限公司 | ||
8 | +***************************************************************************/ | ||
9 | + | ||
10 | +#ifndef __dmpprintwmsservice_h__ | ||
11 | +#define __dmpprintwmsservice_h__ | ||
12 | +#include "dmpprintlayer.h" | ||
13 | +#include "dmpproject.h" | ||
14 | +#include "legendParamater.h" | ||
15 | +#include "../dmpwmsrenderer.h" | ||
16 | +using namespace DmapCore_30; | ||
17 | + | ||
18 | +namespace DmpWms | ||
19 | +{ | ||
20 | + class DmpPrintWMSService :public DmpPrintLayer | ||
21 | + { | ||
22 | + public: | ||
23 | + int width_; | ||
24 | + int height_; | ||
25 | + string serviceName_; | ||
26 | + //不透明度 | ||
27 | + double opacity_; | ||
28 | + | ||
29 | + DmpProject* project_; | ||
30 | + | ||
31 | + double boxX1_, boxY1_, boxX2_, boxY2_; | ||
32 | + | ||
33 | + // clsLock m_clsMapLock; | ||
34 | + | ||
35 | + bool showMapLegend_ = false; | ||
36 | + | ||
37 | + bool showCoord_ = false; | ||
38 | + | ||
39 | + shared_ptr<legendParamater> pLegendParamater_ = nullptr; | ||
40 | + | ||
41 | + //bool DrawImage(); | ||
42 | + bool DrawData(clsCrSurf* pClsCS,DmpWmsParameters::Format format); | ||
43 | + | ||
44 | + bool ReadXML(boost::property_tree::ptree &pt, shared_ptr<DmpPrintParameter> pPrintParameter,string& errorstr); | ||
45 | + private: | ||
46 | + | ||
47 | + bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<DmpWmsRenderer> _map, DmpWmsParameters::Format format,int locationX,int localtionY,int width,int height); | ||
48 | + | ||
49 | + bool DrawCoord(clsCrSurf* pClsCS, shared_ptr<DmpWmsRenderer> _map, DmpWmsParameters::Format format,int locationX,int localtionY,int width,int height); | ||
50 | + | ||
51 | + bool DrawCoordXText(clsCrSurf* pClsCS,shared_ptr<DmpWmsRenderer> _map, | ||
52 | + int locationX,int localtionY,int width,int height); | ||
53 | + | ||
54 | + void DoubleRemoveZero(char* str); | ||
55 | + }; | ||
56 | +} | ||
57 | + | ||
58 | +#endif // __dmpprintwmsservice_h__ |
请
注册
或
登录
后发表评论