提交 baa9a9aafbb756d6a951ab4156154ec5be1ea383

作者 qingxiongf
1 个父辈 8ab79c08

在线编辑

正在显示 53 个修改的文件 包含 1644 行增加387 行删除
@@ -30,6 +30,7 @@ SET(DMAP_CORE_SRCS @@ -30,6 +30,7 @@ SET(DMAP_CORE_SRCS
30 30
31 renderer/clsMalloc.cpp 31 renderer/clsMalloc.cpp
32 renderer/clsStruct.cpp 32 renderer/clsStruct.cpp
  33 + renderer/clsPtree.cpp
33 renderer/clsJson.cpp 34 renderer/clsJson.cpp
34 renderer/clsXML.cpp 35 renderer/clsXML.cpp
35 renderer/clsUtil.cpp 36 renderer/clsUtil.cpp
@@ -82,6 +83,7 @@ SET(DMAP_CORE_HDRS @@ -82,6 +83,7 @@ SET(DMAP_CORE_HDRS
82 renderer/clsMalloc.h 83 renderer/clsMalloc.h
83 renderer/clsStruct.h 84 renderer/clsStruct.h
84 renderer/clsJson.h 85 renderer/clsJson.h
  86 + renderer/clsPtree.h
85 renderer/clsXML.h 87 renderer/clsXML.h
86 renderer/clsUtil.h 88 renderer/clsUtil.h
87 renderer/clsRect.h 89 renderer/clsRect.h
@@ -55,9 +55,9 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) @@ -55,9 +55,9 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode)
55 // geom_ = layerNode.get<std::string>("geom"); 55 // geom_ = layerNode.get<std::string>("geom");
56 // featurecount_ = layerNode.get<unsigned int>("featurecount"); 56 // featurecount_ = layerNode.get<unsigned int>("featurecount");
57 57
58 - boost::property_tree::ptree pRenderer = layerNode.get_child("renderer");  
59 - auto pIter = pRenderer.begin();  
60 - if(pIter == pRenderer.end())return false; 58 + boost::property_tree::ptree ptRenderer = layerNode.get_child("renderer");
  59 + auto pIter = ptRenderer.begin();
  60 + if(pIter == ptRenderer.end())return false;
61 DmapCore_30::Renderer* renderer_30 = nullptr; 61 DmapCore_30::Renderer* renderer_30 = nullptr;
62 DmapCore_30::clsXML::XMLParse(pIter->first, pIter->second, &renderer_30); 62 DmapCore_30::clsXML::XMLParse(pIter->first, pIter->second, &renderer_30);
63 renderer_30_ = shared_ptr<DmapCore_30::Renderer>(renderer_30); 63 renderer_30_ = shared_ptr<DmapCore_30::Renderer>(renderer_30);
@@ -71,7 +71,26 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) @@ -71,7 +71,26 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode)
71 71
72 bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) 72 bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode)
73 { 73 {
74 - return false; 74 + layerNode.add("<xmlattr>.id", id_);
  75 + layerNode.add("<xmlattr>.name", name_);
  76 + layerNode.add("<xmlattr>.alias", title_);
  77 +
  78 + boost::property_tree::ptree ptExtent;
  79 + ptExtent.add("xmin", extent_.xmin());
  80 + ptExtent.add("ymin", extent_.ymin());
  81 + ptExtent.add("xmax", extent_.xmax());
  82 + ptExtent.add("ymax", extent_.ymax());
  83 + layerNode.add_child("extent", ptExtent);
  84 +
  85 + layerNode.add("datasource", dataSource_);
  86 +
  87 + if(this->renderer_30_)
  88 + {
  89 + boost::property_tree::ptree ptRenderer;
  90 + this->renderer_30_->ParsePtree(ptRenderer);
  91 + }
  92 +
  93 + return true;
75 } 94 }
76 95
77 void DmpVectorLayer::setRenderer(DmpFeatureRenderer *renderer) 96 void DmpVectorLayer::setRenderer(DmpFeatureRenderer *renderer)
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 #include"TrueTypeMarkerSymbol.h" 13 #include"TrueTypeMarkerSymbol.h"
14 #include "clsUtil.h" 14 #include "clsUtil.h"
15 #include "clsXML.h" 15 #include "clsXML.h"
16 - 16 +#include "clsPtree.h"
17 namespace DmapCore_30 17 namespace DmapCore_30
18 { 18 {
19 GroupRenderer::GroupRenderer() 19 GroupRenderer::GroupRenderer()
@@ -45,6 +45,19 @@ namespace DmapCore_30 @@ -45,6 +45,19 @@ namespace DmapCore_30
45 45
46 } 46 }
47 47
  48 + bool GroupRenderer::ParsePtree( boost::property_tree::ptree &pt)
  49 + {
  50 + boost::property_tree::ptree ptRenderer;
  51 + int length = (int)m_vSymbols.size();
  52 + for (int i = 0; i < length; i++)
  53 + {
  54 + Renderer* renderer = m_vSymbols[i];
  55 + renderer->ParsePtree(ptRenderer);
  56 + }
  57 + pt.add_child("GROUPRENDERER",ptRenderer);
  58 + return true;
  59 + }
  60 +
48 void GroupRenderer::ToJson(AppendBuffer *ab) 61 void GroupRenderer::ToJson(AppendBuffer *ab)
49 { 62 {
50 63
@@ -16,6 +16,7 @@ namespace DmapCore_30 @@ -16,6 +16,7 @@ namespace DmapCore_30
16 virtual int RendererType(); 16 virtual int RendererType();
17 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 17 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
18 virtual void ToJson(AppendBuffer *ab); 18 virtual void ToJson(AppendBuffer *ab);
  19 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
19 // virtual bool DrawSimpleData(clsCrSurf* pClsCS, DataCollection* data, char* pFlag); 20 // virtual bool DrawSimpleData(clsCrSurf* pClsCS, DataCollection* data, char* pFlag);
20 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag); 21 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag);
21 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag); 22 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag);
@@ -47,6 +47,7 @@ namespace DmapCore_30 @@ -47,6 +47,7 @@ namespace DmapCore_30
47 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL) = 0; 47 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL) = 0;
48 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL) =0; 48 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL) =0;
49 virtual bool Parse( boost::property_tree::ptree &pt, AppendBuffer *f) = 0; 49 virtual bool Parse( boost::property_tree::ptree &pt, AppendBuffer *f) = 0;
  50 + virtual bool ParsePtree( boost::property_tree::ptree &pt)=0;
50 //static bool RendererXmlParse(Renderer**pRen, const char* fileName); 51 //static bool RendererXmlParse(Renderer**pRen, const char* fileName);
51 //static bool RenStr(Renderer** ppRen, const char** psXML); //纯粹作弊,什么都没干,直接调用现有接口 52 //static bool RenStr(Renderer** ppRen, const char** psXML); //纯粹作弊,什么都没干,直接调用现有接口
52 53
@@ -46,6 +46,11 @@ namespace DmapCore_30 @@ -46,6 +46,11 @@ namespace DmapCore_30
46 return true; 46 return true;
47 } 47 }
48 48
  49 + bool ScaleDependentRenderer::ParsePtree( boost::property_tree::ptree &pt)
  50 + {
  51 + return true;
  52 + }
  53 +
49 void ScaleDependentRenderer::ToJson(AppendBuffer *ab) 54 void ScaleDependentRenderer::ToJson(AppendBuffer *ab)
50 { 55 {
51 56
@@ -18,6 +18,7 @@ namespace DmapCore_30 @@ -18,6 +18,7 @@ namespace DmapCore_30
18 ScaleDependentRenderer(); 18 ScaleDependentRenderer();
19 ~ScaleDependentRenderer(); 19 ~ScaleDependentRenderer();
20 virtual BOOL Parse(rapidxml::xml_node<char>* node, AppendBuffer *f); 20 virtual BOOL Parse(rapidxml::xml_node<char>* node, AppendBuffer *f);
  21 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
21 virtual void ToJson(AppendBuffer *ab); 22 virtual void ToJson(AppendBuffer *ab);
22 //virtual BOOL RendererString(Renderer** ppRen, const char** psXML); 23 //virtual BOOL RendererString(Renderer** ppRen, const char** psXML);
23 virtual BOOL DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag); 24 virtual BOOL DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag);
@@ -14,6 +14,7 @@ @@ -14,6 +14,7 @@
14 #include <stdlib.h> 14 #include <stdlib.h>
15 #include <iostream> 15 #include <iostream>
16 #include "clsJson.h" 16 #include "clsJson.h"
  17 +#include "clsPtree.h"
17 #include <string.h> 18 #include <string.h>
18 //#include <string.h> 19 //#include <string.h>
19 #define dotX 5 20 #define dotX 5
@@ -105,6 +106,30 @@ bool SimpleLabelRenderer::Parse(boost::property_tree::ptree &pt, AppendBuffer * @@ -105,6 +106,30 @@ bool SimpleLabelRenderer::Parse(boost::property_tree::ptree &pt, AppendBuffer *
105 return true; 106 return true;
106 } 107 }
107 108
  109 +bool SimpleLabelRenderer::ParsePtree( boost::property_tree::ptree &pt)
  110 +{
  111 + boost::property_tree::ptree ptRenderer;
  112 + clsPtree::PtreeAttrParse("field", ptRenderer, this->m_sField);
  113 + clsPtree::PtreeAttrParse("labelpriorities", ptRenderer, this->m_sLabelPriorities);
  114 + clsPtree::PtreeAttrParse("rotationangles", ptRenderer, this->m_sRotationAngles);
  115 + clsPtree::PtreeAttrParse("rotationanglefield", ptRenderer, this->m_sRotationAngleField);
  116 + clsPtree::PtreeAttrParse("isverticaltoangle", ptRenderer, this->m_bIsVerticalToAngle);
  117 +
  118 + clsPtree::ParseEnum("linelabelpositiondirection", ptRenderer, m_iLineLabelPositionDirection, "level", "parallel", "curved","vertical");
  119 + clsPtree::ParseEnum("linelabelpositionstartorend", ptRenderer, m_iLineLabelPositionStartOrEnd, "start","end","center");
  120 + clsPtree::PtreeAttrParse("linelabelpositionplace", ptRenderer, m_sLineLabelPositionPlaces);
  121 + clsPtree::ParseEnum("polygonlabelpositiondirection", ptRenderer, m_iPolygonLabelPositionDirection, "parallel","straight","parallelandstraight");
  122 +
  123 + clsPtree::PtreeAttrParse("labelinpolygon", ptRenderer, this->m_bLabelInPolygon);
  124 +
  125 + if(m_pTextSymbol)
  126 + {
  127 + m_pTextSymbol->ParsePtree(ptRenderer);
  128 + }
  129 + pt.add_child("SIMPLELABELRENDERER", ptRenderer);
  130 + return true;
  131 +}
  132 +
108 void SimpleLabelRenderer::ToJson(AppendBuffer *ab) 133 void SimpleLabelRenderer::ToJson(AppendBuffer *ab)
109 { 134 {
110 char buff[300] = {0}; 135 char buff[300] = {0};
@@ -17,7 +17,8 @@ namespace DmapCore_30 @@ -17,7 +17,8 @@ namespace DmapCore_30
17 SimpleLabelRenderer(); 17 SimpleLabelRenderer();
18 ~SimpleLabelRenderer(); 18 ~SimpleLabelRenderer();
19 int RendererType(); 19 int RendererType();
20 - virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 20 + virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
  21 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
21 virtual void ToJson(AppendBuffer *ab); 22 virtual void ToJson(AppendBuffer *ab);
22 //virtual bool RendererString(Renderer** ppRen, const char** psXML); 23 //virtual bool RendererString(Renderer** ppRen, const char** psXML);
23 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL); 24 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL);
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 #include"clsXML.h" 4 #include"clsXML.h"
5 #include"clsCrSurf.h" 5 #include"clsCrSurf.h"
6 #include "clsJson.h" 6 #include "clsJson.h"
  7 +#include "clsPtree.h"
7 #define _USE_MATH_DEFINES 8 #define _USE_MATH_DEFINES
8 #include<math.h> 9 #include<math.h>
9 namespace DmapCore_30 10 namespace DmapCore_30
@@ -69,6 +70,21 @@ namespace DmapCore_30 @@ -69,6 +70,21 @@ namespace DmapCore_30
69 return true; 70 return true;
70 } 71 }
71 72
  73 + bool SimpleLineSymbol::ParsePtree( boost::property_tree::ptree &pt)
  74 + {
  75 + boost::property_tree::ptree ptRenderer;
  76 + clsPtree::PtreeAttrParse("icon", ptRenderer, this->m_sPNG);
  77 + //clsPtree::ParseEnum("type", resultbuff, buff, m_iAntialiasing, "antialias_default", "antialias_none", "antialias_gray", "antialias_subpixel", "antialias_fase", "antialias_good", "antialias_best", "true", "false");
  78 + clsPtree::ParseEnum("type", ptRenderer, m_iType, "solid", "dash", "dot", "dash_dot", "dash_dot_dot");
  79 + clsPtree::PtreeAttrParseColor("color", "transparency", ptRenderer, m_iColor);
  80 + clsPtree::PtreeAttrParse("width", ptRenderer, m_dWidth);
  81 +
  82 + clsPtree::ParseEnum("captype", ptRenderer, m_iCapType, "cap_butt", "cap_round", "cap_square");
  83 + clsPtree::ParseEnum("jiontype", ptRenderer, m_iJionType, "jion_miter", "jion_round", "jion_bevel");
  84 + pt.add_child("SIMPLELINESYMBOL",ptRenderer);
  85 + return true;
  86 + }
  87 +
