提交 7d10fd1ee87cfd6d9c6d7de17525d7c888d7cb1b

作者 qingxiongf
1 个父辈 a952e657

字体

... ... @@ -78,9 +78,11 @@ namespace DmapCore_30
78 78 return false;
79 79 }
80 80 }
81   -
82 81
83   - this->m_simpleRenderer = m_pRen->m_simpleRenderer;
  82 + if (m_pRen != NULL)
  83 + {
  84 + this->m_simpleRenderer = m_pRen->m_simpleRenderer;
  85 + }
84 86 return true;
85 87 }
86 88 //clsXML::XMLParse(NULL, f, &m_pRen);
... ...
... ... @@ -91,14 +91,14 @@ namespace DmapCore_30
91 91 {
92 92 char buff[300] = {0};
93 93 boost::property_tree::ptree ptRenderer;
94   - ptRenderer.add("lookupfield",m_sField);
  94 + ptRenderer.add("<xmlattr>.lookupfield",m_sField);
95 95
96 96 int length = (int)m_vComponents.size();
97 97 for (int i = 0; i < length; i++)
98 98 {
99 99 boost::property_tree::ptree ptNode;
100 100 ValueMapRendererComponent* vmrc = m_vComponents[i];
101   - ptNode.add("value",vmrc->GetValue());
  101 + ptNode.add("<xmlattr>.value",vmrc->GetValue());
102 102 if(vmrc->m_pSymbol)
103 103 {
104 104 vmrc->m_pSymbol->ParsePtree(ptNode);
... ... @@ -112,6 +112,7 @@ namespace DmapCore_30
112 112 this->m_pDefaultSymbol->ParsePtree(ptNode);
113 113 ptRenderer.add_child("OTHER",ptNode);
114 114 }
  115 + pt.add_child("VALUEMAPRENDERER",ptRenderer);
115 116 return true;
116 117 }
117 118
... ...
... ... @@ -455,4 +455,85 @@ namespace mapserver
455 455 }
456 456 return 0;
457 457 }
  458 +
  459 + unsigned char DmpMapServerUtil::char_to_hex(unsigned char x)
  460 + {
  461 + return (unsigned char)(x > 9 ? x + 55 : x + 48);
  462 + }
  463 +
  464 + int DmpMapServerUtil::is_alpha_number_char(unsigned char c)
  465 + {
  466 + if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))
  467 + return 1;
  468 + return 0;
  469 + }
  470 +
  471 + std::string DmpMapServerUtil::urlEncode(char* src, int length)
  472 + {
  473 + char buff[1024];
  474 + urlEncode((unsigned char *)src, length, (unsigned char *)buff, 1000);
  475 + return buff;
  476 + }
  477 +
  478 + // url编码实现
  479 +
  480 + void DmpMapServerUtil::urlEncode(unsigned char *src, int src_len, unsigned char *dest, int dest_len)
  481 + {
  482 + unsigned char ch;
  483 + int len = 0;
  484 +
  485 + while (len < (dest_len - 4) && *src)
  486 + {
  487 + ch = (unsigned char)*src;
  488 + if (*src == ' ')
  489 + {
  490 + *dest++ = '+';
  491 + }
  492 + else if (is_alpha_number_char(ch) || strchr("=!~*'()", ch))
  493 + {
  494 + *dest++ = *src;
  495 + }
  496 + else
  497 + {
  498 + *dest++ = '%';
  499 + *dest++ = char_to_hex((unsigned char)(ch >> 4));
  500 + *dest++ = char_to_hex((unsigned char)(ch % 16));
  501 + }
  502 + ++src;
  503 + ++len;
  504 + }
  505 + *dest = 0;
  506 + return;
  507 + }
  508 +
  509 + //解url编码实现
  510 +
  511 + unsigned char * DmpMapServerUtil::urlDecode(unsigned char *encd, unsigned char *decd)
  512 + {
  513 + int j, i;
  514 + char *cd = (char *)encd;
  515 + char p[2];
  516 + unsigned int num;
  517 + j = 0;
  518 +
  519 + for (i = 0; i < strlen(cd); i++)
  520 + {
  521 + memset(p, '/0', 2);
  522 + if (cd[i] != '%')
  523 + {
  524 + decd[j++] = cd[i];
  525 + continue;
  526 + }
  527 +
  528 + p[0] = cd[++i];
  529 + p[1] = cd[++i];
  530 +
  531 + p[0] = p[0] - 48 - ((p[0] >= 'A') ? 7 : 0) - ((p[0] >= 'a') ? 32 : 0);
  532 + p[1] = p[1] - 48 - ((p[1] >= 'A') ? 7 : 0) - ((p[1] >= 'a') ? 32 : 0);
  533 + decd[j++] = (unsigned char)(p[0] * 16 + p[1]);
  534 + }
  535 + decd[j] = '/0';
  536 +
  537 + return decd;
  538 + }
458 539 }
\ No newline at end of file
... ...
... ... @@ -29,6 +29,13 @@ namespace mapserver
29 29 static std::vector<std::string> stringSplit(const std::string &str, const std::string &pattern);
30 30
31 31 static int HttpPost(const std::string& url, std::string& postData, std::string& responseData );
  32 +
  33 + static unsigned char char_to_hex(unsigned char x);
  34 + static int is_alpha_number_char(unsigned char c);
  35 + static std::string urlEncode(char* src, int length);
  36 + static void urlEncode(unsigned char *src, int src_len, unsigned char *dest, int dest_len);
  37 + static unsigned char *urlDecode(unsigned char *encd, unsigned char *decd);
  38 +
