提交 79df1cf330251ea5a562d4921e116820f7404348

作者 qingxiongf
1 个父辈 8121b11d

json

@@ -12,7 +12,7 @@ namespace DmapCore_30 @@ -12,7 +12,7 @@ namespace DmapCore_30
12 { 12 {
13 SimpleMarkerSymbol::SimpleMarkerSymbol() 13 SimpleMarkerSymbol::SimpleMarkerSymbol()
14 { 14 {
15 - m_iAntialiasing = CAIRO_ANTIALIAS_BEST; 15 + m_iAntialiasing = CAIRO_ANTIALIAS_FAST;
16 m_bBoundary = true; 16 m_bBoundary = true;
17 m_iColor = clsUtil::RandomColor(); 17 m_iColor = clsUtil::RandomColor();
18 clsUtil::ToCairoColor(m_iColor, r, g, b, a); 18 clsUtil::ToCairoColor(m_iColor, r, g, b, a);
@@ -12,7 +12,7 @@ namespace DmapCore_30 @@ -12,7 +12,7 @@ namespace DmapCore_30
12 { 12 {
13 SimplePolygonSymbol::SimplePolygonSymbol() 13 SimplePolygonSymbol::SimplePolygonSymbol()
14 { 14 {
15 - m_iAntialiasing = CAIRO_ANTIALIAS_BEST; 15 + m_iAntialiasing = CAIRO_ANTIALIAS_FAST;
16 m_iBackgroundColor = clsUtil::RandomColor(); 16 m_iBackgroundColor = clsUtil::RandomColor();
17 clsUtil::ToCairoColor(m_iBackgroundColor, r, g, b, a); 17 clsUtil::ToCairoColor(m_iBackgroundColor, r, g, b, a);
18 m_iLineType = 0; 18 m_iLineType = 0;
@@ -323,7 +323,7 @@ namespace DmapCore_30 @@ -323,7 +323,7 @@ namespace DmapCore_30
323 //int surf_w = pClsCS->m_iW; int surf_h = pClsCS->m_iH; 323 //int surf_w = pClsCS->m_iW; int surf_h = pClsCS->m_iH;
324 324
325 //文字被截取 325 //文字被截取
326 - if(iX < -30 || (iX + iTextW) > pClsCS->m_iW + 30 || (iY - iTextH ) < -15 || iY > pClsCS->m_iH + 15) 326 + if(iX < 0 || (iX + iTextW) > pClsCS->m_iW || (iY - iTextH ) < 0 || iY > pClsCS->m_iH)
327 { 327 {
328 return false; 328 return false;
329 } 329 }
1 #ifndef _clsMalloc_H_ 1 #ifndef _clsMalloc_H_
2 #define _clsMalloc_H_ 2 #define _clsMalloc_H_
  3 +
  4 +#include "dmap_core.h"
  5 +#include "stdio.h"
  6 +#include <string>
3 namespace DmapCore_30 7 namespace DmapCore_30
4 { 8 {
5 - class clsMalloc 9 + class CORE_EXPORT clsMalloc
6 { 10 {
7 public: 11 public:
8 clsMalloc(); 12 clsMalloc();
@@ -287,7 +287,7 @@ namespace DmapCore_30 @@ -287,7 +287,7 @@ namespace DmapCore_30
287 //CAIRO_ANTIALIAS_FAST, 287 //CAIRO_ANTIALIAS_FAST,
288 // CAIRO_ANTIALIAS_GOOD, 288 // CAIRO_ANTIALIAS_GOOD,
289 // CAIRO_ANTIALIAS_BEST 289 // CAIRO_ANTIALIAS_BEST
290 - // cairo_set_antialias(cr,CAIRO_ANTIALIAS_FAST); 290 + cairo_set_antialias(cr,CAIRO_ANTIALIAS_FAST);
291 return true; 291 return true;
292 switch (iAntialias) 292 switch (iAntialias)
293 { 293 {
@@ -8,6 +8,7 @@ SET (MAPSERVER_SRCS @@ -8,6 +8,7 @@ SET (MAPSERVER_SRCS
8 dmppgsql.cpp 8 dmppgsql.cpp
9 dmppgsqlpool.cpp 9 dmppgsqlpool.cpp
10 dmppgsqlsourcepools.cpp 10 dmppgsqlsourcepools.cpp
  11 + dmpgeometry.cpp
11 wfs/dmpwfs.cpp 12 wfs/dmpwfs.cpp
12 wfs/dmpwfsfilter.cpp 13 wfs/dmpwfsfilter.cpp
13 wfs/dmpgmlfilter.cpp 14 wfs/dmpgmlfilter.cpp
@@ -44,6 +45,7 @@ SET (MAPSERVER_HDRS @@ -44,6 +45,7 @@ SET (MAPSERVER_HDRS
44 dmppgsql.h 45 dmppgsql.h
45 dmppgsqlpool.h 46 dmppgsqlpool.h
46 dmppgsqlsourcepools.h 47 dmppgsqlsourcepools.h
  48 + dmpgeometry.h
47 wfs/dmpwfs.h 49 wfs/dmpwfs.h
48 wfs/dmpwfsfilter.h 50 wfs/dmpwfsfilter.h
49 wfs/dmpgmlfilter.h 51 wfs/dmpgmlfilter.h
  1 +/**************************************************************************
  2 +* file: dmpgeometry.cpp
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-02-22 10:13:27
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +#include "dmpgeometry.h"
  10 +#include <iostream>
  11 +#include <string.h>
  12 +#include <sstream>
  13 +
  14 +namespace mapserver
  15 +{
  16 + std::string Dmpgeometry::geoJsonfromWKB(const char* wkb)
  17 + {
  18 + unsigned char* pwkb = (unsigned char*)wkb;
  19 + unsigned char hasZorSrsid = ((unsigned char *)(pwkb + 4))[0] / 16;
  20 +
  21 + unsigned char type = ((unsigned char *)(pwkb + 1))[0];
  22 + this->hasZ_ = hasZorSrsid / 8;
  23 + this->hasSrid_ = hasZorSrsid % 8;
  24 +
  25 +
  26 + notbig_ = this->ReadByte(pwkb);
  27 + int shape = this->ReadInt(pwkb, notbig_);
  28 + if (hasSrid_)
  29 + {
  30 + srid_ = this->ReadInt(pwkb, notbig_);
  31 + }
  32 +
  33 + std::stringstream sstream;
  34 +
  35 + switch (type)
  36 + {
  37 + case DmpWkbTypes::Type::Point:
  38 + // case DmpWkbTypes::Type::PointZ:
  39 + // case DmpWkbTypes::Type::PointM:
  40 + // case DmpWkbTypes::Type::PointZM:
  41 + {
  42 + sstream << R"({"type":"Point","coordinates": [)";
  43 + readPointfromWKB(pwkb,sstream);
  44 + break;
  45 + }
  46 +
  47 +
  48 + case DmpWkbTypes::Type::MultiPoint:
  49 + // case DmpWkbTypes::Type::MultiPointZ:
  50 + // case DmpWkbTypes::Type::MultiPointM:
  51 + // case DmpWkbTypes::Type::MultiPointZM:
  52 + {
  53 + sstream << R"({"type":"MultiPoint","coordinates": [)";
  54 + int nPoint = this->ReadInt(pwkb, notbig_);
  55 + for (int j = 0; j < nPoint; j++)
  56 + {
  57 + pwkb += 5;
  58 + if(j>0) sstream << ",";
  59 + readPointfromWKB(pwkb,sstream);
  60 + }
  61 + break;
  62 + }
  63 +
  64 + case DmpWkbTypes::Type::LineString:
  65 + // case DmpWkbTypes::Type::LineStringZ:
  66 + // case DmpWkbTypes::Type::LineStringM:
  67 + // case DmpWkbTypes::Type::LineStringZM:
  68 + {
  69 + sstream << R"({"type":"LineString","coordinates": [)";
  70 + readLinefromWKB(pwkb,sstream);
  71 + break;
  72 + }
  73 +
  74 +
  75 + case DmpWkbTypes::Type::MultiLineString:
  76 + // case DmpWkbTypes::Type::MultiLineStringZ:
  77 + // case DmpWkbTypes::Type::MultiLineStringM:
  78 + // case DmpWkbTypes::Type::MultiLineStringZM:
  79 + {
  80 + sstream << R"({"type":"MultiLineString","coordinates": [)";
  81 + int nLine = this->ReadInt(pwkb, notbig_);
  82 + for (int j = 0; j < nLine; j++)
  83 + {
  84 + pwkb += 5;
  85 + if(j>0) sstream << ",";
  86 + readLinefromWKB(pwkb,sstream);
  87 + }
  88 + break;
  89 + }
  90 +
  91 + case DmpWkbTypes::Type::Polygon:
  92 + // case DmpWkbTypes::Type::PolygonZ:
  93 + // case DmpWkbTypes::Type::PolygonM:
  94 + // case DmpWkbTypes::Type::PolygonZM:
  95 + {
  96 + sstream << R"({"type":"Polygon","coordinates": [)";
  97 + readPolygonfromWKB(pwkb,sstream);
  98 + break;
  99 + }
  100 +
  101 + case DmpWkbTypes::Type::MultiPolygon:
  102 + // case DmpWkbTypes::Type::MultiPolygonZ:
  103 + // case DmpWkbTypes::Type::MultiPolygonM:
  104 + // case DmpWkbTypes::Type::MultiPolygonZM:
  105 + {
  106 + sstream << R"({"type":"MultiPolygon","coordinates": [)";
  107 + int nPolygon = this->ReadInt(pwkb, notbig_);
  108 + for (int j = 0; j < nPolygon; j++)
  109 + {
  110 + pwkb += 5;
  111 + if(j>0) sstream << ",";
  112 + readPolygonfromWKB(pwkb,sstream);
  113 + }
  114 + break;
  115 + }
  116 +
  117 + default:
  118 + break;
  119 + }
  120 +
  121 + sstream << "]}";
  122 +
  123 + return sstream.str();;
  124 + }
  125 +
  126 + bool Dmpgeometry::readPointfromWKB(unsigned char*& pwkb, stringstream& sstream )
  127 + {
  128 + double xx = this->ReadDouble(pwkb,notbig_);
  129 + double yy = this->ReadDouble(pwkb,notbig_);
  130 +
  131 + // sprintf(buff, "[%.6f,%.6f]" ,xx,yy);
  132 + sstream << "[" << ToDoubleStr(xx) << "," << ToDoubleStr(yy) << "]";
  133 +
  134 + if(hasZ_)
  135 + {
  136 + pwkb += 8;
  137 + // double zz = this->ReadDouble(pwkb,notbig_);
  138 + }
  139 + return true;
  140 + }
  141 +
  142 + char* Dmpgeometry::ToDoubleStr(double value)
  143 + {
  144 + int len = sprintf(buff, "%.6f" ,value);
  145 + for ( len --; len >0; len--)
  146 + {
  147 + if(buff[len] == '0')
  148 + {
  149 + buff[len] = 0;
  150 + }
  151 + else if(buff[len] == '.')
  152 + {
  153 + buff[len] = 0;
  154 + break;
  155 + }
  156 + else
  157 + {
  158 + break;
  159 + }
  160 + }
  161 +
  162 + return buff;
  163 +
  164 + }
  165 +
  166 + bool Dmpgeometry::readLinefromWKB(unsigned char*& pwkb, stringstream& sstream)
  167 + {
  168 + int nPoint = this->ReadInt(pwkb, notbig_);
  169 + sstream << "[";
  170 + for (size_t i = 0; i < nPoint; i++)
  171 + {
  172 + if(i>0) sstream << ",";
  173 + readPointfromWKB(pwkb, sstream);
  174 + }
  175 + sstream << "]";
  176 +
  177 + return true;
  178 + }
  179 +
  180 + bool Dmpgeometry::readPolygonfromWKB(unsigned char*& pwkb, stringstream& sstream)
  181 + {
  182 + int nline = this->ReadInt(pwkb, notbig_);
  183 + sstream << "[";
  184 + for (size_t i = 0; i < nline; i++)
  185 + {
  186 + if(i>0) sstream << ",";
  187 + readLinefromWKB(pwkb, sstream);
  188 + }
  189 + sstream << "]";
  190 +
  191 + return true;
  192 + }
  193 +
  194 +
  195 +
  196 +int Dmpgeometry::ReadInt(unsigned char*& here, int not_big1)
  197 +{
  198 + unsigned char * mem = (unsigned char *)malloc(4);
  199 + memcpy(mem, here, 4);
  200 + if (!not_big1)
  201 + this->Exchange4(mem);
  202 + int num = ((int*)mem)[0];
  203 + free(mem);
  204 + here += 4;
  205 + return num;
  206 +}
  207 +int Dmpgeometry::ReadByte(unsigned char*& here)
  208 +{
  209 + int num = ((char*)here)[0];
  210 + here++;
  211 + return num;
  212 +}
  213 +
  214 +double Dmpgeometry::ReadDouble(unsigned char*& here, int not_big)
  215 +{
  216 + //DmapCore_30::clsMalloc clsM(8);
  217 + unsigned char * mem = (unsigned char *)malloc(8);
  218 + memcpy(mem, here, 8);
  219 + if (!not_big)
  220 + Exchange8(mem);
  221 + double num = ((double*)mem)[0];
  222 + free(mem);
  223 + here += 8;
  224 + return num;
  225 +}
  226 +
  227 +bool Dmpgeometry::Exchange4(unsigned char * here)
  228 +{
  229 + unsigned char temp;
  230 + for (int i = 0; i < 2; i++)
  231 + {
  232 + temp = here[i];
  233 + here[i] = here[3 - i];
  234 + here[3 - i] = temp;
  235 + }
  236 + return true;
  237 +}
  238 +
  239 +bool Dmpgeometry::Exchange8(unsigned char * here)
  240 +{
  241 + unsigned char temp;
  242 + for (int i = 0; i < 4; i++)
  243 + {
  244 + temp = here[i];
  245 + here[i] = here[7 - i];
  246 + here[7 - i] = temp;
  247 + }
  248 + return true;
  249 +}
  250 +
  251 +
  252 +}
  253 +
  1 +/**************************************************************************
  2 +* file: dmpgeometry.h
  3 +
  4 +* Author: qingxiongf
  5 +* Date: 2022-02-22 10:07:04
  6 +* Email: qingxiongf@chinadci.com
  7 +* copyright: 广州城市信息研究所有限公司
  8 +***************************************************************************/
  9 +
  10 +#ifndef __dmpgeometry_h__
  11 +#define __dmpgeometry_h__
  12 +#include <geometry/dmpwkbtypes.h>
  13 +#include <string>
  14 +using namespace std;
  15 +namespace mapserver
  16 +{
  17 + class Dmpgeometry
  18 + {
  19 + /* data */
  20 + public:
  21 + // Dmpgeometry(/* args */);
  22 + // ~Dmpgeometry();
  23 +
  24 + // static Dmpgeometry geometryfromWKT(const char* wkt);
  25 +
  26 + std::string geoJsonfromWKB(const char* wkb);
  27 +
  28 + bool readPointfromWKB(unsigned char*& pwkb, stringstream& outstream);
  29 + bool readLinefromWKB(unsigned char*& pwkb, stringstream& outstream);
  30 + bool readPolygonfromWKB(unsigned char*& pwkb, stringstream& outstream);
  31 +
  32 + // static string geoJsonfromWKT(const char* wkt);
  33 + private:
  34 + int ReadInt(unsigned char*& pwkb, int not_big1);
  35 + double ReadDouble(unsigned char*& pwkb, int not_big1);
  36 + int ReadByte(unsigned char*& pwkb);
  37 + bool Exchange4(unsigned char* pwkb);
  38 + bool Exchange8(unsigned char* pwkb);
  39 +
  40 + char* ToDoubleStr(double value);
  41 + private:
  42 + int srid_;
  43 + bool hasZ_;
  44 + bool hasSrid_;
  45 + int notbig_;
  46 +
  47 + DmpWkbTypes::Type type_;
  48 + char buff[100];
  49 +
  50 + };
  51 +
  52 +}
  53 +
  54 +#endif // __dmpgeometry_h__
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 #include <ostream> 12 #include <ostream>
13 #include <string> 13 #include <string>
14 #include <boost/asio.hpp> 14 #include <boost/asio.hpp>
15 - 15 +#include "dmpgeometry.h"
16 using boost::asio::ip::tcp; 16 using boost::asio::ip::tcp;
17 17
18 namespace mapserver 18 namespace mapserver
@@ -56,17 +56,9 @@ namespace mapserver @@ -56,17 +56,9 @@ namespace mapserver
56 int fieldsCount = pPgsqlConn->GetFieldCount(); 56 int fieldsCount = pPgsqlConn->GetFieldCount();
57 for (; pPgsqlConn->next();) 57 for (; pPgsqlConn->next();)
58 { 58 {
59 - // css++;  
60 - //if(css!=24)continue;  
61 - //break;  
62 - //string geometry = "";  
63 - //string properties = "";  
64 responseData.append("<gims:featureMember>"); 59 responseData.append("<gims:featureMember>");
65 sprintf(buff, "<gims:%s fid=\"%s.%d\">", layerName.c_str(), layerName.c_str(), count + 1); 60 sprintf(buff, "<gims:%s fid=\"%s.%d\">", layerName.c_str(), layerName.c_str(), count + 1);
66 responseData.append(buff); 61 responseData.append(buff);
67 - //responseData.append("\r\n");  
68 -  
69 - //columns[md[ i ].getString(MetaData::ATTR_NAME)] = i;  
70 for (int i = 0; i < fieldsCount; i++) 62 for (int i = 0; i < fieldsCount; i++)
71 { 63 {
72 const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); 64 const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str();
@@ -77,7 +69,7 @@ namespace mapserver @@ -77,7 +69,7 @@ namespace mapserver
77 if (strncmp(sfieldName, "RN_RN", 5) == 0) 69 if (strncmp(sfieldName, "RN_RN", 5) == 0)
78 continue; 70 continue;
79 std::string strFieldName = sfieldName; 71 std::string strFieldName = sfieldName;
80 - //DmapDll::StringHelp::ToXMLString(strFieldName); 72 + //DmapDll::StringHelp::ToXMLString(strFieldName);
81 73
82 if (strFieldName == "geometry_as_gml") 74 if (strFieldName == "geometry_as_gml")
83 { 75 {
@@ -165,6 +157,12 @@ namespace mapserver @@ -165,6 +157,12 @@ namespace mapserver
165 geometry = pPgsqlConn->getString(i); 157 geometry = pPgsqlConn->getString(i);
166 continue; 158 continue;
167 } 159 }
  160 + else if(strFieldName == "geometry_as_wkt")
  161 + {
  162 + Dmpgeometry dmpgeometry;
  163 + geometry = dmpgeometry.geoJsonfromWKB(pPgsqlConn->getString(i));
  164 + continue;
  165 + }
168 else 166 else
169 { 167 {
170 const char *v = pPgsqlConn->getString(i); 168 const char *v = pPgsqlConn->getString(i);
@@ -535,7 +533,7 @@ namespace mapserver @@ -535,7 +533,7 @@ namespace mapserver
535 533
536 for (i = 0; i < strlen(cd); i++) 534 for (i = 0; i < strlen(cd); i++)
537 { 535 {
538 - memset(p, '/0', 2); 536 + memset(p, '\0', 2);
539 if (cd[i] != '%') 537 if (cd[i] != '%')
540 { 538 {
541 decd[j++] = cd[i]; 539 decd[j++] = cd[i];
@@ -549,7 +547,7 @@ namespace mapserver @@ -549,7 +547,7 @@ namespace mapserver
549 p[1] = p[1] - 48 - ((p[1] >= 'A') ? 7 : 0) - ((p[1] >= 'a') ? 32 : 0); 547 p[1] = p[1] - 48 - ((p[1] >= 'A') ? 7 : 0) - ((p[1] >= 'a') ? 32 : 0);
550 decd[j++] = (unsigned char)(p[0] * 16 + p[1]); 548 decd[j++] = (unsigned char)(p[0] * 16 + p[1]);
551 } 549 }
552 - decd[j] = '/0'; 550 + decd[j] = '\0';
553 551
554 return decd; 552 return decd;
555 } 553 }
@@ -537,7 +537,8 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ @@ -537,7 +537,8 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
537 { 537 {
538 typeString = "geometry"; 538 typeString = "geometry";
539 typeInt = PGFieldType::ShapeFieldType; 539 typeInt = PGFieldType::ShapeFieldType;
540 - fields_str += " st_asgeojson(\"" + (fieldname) + "\") as geometry_as_geojson"; 540 + fields_str += " \"" + (fieldname) + "\" as geometry_as_wkt ";
  541 + //fields_str += " st_asgeojson(\"" + (fieldname) + "\") as geometry_as_geojson";
541 } 542 }
542 else if (typeString == "integer") 543 else if (typeString == "integer")
543 { 544 {
@@ -591,8 +592,14 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ @@ -591,8 +592,14 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
591 std::string sql = format(ss.c_str(), layer->schema().c_str(), tableName.c_str()); 592 std::string sql = format(ss.c_str(), layer->schema().c_str(), tableName.c_str());
592 593
593 string shapeName = layer->geom(); 594 string shapeName = layer->geom();
594 - sql += format(" ST_DWithin(\"%s\", ST_GeometryFromText('POINT(%f %f)',%s),%f) limit %d ",  
595 - shapeName.c_str(), x, y,layer->srid().c_str(), dis, feature_count); 595 + // WHERE \"%s\" && \'BOX3D(%lf %lf,%lf %lf)\'::box3d
  596 + //sql += format(" ST_DWithin(\"%s\", ST_GeometryFromText('POINT(%f %f)',%s),%f) limit %d ",
  597 + // shapeName.c_str(), x, y,layer->srid().c_str(), dis, feature_count);
  598 +
  599 + sql += format(" \"%s\" && \'BOX3D(%lf %lf,%lf %lf)\'::box3d limit %d ",
  600 + shapeName.c_str(), x - dis, y - dis, x + dis, y + dis, feature_count);
  601 +
  602 +
596 //cout<<sql.c_str() <<endl; 603 //cout<<sql.c_str() <<endl;
597 return sql; 604 return sql;
598 } 605 }
@@ -625,7 +632,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ @@ -625,7 +632,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
625 string sql = this->GetFeatureInfoSQL(layer, x0, y0, dis, feature_count); //sql语句中使用 ::box 632 string sql = this->GetFeatureInfoSQL(layer, x0, y0, dis, feature_count); //sql语句中使用 ::box
626 if (sql == "") continue; 633 if (sql == "") continue;
627 string layerName = layer->name(); 634 string layerName = layer->name();
628 - //printf("%s\r\n",sql.c_str()); 635 + printf("%s\r\n",sql.c_str());
629 if (pPgsqlConn->ExecWaitBinary(sql)) 636 if (pPgsqlConn->ExecWaitBinary(sql))
630 { 637 {
631 if(pPgsqlConn->GetRowCount()>0 || i==0) 638 if(pPgsqlConn->GetRowCount()>0 || i==0)
@@ -970,7 +977,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ @@ -970,7 +977,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
970 } 977 }
971 978
972 //for (int i = 0; i < (int)(m_vLayers.size()); i++) 979 //for (int i = 0; i < (int)(m_vLayers.size()); i++)
973 - for (int i = (int)(m_vLayers.size()) -1; i > 0; i--) 980 + for (int i = (int)(m_vLayers.size()) -1; i >= 0; i--)
974 { 981 {
975 DmpVectorLayer *layer = m_vLayers[i]; 982 DmpVectorLayer *layer = m_vLayers[i];
976 sprintf(buff, "<log>draw layer %s</log>", layer->name().c_str()); 983 sprintf(buff, "<log>draw layer %s</log>", layer->name().c_str());
@@ -1229,7 +1236,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ @@ -1229,7 +1236,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\
1229 1236
1230 1237
1231 //for (int i = 0; i < (int)(m_vLayers.size()); i++) 1238 //for (int i = 0; i < (int)(m_vLayers.size()); i++)
1232 - for (int i = (int)(m_vLayers.size()) -1; i > 0; i--) 1239 + for (int i = (int)(m_vLayers.size()) -1; i >= 0; i--)
1233 { 1240 {
1234 DmpVectorLayer *layer = m_vLayers[i]; 1241 DmpVectorLayer *layer = m_vLayers[i];
1235 1242
@@ -74,7 +74,11 @@ namespace DmpWms @@ -74,7 +74,11 @@ namespace DmpWms
74 ptGeographicBoundingbox.add("southBoundLatitude", miny); 74 ptGeographicBoundingbox.add("southBoundLatitude", miny);
75 ptGeographicBoundingbox.add("northBoundLatitude", maxy); 75 ptGeographicBoundingbox.add("northBoundLatitude", maxy);
76 ptProject.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox); 76 ptProject.add_child("EX_GeographicBoundingBox",ptGeographicBoundingbox);
77 - 77 + if( mapLayers.begin() != mapLayers.end())
  78 + {
  79 + ptProject.add("source", mapLayers.begin()->second->source());
  80 + }
  81 +
78 boost::property_tree::ptree ptLayers; 82 boost::property_tree::ptree ptLayers;
79 for (std::map<std::string, DmpMapLayer*>::iterator iter= mapLayers.begin();iter != mapLayers.end(); iter++) 83 for (std::map<std::string, DmpMapLayer*>::iterator iter= mapLayers.begin();iter != mapLayers.end(); iter++)
80 { 84 {
@@ -90,8 +94,9 @@ namespace DmpWms @@ -90,8 +94,9 @@ namespace DmpWms
90 boost::property_tree::ptree ptLayer; 94 boost::property_tree::ptree ptLayer;
91 ptLayer.add("Name", layer->name()); 95 ptLayer.add("Name", layer->name());
92 ptLayer.add("Title", layer->title()); 96 ptLayer.add("Title", layer->title());
93 - ptLayer.add("CRS", srs); 97 + ptLayer.add("CRS", layer->srid().empty()?srs:("EPSG:" + layer->srid()));
94 ptLayer.add("Type", layer->GeomTypeString()); 98 ptLayer.add("Type", layer->GeomTypeString());
  99 + ptLayer.add("source", layer->source());
95 100
96 boost::property_tree::ptree ptGeographicBoundingbox; 101 boost::property_tree::ptree ptGeographicBoundingbox;
97 ptGeographicBoundingbox.add("westBoundLongitude", layer->extent().xmin()); 102 ptGeographicBoundingbox.add("westBoundLongitude", layer->extent().xmin());
注册登录 后发表评论