72 void SimpleLineSymbol::ToJson(AppendBuffer *ab) 88 void SimpleLineSymbol::ToJson(AppendBuffer *ab)
73 { 89 {
74 char buff[300] = {0}; 90 char buff[300] = {0};
@@ -29,6 +29,7 @@ namespace DmapCore_30 @@ -29,6 +29,7 @@ namespace DmapCore_30
29 static SimpleLineSymbol* CreateNew(); 29 static SimpleLineSymbol* CreateNew();
30 virtual int RendererType(); 30 virtual int RendererType();
31 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 31 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
  32 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
32 virtual void ToJson(AppendBuffer *ab); 33 virtual void ToJson(AppendBuffer *ab);
33 //virtual bool RendererString(Renderer** ppRen, const char** psXML); 34 //virtual bool RendererString(Renderer** ppRen, const char** psXML);
34 virtual bool DrawData(clsCrSurf* clsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL); 35 virtual bool DrawData(clsCrSurf* clsCS, DataCollection* data, bool drawSimpleData, char* pFlag = NULL);
@@ -5,6 +5,7 @@ @@ -5,6 +5,7 @@
5 #include "clsXML.h" 5 #include "clsXML.h"
6 #include "DataCollection.h" 6 #include "DataCollection.h"
7 #include "clsJson.h" 7 #include "clsJson.h"
  8 +#include "clsPtree.h"
8 #define _USE_MATH_DEFINES 9 #define _USE_MATH_DEFINES
9 #include <math.h> 10 #include <math.h>
10 namespace DmapCore_30 11 namespace DmapCore_30
@@ -75,6 +76,27 @@ namespace DmapCore_30 @@ -75,6 +76,27 @@ namespace DmapCore_30
75 return true; 76 return true;
76 } 77 }
77 78
  79 + bool SimpleMarkerSymbol::ParsePtree( boost::property_tree::ptree &pt)
  80 + {
  81 + boost::property_tree::ptree ptRenderer;
  82 + string png = this->m_sPNG;
  83 + if(png != "" && png.find("symbollib") != png.npos)
  84 + {
  85 + int pos = png.find("symbollib");
  86 + png = "../" + png.substr(pos,png.length() - pos);
  87 + }
  88 + clsPtree::PtreeAttrParse("png", ptRenderer, png);
  89 + clsPtree::ParseEnum("type", ptRenderer, m_iType, "circle", "triangle", "square", "cross", "star", "icon");
  90 + clsPtree::PtreeAttrParseColor("color", "transparency", ptRenderer, m_iColor);
  91 + clsPtree::PtreeAttrParse("boundary", ptRenderer, m_bBoundary);
  92 + clsPtree::PtreeAttrParseColor("outline", "outlinetransparency", ptRenderer, m_iOutline);
  93 + clsPtree::PtreeAttrParse("width", ptRenderer, m_dWidth);
  94 + clsPtree::PtreeAttrParse("size", ptRenderer, m_dSize);
  95 + pt.add_child("SIMPLEMARKERSYMBOL",ptRenderer);
  96 + return true;
  97 + }
  98 +
  99 +
78 void SimpleMarkerSymbol::ToJson(AppendBuffer* ab) 100 void SimpleMarkerSymbol::ToJson(AppendBuffer* ab)
79 { 101 {
80 102
@@ -28,7 +28,7 @@ namespace DmapCore_30 @@ -28,7 +28,7 @@ namespace DmapCore_30
28 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater, int layerType,char* pFlag = NULL); 28 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater, int layerType,char* pFlag = NULL);
29 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 29 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
30 virtual void ToJson(AppendBuffer* ab); 30 virtual void ToJson(AppendBuffer* ab);
31 - 31 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
32 bool TryFindHeatRenderer(){ return false; } 32 bool TryFindHeatRenderer(){ return false; }
33 33
34 34
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 #include"clsCrSurf.h" 4 #include"clsCrSurf.h"
5 #include"clsXML.h" 5 #include"clsXML.h"
6 #include "clsJson.h" 6 #include "clsJson.h"
  7 +#include "clsPtree.h"
7 #include"clsStruct.h" 8 #include"clsStruct.h"
8 #include "DataCollection.h" 9 #include "DataCollection.h"
9 10
@@ -127,6 +128,38 @@ namespace DmapCore_30 @@ -127,6 +128,38 @@ namespace DmapCore_30
127 } 128 }
128 return true; 129 return true;
129 } 130 }
  131 +
  132 + bool SimplePolygonSymbol::ParsePtree( boost::property_tree::ptree &pt)
  133 + {
  134 + boost::property_tree::ptree ptRenderer;
  135 + clsPtree::PtreeAttrParse("icon", ptRenderer, this->m_sPNG);
  136 + clsPtree::ParseEnum("filltype", ptRenderer, m_iFillType, "solid", "bdiagonal", "fdiagonal", "cross", "diagcross", "horizontal", "vertical", "gray", "lightgray", "darkgray", "icon","character" ),
  137 + clsPtree::PtreeAttrParseColor("fillcolor", "filltransparency", ptRenderer, m_iFillColor);
  138 +
  139 + clsPtree::PtreeAttrParse("boundary", ptRenderer, m_bBoundary);
  140 + clsPtree::PtreeAttrParse("width", ptRenderer, m_dWidth);
  141 + clsPtree::ParseEnum("linetype", ptRenderer, m_iLineType, "solid", "dash", "dot", "dash_dot", "dash_dot_dot");
  142 + clsPtree::PtreeAttrParseColor("boundarycolor", "boundarytransparency", ptRenderer, m_iBoundaryColor);
  143 + clsPtree::PtreeAttrParse("fillinterval", ptRenderer, m_lFillInterval);
  144 + clsPtree::PtreeAttrParse("needfill", ptRenderer, m_bNeedFill);
  145 +
  146 + clsPtree::PtreeAttrParse("needbackground", ptRenderer, m_bNeedBackground);
  147 + clsPtree::PtreeAttrParseColor("backgroundcolor", "backgroundtransparency", ptRenderer, m_iBackgroundColor);
  148 +
  149 + clsPtree::PtreeAttrParse("fillsize", ptRenderer, m_iFillsize);
  150 +
  151 + clsPtree::PtreeAttrParse("diagalignment", ptRenderer, m_diagalignment);
  152 + if(m_iFillType == dmapFillTypeCharacter)
  153 + {
  154 + clsPtree::PtreeAttrParse("character", ptRenderer, m_lCharacter);
  155 + clsPtree::PtreeAttrParse("font", ptRenderer, m_sFont);
  156 + clsPtree::PtreeAttrParse("fontname", ptRenderer, m_sFontname);
  157 + }
  158 + pt.add_child("SIMPLEPOLYGONSYMBOL",ptRenderer);
  159 +
  160 + return true;
  161 + }
  162 +
130 void SimplePolygonSymbol::ToJson(AppendBuffer *ab) 163 void SimplePolygonSymbol::ToJson(AppendBuffer *ab)
131 { 164 {
132 char buff[300] = {0}; 165 char buff[300] = {0};
@@ -44,6 +44,7 @@ namespace DmapCore_30 @@ -44,6 +44,7 @@ namespace DmapCore_30
44 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL); 44 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL);
45 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL); 45 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL);
46 virtual void ToJson(AppendBuffer *ab); 46 virtual void ToJson(AppendBuffer *ab);
  47 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
47 int m_iAntialiasing; 48 int m_iAntialiasing;
48 49
49 bool TryFindHeatRenderer(){ return false; } 50 bool TryFindHeatRenderer(){ return false; }
@@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
11 #include"ValueMapRenderer.h" 11 #include"ValueMapRenderer.h"
12 //#include"RangeMapRenderer.h" 12 //#include"RangeMapRenderer.h"
13 #include"GroupRenderer.h" 13 #include"GroupRenderer.h"
  14 +#include "clsPtree.h"
14 namespace DmapCore_30 15 namespace DmapCore_30
15 { 16 {
16 SimpleRenderer::SimpleRenderer() 17 SimpleRenderer::SimpleRenderer()
@@ -93,6 +94,41 @@ namespace DmapCore_30 @@ -93,6 +94,41 @@ namespace DmapCore_30
93 return true; 94 return true;
94 } 95 }
95 96
  97 + bool SimpleRenderer::ParsePtree( boost::property_tree::ptree &pt)
  98 + {
  99 + boost::property_tree::ptree ptRenderer;
  100 + char buff_maxscale[100];
  101 + char buff_minscale[100];
  102 + if(this->m_dUpper>100000000)
  103 + {
  104 + sprintf(buff_maxscale,"%e", this->m_dUpper);
  105 + }
  106 + else
  107 + {
  108 + sprintf(buff_maxscale,"%.0f", this->m_dUpper);
  109 + }
  110 +
  111 + if(this->m_dLower>100000000)
  112 + {
  113 + sprintf(buff_minscale,"%e", this->m_dLower);
  114 + }
  115 + else
  116 + {
  117 + sprintf(buff_minscale,"%.0f", this->m_dLower);
  118 + }
  119 +
  120 + ptRenderer.add("maxscale",buff_maxscale);
  121 + ptRenderer.add("minscale",buff_minscale);
  122 + ptRenderer.add("alwaysShow", m_alwaysShow?"true":"false");
  123 +
  124 + if(this->m_pRen)
  125 + {
  126 + this->m_pRen->ParsePtree(ptRenderer);
  127 + }
  128 + pt.add_child("TEXTSYMBOL",ptRenderer);
  129 + return true;
  130 + }
  131 +
96 void SimpleRenderer::ToJson(AppendBuffer *ab) 132 void SimpleRenderer::ToJson(AppendBuffer *ab)
97 { 133 {
98 char buff[600]; 134 char buff[600];
@@ -17,6 +17,7 @@ namespace DmapCore_30 @@ -17,6 +17,7 @@ namespace DmapCore_30
17 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL); 17 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL);
18 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 18 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
19 virtual void ToJson(AppendBuffer *ab); 19 virtual void ToJson(AppendBuffer *ab);
  20 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
20 void TryAddField(vector<string>&pvField); 21 void TryAddField(vector<string>&pvField);
21 bool TryFindHeatRenderer(); 22 bool TryFindHeatRenderer();
22 23
@@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
4 #include"clsUtil.h" 4 #include"clsUtil.h"
5 #include"clsMalloc.h" 5 #include"clsMalloc.h"
6 #include "clsJson.h" 6 #include "clsJson.h"
  7 +#include "clsPtree.h"
7 #include <math.h> 8 #include <math.h>
8 namespace DmapCore_30 9 namespace DmapCore_30
9 { 10 {
@@ -96,6 +97,36 @@ namespace DmapCore_30 @@ -96,6 +97,36 @@ namespace DmapCore_30
96 return true; 97 return true;
97 } 98 }
98 99
  100 + bool TextSymbol::ParsePtree( boost::property_tree::ptree &pt)
  101 + {
  102 + boost::property_tree::ptree ptRenderer;
  103 + //sprintf(resultbuff, R"("TEXTSYMBOL":{"antialiasing":"antialias_default",)");
  104 + clsPtree::PtreeAttrParse("font", ptRenderer, this->m_sFont);
  105 + clsPtree::PtreeAttrParse("fontsize", ptRenderer, this->m_iFontSize);
  106 + //
  107 + clsPtree::PtreeAttrParseColor("fontcolor", "fonttransparency", ptRenderer, m_iFontColor);
  108 + clsPtree::PtreeAttrParse("x_dis", ptRenderer, this->m_dXdis);
  109 + clsPtree::PtreeAttrParse("y_dis", ptRenderer, this->m_dYdis);
  110 + //clsPtree::ParseEnum("antialiasing", ptRenderer, m_iAntialiasing, "antialias_default", "antialias_none", "antialias_gray", "antialias_subpixel", "antialias_fase", "antialias_good", "antialias_best", "true", "false");
  111 + clsPtree::ParseEnum("slant", ptRenderer, m_iSlant,"normal", "italic", "oblique");
  112 + clsPtree::ParseEnum("weight", ptRenderer, m_iWeight, "normal", "bold");
  113 + clsPtree::PtreeAttrParse("background", ptRenderer, m_bBackGround);
  114 + if (m_bBackGround)
  115 + clsPtree::PtreeAttrParseColor("bgcolor", "bgtransparency", ptRenderer, m_iBGColor);
  116 +
  117 + clsPtree::PtreeAttrParse("glowing", ptRenderer, m_bGlowing);
  118 + if (m_bGlowing)
  119 + clsPtree::PtreeAttrParseColor("glowingcolor", "glowingtransparency", ptRenderer, m_iBGColor);
  120 +
  121 +
  122 + clsPtree::PtreeAttrParse("shadow", ptRenderer, m_bGlowing);
  123 + if (m_bGlowing)
  124 + clsPtree::PtreeAttrParseColor("shadowcolor", "shadowtransparency", ptRenderer, m_iShadowColor);
  125 +
  126 + pt.add_child("TEXTSYMBOL",ptRenderer);
  127 + return true;
  128 + }
  129 +
99 void TextSymbol::ToJson(AppendBuffer *ab) 130 void TextSymbol::ToJson(AppendBuffer *ab)
100 { 131 {
101 char buff[300] = {0}; 132 char buff[300] = {0};
@@ -28,6 +28,7 @@ namespace DmapCore_30 @@ -28,6 +28,7 @@ namespace DmapCore_30
28 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater, int layerType,char* pFlag = NULL); 28 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater, int layerType,char* pFlag = NULL);
29 bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 29 bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
30 virtual void ToJson(AppendBuffer *ab); 30 virtual void ToJson(AppendBuffer *ab);
  31 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
31 static bool RendererXmlParse(Renderer**pRen, const char* fileName); 32 static bool RendererXmlParse(Renderer**pRen, const char* fileName);
32 33
33 bool TryFindHeatRenderer(){ return false; } 34 bool TryFindHeatRenderer(){ return false; }
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 #include"clsUtil.h" 6 #include"clsUtil.h"
7 #include"clsXML.h" 7 #include"clsXML.h"
8 #include "clsJson.h" 8 #include "clsJson.h"
  9 +#include "clsPtree.h"
9 #define _USE_MATH_DEFINES 10 #define _USE_MATH_DEFINES
10 #include<math.h> 11 #include<math.h>
11 #define ShadowSize 1 12 #define ShadowSize 1
@@ -384,6 +385,37 @@ namespace DmapCore_30 @@ -384,6 +385,37 @@ namespace DmapCore_30
384 return true; 385 return true;
385 } 386 }
386 387
  388 + bool TrueTypeMarkerSymbol::ParsePtree( boost::property_tree::ptree &pt)
  389 + {
  390 + boost::property_tree::ptree ptRenderer;
  391 + clsPtree::PtreeAttrParse("angle",ptRenderer, m_dAngle);
  392 + clsPtree::PtreeAttrParse("anglefield",ptRenderer, m_sAngleField);
  393 + clsPtree::ParseEnum("antialiasing",ptRenderer, m_iAntialiasing,"default", "none", "gray", "subpixel", "fast", "good", "best", "true", "false");
  394 + clsPtree::PtreeAttrParse("character",ptRenderer, m_lCharacter);
  395 + clsPtree::PtreeAttrParseColor("fontcolor", "fonttransparency",ptRenderer, m_iFontColor);
  396 +
  397 + clsPtree::PtreeAttrParse("fontname",ptRenderer,m_fontname);
  398 + clsPtree::PtreeAttrParse("characterxdis",ptRenderer, m_dCharacterXdis);
  399 + clsPtree::PtreeAttrParse("characterydis",ptRenderer, m_dCharacterYdis);
  400 + clsPtree::PtreeAttrParse("font",ptRenderer, m_sFont);
  401 + clsPtree::PtreeAttrParseColor("glowingcolor", "glowingtransparency",ptRenderer, m_iFontColor);
  402 + clsPtree::PtreeAttrParse("fontsize",ptRenderer, m_lFontSize);
  403 +
  404 + clsPtree::PtreeAttrParse("haveglowing",ptRenderer, m_bHaveGlowing);
  405 + if (m_bHaveGlowing)
  406 + {
  407 + clsPtree::PtreeAttrParseColor("haveglowing", "fonttransparency",ptRenderer, m_iGlowingColor);
  408 + }
  409 + clsPtree::PtreeAttrParse("haveglowing",ptRenderer, m_bHaveGlowing);
  410 +
  411 + clsPtree::ParseEnum("linetype",ptRenderer, m_iSlant,"normal", "italic", "oblique");
  412 + clsPtree::ParseEnum("linetype",ptRenderer, m_iWeight,"normal", "bold");
  413 + clsPtree::PtreeAttrParse("haveunderline",ptRenderer, m_bHaveUnderLine);
  414 + clsPtree::PtreeAttrParse("havedeleteline",ptRenderer, m_bHaveDeleteLine);
  415 + pt.add_child("TRUETYPEMARKERSYMBOL",ptRenderer);
  416 + return true;
  417 + }
  418 +