32 39 };
33 40 }
34 41
... ...
... ... @@ -50,6 +50,7 @@ namespace DmpMapping
50 50
51 51 DmpProject* project = (DmpProject*)context.serverProject()->project();
52 52 std::string projectData = project->WriteXml();
  53 + // printf("%s\r\n",projectData.c_str());
53 54 if(!guid.empty() && !projectData.empty())
54 55 {
55 56
... ...
... ... @@ -90,7 +90,7 @@ namespace DmpMapping
90 90 if (mapFont.find(buff) != mapFont.end())
91 91 {
92 92 boost::property_tree::ptree ptNode;
93   - ptNode.put("", buff);
  93 + ptNode.put("", mapFont[buff]);
94 94 ptRoot.push_back(std::make_pair("", ptNode));
95 95 }
96 96 }
... ...
... ... @@ -12,6 +12,7 @@
12 12 #include "dmpserverproject.h"
13 13 #include "dmpvectorlayer.h"
14 14 #include "dmpserverproject.h"
  15 +#include "dmpmapserverutil.h"
15 16
16 17 namespace DmpWfs
17 18 {
... ... @@ -35,7 +36,7 @@ namespace DmpWfs
35 36 {
36 37 sprintf(char_hrefUrl, "http://%s:%s%s", domain.c_str(),port.c_str(), context.request()->path().c_str());
37 38 }
38   - hrefUrl = char_hrefUrl;
  39 + hrefUrl = DmpMapServerUtil::urlEncode(char_hrefUrl,1024);
39 40 // hrefUrl = "http://172.26.40.51:8821/?mapService=test";
40 41 std::shared_ptr<boost::property_tree::ptree> doc = getCapabilities(project, name,title, version,hrefUrl, projectSettings);
41 42
... ... @@ -63,6 +64,7 @@ namespace DmpWfs
63 64 rootname = "WFS_Capabilities";
64 65 xmlRoot.add("<xmlattr>.xmlns:xsi","http://www.w3.org/2001/XMLSchema-instance");
65 66 xmlRoot.add("<xmlattr>.xmlns","http://www.opengis.net/wfs");
  67 + xmlRoot.add("<xmlattr>.ogc","http://www.ogc.net/wfs");
66 68 xmlRoot.add("<xmlattr>.xmlns:sld","http://www.opengis.net/sld");
67 69 xmlRoot.add("<xmlattr>.xsi:schemaLocation","http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-capabilities.xsd");
68 70 xmlRoot.add("<xmlattr>.version", version);
... ...
  1 +/**************************************************************************
  2 +* file: dmpprint.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-01-20 18:50:40
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpprint.h"
... ...
  1 +/**************************************************************************
  2 +* file: dmpprint.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-01-20 18:50:30
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpprint_h__
  11 +#define __dmpprint_h__
  12 +
  13 +
  14 +
  15 +
  16 +#endif // __dmpprint_h__
... ...
... ... @@ -10,6 +10,7 @@
10 10 #include "dmpserverresponse.h"
11 11 #include "dmpserverrequest.h"
12 12 #include "dmpserverproject.h"
  13 +#include "dmpmapserverutil.h"
13 14 namespace DmpWms
14 15 {
15 16 void writeGetCapabilities( const DmpServerContext &context, const DmpWmsParameters& params,
... ...
... ... @@ -593,19 +593,13 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
593 593 {
594 594 DmpVectorLayer *layer = (DmpVectorLayer *)m_vLayers[i];
595 595
596   - //double r1 = layer->m_dUpperScale; // *
597   - //double r2 = layer->m_dLowerScale; // *
598   -
599   - ///if ((this->m_dScaleDenominator > r1 || this->m_dScaleDenominator < r2 || ml->m_pRenderer == 0))
600   - // continue;
601   -
602 596 double start = clock();
603 597 double cost, cost2;
604 598
605 599 string sql = this->GetFeatureInfoSQL(layer, x0, y0, dis, feature_count); //sql语句中使用 ::box
606 600 if (sql == "")
607 601 continue;
608   - printf("%s\r\n",sql.c_str());
  602 + //printf("%s\r\n",sql.c_str());
609 603 string layerName = layer->name();
610 604 try
611 605 {
... ... @@ -614,9 +608,16 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
614 608 break;
615 609 if (pPgsqlConn->ExecWaitBinary(sql))
616 610 {
617   - string srid = std::__cxx11::to_string(layer->crs().srid());
618   - mapserver::DmpMapServerUtil::responseGeojson(pPgsqlConn, responseData, layerName, srid);
619   - return true;
  611 + if(pPgsqlConn->GetRowCount()>0 || i==0)
  612 + {
  613 + string srid = std::__cxx11::to_string(layer->crs().srid());
  614 + mapserver::DmpMapServerUtil::responseGeojson(pPgsqlConn, responseData, layerName, srid);
  615 + return true;
  616 + }
  617 + else
  618 + {
  619 + continue;
  620 + }
620 621 }
621 622 }
622 623 catch (const std::exception &e)
... ...
注册登录 后发表评论