387 void TrueTypeMarkerSymbol::ToJson(AppendBuffer *ab) 419 void TrueTypeMarkerSymbol::ToJson(AppendBuffer *ab)
388 { 420 {
389 char buff[300] = {0}; 421 char buff[300] = {0};
@@ -25,7 +25,7 @@ namespace DmapCore_30 @@ -25,7 +25,7 @@ namespace DmapCore_30
25 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL); 25 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL);
26 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f); 26 virtual bool Parse(boost::property_tree::ptree &pt, AppendBuffer *f);
27 virtual void ToJson(AppendBuffer *ab); 27 virtual void ToJson(AppendBuffer *ab);
28 - 28 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
29 double m_dAngle; //旋转角度固定值 29 double m_dAngle; //旋转角度固定值
30 string m_sAngleField; //旋转角度以某个字段的数据为依据,改数据获取后会转化成 0~2π 30 string m_sAngleField; //旋转角度以某个字段的数据为依据,改数据获取后会转化成 0~2π
31 /* 31 /*
@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 #include "ValueMapRenderer.h" 2 #include "ValueMapRenderer.h"
3 #include"clsXML.h" 3 #include"clsXML.h"
4 #include "clsJson.h" 4 #include "clsJson.h"
  5 +#include "clsPtree.h"
5 #include"ValueMapRendererComponent.h" 6 #include"ValueMapRendererComponent.h"
6 #include<map> 7 #include<map>
7 using namespace std; 8 using namespace std;
@@ -74,6 +75,34 @@ namespace DmapCore_30 @@ -74,6 +75,34 @@ namespace DmapCore_30
74 return true; 75 return true;
75 } 76 }
76 77
  78 + bool ValueMapRenderer::ParsePtree( boost::property_tree::ptree &pt)
  79 + {
  80 + char buff[300] = {0};
  81 + boost::property_tree::ptree ptRenderer;
  82 + ptRenderer.add("lookupfield",m_sField);
  83 +
  84 + int length = (int)m_vComponents.size();
  85 + for (int i = 0; i < length; i++)
  86 + {
  87 + boost::property_tree::ptree ptNode;
  88 + ValueMapRendererComponent* vmrc = m_vComponents[i];
  89 + ptNode.add("value",vmrc->GetValue());
  90 + if(vmrc->m_pSymbol)
  91 + {
  92 + vmrc->m_pSymbol->ParsePtree(ptNode);
  93 + }
  94 + ptRenderer.add_child("EXACT",ptNode);
  95 + }
  96 +
  97 + if (m_pDefaultSymbol)
  98 + {
  99 + boost::property_tree::ptree ptNode;
  100 + this->m_pDefaultSymbol->ParsePtree(ptNode);
  101 + ptRenderer.add_child("OTHER",ptNode);
  102 + }
  103 + return true;
  104 + }
  105 +
77 void ValueMapRenderer::ToJson(AppendBuffer *ab) 106 void ValueMapRenderer::ToJson(AppendBuffer *ab)
78 { 107 {
79 char buff[300] = {0}; 108 char buff[300] = {0};
@@ -24,7 +24,7 @@ namespace DmapCore_30 @@ -24,7 +24,7 @@ namespace DmapCore_30
24 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL); 24 virtual bool DrawData(clsCrSurf* pClsCS, DataCollection* data, int dataIndex, char* pFlag = NULL);
25 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL); 25 virtual bool DrawLegend(clsCrSurf* pClsCS, shared_ptr<legendParamater> pLegendParamater,int layerType, char* pFlag = NULL);
26 virtual void ToJson(AppendBuffer *ab); 26 virtual void ToJson(AppendBuffer *ab);
27 - 27 + virtual bool ParsePtree( boost::property_tree::ptree &pt);
28 const char* GetTag(); 28 const char* GetTag();
29 bool SetTag(const char* sTag); 29 bool SetTag(const char* sTag);
30 Renderer* GetDefaultSymbol(); 30 Renderer* GetDefaultSymbol();
@@ -2,6 +2,9 @@ @@ -2,6 +2,9 @@
2 #define _clsJson_H_ 2 #define _clsJson_H_
3 #include"string" 3 #include"string"
4 #include "AppendBuffer.h" 4 #include "AppendBuffer.h"
  5 +#include <boost/property_tree/ptree.hpp>
  6 +#include <boost/property_tree/json_parser.hpp>
  7 +#include <boost/foreach.hpp>
5 using namespace std; 8 using namespace std;
6 namespace DmapCore_30 9 namespace DmapCore_30
7 { 10 {
  1 +/**************************************************************************
  2 +* file: clsPtree.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 16:52:23
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +
  11 +#include "clsPtree.h"
  12 +#include <stdarg.h>
  13 +#include <string.h>
  14 +
  15 +namespace DmapCore_30
  16 +{
  17 + void clsPtree::ParseEnum(const char *name, boost::property_tree::ptree& pt, int v, string a1, string a2 , string a3, string a4, string a5, string a6, string a7, string a8, string a9, string a10, string a11, string a12, string a13, string a14, string a15, string a16)
  18 + {
  19 +
  20 + string vstring = a1;
  21 + switch (v)
  22 + {
  23 + case 0: vstring = a1; break;
  24 + case 1: vstring = a2; break;
  25 + case 2: vstring = a3; break;
  26 + case 3: vstring = a4; break;
  27 + case 4: vstring = a5; break;
  28 + case 5: vstring = a6; break;
  29 + case 6: vstring = a7; break;
  30 + case 7: vstring = a8; break;
  31 + case 8: vstring = a9; break;
  32 + case 9: vstring = a10; break;
  33 + case 10: vstring = a11; break;
  34 + case 11: vstring = a12; break;
  35 + case 12: vstring = a13; break;
  36 + case 13: vstring = a14; break;
  37 + case 14: vstring = a15; break;
  38 + case 15: vstring = a16; break;
  39 + }
  40 + std::string ptname = "<xmlattr>.";
  41 + ptname += name;
  42 + pt.add(ptname, vstring);
  43 +
  44 + }
  45 +
  46 + void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, string &v)
  47 + {
  48 + std::string ptname = "<xmlattr>.";
  49 + ptname += name;
  50 + pt.add(ptname, v);
  51 + }
  52 +
  53 + void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, bool &v)
  54 + {
  55 + std::string ptname = "<xmlattr>.";
  56 + ptname += name;
  57 + pt.add(ptname, v?"true":"false");
  58 + }
  59 +
  60 + void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, double &v)
  61 + {
  62 + std::string ptname = "<xmlattr>.";
  63 + ptname += name;
  64 + pt.add(ptname, v);
  65 + }
  66 +
  67 + void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, int &v)
  68 + {
  69 + std::string ptname = "<xmlattr>.";
  70 + ptname += name;
  71 + pt.add(ptname, v);
  72 + }
  73 +
  74 + void clsPtree::PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, long &v)
  75 + {
  76 + std::string ptname = "<xmlattr>.";
  77 + ptname += name;
  78 + pt.add(ptname, v);
  79 + }
  80 +
  81 +
  82 +
  83 +
  84 + void clsPtree::PtreeAttrParseColor(const char* name,const char*name2, boost::property_tree::ptree& pt,unsigned int& value)
  85 + {
  86 + string sColor = "", sTransparency = "";
  87 + std::string ptname = "<xmlattr>.";
  88 + pt.add(ptname + name, sColor);
  89 + pt.add(ptname + name2, sTransparency);
  90 +
  91 + }
  92 +
  93 +} // namespace DmapDll
  1 +/**************************************************************************
  2 +* file: clsPtree.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 16:52:09
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __clsPtree_h__
  11 +#define __clsPtree_h__
  12 +
  13 +#include <boost/property_tree/ptree.hpp>
  14 +#include <boost/property_tree/json_parser.hpp>
  15 +#include <boost/foreach.hpp>
  16 +using namespace std;
  17 +namespace DmapCore_30
  18 +{
  19 + class Renderer;
  20 + class clsPtree
  21 + {
  22 + public:
  23 + static void ParseEnum(const char* name, boost::property_tree::ptree& pt,int, string a1 = "", string a2 = "", string a3 = "", string a4 = "", string a5 = "", string a6 = "", string a7 = "", string a8 = "", string a9 = "", string a10 = "", string a11 = "", string a12 = "", string a13 = "", string a14 = "", string a15 = "", string a16 = "");
  24 + static void PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, string &v);
  25 + static void PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, bool &v);
  26 + static void PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, double &v);
  27 + static void PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, int &v);
  28 + static void PtreeAttrParse(const char* name, boost::property_tree::ptree& pt, long &v);
  29 + // static void JsonAttrEnd(char* resultbuff);
  30 +
  31 + static void PtreeAttrParseColor(const char* name,const char*name2, boost::property_tree::ptree& pt, unsigned int&value);
  32 + };
  33 +}
  34 +
  35 +#endif // __clsPtree_h__
@@ -6,10 +6,12 @@ @@ -6,10 +6,12 @@
6 SET (API_SRCS 6 SET (API_SRCS
7 dmpapi.cpp 7 dmpapi.cpp
8 dmpmanagerapihandler.cpp 8 dmpmanagerapihandler.cpp
  9 + dmpvectormappingapihandler.cpp
9 ) 10 )
10 11
11 SET (API_HDRS 12 SET (API_HDRS
12 dmpmanagerapihandler.h 13 dmpmanagerapihandler.h
  14 + dmpvectormappingapihandler.h
13 ) 15 )
14 16
15 ######################################################## 17 ########################################################
@@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
15 #include <boost/make_shared.hpp> 15 #include <boost/make_shared.hpp>
16 #include "dmpservermanagerapi.h" 16 #include "dmpservermanagerapi.h"
17 #include "dmpmanagerapihandler.h" 17 #include "dmpmanagerapihandler.h"
  18 +#include "dmpvectormappingapihandler.h"
18 19
19 using namespace std; 20 using namespace std;
20 21
@@ -33,6 +34,8 @@ namespace DmpApi @@ -33,6 +34,8 @@ namespace DmpApi
33 }; 34 };
34 // Register handlers 35 // Register handlers
35 mgr_api->registerHandler<DmpManagerApiHandler>(); 36 mgr_api->registerHandler<DmpManagerApiHandler>();
  37 + // Register VectorMapping handlers
  38 + mgr_api->registerHandler<DmpVectorMappingApiHandler>();
36 // Register API 39 // Register API
37 std::shared_ptr<DmpServerApi> api(mgr_api); 40 std::shared_ptr<DmpServerApi> api(mgr_api);
38 registry.registerApi(api); 41 registry.registerApi(api);
  1 +/**************************************************************************
  2 +* file: dmpvectormappingapihandler.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-27 10:58:08
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#include <unistd.h>
  11 +#include <dirent.h>
  12 +#include <stdlib.h>
  13 +#include <sys/stat.h>
  14 +#include <map>
  15 +#include <set>
  16 +#include <fontconfig/fontconfig.h>
  17 +
  18 +#include <boost/foreach.hpp>
  19 +#include <boost/lexical_cast.hpp>
  20 +#include <boost/algorithm/string.hpp>
  21 +#include <boost/date_time.hpp>
  22 +#include <boost/property_tree/ptree.hpp>
  23 +#include <boost/property_tree/json_parser.hpp>
  24 +#include <boost/typeof/typeof.hpp>
  25 +
  26 +#include "dmpserverrequest.h"
  27 +#include "dmpserverresponse.h"
  28 +#include "dmplogger.h"
  29 +#include "dmpservermanager.h"
  30 +#include "dmpserverutils.h"
  31 +#include "dmpvectormappingapihandler.h"
  32 +
  33 +DmpVectorMappingApiHandler::DmpVectorMappingApiHandler()
  34 +{
  35 +
  36 +}
  37 +
  38 +void DmpVectorMappingApiHandler::HandleRequest(const DmpServerApiContext &context) const
  39 +{
  40 + if (OperationId().compare("getmap") == 0) {
  41 +
  42 + }
  43 + else if (OperationId().compare("getdmd") == 0) {
  44 +
  45 + }
  46 + else if (OperationId().compare("getdatatabledetail") == 0) {
  47 +
  48 + }
  49 + else if (OperationId().compare("gettypefacelist") == 0) {
  50 + getTypefaceList(context);
  51 + }
  52 + else if (OperationId().compare("getimagetyplist") == 0) {
  53 + getImageTypeList(context);
  54 + }
  55 + else if (OperationId().compare("getimagelist") == 0) {
  56 + getImageList(context);
  57 + }
  58 + else if (OperationId().compare("getimage") == 0) {
  59 + getImage(context);
  60 + }
  61 +}
  62 +
  63 +
  64 +void DmpVectorMappingApiHandler::getDataTableDetail(const DmpServerApiContext &context) const
  65 +{
  66 + switch (context.request()->method())
  67 + {
  68 + case DmpServerRequest::Method::GET_METHOD:
  69 + {
  70 + context.response()->write("{\"status\":\"true\",\"message\":\"服务发布测试——————GET\"}");
  71 + break;
  72 + }
  73 + case DmpServerRequest::Method::POST_METHOD:
  74 + {
  75 + std::string dbsource;
  76 + std::string schema;
  77 + std::string tablename;
  78 +
  79 + const char* data = (char*)(context.request()->GetData());
  80 + if(data && *data != '\0')
  81 + {
  82 + try
  83 + {
  84 + std::stringstream stream(data);
  85 + boost::property_tree::ptree pt;
  86 + boost::property_tree::read_json(stream, pt);
  87 +
  88 + dbsource = pt.get<std::string>("dbsource");
  89 + schema = pt.get<std::string>("schema");
  90 + tablename = pt.get<int>("tablename");
  91 +
  92 + }
  93 + catch (boost::property_tree::ptree_bad_path& e) {
  94 + LOGGER_ERROR(e.what());
  95 + context.response()->write("{\"status\":\"false\",\"message\":\"获取表信息失败\"}");
  96 + return;
  97 + }
  98 + catch (boost::property_tree::ptree_bad_data& e) {
  99 + LOGGER_ERROR(e.what());
  100 + context.response()->write("{\"status\":\"false\",\"message\":\"获取表信息失败\"}");
  101 + return;
  102 + }
  103 + if(false) {
  104 + // context.manager()->publish(serverType, name, title, capabilities, project)
  105 + LOGGER_INFO("服务发布成功");
  106 + context.response()->write("{\"status\":\"true\",\"message\":\"Pulish service successful!\"}");
  107 + // std::string projData;
  108 + // DmpServerUtils::Base64Decode(project, &projData);
  109 + // context.response()->removeHeader("Content-Type");
  110 + // context.response()->setHeader("Content-Type", "text/xml;charset=utf-8");
  111 + // context.response()->write(projData);
  112 + }
  113 + else
  114 + {
  115 + LOGGER_ERROR("获取表信息失败");
  116 + context.response()->write("{\"status\":\"false\",\"message\":\"获取表信息失败!\"}");
  117 + }
  118 + }
  119 + else
  120 + {
  121 + LOGGER_ERROR("POST数据为空");
  122 + context.response()->write("{\"status\":\"false\",\"message\":\"POST数据为空,获取表信息失败!\"}");
  123 + return;
  124 + }
  125 + break;
  126 +
  127 + }
  128 + default:
  129 + {
  130 +
  131 + }
  132 + }
  133 +}
  134 +
  135 +
  136 +void DmpVectorMappingApiHandler::getTypefaceList(const DmpServerApiContext &context) const
  137 +{
  138 + FcConfig *config = FcInitLoadConfigAndFonts();
  139 + FcPattern *pat = FcPatternCreate();
  140 + FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, FC_STYLE, FC_LANG, FC_FILE, (char *)0);
  141 + FcFontSet *fs = FcFontList(config, pat, os);
  142 + if(fs == nullptr)
  143 + {
  144 + context.response()->writeJson("{\"error\":\"load FcFontSet failed\"}");
  145 + return;
  146 + }
  147 + //printf("Total matching fonts: %d\n", fs->nfont);
  148 + boost::property_tree::ptree ptDoc;
  149 + boost::property_tree::ptree ptRoot;
  150 +
  151 + std::map<std::string, std::string> mapFont;
  152 + mapFont["SimSun"] = "宋体";
  153 + mapFont["NSimSun"] = "新宋体";
  154 + mapFont["SimHei"] = "黑体";
  155 + mapFont["FangSong"] = "仿宋";
  156 + mapFont["KaiTi"] = "楷体";
  157 + mapFont["LiSu"] = "隶书";
  158 + mapFont["YouYuan"] = "幼圆";
  159 + mapFont["STXihei"] = "华文细黑";
  160 + mapFont["STKaiti"] = "华文楷体";
  161 + mapFont["STSong"] = "华文宋体";
  162 + mapFont["STZhongsong"] = "华文中宋";
  163 + mapFont["STFangsong"] = "华文仿宋";
  164 + mapFont["FZShuTi"] = "方正舒体";
  165 + mapFont["FZYaoti"] = "方正姚体";
  166 + mapFont["STCaiyun"] = "华文彩云";
  167 + mapFont["STHupo"] = "华文琥珀";
  168 + mapFont["STLiti"] = "华文隶书";
  169 + mapFont["STXingkai"] = "华文行楷";
  170 + mapFont["STXinwei"] = "华文新魏";
  171 + mapFont["Microsoft YaHei"] = "微软雅黑";
  172 + mapFont["Microsoft JhengHei"] = "微軟正黑體";
  173 + mapFont["DengXian"] = "等线";
  174 + mapFont["MingLiU"] = "細明體";
  175 + mapFont["MingLiU_HKSCS"] = "細明體_HKSCS";
  176 + mapFont["MingLiU"] = "細明體";
  177 +
  178 + std::set<std::string> setFont;
  179 + char buff[1000];
  180 + for (int i = 0; fs && i < fs->nfont; ++i)
  181 + {
  182 +
  183 + FcPattern *font = fs->fonts[i];
  184 + FcChar8 *file, *style, *family, *prgname;
  185 + if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch &&
  186 + FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch &&
  187 + FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch)
  188 + {
  189 + sprintf(buff, "%s", family);
  190 + if (setFont.find(buff) == setFont.end())
  191 + {
  192 +
  193 + setFont.insert(buff);
  194 + if (mapFont.find(buff) != mapFont.end())
  195 + {
  196 + boost::property_tree::ptree ptNode;
  197 + ptNode.put("",buff);
  198 + ptRoot.push_back(std::make_pair("",ptNode));
  199 + }
  200 + }
  201 + }
  202 + }
  203 +
  204 + for (std::set<std::string>::iterator iter = setFont.begin();
  205 + iter != setFont.end(); iter++)
  206 + {
  207 + if (mapFont.find(*iter) == mapFont.end())
  208 + {
  209 + boost::property_tree::ptree ptNode;
  210 + ptNode.put("",*iter);
  211 + ptRoot.push_back(std::make_pair("",ptNode));
  212 + }
  213 + }
  214 +
  215 + FcFontSetDestroy(fs);
  216 +
  217 + ptDoc.add_child("value",ptRoot);
  218 + std::stringstream stream;
  219 + write_json(stream, ptDoc);
  220 + std::string responseStr = stream.str();
  221 + context.response()->writeJson(responseStr);
  222 +
  223 +}
  224 +
  225 +void DmpVectorMappingApiHandler::getImage(const DmpServerApiContext &context) const
  226 +{
  227 + DmpServerParameters params = context.request()->serverParameters();
  228 + std::string name;
  229 + params.getValue("name", name);
  230 +
  231 + std::string imagePath = getFilePath("../symbollib/" + name);
  232 + FILE *file = fopen(imagePath.c_str(), "rb");
  233 +
  234 + try
  235 + {
  236 + char buff[1024];
  237 + if (file == 0)
  238 + {
  239 + context.response()->writeJson("{\"error\":\"open file failed\"}");
  240 + return;
  241 + }
  242 +
  243 + context.response()->removeHeader("Content-Type");
  244 + context.response()->setHeader("Content-Type", "image/png");
  245 +
  246 + for (int i = 0; i < 20000; i++)
  247 + {
  248 + size_t t = fread(buff, 1, sizeof(buff), file);
  249 + context.response()->writeContent(buff,t);
  250 +
  251 + if (t != sizeof(buff))
  252 + break;
  253 + }
  254 + fclose(file);
  255 + return;
  256 + }
  257 + catch (...)
  258 + {
  259 + if (file)
  260 + fclose(file);
  261 +
  262 + }
  263 + context.response()->writeJson("{\"error\":\"Parameter name is null\"}");
  264 +
  265 +}
  266 +
  267 +
  268 +void DmpVectorMappingApiHandler::getImageTypeList(const DmpServerApiContext &context) const
  269 +{
  270 + DIR *dirp;
  271 + struct dirent *dp;
  272 + std::string imagePath = getFilePath("../symbollib");
  273 + dirp = opendir(imagePath.c_str());
  274 +
  275 + boost::property_tree::ptree ptDoc;
  276 + boost::property_tree::ptree ptRoot;
  277 +
  278 + if (dirp)
  279 + {
  280 + while ((dp = readdir(dirp)) != NULL)
  281 + {
  282 + if (dp->d_name == NULL || dp->d_name[0] == '.')
  283 + {
  284 + continue;
  285 + }
  286 +
  287 + boost::property_tree::ptree ptDir;
  288 +
  289 + ptDir.add("name", dp->d_name);
  290 + ptRoot.push_back(std::make_pair("",ptDir));
  291 + //ptRoot.add_child("imageType",ptDir);
  292 + }
  293 + closedir(dirp);
  294 + }
  295 + else
  296 + {
  297 + LOGGER_ERROR("not find dir "+ imagePath);
  298 + }
  299 +
  300 + ptDoc.add_child("value",ptRoot);
  301 + std::stringstream stream;
  302 + write_json(stream, ptDoc);
  303 + std::string responseStr = stream.str();
  304 + context.response()->writeJson(responseStr);
  305 +}
  306 +
  307 + void DmpVectorMappingApiHandler::getImageList(const DmpServerApiContext &context) const
  308 + {
  309 + DmpServerParameters params = context.request()->serverParameters();
  310 + std::string name;
  311 + params.getValue("name", name);
  312 +
  313 + if(name.empty())
  314 + {
  315 + context.response()->writeJson("{\"error\":\"Parameter name is null\"}");
  316 + return;
  317 + }
  318 +
  319 + struct dirent *dp;
  320 + std::string imagePath = getFilePath("../symbollib/" + name);
  321 + DIR *dirp = opendir(imagePath.c_str());
  322 +
  323 + boost::property_tree::ptree ptDoc;
  324 + boost::property_tree::ptree ptRoot;
  325 +
  326 + if (dirp)
  327 + {
  328 + while ((dp = readdir(dirp)) != NULL)
  329 + {
  330 + boost::property_tree::ptree ptDir;
  331 + if (dp->d_name == NULL || dp->d_name[0] == '.')
  332 + {
  333 + continue;
  334 + }
  335 + ptDir.add("name", dp->d_name);
  336 + ptDir.add("path", ("../symbollib/" + name + "/" + dp->d_name));
  337 + ptRoot.push_back(std::make_pair("",ptDir));
  338 + }
  339 + closedir(dirp);
  340 + }
  341 + else
  342 + {
  343 + LOGGER_ERROR("not find dir " + imagePath);
  344 + }
  345 +
  346 + ptDoc.add_child("value",ptRoot);
  347 + std::stringstream stream;
  348 + write_json(stream, ptDoc);
  349 + std::string responseStr = stream.str();
  350 + context.response()->writeJson(responseStr);
  351 +
  352 + }
  353 +
  354 + std::string DmpVectorMappingApiHandler::getFilePath(const std::string& path) const
  355 + {
  356 + char sz[300] = {0};
  357 + if (getCurrentFolderPath(sz, sizeof(sz)) > 0)
  358 + {
  359 + std::string s;
  360 + s = sz;
  361 + size_t t = s.rfind('/');
  362 + sz[t] = 0;
  363 + if (path[0] == '/')
  364 + {
  365 + return path;
  366 + }
  367 + int i = 0;
  368 + if (path[0] == '.')
  369 + {
  370 + if (path[1] == '.')
  371 + {
  372 + i++;
  373 + s = sz;
  374 + t = s.rfind('/');
  375 + sz[t] = 0;
  376 + }
  377 + i++;
  378 + }
  379 + if ((sz[t] == '/' || sz[t] == '\\') && (path[i] == '/' || path[i] == '\\'))
  380 + {
  381 + i++;
  382 + }
  383 +
  384 + int j = t;
  385 + for (j = t; i < path.length(); i++, j++)
  386 + {
  387 + if (path[i] == '\\')
  388 + {
  389 + sz[j] = '/';
  390 + }
  391 + else
  392 + {
  393 + sz[j] = path[i];
  394 + }
  395 + }
  396 + sz[j] = 0;
  397 + //strcat(sz, path.c_str());
  398 + return sz;
  399 + }
  400 + else
  401 + return 0;
  402 + }
  403 +
  404 +size_t DmpVectorMappingApiHandler::getCurrentFolderPath(char *processdir, size_t len) const
  405 +{
  406 + char *path_end;
  407 + if (readlink("/proc/self/exe", processdir, len) <= 0)
  408 + return -1;
  409 + path_end = strrchr(processdir, '/');
  410 + if (path_end == NULL)
  411 + return -1;
  412 + ++path_end;
  413 + //strcpy(processname, path_end);
  414 + *path_end = '\0';
  415 + return (size_t)(path_end - processdir);
  416 +}
  1 +/**************************************************************************
  2 +* file: dmpvectormappingapihandler.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-27 10:58:13
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpvectormappingapihandler_h__
  11 +#define __dmpvectormappingapihandler_h__
  12 +
  13 +#include "dmpserverapihandler.h"
  14 +
  15 +
  16 +class DmpVectorMappingApiHandler : public DmpServerApiHandler
  17 +{
  18 +public:
  19 + DmpVectorMappingApiHandler();
  20 + void HandleRequest(const DmpServerApiContext &context) const override;
  21 + //填写正则表达式,来验证对应的url是否符合handler的处理
  22 + //Path: /dmap/api/Vectormapping/{action}
  23 + std::string Path() const override { return "/dmap/api/vectormapping/(?<action>[^/]+?)"; }
  24 +private:
  25 +
  26 + void setMapRenderer(const DmpServerApiContext &context) const; //提交符号化
  27 +
  28 + void getValueList(const DmpServerApiContext &context) const; //获取数据表列表
  29 + void getmap(const DmpServerApiContext &context) const; // getmap 获取图片
  30 + void getTypefaceList(const DmpServerApiContext &context) const; //获取字体列表
  31 + void getImageTypeList(const DmpServerApiContext &context) const; //获取图片目录列表
  32 + void getImageList(const DmpServerApiContext &context) const; //获取图片列表
  33 + void getImage(const DmpServerApiContext &context) const; //获取图片
  34 + void getDMD(const DmpServerApiContext &context) const; //获取图片
  35 + void getDataTableDetail(const DmpServerApiContext &context) const; //获取数据表信息
  36 +private:
  37 + std::string getFilePath(const std::string& path) const;
  38 + size_t getCurrentFolderPath(char *processdir, size_t len) const;
  39 +
  40 +};
  41 +
  42 +
  43 +#endif // __dmpvectormappingapihandler_h__
@@ -8,16 +8,18 @@ SET (MAPSERVER_SRCS @@ -8,16 +8,18 @@ SET (MAPSERVER_SRCS
8 dmppgsql.cpp 8 dmppgsql.cpp
9 dmppgsqlpool.cpp 9 dmppgsqlpool.cpp
10 dmppgsqlsourcepools.cpp 10 dmppgsqlsourcepools.cpp
11 - #wfs/dmpwfs.cpp  
12 - #wfs/dmpwfsgetcapabilities.cpp  
13 - #wfs/dmpwfsgetfeature.cpp  
14 - #wfs/dmpwfsparameters.cpp 11 + wfs/dmpwfs.cpp
  12 + wfs/dmpwfsgetcapabilities.cpp
  13 + wfs/dmpwfsgetfeature.cpp
  14 + wfs/dmpwfsparameters.cpp
15 wms/dmpwmsrenderer.cpp 15 wms/dmpwmsrenderer.cpp
16 wms/dmpwms.cpp 16 wms/dmpwms.cpp
17 wms/dmpwmsparameters.cpp 17 wms/dmpwmsparameters.cpp
18 wms/dmpwmsgetcapabilities.cpp 18 wms/dmpwmsgetcapabilities.cpp
19 wms/dmpwmsgetmap.cpp 19 wms/dmpwmsgetmap.cpp
20 wms/dmpwmsgetfeatureinfo.cpp 20 wms/dmpwmsgetfeatureinfo.cpp
  21 + mapping/dmpmapping.cpp
  22 + mapping/dmpeditservice.cpp
21 ) 23 )
22 24
23 SET (MAPSERVER_HDRS 25 SET (MAPSERVER_HDRS
@@ -26,16 +28,18 @@ SET (MAPSERVER_HDRS @@ -26,16 +28,18 @@ SET (MAPSERVER_HDRS
26 dmppgsql.h 28 dmppgsql.h
27 dmppgsqlpool.h 29 dmppgsqlpool.h
28 dmppgsqlsourcepools.h 30 dmppgsqlsourcepools.h
29 - #wfs/dmpwfs.h  
30 - #wfs/dmpwfsgetcapabilities.h  
31 - #wfs/dmpwfsgetfeature.h  
32 - #wfs/dmpwfsparameters.h 31 + wfs/dmpwfs.h
  32 + wfs/dmpwfsgetcapabilities.h
  33 + wfs/dmpwfsgetfeature.h
  34 + wfs/dmpwfsparameters.h
33 wms/dmpwmsrenderer.h 35 wms/dmpwmsrenderer.h
34 wms/dmpwms.h 36 wms/dmpwms.h
35 wms/dmpwmsparameters.h 37 wms/dmpwmsparameters.h
36 wms/dmpwmsgetcapabilities.h 38 wms/dmpwmsgetcapabilities.h
37 wms/dmpwmsgetmap.h 39 wms/dmpwmsgetmap.h
38 wms/dmpwmsgetfeatureinfo.h 40 wms/dmpwmsgetfeatureinfo.h
  41 + mapping/dmpmapping.h
  42 + mapping/dmpeditservice.h
39 ) 43 )
40 44
41 ######################################################## 45 ########################################################
@@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
10 #include <boost/regex.hpp> 10 #include <boost/regex.hpp>
11 #include <boost/lexical_cast.hpp> 11 #include <boost/lexical_cast.hpp>
12 #include "wms/dmpwms.h" 12 #include "wms/dmpwms.h"
  13 +#include "wfs/dmpwfs.h"
  14 +#include "mapping/dmpmapping.h"
13 #include "dmpserverresponse.h" 15 #include "dmpserverresponse.h"
14 16
15 namespace mapserver 17 namespace mapserver
@@ -19,6 +21,12 @@ DmpMapServer::DmpMapServer() @@ -19,6 +21,12 @@ DmpMapServer::DmpMapServer()
19 { 21 {
20 DmpService* wmsServer = new DmpWms::DmpWMSService(); 22 DmpService* wmsServer = new DmpWms::DmpWMSService();
21 services_[wmsServer->name()] = wmsServer; 23 services_[wmsServer->name()] = wmsServer;
  24 +
  25 + DmpService* wfsServer = new DmpWfs::DmpWFSService();
  26 + services_[wfsServer->name()] = wfsServer;
  27 +
  28 + DmpService* mappingServer = new DmpMapping::DmpMappingService();
  29 + services_[mappingServer->name()] = mappingServer;
22 } 30 }
23 31
24 DmpMapServer::~DmpMapServer() 32 DmpMapServer::~DmpMapServer()
@@ -73,6 +81,10 @@ void DmpMapServer::executeRequest(DmpServerRequest &request, DmpServerResponse & @@ -73,6 +81,10 @@ void DmpMapServer::executeRequest(DmpServerRequest &request, DmpServerResponse &
73 DmpServerContext context {&request, &response, serverProj}; 81 DmpServerContext context {&request, &response, serverProj};
74 service->executeRequest(context); 82 service->executeRequest(context);
75 } 83 }
  84 + else if(service->name() == "MappingService"){
  85 + DmpServerContext context {&request, &response, nullptr};
  86 + service->executeRequest(context);
  87 + }
76 else { 88 else {
77 response.writeHtml(htmlstr + "找不到服务\"" + serviceName + "\"</p></body></html>\n"); 89 response.writeHtml(htmlstr + "找不到服务\"" + serviceName + "\"</p></body></html>\n");
78 } 90 }
  1 +/**************************************************************************
  2 +* file: dmpeditservice.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 14:32:34
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpeditservice.h"
  10 +#include "dmplogger.h"
  11 +#include "dmpserverresponse.h"
  12 +#include "dmpserverrequest.h"
  13 +#include <boost/property_tree/ptree.hpp>
  14 +#include <boost/property_tree/json_parser.hpp>
  15 +#include <boost/typeof/typeof.hpp>
  16 +
  17 +namespace DmpMapping
  18 +{
  19 + bool loadService(const DmpServerContext &context, ProjectMap& vectorMappingProjects, const char* data)
  20 + {
  21 + if(data== nullptr || *data == '\0')
  22 + {
  23 + LOGGER_ERROR("post 参数错误");
  24 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}");
  25 + return false;
  26 + }
  27 +
  28 + if(!context.serverProject())
  29 + {
  30 + LOGGER_ERROR("加载服务信息失败,服务名称是否错误");
  31 + context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}");
  32 + return false;
  33 + }
  34 +
  35 + try
  36 + {
  37 + std::stringstream stream(data);
  38 + boost::property_tree::ptree pt;
  39 + boost::property_tree::read_json(stream, pt);
  40 +
  41 + std::string guid = pt.get<std::string>("guid");
  42 + std::string project = pt.get<std::string>("project");
  43 + if(!guid.empty() && !project.empty())
  44 + {
  45 + std::string projData;
  46 + if (!DmpServerUtils::Base64Decode(project, &projData))
  47 + {
  48 + return false;
  49 + }
  50 + shared_ptr<DmpProject> project(new DmpProject());
  51 + if (!project->Read(projData))
  52 + {
  53 + return false;
  54 + }
  55 + vectorMappingProjects[guid] = project;
  56 + context.response()->write("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}");
  57 + }
  58 + else
  59 + {
  60 + LOGGER_ERROR("post 参数错误");
  61 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}");
  62 + return false;
  63 + }
  64 +
  65 + }
  66 + catch (boost::property_tree::ptree_bad_path &e)
  67 + {
  68 + LOGGER_ERROR(e.what());
  69 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}");
  70 + return false;
  71 + }
  72 + catch (boost::property_tree::ptree_bad_data &e)
  73 + {
  74 + LOGGER_ERROR(e.what());
  75 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}");
  76 + return false;
  77 + }
  78 + return false;
  79 + }
  80 +
  81 + bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data)
  82 + {
  83 + if(data== nullptr || *data == '\0')
  84 + {
  85 + LOGGER_ERROR("post 参数错误");
  86 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}");
  87 + return false;
  88 + }
  89 +
  90 + if(!context.serverProject())
  91 + {
  92 + LOGGER_ERROR("加载服务信息失败,服务名称是否错误");
  93 + context.response()->write("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}");
  94 + return false;
  95 + }
  96 +
  97 + try
  98 + {
  99 + std::stringstream stream(data);
  100 + boost::property_tree::ptree pt;
  101 + boost::property_tree::read_json(stream, pt);
  102 +
  103 + std::string guid = pt.get<std::string>("guid");
  104 + std::string project = pt.get<std::string>("project");
  105 + if(!guid.empty() && !project.empty())
  106 + {
  107 + std::string projData;
  108 + if (!DmpServerUtils::Base64Decode(project, &projData))
  109 + {
  110 + return false;
  111 + }
  112 + shared_ptr<DmpProject> project(new DmpProject());
  113 + if (!project->Read(projData))
  114 + {
  115 + return false;
  116 + }
  117 + vectorMappingProjects[guid] = project;
  118 + context.response()->write("{\"status\":\"true\",\"message\":\"创建编辑服务工作空间成功!\"}");
  119 + }
  120 + else
  121 + {
  122 + LOGGER_ERROR("post 参数错误");
  123 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误!\"}");
  124 + return false;
  125 + }
  126 +
  127 + }
  128 + catch (boost::property_tree::ptree_bad_path &e)
  129 + {
  130 + LOGGER_ERROR(e.what());
  131 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}");
  132 + return false;
  133 + }
  134 + catch (boost::property_tree::ptree_bad_data &e)
  135 + {
  136 + LOGGER_ERROR(e.what());
  137 + context.response()->write("{\"status\":\"false\",\"message\":\"post 参数错误\"}");
  138 + return false;
  139 + }
  140 + return false;
  141 + }
  142 +
  143 +}
  1 +/**************************************************************************
  2 +* file: dmpeditservice.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 14:32:27
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpeditservice_h__
  11 +#define __dmpeditservice_h__
  12 +#include <map>
  13 +#include <memory>
  14 +#include <functional>
  15 +#include "dmpproject.h"
  16 +#include "dmpservercontext.h"
  17 +#include "dmppgsqlsourcepools.h"
  18 +
  19 +namespace DmpMapping
  20 +{
  21 + typedef std::map<std::string, std::shared_ptr<DmpProject>> ProjectMap;
  22 +
  23 + bool loadService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data);
  24 +
  25 +
  26 + bool editService(const DmpServerContext &context,ProjectMap& vectorMappingProjects, const char* data);
  27 +
  28 +}
  29 +
  30 +
  31 +#endif // __dmpeditservice_h__
  1 +/**************************************************************************
  2 +* file: dmpgetdatatabledetail.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 13:39:55
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpgetdatatabledetail.h"
  10 +#include "dmpserverresponse.h"
  11 +#include "dmpserverrequest.h"
  12 +#include "dmpserverproject.h"
  13 +
  14 +namespace DmpMapping
  15 +{
  16 + bool getDataTableDetail(const DmpServerContext &context,const char* data);
  17 +}
  1 +/**************************************************************************
  2 +* file: dmpgetdatatabledetail.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 13:39:50
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpgetdatatabledetail_h__
  11 +#define __dmpgetdatatabledetail_h__
  12 +
  13 +#include <string>
  14 +
  15 +namespace DmpMapping
  16 +{
  17 + bool getDataTableDetail(const DmpServerContext &context,const char* data);
  18 +}
  19 +
  20 +#endif // __dmpgetdatatabledetail_h__
  1 +/**************************************************************************
  2 +* file: dmpmapping.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 10:49:10
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#include <iostream>
  11 +#include <string>
  12 +#include "dmpservice.h"
  13 +#include <boost/dll/alias.hpp> // for BOOST_DLL_ALIAS
  14 +#include <boost/filesystem.hpp>
  15 +#include <boost/function.hpp>
  16 +#include <boost/make_shared.hpp>
  17 +#include "dmpserverresponse.h"
  18 +#include "dmplogger.h"
  19 +#include "../wms/dmpwmsgetmap.h"
  20 +#include "dmpmapping.h"
  21 +using namespace std;
  22 +
  23 +namespace DmpMapping
  24 +{
  25 + DmpMappingService::DmpMappingService()
  26 + {
  27 + LOGGER_DEBUG("Constructing WmsService");
  28 + }
  29 +
  30 + DmpMappingService::~DmpMappingService()
  31 + {
  32 + LOGGER_DEBUG("Destructing WmsService");
  33 + }
  34 +
  35 + void DmpMappingService::executeRequest(const DmpServerContext &context)
  36 + {
  37 + LOGGER_DEBUG("Destructing WmsService");
  38 +
  39 + const char* data = (char*)(context.request()->GetData());
  40 +
  41 +
  42 +
  43 + }
  44 +}
  45 +
  1 +/**************************************************************************
  2 +* file: dmpmapping.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-29 10:49:16
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#ifndef __dmpmapping_h__
  10 +#define __dmpmapping_h__
  11 +#include <string>
  12 +#include <string>
  13 +#include "dmpeditservice.h"
  14 +#include "dmpservice.h"
  15 +namespace DmpMapping
  16 +{
  17 + class DmpMappingService : public DmpService
  18 + {
  19 + public:
  20 + DmpMappingService();
  21 + ~DmpMappingService();
  22 + std::string name() const override { return std::string("MappingService"); }
  23 + std::string version() const override { return std::string("1.3.0"); }
  24 + std::string description() const override { return std::string("在线配图服务"); }
  25 + bool allowMethod(DmpServerRequest::Method method) const override { return method == DmpServerRequest::GET_METHOD; }
  26 + void executeRequest(const DmpServerContext &context) override;
  27 + private:
  28 +
  29 + //存储工程文档实例
  30 + ProjectMap vectorMappingProjects_;
  31 + };
  32 +}
  33 +
  34 +#endif // __dmpmapping_h__
  1 +/**************************************************************************
  2 +* file: dmpsqlfactory.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-27 20:31:37
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpsqlfactory.h"
  10 +
  11 +namespace DmpWfs
  12 +{
  13 +
  14 + DmpSqlFactory::DmpSqlFactory(void)
  15 + {
  16 + count_ = 1000;
  17 + startIndex_ = 0;
  18 + }
  19 +
  20 + DmpSqlFactory::~DmpSqlFactory(void)
  21 + {
  22 + }
  23 +
  24 + void DmpSqlFactory::setStartIndexCount(int startIndex, int count, const std::string& resultType)
  25 + {
  26 + if (count > 0)
  27 + {
  28 + this->count_ = count;
  29 + }
  30 +
  31 + if (startIndex >=0)
  32 + {
  33 + this->startIndex_ = startIndex;
  34 + }
  35 + this->resultType_ = resultType;
  36 + }
  37 +
  38 + void DmpSqlFactory::appendCondition(char *c)
  39 + {
  40 + if (condition.size() == 0)
  41 + {
  42 + condition = c;
  43 + }
  44 + else
  45 + {
  46 + condition += " and ";
  47 + condition += c;
  48 + }
  49 + }
  50 +
  51 + void DmpSqlFactory::appendCondition(std::string &c)
  52 + {
  53 + if (condition.size() == 0)
  54 + {
  55 + condition = c;
  56 + }
  57 + else
  58 + {
  59 + condition += " and ";
  60 + condition += c;
  61 + }
  62 + }
  63 +
  64 + std::string DmpSqlFactory::getSql()
  65 + {
  66 + std::string sql = "select ";
  67 + if (resultType_ == "hits")
  68 + {
  69 + sql += "count(*) as count";
  70 + }
  71 + else
  72 + {
  73 + if (this->prop.size() == 0)
  74 + {
  75 + sql += "*";
  76 + }
  77 + else
  78 + sql += this->prop;
  79 + }
  80 + sql += " from \"";
  81 + sql += this->table;
  82 + sql += "\" where ";
  83 + if (this->condition.size() == 0)
  84 + {
  85 + sql += "1=1";
  86 + }
  87 + else
  88 + {
  89 + sql += this->condition;
  90 + }
  91 + if (this->order.size() > 0)
  92 + {
  93 + sql += this->order;
  94 + }
  95 +
  96 + if (count_ <= 0)
  97 + {
  98 + count_ = 1000;
  99 + }
  100 + if (count_ > 0 || startIndex_ > 0)
  101 + {
  102 + char sz[100];
  103 + sprintf(sz, " limit %ld offset %ld", count_, startIndex_);
  104 + sql += sz;
  105 + }
  106 + return sql;
  107 + }
  108 +
  109 +}
  1 +/**************************************************************************
  2 +* file: dmpsqlfactory.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-27 20:31:30
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpsqlfactory_h__
  11 +#define __dmpsqlfactory_h__
  12 +#include <string>
  13 +#include <string.h>
  14 +namespace DmpWfs
  15 +{
  16 + class DmpSqlFactory
  17 + {
  18 + public:
  19 + DmpSqlFactory(void);
  20 + ~DmpSqlFactory(void);
  21 +
  22 + void setStartIndexCount(int startIndex, int count, const std::string &resultType);
  23 + void appendCondition(std::string &c);
  24 + void appendCondition(char *c);
  25 + std::string getSql();
  26 +
  27 + private:
  28 + std::string prop;
  29 + std::string condition;
  30 + std::string order;
  31 + std::string table;
  32 +
  33 + std::string resultType_;
  34 + int startIndex_;
  35 + int count_;
  36 + };
  37 +}
  38 +
  39 +#endif // __dmpsqlfactory_h__
@@ -14,61 +14,48 @@ @@ -14,61 +14,48 @@
14 #include <boost/filesystem.hpp> 14 #include <boost/filesystem.hpp>
15 #include <boost/function.hpp> 15 #include <boost/function.hpp>
16 #include <boost/make_shared.hpp> 16 #include <boost/make_shared.hpp>
  17 +#include "dmpserverresponse.h"
  18 +#include "dmpwfs.h"
  19 +#include "dmplogger.h"
  20 +#include "dmpwfsparameters.h"
  21 +#include "dmpwfsgetcapabilities.h"
  22 +#include "dmpwfsgetfeature.h"
17 using namespace std; 23 using namespace std;
18 24
19 namespace DmpWfs 25 namespace DmpWfs
20 { 26 {
21 - class DmpWFSService : public DmpService  
22 - {  
23 - public:  
24 - DmpWFSService() {  
25 - std::cout << "Constructing WfsService" << std::endl;  
26 - }  
27 -  
28 - ~DmpWFSService() {  
29 - std::cout << "Destructing WfsService" << std::endl;  
30 - }  
31 -  
32 - string name() const override { return string("WFSService"); }  
33 - string version() const override { return string("1.0.0"); }  
34 - string description() const override { return string("WFS服务"); }  
35 - bool allowMethod(DmpServerRequest::Method method) const override  
36 - {  
37 - return method == DmpServerRequest::GET_METHOD;  
38 - }  
39 -  
40 - void executeRequest(const DmpServerRequest &request, DmpServerResponse &response) override  
41 - {  
42 - std::string url = request.url();  
43 -  
44 - response.Write("hello, wfs");  
45 - }  
46 -  
47 - // bool Register(DmpServiceComposite* service_comp) override  
48 - // {  
49 - // return false;  
50 - // }  
51 -  
52 - };  
53 -  
54 //实际中,WebGIS服务器针对这些功能并不是必须全部实现,而是实现全部或部分。 27 //实际中,WebGIS服务器针对这些功能并不是必须全部实现,而是实现全部或部分。
55 //因此,根据依据这些功能的支持与否,可以将WFS分为3类: 28 //因此,根据依据这些功能的支持与否,可以将WFS分为3类:
56 //Basic WFS —— 必须支持GetCapabilities、DescribeFeature Type、GetFeature功能 29 //Basic WFS —— 必须支持GetCapabilities、DescribeFeature Type、GetFeature功能
57 //XLink WFS —— 必须在Basic WFS基础上加上GetGmlObject操作 30 //XLink WFS —— 必须在Basic WFS基础上加上GetGmlObject操作
58 //Transaction WFS —— 也称为WFS-T,必须在Basic WFS基础上加上Transaction功能以及支持编辑数据,另外也可以加上GetGmlObject或LockFeature功能 31 //Transaction WFS —— 也称为WFS-T,必须在Basic WFS基础上加上Transaction功能以及支持编辑数据,另外也可以加上GetGmlObject或LockFeature功能
59 - class DmpWfsModule : public DmpServiceModule 32 + DmpWFSService::DmpWFSService()
  33 + {
  34 + LOGGER_DEBUG("Constructing WmsService");
  35 + }
  36 +
  37 + DmpWFSService::~DmpWFSService()
60 { 38 {
61 - public:  
62 - void registerSelf(DmpServerRegistry &registry) override  
63 - {  
64 - cout<<"WFSModule::registerSelf called" <<endl;  
65 - registry.registerServer(make_shared<DmpWfs::DmpWFSService>());  
66 - }  
67 - }; 39 + LOGGER_DEBUG("Destructing WmsService");
  40 + }
68 41
69 - shared_ptr<DmpServiceModule> Create() 42 + void DmpWFSService::executeRequest(const DmpServerContext &context)
70 { 43 {
71 - return make_shared<DmpWfsModule>(); 44 + const DmpWfsParameters params(context.request()->serverParameters());
  45 + const DmpProject* project = context.serverProject()->project();
  46 + const std::string request = params.Request();
  47 + if (request.empty())
  48 + {
  49 + context.response()->writeHtml("wms,Operation is null");
  50 + }
  51 + else if(boost::iequals(request, "getcapabilities"))
  52 + {
  53 + writeGetCapabilities(context,params, project);
  54 + }
  55 + else if(boost::iequals(request, "getmap"))
  56 + {
  57 + writeGetFeature(context,params, project);
  58 + }
72 } 59 }
73 } 60 }
74 -BOOST_DLL_ALIAS(DmpWfs::Create, service_module) 61 +
@@ -8,12 +8,12 @@ @@ -8,12 +8,12 @@
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10 #ifndef __dmpwfs_h__ 10 #ifndef __dmpwfs_h__
11 -#define __dmpwm]fs_h__ 11 +#define __dmpwfs_h__
12 #include <string> 12 #include <string>
13 #include "dmpservice.h" 13 #include "dmpservice.h"
14 #include "dmpwfsparameters.h" 14 #include "dmpwfsparameters.h"
15 15
16 -namespace DmpWms 16 +namespace DmpWfs
17 { 17 {
18 class DmpWFSService : public DmpService 18 class DmpWFSService : public DmpService
19 { 19 {
  1 +/**************************************************************************
  2 +* file: dmpwfsfilter.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-28 11:21:25
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpwfsfilter.h"
  10 +namespace DmpWfs
  11 +{
  12 +
  13 + dmpwfsfilter::dmpwfsfilter(/* args */)
  14 + {
  15 + }
  16 +
  17 + dmpwfsfilter::~dmpwfsfilter()
  18 + {
  19 + }
  20 +}
  1 +/**************************************************************************
  2 +* file: dmpwfsfilter.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2021-12-28 11:21:20
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpwfsfilter_h__
  11 +#define __dmpwfsfilter_h__
  12 +
  13 +namespace DmpWfs
  14 +{
  15 + class dmpwfsfilter
  16 + {
  17 + public:
  18 + dmpwfsfilter(/* args */);
  19 + ~dmpwfsfilter();
  20 + private:
  21 + /* data */
  22 + };
  23 +
  24 +
  25 +}
  26 +
  27 +#endif // __dmpwfsfilter_h__
@@ -11,21 +11,21 @@ @@ -11,21 +11,21 @@
11 #include "dmpserverrequest.h" 11 #include "dmpserverrequest.h"
12 #include "dmpserverproject.h" 12 #include "dmpserverproject.h"
13 #include "dmpvectorlayer.h" 13 #include "dmpvectorlayer.h"
14 - 14 +#include "dmpserverproject.h"
15 15
16 namespace DmpWfs 16 namespace DmpWfs
17 { 17 {
18 void writeGetCapabilities( const DmpServerContext &context, const DmpWfsParameters& params, 18 void writeGetCapabilities( const DmpServerContext &context, const DmpWfsParameters& params,
19 const DmpProject* project, bool projectSettings) 19 const DmpProject* project, bool projectSettings)
20 { 20 {
21 - std::string serviceName = context.serverProject()->name();  
22 - std::string serviceTitle = context.serverProject()->title();  
23 - if(serviceTitle.empty()) serviceTitle = serviceName; 21 + std::string name = context.serverProject()->name();
  22 + std::string title = context.serverProject()->title();
  23 + if(title.empty()) title = name;
24 24
25 std::string version = params.Version(); 25 std::string version = params.Version();
26 std::string hrefUrl; 26 std::string hrefUrl;
27 char char_hrefUrl[1024] = {0}; 27 char char_hrefUrl[1024] = {0};
28 - std::string domain = context.request()->domain(); 28 + std::string domain = context.request()->domain();
29 std::string port = context.request()->port(); 29 std::string port = context.request()->port();
30 if(port == "80" || port =="") 30 if(port == "80" || port =="")
31 { 31 {
@@ -37,7 +37,7 @@ namespace DmpWfs @@ -37,7 +37,7 @@ namespace DmpWfs
37 } 37 }
38 hrefUrl = char_hrefUrl; 38 hrefUrl = char_hrefUrl;
39 // hrefUrl = "http://172.26.40.51:8821/?mapService=test"; 39 // hrefUrl = "http://172.26.40.51:8821/?mapService=test";
40 - std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, version,hrefUrl,serviceName,serviceTitle,projectSettings); 40 + std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, name,title, version,hrefUrl, projectSettings);
41 41
42 std::stringstream stream; 42 std::stringstream stream;
43 write_xml(stream, *doc.get()); 43 write_xml(stream, *doc.get());
@@ -52,7 +52,7 @@ namespace DmpWfs @@ -52,7 +52,7 @@ namespace DmpWfs
52 52
53 53
54 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, 54 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
55 - const std::string &serviceName, const std::string &serviceTitle, 55 + const std::string &name, const std::string &title,
56 const std::string &version, const std::string &hrefUrl, 56 const std::string &version, const std::string &hrefUrl,
57 bool projectSettings ) 57 bool projectSettings )
58 { 58 {
@@ -69,10 +69,10 @@ namespace DmpWfs @@ -69,10 +69,10 @@ namespace DmpWfs
69 xmlRoot.add("<xmlattr>.updateSequence", "0"); 69 xmlRoot.add("<xmlattr>.updateSequence", "0");
70 70
71 boost::property_tree::ptree ptService; 71 boost::property_tree::ptree ptService;
72 - ptService.add("Name", serviceName);  
73 - ptService.add("Title", serviceTitle); 72 + ptService.add("Name", name);
  73 + ptService.add("Title", title);
74 ptService.add("Abstract", "dmap wfs service"); 74 ptService.add("Abstract", "dmap wfs service");
75 - ptService.add("Keywords", "WFS,DMAP,"+ serviceName ); 75 + ptService.add("Keywords", "WFS,DMAP,"+ name );
76 ptService.add("OnlineResource", hrefUrl); 76 ptService.add("OnlineResource", hrefUrl);
77 ptService.add("Fees","none"); 77 ptService.add("Fees","none");
78 ptService.add("AccessConstraints","none"); 78 ptService.add("AccessConstraints","none");
1 -/**************************************************************************  
2 -* file: dmpwfsgetcapabilities.cpp  
3 -  
4 -* Author: qingxiongf  
5 -* Date: 2021-12-22 14:04:56  
6 -* Email: qingxiongf@chinadci.com  
7 -* copyright: 广州城市信息研究所有限公司  
8 -***************************************************************************/  
9 -#include "dmpwfsgetcapabilities.h"  
10 -#include "dmpserverresponse.h"  
11 -#include "dmpserverrequest.h"  
12 -#include "dmpserverproject.h"  
13 -#include "dmpvectorlayer.h"  
14 -  
15 -  
16 -namespace DmpWfs  
17 -{  
18 - void writeGetCapabilities( const DmpServerContext &context, const DmpWfsParameters& params,  
19 - const DmpProject* project, bool projectSettings)  
20 - {  
21 - std::string serviceName = context.serverProject()->name();  
22 - std::string serviceTitle = context.serverProject()->title();  
23 - if(serviceTitle.empty()) serviceTitle = serviceName;  
24 -  
25 - std::string version = params.Version();  
26 - std::string hrefUrl;  
27 - char char_hrefUrl[1024] = {0};  
28 - std::string domain = context.request()->domain();  
29 - std::string port = context.request()->port();  
30 - if(port == "80" || port =="")  
31 - {  
32 - sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->path().c_str());  
33 - }  
34 - else  
35 - {  
36 - sprintf(char_hrefUrl, "http://%s:%s%s", domain.c_str(),port.c_str(), context.request()->path().c_str());  
37 - }  
38 - hrefUrl = char_hrefUrl;  
39 - // hrefUrl = "http://172.26.40.51:8821/?mapService=test";  
40 - std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, version,hrefUrl,serviceName,serviceTitle,projectSettings);  
41 -  
42 - std::stringstream stream;  
43 - write_xml(stream, *doc.get());  
44 - std::string xml;  
45 - xml = stream.str();  
46 -  
47 - // DmpServerResponse* response = context.response();  
48 - context.response()->removeHeader("Content-Type");  
49 - context.response()->setHeader("Content-Type", "text/xml;charset=utf-8");  
50 - context.response()->write(xml);  
51 - }  
52 -  
53 -  
54 - std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,  
55 - const std::string &serviceName, const std::string &serviceTitle,  
56 - const std::string &version, const std::string &hrefUrl,  
57 - bool projectSettings )  
58 - {  
59 - std::shared_ptr<boost::property_tree::ptree> xmlRootDoc(new boost::property_tree::ptree());  
60 - boost::property_tree::ptree xmlRoot;  
61 - std::string rootname;  
62 -  
63 - rootname = "WFS_Capabilities";  
64 - xmlRoot.add("<xmlattr>.xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");  
65 - xmlRoot.add("<xmlattr>.xmlns","http://www.opengis.net/wfs");  
66 - xmlRoot.add("<xmlattr>.xmlns:sld","http://www.opengis.net/sld");  
67 - xmlRoot.add("<xmlattr>.xsi:schemaLocation","http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd");  
68 - xmlRoot.add("<xmlattr>.version", version);  
69 - xmlRoot.add("<xmlattr>.updateSequence", "0");  
70 -  
71 - boost::property_tree::ptree ptService;  
72 - ptService.add("Name", serviceName);  
73 - ptService.add("Title", serviceTitle);  
74 - ptService.add("Abstract", "dmap wfs service");  
75 - ptService.add("Keywords", "WFS,DMAP,"+ serviceName );  
76 - ptService.add("OnlineResource", hrefUrl);  
77 - ptService.add("Fees","none");  
78 - ptService.add("AccessConstraints","none");  
79 - xmlRoot.add_child("Service",ptService);  
80 -  
81 - boost::property_tree::ptree ptCapability;  
82 - addCapabilitiesRequest(ptCapability,hrefUrl);  
83 - xmlRoot.add_child("Capability",ptCapability);  
84 -  
85 - boost::property_tree::ptree ptFeatureTypeList;  
86 - addFeatureTypeList(ptFeatureTypeList,project);  
87 - xmlRoot.add_child("FeatureTypeList",ptFeatureTypeList);  
88 -  
89 - boost::property_tree::ptree ptFilter;  
90 - addFilterCapabilities(ptFilter,hrefUrl);  
91 - xmlRoot.add_child("ogc:Filter_Capabilities",ptFilter);  
92 -  
93 - xmlRootDoc->add_child(rootname,xmlRoot);  
94 - return xmlRootDoc;  
95 -  
96 - }  
97 -  
98 - void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl)  
99 - {  
100 - boost::property_tree::ptree ptRequest;  
101 -  
102 - boost::property_tree::ptree ptGetCapabilities;  
103 - addCapabilitiesRequest_DCPType(ptGetCapabilities, hrefUrl, "Get");  
104 - addCapabilitiesRequest_DCPType(ptGetCapabilities, hrefUrl, "Post");  
105 - ptRequest.add_child("GetCapabilities", ptGetCapabilities);  
106 -  
107 - boost::property_tree::ptree ptDescribeFeatureType;  
108 - boost::property_tree::ptree ptSchemaDescriptionLanguage;  
109 - ptSchemaDescriptionLanguage.add("XMLSCHEMA","");  
110 - ptDescribeFeatureType.add_child("SchemaDescriptionLanguage",ptSchemaDescriptionLanguage);  
111 - addCapabilitiesRequest_DCPType(ptDescribeFeatureType, hrefUrl, "Get");  
112 - addCapabilitiesRequest_DCPType(ptDescribeFeatureType, hrefUrl, "Post");  
113 - ptRequest.add_child("DescribeFeatureType", ptDescribeFeatureType);  
114 -  
115 - boost::property_tree::ptree ptGetFeature;  
116 - boost::property_tree::ptree ptResultFormat;  
117 - ptResultFormat.add("GML2","");  
118 - ptResultFormat.add("GML3","");  
119 - ptResultFormat.add("GeoJSON","");  
120 - ptGetFeature.add_child("ResultFormat",ptResultFormat);  
121 - addCapabilitiesRequest_DCPType(ptGetFeature, hrefUrl, "Get");  
122 - addCapabilitiesRequest_DCPType(ptGetFeature, hrefUrl, "Post");  
123 - ptRequest.add_child("GetFeature", ptGetFeature);  
124 -  
125 - boost::property_tree::ptree ptTransaction;  
126 - addCapabilitiesRequest_DCPType(ptTransaction, hrefUrl, "Post");  
127 - ptRequest.add_child("Transaction", ptTransaction);  
128 -  
129 - pt.add_child("Request", ptRequest);  
130 - return;  
131 - }  
132 -  
133 - void addCapabilitiesRequest_DCPType(boost::property_tree::ptree &pt, const std::string &hrefUrl, std::string method)  
134 - {  
135 - boost::property_tree::ptree pt_dcpType;  
136 - boost::property_tree::ptree pt_http;  
137 - boost::property_tree::ptree pt_method;  
138 -  
139 - pt_method.add("<xmlattr>.onlineResource", hrefUrl);  
140 -  
141 - pt_http.add_child(method, pt_method);  
142 - pt_dcpType.add_child("HTTP", pt_http);  
143 - pt.add_child("DCPType", pt_dcpType);  
144 - }  
145 -  
146 - void addFeatureTypeList(boost::property_tree::ptree &pt,const DmpProject *project)  
147 - {  
148 - boost::property_tree::ptree ptOperations;  
149 - ptOperations.add("Query","");  
150 - pt.add_child("Operations", ptOperations);  
151 -  
152 - int i = 0;  
153 - std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers();  
154 - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++, i++)  
155 - {  
156 - DmpVectorLayer *layer = (DmpVectorLayer *)iter->second;  
157 - std::string source = layer->source();  
158 - shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source());  
159 - if (pPgsqlConn != nullptr)  
160 - {  
161 - boost::property_tree::ptree ptFeatureType;  
162 - std::string srs = "EPSG:" + std::__cxx11::to_string(project->crs().srid());  
163 - ptFeatureType.add("<xmlattr>.id", i);  
164 - ptFeatureType.add("Name", layer->name());  
165 - ptFeatureType.add("Title", layer->title());  
166 - ptFeatureType.add("DisplayColumn", "");  
167 - ptFeatureType.add("Geometry", "点");  
168 - ptFeatureType.add("GeometryColumn", layer->geom());  
169 - ptFeatureType.add("SRS", srs);  
170 -  
171 - boost::property_tree::ptree ptBoundingbox;  
172 - ptBoundingbox.add("<xmlattr>.CRS", srs);  
173 - if (boost::iequals(srs, "CRS:84") || boost::iequals(srs, "EPSG:4326"))  
174 - {  
175 - ptBoundingbox.add("<xmlattr>.miny", layer->extent().xmin());  
176 - ptBoundingbox.add("<xmlattr>.maxy", layer->extent().xmax());  
177 - ptBoundingbox.add("<xmlattr>.minx", layer->extent().ymin());  
178 - ptBoundingbox.add("<xmlattr>.maxx", layer->extent().ymax());  
179 - }  
180 - else  
181 - {  
182 - ptBoundingbox.add("<xmlattr>.minx", layer->extent().xmin());  
183 - ptBoundingbox.add("<xmlattr>.maxx", layer->extent().xmax());  
184 - ptBoundingbox.add("<xmlattr>.miny", layer->extent().ymin());  
185 - ptBoundingbox.add("<xmlattr>.maxy", layer->extent().ymax());  
186 - }  
187 - ptFeatureType.add_child("LatLongBoundingBox", ptBoundingbox);  
188 -  
189 - boost::property_tree::ptree ptFields;  
190 - for (; pPgsqlConn->next();)  
191 - {  
192 - std::string fieldname = pPgsqlConn->getString(0);  
193 - std::string typeString = pPgsqlConn->getString(1);  
194 - std::string aliasName = "";  
195 - std::string type = "";  
196 - int typeInt = PGFieldType::VarCharFieldType;  
197 - if (layer->geom() == fieldname)  
198 - {  
199 - typeString = "geometry";  
200 - typeInt = PGFieldType::ShapeFieldType;  
201 - }  
202 - else if (typeString == "integer")  
203 - {  
204 - typeInt = PGFieldType::IntFieldType;  
205 - }  
206 - else if (typeString == "bigint")  
207 - {  
208 - typeInt = PGFieldType::BigIntFieldType;  
209 - }  
210 - else if (typeString == "double precision" || typeString == "real" || typeString == "numeric")  
211 - {  
212 - typeInt = PGFieldType::DoubleFieldType;  
213 - }  
214 - else if (typeString == "character varying" || typeString == "text")  
215 - {  
216 - typeInt = PGFieldType::VarCharFieldType;  
217 - }  
218 - else if (typeString == "geometry")  
219 - {  
220 - typeInt = PGFieldType::ShapeFieldType;  
221 - }  
222 - else if (typeString == "bytea")  
223 - {  
224 - typeInt = PGFieldType::ByteaFieldType;  
225 - }  
226 - else if (typeString == "timestamp without time zone")  
227 - {  
228 - typeInt = PGFieldType::TimestampWithoutTimeZone;  
229 - }  
230 -  
231 - switch (typeInt)  
232 - {  
233 - case PGFieldType::IntFieldType:  
234 - typeString = "integer";  
235 - break;  
236 - case PGFieldType::BigIntFieldType:  
237 - case PGFieldType::DoubleFieldType:  
238 - typeString = "double";  
239 - break;  
240 - case PGFieldType::VarCharFieldType:  
241 - typeString = "string";  
242 - break;  
243 - default:  
244 - break;  
245 - }  
246 - boost::property_tree::ptree ptField;  
247 - ptField.add("<xmlattr>.name", fieldname);  
248 - ptField.add("<xmlattr>.aliasName", aliasName);  
249 - ptField.add("<xmlattr>.type", "xsd:" + typeString);  
250 - ptField.add("<xmlattr>.minOccurs", "0");  
251 - ptField.add("<xmlattr>.maxOccurs", "1");  
252 - ptFields.add_child("Field", ptField);  
253 - }  
254 - ptFeatureType.add_child("Fields", ptFields);  
255 - pt.add_child("FeatureType", ptFeatureType);  
256 - }  
257 -  
258 - }  
259 - }  
260 -  
261 -  
262 - void addFilterCapabilities(boost::property_tree::ptree &pt,const std::string &hrefUrl)  
263 - {  
264 - boost::property_tree::ptree ptFilterCapabilities;  
265 -  
266 - boost::property_tree::ptree ptSpatialCapabilities;  
267 - boost::property_tree::ptree ptSpatialOperators;  
268 - ptSpatialOperators.add("ogc:BBOX","");  
269 - ptSpatialCapabilities.add_child("ogc:Spatial_Operators",ptSpatialOperators);  
270 - ptFilterCapabilities.add_child("ogc:Spatial_Capabilities", ptSpatialCapabilities);  
271 -  
272 -  
273 - boost::property_tree::ptree ptScalarCapabilities;  
274 - boost::property_tree::ptree ptComparisonOperators;  
275 - ptComparisonOperators.add("ogc:Simple_Comparisons","");  
276 - ptScalarCapabilities.add_child("ogc:Comparison_Operators",ptComparisonOperators);  
277 - ptFilterCapabilities.add_child("ogc:Filter_Capabilities", ptScalarCapabilities);  
278 -  
279 - pt.add_child("ogc:Filter_Capabilities", ptFilterCapabilities);  
280 - }  
281 -  
282 -  
283 -}  
@@ -41,7 +41,7 @@ namespace DmpWfs @@ -41,7 +41,7 @@ namespace DmpWfs
41 * \returns GetCapabilities XML document 41 * \returns GetCapabilities XML document
42 */ 42 */
43 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, 43 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
44 - const std::string &serviceName, const std::string &serviceTitle, 44 + const std::string &name, const std::string &title,
45 const std::string &version, const std::string &hrefUrl, 45 const std::string &version, const std::string &hrefUrl,
46 bool projectSettings ); 46 bool projectSettings );
47 47
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 * copyright: 广州城市信息研究所有限公司 7 * copyright: 广州城市信息研究所有限公司
8 ***************************************************************************/ 8 ***************************************************************************/
9 #include "dmpwfsgetfeature.h" 9 #include "dmpwfsgetfeature.h"
  10 +#include "dmpsqlfactory.h"
10 namespace DmpWfs 11 namespace DmpWfs
11 { 12 {
12 void writeGetFeature(const DmpServerContext &context,const DmpWfsParameters& params, 13 void writeGetFeature(const DmpServerContext &context,const DmpWfsParameters& params,
@@ -21,21 +22,23 @@ namespace DmpWfs @@ -21,21 +22,23 @@ namespace DmpWfs
21 bool projectSettings) 22 bool projectSettings)
22 { 23 {
23 char buff[5000]; 24 char buff[5000];
24 - return "";  
25 - // SqlFactory sqlF; 25 + DmpSqlFactory sqlFactory;
26 26
27 - /*shared_ptr<WMSServer> service = _dmapWms.GetWmsService(parseString.mapService);  
28 - if(service == nullptr)  
29 - {  
30 - return false;  
31 - } 27 + int maxFeatures = params.MaxFeatures();
  28 + int startIndex = params.StartIndex();
  29 + std::string typeName = params.TypeName();
  30 + std::string featureID = params.FeatureID();
  31 + std::string propertyName = params.PropertyName();
  32 + std::string resultType = params.ResultType();
  33 +
  34 + sqlFactory.setStartIndexCount(startIndex, maxFeatures, resultType);
32 35
33 - sqlF.SetStartIndexCount(parseString.startIndex, parseString.maxFeatures, parseString.resulttype);  
34 std::vector<std::string> ids; 36 std::vector<std::string> ids;
35 - if (parseString.featureid) 37 + if (!featureID.empty())
36 { 38 {
37 char *idstring[1000]; 39 char *idstring[1000];
38 //将ID值以逗号分开,并返回个数 40 //将ID值以逗号分开,并返回个数
  41 + /*
39 int idn = StringHelp::ParseStringTok(parseString.featureid, ',', idstring, 1000); 42 int idn = StringHelp::ParseStringTok(parseString.featureid, ',', idstring, 1000);
40 for (int i = 0; i < idn; i++) 43 for (int i = 0; i < idn; i++)
41 { 44 {
@@ -55,11 +58,12 @@ namespace DmpWfs @@ -55,11 +58,12 @@ namespace DmpWfs
55 ids.push_back(ss[0]); 58 ids.push_back(ss[0]);
56 } 59 }
57 } 60 }
  61 + */
58 } 62 }
59 63
60 - std::vector<std::string> props; 64 + /* std::vector<std::string> props;
61 std::vector<std::string> propsAs; 65 std::vector<std::string> propsAs;
62 - if (parseString.propertyname) 66 + if (propertyName.empty())
63 { 67 {
64 char *idstring[1000]; 68 char *idstring[1000];
65 int idn = StringHelp::ParseStringTok(parseString.propertyname, ',', idstring, 1000); 69 int idn = StringHelp::ParseStringTok(parseString.propertyname, ',', idstring, 1000);
@@ -88,9 +92,10 @@ namespace DmpWfs @@ -88,9 +92,10 @@ namespace DmpWfs
88 } 92 }
89 } 93 }
90 } 94 }
  95 + */
91 96
92 - if (parseString.layerName == 0)  
93 - return Error(buff, ErrorClass::ParaError, "layername not exist", ab); 97 + // if (parseString.layerName == 0)
  98 + // return Error(buff, ErrorClass::ParaError, "layername not exist", ab);
94 99
95 //const char *realLayer=0; 100 //const char *realLayer=0;
96 //GetUpLayerID是干什么的? 101 //GetUpLayerID是干什么的?
@@ -98,7 +103,7 @@ namespace DmpWfs @@ -98,7 +103,7 @@ namespace DmpWfs
98 // if (_GetUperLayerId(parseString.layerName, sLayer) == false) 103 // if (_GetUperLayerId(parseString.layerName, sLayer) == false)
99 // return Error(buff, ErrorClass::ParaError, "layer not exist", ab); 104 // return Error(buff, ErrorClass::ParaError, "layer not exist", ab);
100 105
101 - shared_ptr<MapLayer> mapLayer = service->GetLayer(parseString.layerName); 106 + /* shared_ptr<MapLayer> mapLayer = service->GetLayer(parseString.layerName);
102 107
103 108
104 if(mapLayer == nullptr) 109 if(mapLayer == nullptr)
@@ -118,9 +123,11 @@ namespace DmpWfs @@ -118,9 +123,11 @@ namespace DmpWfs
118 return Error(buff, ErrorClass::ParaError, "layername not exist", ab); 123 return Error(buff, ErrorClass::ParaError, "layername not exist", ab);
119 } 124 }
120 125
  126 +
  127 +
121 128
122 shared_ptr<TableDesc> pTabledesc = this->ToTableDesc(fields,mapLayer->m_layerName); 129 shared_ptr<TableDesc> pTabledesc = this->ToTableDesc(fields,mapLayer->m_layerName);
123 - 130 +
124 131
125 size_t propCount = props.size(); 132 size_t propCount = props.size();
126 if (propCount) 133 if (propCount)
@@ -204,6 +211,7 @@ namespace DmpWfs @@ -204,6 +211,7 @@ namespace DmpWfs
204 isPicture = 0; 211 isPicture = 0;
205 return this->FormatWFSXMLCAll(pWorkspace, ab, parseString.layerName, buff, ver); 212 return this->FormatWFSXMLCAll(pWorkspace, ab, parseString.layerName, buff, ver);
206 }*/ 213 }*/
  214 + return "";
207 } 215 }
208 216
209 217
@@ -6,9 +6,175 @@ @@ -6,9 +6,175 @@
6 * Email: qingxiongf@chinadci.com 6 * Email: qingxiongf@chinadci.com
7 * copyright: 广州城市信息研究所有限公司 7 * copyright: 广州城市信息研究所有限公司
8 ***************************************************************************/ 8 ***************************************************************************/
  9 +#include <iostream>
  10 +#include <boost/lexical_cast.hpp>
  11 +#include <boost/algorithm/string.hpp>
  12 +#include "dmplogger.h"
  13 +#include "dmpserverutils.h"
9 #include "dmpwfsparameters.h" 14 #include "dmpwfsparameters.h"
10 15
11 namespace DmpWfs 16 namespace DmpWfs
12 { 17 {
  18 + DmpWfsParameters::DmpWfsParameters()
  19 + : DmpServerParameters()
  20 + {
  21 + }
  22 +
  23 + DmpWfsParameters::DmpWfsParameters(const DmpServerParameters &params)
  24 + {
  25 + params_ = params.parameters();
  26 + }
  27 +
  28 + bool DmpWfsParameters::GetStringParameter(const char* key, std::string &value) const
  29 + {
  30 + std::map<std::string, std::string>::const_iterator iter;
  31 + iter = params_.find(key);
  32 + if (iter != params_.end())
  33 + {
  34 + try
  35 + {
  36 + value = boost::lexical_cast<std::string>(iter->second);
  37 + return true;
  38 + }
  39 + catch (boost::bad_lexical_cast &e)
  40 + {
  41 + LOGGER_ERROR(e.what());
  42 + }
  43 + }
  44 + return false;
  45 + }
  46 +
  47 + bool DmpWfsParameters::GetIntParameter(const char* key, int& value) const
  48 + {
  49 + std::map<std::string, std::string>::const_iterator iter;
  50 + iter = params_.find(key);
  51 + if (iter != params_.end())
  52 + {
  53 + try
  54 + {
  55 + value= boost::lexical_cast<int>(iter->second);
  56 + return true;
  57 + }
  58 + catch (boost::bad_lexical_cast &e)
  59 + {
  60 + LOGGER_ERROR(e.what());
  61 + }
  62 + }
  63 + return false;
  64 + }
  65 +
  66 +
  67 + std::string DmpWfsParameters::Service() const
  68 + {
  69 + std::string value = "WMS";
  70 + this->GetStringParameter("SERVICE", value);
  71 + return value;
  72 + }
  73 +
  74 + //必须 值为GetCapabilities GetFeature DescribeFeatureType GetGmlObject Transaction LockFeature
  75 + std::string DmpWfsParameters::Request() const
  76 + {
  77 + std::string value = "";
  78 + GetStringParameter("REQUEST",value);
  79 + return value;
  80 + }
  81 +
  82 +
  83 + //必须 服务版本, 值为 1.0.0, 1.1.0, 1.1.1, 1.3
  84 + std::string DmpWfsParameters::Version() const
  85 + {
  86 + std::string value = "";
  87 + GetStringParameter("VERSION",value);
  88 + return value;
  89 + }
  90 +
  91 + std::string DmpWfsParameters::TypeName() const
  92 + {
  93 + std::string value = "";
  94 + if(!GetStringParameter("TYPENAME",value))
  95 + {
  96 + GetStringParameter("LAYER",value);
  97 + }
  98 + return value;
  99 + }
  100 +
  101 + std::string DmpWfsParameters::OutputFormat() const
  102 + {
  103 + std::string value = "";
  104 + if(!GetStringParameter("OUTPUTFORMAT",value))
  105 + {
  106 + GetStringParameter("FORMAT",value);
  107 + }
  108 + return value;
  109 + }
  110 +
  111 +
  112 +
  113 + std::string DmpWfsParameters::BBox() const
  114 + {
  115 + std::string value = "";
  116 + GetStringParameter("BBOX",value);
  117 + return value;
  118 + }
  119 +
  120 + std::string DmpWfsParameters::Filter() const
  121 + {
  122 + std::string value = "";
  123 + GetStringParameter("FILTER",value);
  124 + return value;
  125 + }
  126 +
  127 + std::string DmpWfsParameters::Sortby() const
  128 + {
  129 + std::string value = "";
  130 + GetStringParameter("SORTBY",value);
  131 + return value;
  132 + }
  133 +
  134 + int DmpWfsParameters::MaxFeatures() const //指定返回最多要素
  135 + {
  136 + int value = 0;
  137 + if(!GetIntParameter("MAXFEATRUES",value))
  138 + {
  139 + GetIntParameter("COUNT",value);
  140 + }
  141 + return value;
  142 + }
  143 +
  144 + int DmpWfsParameters::StartIndex() const
  145 + {
  146 + int value = 0;
  147 + GetIntParameter("STARTINDEX",value);
  148 + return value;
  149 + }
  150 +
  151 + std::string DmpWfsParameters::PropertyName() const
  152 + {
  153 + std::string value = "";
  154 + GetStringParameter("PROPERTYNAME",value);
  155 + return value;
  156 + }
  157 +
  158 +
  159 + std::string DmpWfsParameters::SrsName() const //空间参考坐标
  160 + {
  161 + std::string value = "";
  162 + GetStringParameter("SYSNAME",value);
  163 + return value;
  164 + }
  165 +
  166 + std::string DmpWfsParameters::FeatureID() const //要素ID
  167 + {
  168 + std::string value = "";
  169 + GetStringParameter("FEATUREID",value);
  170 + return value;
  171 + }
  172 +
  173 + std::string DmpWfsParameters::ResultType() const //要素ID
  174 + {
  175 + std::string value = "";
  176 + GetStringParameter("RESULTTYPE",value);
  177 + return value;
  178 + }
13 179
14 } 180 }
@@ -41,17 +41,20 @@ namespace DmpWfs @@ -41,17 +41,20 @@ namespace DmpWfs
41 41
42 //DescribeFeatureType 42 //DescribeFeatureType
43 //GetFeature 43 //GetFeature
44 - std::string TypeName() const; //必须 坐标系 44 + std::string TypeName() const; //必须
45 std::string OutputFormat() const; //必须 45 std::string OutputFormat() const; //必须
46 - std::string BBox() const; //必须 46 + std::string BBox() const;
47 std::string Filter() const; 47 std::string Filter() const;
48 std::string Sortby() const; 48 std::string Sortby() const;
49 int MaxFeatures() const; //指定返回最多要素 49 int MaxFeatures() const; //指定返回最多要素
  50 + int StartIndex() const;
50 std::string PropertyName() const; //指定返回的要素属性,没有指定不返回 51 std::string PropertyName() const; //指定返回的要素属性,没有指定不返回
51 std::string SrsName() const; //空间参考坐标 52 std::string SrsName() const; //空间参考坐标
52 std::string FeatureID() const; //要素ID 53 std::string FeatureID() const; //要素ID
  54 + std::string ResultType() const;
  55 +
53 //std::string Expiry(); 56 //std::string Expiry();
54 - //std::string ResultType(); 57 +
55 //std::string FeatureVsrsion(); 58 //std::string FeatureVsrsion();
56 59
57 //Transaction(对要素数据增、删、改) 60 //Transaction(对要素数据增、删、改)
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 #include "dmpwmsgetcapabilities.h" 9 #include "dmpwmsgetcapabilities.h"
10 #include "dmpserverresponse.h" 10 #include "dmpserverresponse.h"
11 #include "dmpserverrequest.h" 11 #include "dmpserverrequest.h"
12 - 12 +#include "dmpserverproject.h"
13 namespace DmpWms 13 namespace DmpWms
14 { 14 {
15 void writeGetCapabilities( const DmpServerContext &context, const DmpWmsParameters& params, 15 void writeGetCapabilities( const DmpServerContext &context, const DmpWmsParameters& params,
@@ -20,6 +20,8 @@ namespace DmpWms @@ -20,6 +20,8 @@ namespace DmpWms
20 char char_hrefUrl[1024] = {0}; 20 char char_hrefUrl[1024] = {0};
21 std::string domain = context.request()->domain(); 21 std::string domain = context.request()->domain();
22 std::string port = context.request()->port(); 22 std::string port = context.request()->port();
  23 + std::string name = context.serverProject()->name();
  24 + std::string title = context.serverProject()->title();
23 if(port == "80" || port =="") 25 if(port == "80" || port =="")
24 { 26 {
25 sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->path().c_str()); 27 sprintf(char_hrefUrl, "http://%s%s", domain.c_str(), context.request()->path().c_str());
@@ -30,7 +32,7 @@ namespace DmpWms @@ -30,7 +32,7 @@ namespace DmpWms
30 } 32 }
31 hrefUrl = char_hrefUrl; 33 hrefUrl = char_hrefUrl;
32 // hrefUrl = "http://172.26.40.51:8821/?mapService=test"; 34 // hrefUrl = "http://172.26.40.51:8821/?mapService=test";
33 - std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, version,hrefUrl, projectSettings); 35 + std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, version,hrefUrl,name,title, projectSettings);
34 36
35 std::stringstream stream; 37 std::stringstream stream;
36 write_xml(stream, *doc.get()); 38 write_xml(stream, *doc.get());
@@ -44,7 +46,7 @@ namespace DmpWms @@ -44,7 +46,7 @@ namespace DmpWms
44 } 46 }
45 47
46 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, 48 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
47 - const std::string &version, const std::string &hrefUrl, 49 + const std::string &version, const std::string &hrefUrl, std::string& name, std::string& title,
48 bool projectSettings ) 50 bool projectSettings )
49 { 51 {
50 std::shared_ptr<boost::property_tree::ptree> xmlRootDoc(new boost::property_tree::ptree()); 52 std::shared_ptr<boost::property_tree::ptree> xmlRootDoc(new boost::property_tree::ptree());
@@ -67,8 +69,8 @@ namespace DmpWms @@ -67,8 +69,8 @@ namespace DmpWms
67 } 69 }
68 70
69 boost::property_tree::ptree ptService; 71 boost::property_tree::ptree ptService;
70 - ptService.add("Name", "project_name");  
71 - ptService.add("Title", "project_title"==""? "project_name": "project_title"); 72 + ptService.add("Name", name);
  73 + ptService.add("Title", title);
72 ptService.add("Abstract", "dmap wms service"); 74 ptService.add("Abstract", "dmap wms service");
73 ptService.add("Keywords", "WMS,DMAP"); 75 ptService.add("Keywords", "WMS,DMAP");
74 ptService.add("OnlineResource", hrefUrl); 76 ptService.add("OnlineResource", hrefUrl);
@@ -82,7 +84,7 @@ namespace DmpWms @@ -82,7 +84,7 @@ namespace DmpWms
82 boost::property_tree::ptree format; 84 boost::property_tree::ptree format;
83 format.add("Format", "XML"); 85 format.add("Format", "XML");
84 ptCapability.add_child("Exception",format); 86 ptCapability.add_child("Exception",format);
85 - addCapabilitiesLayers(ptCapability,project); 87 + addCapabilitiesLayers(ptCapability,project,name,title);
86 88
87 xmlRoot.add_child("Capability",ptCapability); 89 xmlRoot.add_child("Capability",ptCapability);
88 xmlRootDoc->add_child(rootname,xmlRoot); 90 xmlRootDoc->add_child(rootname,xmlRoot);
@@ -142,14 +144,14 @@ namespace DmpWms @@ -142,14 +144,14 @@ namespace DmpWms
142 return; 144 return;
143 } 145 }
144 146
145 - void addCapabilitiesLayers(boost::property_tree::ptree &pt,const DmpProject* project) 147 + void addCapabilitiesLayers(boost::property_tree::ptree &pt,const DmpProject* project, std::string& name, std::string& title)
146 { 148 {
147 std::string srs = "EPSG:" + std::__cxx11::to_string(project->crs().srid()); 149 std::string srs = "EPSG:" + std::__cxx11::to_string(project->crs().srid());
148 150
149 boost::property_tree::ptree ptProject; 151 boost::property_tree::ptree ptProject;
150 // ptProject.add("<xmlattr>.queryable","1"); 152 // ptProject.add("<xmlattr>.queryable","1");
151 - ptProject.add("Name", "project_name");  
152 - ptProject.add("Title", "project_title"==""? "project_name": "project_title"); 153 + ptProject.add("Name", name);
  154 + ptProject.add("Title", title);
153 ptProject.add("CRS", srs); 155 ptProject.add("CRS", srs);
154 156
155 157
@@ -16,12 +16,13 @@ @@ -16,12 +16,13 @@
16 #include <memory> 16 #include <memory>
17 #include <vector> 17 #include <vector>
18 #include "dmpproject.h" 18 #include "dmpproject.h"
19 -#include "dmpwmsparameters.h" 19 +#include "dmpwmsgetmap.h"
20 #include "dmpservercontext.h" 20 #include "dmpservercontext.h"
21 21
22 namespace DmpWms 22 namespace DmpWms
23 { 23 {
24 24
  25 +
25 /** 26 /**
26 * Output GetCapabilities response 27 * Output GetCapabilities response
27 */ 28 */
@@ -39,7 +40,7 @@ namespace DmpWms @@ -39,7 +40,7 @@ namespace DmpWms
39 * \returns GetCapabilities XML document 40 * \returns GetCapabilities XML document
40 */ 41 */
41 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project, 42 std::shared_ptr<boost::property_tree::ptree> getCapabilities( const DmpProject* project,
42 - const std::string &version, const std::string &hrefUrl, 43 + const std::string &version, const std::string &hrefUrl,std::string& name, std::string& title,
43 bool projectSettings ); 44 bool projectSettings );
44 45
45 void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl); 46 void addCapabilitiesRequest(boost::property_tree::ptree &pt, const std::string &hrefUrl);
@@ -47,7 +48,7 @@ namespace DmpWms @@ -47,7 +48,7 @@ namespace DmpWms
47 void addCapabilitiesRequestNode(boost::property_tree::ptree &pt, const std::string &hrefUrl, 48 void addCapabilitiesRequestNode(boost::property_tree::ptree &pt, const std::string &hrefUrl,
48 const char* request,const std::vector<const char*>& formatList); 49 const char* request,const std::vector<const char*>& formatList);
49 50
50 - void addCapabilitiesLayers(boost::property_tree::ptree &pt,const DmpProject* project); 51 + void addCapabilitiesLayers(boost::property_tree::ptree &pt,const DmpProject* project,std::string& name, std::string& title);
51 52
52 void addCapabilitiesLayer(boost::property_tree::ptree &pt,DmpMapLayer* layer,const std::string& srs); 53 void addCapabilitiesLayer(boost::property_tree::ptree &pt,DmpMapLayer* layer,const std::string& srs);
53 54
@@ -2,5 +2,11 @@ @@ -2,5 +2,11 @@
2 URL 路径: 2 URL 路径:
3 http://localhost:8088/DMap/Services/广州地址/MapServer/WMSService?Service=WMS 3 http://localhost:8088/DMap/Services/广州地址/MapServer/WMSService?Service=WMS
4 4
  5 +http://localhost:8088/DMap/Services/MapServer/WMSService?Service=WMS
  6 +
  7 +
  8 +
5 /DMap/Services/?([\\w./]*)/MapServer/([\\w]+) 9 /DMap/Services/?([\\w./]*)/MapServer/([\\w]+)
6 10
  11 +http://localhost:8088/dmap/api/vectormapping/gettypefacelist
  12 +
注册登录 后发表评论