正在显示
17 个修改的文件
包含
693 行增加
和
258 行删除
| ... | ... | @@ -50,6 +50,7 @@ DmpProject::~DmpProject() |
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | mapLayers_.clear(); |
| 53 | + vectorLayers_.clear(); | |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | bool DmpProject::Read(const std::string &data) |
| ... | ... | @@ -100,6 +101,7 @@ bool DmpProject::Read(const std::string &data) |
| 100 | 101 | std::string name = mapLayer->name(); |
| 101 | 102 | boost::to_upper(name); |
| 102 | 103 | mapLayers_[name] = mapLayer; |
| 104 | + vectorLayers_.push_back(mapLayer); | |
| 103 | 105 | } |
| 104 | 106 | else |
| 105 | 107 | { |
| ... | ... | @@ -138,18 +140,17 @@ bool DmpProject::WritePtree(boost::property_tree::ptree& ptDoc) |
| 138 | 140 | ptDmap.add_child("projectCrs",ptProjectCrs); |
| 139 | 141 | |
| 140 | 142 | boost::property_tree::ptree ptProjectlayers; |
| 141 | - | |
| 142 | - std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers_.begin(); | |
| 143 | - for (; iter != mapLayers_.end(); ++iter) | |
| 143 | + | |
| 144 | + for(int i =0; i< vectorLayers_.size(); i++) | |
| 144 | 145 | { |
| 145 | - DmpMapLayer *mapLayer = iter->second; | |
| 146 | + DmpMapLayer *mapLayer = vectorLayers_[i]; | |
| 146 | 147 | if (mapLayer && mapLayer->type() == DmpMapLayerType::VectorLayer) |
| 147 | 148 | { |
| 148 | 149 | boost::property_tree::ptree ptlayer; |
| 149 | 150 | ptlayer.add("<xmlattr>.type", "1"); |
| 150 | - DmpVectorLayer *vectorMapLayer =(DmpVectorLayer *) mapLayer; | |
| 151 | + DmpVectorLayer *vectorMapLayer = (DmpVectorLayer *)mapLayer; | |
| 151 | 152 | vectorMapLayer->writeXml(ptlayer); |
| 152 | - ptProjectlayers.add_child("maplayer",ptlayer); | |
| 153 | + ptProjectlayers.add_child("maplayer", ptlayer); | |
| 153 | 154 | } |
| 154 | 155 | } |
| 155 | 156 | |
| ... | ... | @@ -189,6 +190,11 @@ std::map<std::string, DmpMapLayer*> DmpProject::mapLayers() const |
| 189 | 190 | return mapLayers_; |
| 190 | 191 | } |
| 191 | 192 | |
| 193 | +std::vector<DmpMapLayer*> DmpProject::vectorLayers() const | |
| 194 | +{ | |
| 195 | + return vectorLayers_; | |
| 196 | +} | |
| 197 | + | |
| 192 | 198 | DmpMapLayer *DmpProject::getLayer(const std::string &layerName) const |
| 193 | 199 | { |
| 194 | 200 | if(layerName.empty()){ | ... | ... |
| ... | ... | @@ -31,6 +31,7 @@ class CORE_EXPORT DmpProject |
| 31 | 31 | std::string WriteJson(); |
| 32 | 32 | DmpCoordinateReferenceSystem crs() const; |
| 33 | 33 | std::map<std::string, DmpMapLayer*> mapLayers() const; |
| 34 | + std::vector<DmpMapLayer*> vectorLayers() const; | |
| 34 | 35 | DmpMapLayer* getLayer(const std::string &layerName) const; |
| 35 | 36 | DmpMapLayer* getLayer()const; |
| 36 | 37 | private: |
| ... | ... | @@ -40,6 +41,8 @@ class CORE_EXPORT DmpProject |
| 40 | 41 | std::string file_; |
| 41 | 42 | DmpCoordinateReferenceSystem crs_; |
| 42 | 43 | std::map<std::string, DmpMapLayer*> mapLayers_; |
| 44 | + std::vector<DmpMapLayer*> vectorLayers_; | |
| 45 | + | |
| 43 | 46 | }; |
| 44 | 47 | |
| 45 | 48 | #endif //__dmpproject_h__ | ... | ... |
| ... | ... | @@ -62,9 +62,9 @@ bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) |
| 62 | 62 | wkbType_ = DmpWkbTypes::Point; |
| 63 | 63 | else if (boost::iequals(wkbTypeString_, "MULTIPOINT")) |
| 64 | 64 | wkbType_ = DmpWkbTypes::MultiPoint; |
| 65 | - else if (boost::iequals(wkbTypeString_, "LINESTRING")) | |
| 65 | + else if (boost::iequals(wkbTypeString_, "LINESTRING") || boost::iequals(wkbTypeString_, "LINE") ) | |
| 66 | 66 | wkbType_ = DmpWkbTypes::LineString; |
| 67 | - else if (boost::iequals(wkbTypeString_, "MULTILINESTRING")) | |
| 67 | + else if (boost::iequals(wkbTypeString_, "MULTILINESTRING")|| boost::iequals(wkbTypeString_, "MULTILINE") ) | |
| 68 | 68 | wkbType_ = DmpWkbTypes::MultiLineString; |
| 69 | 69 | else if (boost::iequals(wkbTypeString_, "POLYGON")) |
| 70 | 70 | wkbType_ = DmpWkbTypes::Polygon; |
| ... | ... | @@ -93,6 +93,13 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) |
| 93 | 93 | layerNode.add("<xmlattr>.id", id_); |
| 94 | 94 | layerNode.add("<xmlattr>.name", name_); |
| 95 | 95 | layerNode.add("<xmlattr>.alias", title_); |
| 96 | + | |
| 97 | + layerNode.add("<xmlattr>.schema",schema_ ); | |
| 98 | + layerNode.add("<xmlattr>.geomfield",geom_ ); | |
| 99 | + layerNode.add("<xmlattr>.featurecount",featurecount_ ); | |
| 100 | + layerNode.add("<xmlattr>.geometry",wkbTypeString_ ); | |
| 101 | + layerNode.add("<xmlattr>.srid",srid_ ); | |
| 102 | + | |
| 96 | 103 | |
| 97 | 104 | boost::property_tree::ptree ptExtent; |
| 98 | 105 | ptExtent.add("xmin", extent_.xmin()); |
| ... | ... | @@ -162,11 +169,14 @@ bool DmpVectorLayer::writejson(std::string &json) |
| 162 | 169 | sprintf(buff_minscale, "%.0f", this->minScale()); |
| 163 | 170 | } |
| 164 | 171 | //Display scale setting type="1" geometry="Point" alwaysShow="true" maxScale="0" maxScale="50000"> |
| 172 | + | |
| 165 | 173 | char resultbuff[1000]; |
| 166 | 174 | string json_source = this->source(); |
| 167 | 175 | DmapCore_30::clsUtil::ToJSONString(json_source); |
| 168 | 176 | sprintf(resultbuff, |
| 169 | - R"({"workspace":"","type":"1","dbsource":"%s","data":"","schema":"%s","alias":"%s","name":"%s","id":"%s","filter":"%s","visible":"%s","tag":"","minScale":"%s","maxScale":"%s","geometry":"%s","alwaysShow":"%s")", | |
| 177 | + R"({"workspace":"","type":"1","dbsource":"%s","data":"","schema":"%s", | |
| 178 | +"alias":"%s","name":"%s","id":"%s","filter":"%s","visible":"%s","tag":"","minScale":"%s", | |
| 179 | +"maxScale":"%s","geometry":"%s","alwaysShow":"%s","geomfield":"%s","srid":"%s","featurecount":"%ld")", | |
| 170 | 180 | json_source.c_str(), |
| 171 | 181 | this->schema().c_str(), |
| 172 | 182 | this->title().c_str(), |
| ... | ... | @@ -176,7 +186,11 @@ bool DmpVectorLayer::writejson(std::string &json) |
| 176 | 186 | "true", |
| 177 | 187 | buff_minscale, buff_maxscale, |
| 178 | 188 | shapeTypeString.c_str(), |
| 179 | - alwaysShow ? "true" : "false"); | |
| 189 | + alwaysShow ? "true" : "false", | |
| 190 | + geom_.c_str(), | |
| 191 | + srid_.c_str(), | |
| 192 | + featurecount_ | |
| 193 | + ); | |
| 180 | 194 | |
| 181 | 195 | json.append(resultbuff); |
| 182 | 196 | if (this->renderer_30_ != nullptr) | ... | ... |
| ... | ... | @@ -23,10 +23,9 @@ namespace DmapCore_30 |
| 23 | 23 | m_iN = 0; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - | |
| 27 | - void DataCollection::InitDataCollection(PGresult *res, int shapeType, int imageWidth, int imageHeight, | |
| 28 | - int subset, double r, | |
| 29 | - double dScaleDenominator, double x_dis, double y_dis) | |
| 26 | + void DataCollection::InitDataCollection(PGresult *res, int shapeType, int imageWidth, int imageHeight, | |
| 27 | + int subset, double r, | |
| 28 | + double dScaleDenominator, double x_dis, double y_dis) | |
| 30 | 29 | { |
| 31 | 30 | //InitDataCollection(); |
| 32 | 31 | m_iN = 1; |
| ... | ... | @@ -47,7 +46,7 @@ namespace DmapCore_30 |
| 47 | 46 | { |
| 48 | 47 | m_subset = subset + 2; |
| 49 | 48 | } |
| 50 | - | |
| 49 | + | |
| 51 | 50 | this->CollectFieldName(res); |
| 52 | 51 | |
| 53 | 52 | switch (shapeType) |
| ... | ... | @@ -56,6 +55,7 @@ namespace DmapCore_30 |
| 56 | 55 | MallocForPoint(res); |
| 57 | 56 | break; |
| 58 | 57 | case GeometryType_MultiPoint: |
| 58 | + MallocForPoint(res); | |
| 59 | 59 | break; |
| 60 | 60 | case GeometryType_LineString: |
| 61 | 61 | MallocForLineStringGeom(res); |
| ... | ... | @@ -70,14 +70,13 @@ namespace DmapCore_30 |
| 70 | 70 | MallocForPolygonForGeom(res); |
| 71 | 71 | break; |
| 72 | 72 | default: |
| 73 | - | |
| 73 | + | |
| 74 | 74 | break; |
| 75 | 75 | } |
| 76 | 76 | //CollectAllField(res); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - | |
| 80 | -/* | |
| 79 | + /* | |
| 81 | 80 | void DataCollection::InitDataCollection(Geometry *geom, double r, double dScaleDenominator, |
| 82 | 81 | double x_dis, double y_dis) |
| 83 | 82 | { |
| ... | ... | @@ -139,7 +138,6 @@ namespace DmapCore_30 |
| 139 | 138 | } |
| 140 | 139 | }*/ |
| 141 | 140 | |
| 142 | - | |
| 143 | 141 | DataCollection::~DataCollection() |
| 144 | 142 | { |
| 145 | 143 | //cout<<"free begin;" <<endl; |
| ... | ... | @@ -179,8 +177,6 @@ namespace DmapCore_30 |
| 179 | 177 | //cout<<"free end;" <<endl; |
| 180 | 178 | } |
| 181 | 179 | |
| 182 | - | |
| 183 | - | |
| 184 | 180 | /* |
| 185 | 181 | Malloc PGresult |
| 186 | 182 | */ |
| ... | ... | @@ -264,6 +260,94 @@ namespace DmapCore_30 |
| 264 | 260 | return true; |
| 265 | 261 | } |
| 266 | 262 | |
| 263 | + | |
| 264 | + /* | |
| 265 | + Malloc PGresult | |
| 266 | + */ | |
| 267 | + bool DataCollection::MallocForPointGeom(PGresult *res) | |
| 268 | + { | |
| 269 | + m_iStructType = clsStruct::Struct_Point; | |
| 270 | + | |
| 271 | + int n_fields = PQnfields(res); | |
| 272 | + map<int, PointClass *> map_Point; | |
| 273 | + | |
| 274 | + for (size_t i = 0; i < m_iPartCount; i++) | |
| 275 | + { | |
| 276 | + unsigned char *here = (unsigned char *)PQgetvalue(res, i, 0); | |
| 277 | + unsigned char hasZorSrsid = ((unsigned char *)(here + 4))[0] / 16; | |
| 278 | + unsigned char hasZ = hasZorSrsid / 8; | |
| 279 | + unsigned char hasSrsid = hasZorSrsid % 8; | |
| 280 | + | |
| 281 | + int not_big = here[0]; | |
| 282 | + here++; | |
| 283 | + int shapetype = ((int *)here)[0]; | |
| 284 | + here += 4; | |
| 285 | + if (hasSrsid) | |
| 286 | + here += 4; | |
| 287 | + | |
| 288 | + int size = ((int *)here)[0]; | |
| 289 | + | |
| 290 | + | |
| 291 | + double x = ((double *)here)[0]; | |
| 292 | + here += 8; // clsUtil::ReadDouble(here, not_big); | |
| 293 | + double y = ((double *)here)[0]; | |
| 294 | + here += 8; // clsUtil::ReadDouble(here, not_big); | |
| 295 | + double x0 = 0, y0 = 0; | |
| 296 | + this->ToScale(x, y, x0, y0); | |
| 297 | + | |
| 298 | + int key = ((int)(x0 / m_subset)) * 10000 + ((int)(y0 / m_subset)); | |
| 299 | + if (map_Point.find(key) == map_Point.end()) | |
| 300 | + { | |
| 301 | + PointClass *pointClass = new PointClass(); | |
| 302 | + pointClass->x = x0; | |
| 303 | + pointClass->y = y0; | |
| 304 | + /*clsStruct::POINT* pp0 = new clsStruct::POINT(); | |
| 305 | + pp0->x = x0; | |
| 306 | + pp0->y = y0;*/ | |
| 307 | + map_Point[key] = pointClass; | |
| 308 | + for (int i0 = 1; i0 < n_fields; i0++) | |
| 309 | + { | |
| 310 | + char *vc = PQgetvalue(res, i, i0); | |
| 311 | + pointClass->m_pdata.push_back(vc); | |
| 312 | + } | |
| 313 | + } | |
| 314 | + } | |
| 315 | + | |
| 316 | + clsStruct::POINT *pp = (clsStruct::POINT *)malloc(sizeof(clsStruct::POINT) * map_Point.size()); | |
| 317 | + if (pp == NULL) | |
| 318 | + return false; | |
| 319 | + int index = 0; | |
| 320 | + | |
| 321 | + //创建预留空间 | |
| 322 | + m_vAllField.resize(map_Point.size()); | |
| 323 | + for (int i = 0; i < map_Point.size(); i++) | |
| 324 | + m_vAllField[i].resize(n_fields - 1); //这里是不包含shape 数据的 | |
| 325 | + //开辟预留空间后, 可以直接赋值,不需要 pushback | |
| 326 | + | |
| 327 | + for (map<int, PointClass *>::iterator iter = map_Point.begin(); iter != map_Point.end(); iter++) | |
| 328 | + { | |
| 329 | + PointClass *p = iter->second; | |
| 330 | + pp[index].x = p->x; | |
| 331 | + pp[index].y = p->y; | |
| 332 | + for (int j = 0; j < n_fields - 1; j++) //这里从第二列开始 | |
| 333 | + { | |
| 334 | + m_vAllField[index][j] = p->m_pdata.at(j); | |
| 335 | + } | |
| 336 | + p->m_pdata.clear(); | |
| 337 | + delete p; | |
| 338 | + iter->second = NULL; | |
| 339 | + index++; | |
| 340 | + } | |
| 341 | + | |
| 342 | + this->m_iPartCount = map_Point.size(); | |
| 343 | + | |
| 344 | + map_Point.clear(); | |
| 345 | + | |
| 346 | + m_pData = pp; | |
| 347 | + return true; | |
| 348 | + } | |
| 349 | + | |
| 350 | + | |
| 267 | 351 | bool DataCollection::MallocForLineStringGeom(PGresult *res) |
| 268 | 352 | { |
| 269 | 353 | m_iStructType = clsStruct::Struct_MLine; |
| ... | ... | @@ -293,7 +377,7 @@ namespace DmapCore_30 |
| 293 | 377 | //if (shapetype < 0) isLineZ = true; |
| 294 | 378 | if (geom_type == DCGeometryType::GeometryType_LineString) |
| 295 | 379 | { |
| 296 | - int nLine = 1;//clsUtil::ReadInt(here, not_big); | |
| 380 | + int nLine = 1; //clsUtil::ReadInt(here, not_big); | |
| 297 | 381 | clsStruct::LINE *pPath = (clsStruct::LINE *)malloc(sizeof(clsStruct::LINE) * nLine); |
| 298 | 382 | if (pPath == 0) |
| 299 | 383 | continue; |
| ... | ... | @@ -472,8 +556,6 @@ namespace DmapCore_30 |
| 472 | 556 | return true; |
| 473 | 557 | } |
| 474 | 558 | |
| 475 | - | |
| 476 | - | |
| 477 | 559 | bool DataCollection::PolygonIsLessThanOnePixel(unsigned char *here, int not_big1) |
| 478 | 560 | { |
| 479 | 561 | double dpix = 1 / this->m_dR; |
| ... | ... | @@ -1138,7 +1220,7 @@ namespace DmapCore_30 |
| 1138 | 1220 | return true; |
| 1139 | 1221 | } |
| 1140 | 1222 | |
| 1141 | -/* | |
| 1223 | + /* | |
| 1142 | 1224 | bool DataCollection::MallocForPoint(Point *p) |
| 1143 | 1225 | { |
| 1144 | 1226 | m_iStructType = clsStruct::Struct_Point; |
| ... | ... | @@ -1598,7 +1680,7 @@ namespace DmapCore_30 |
| 1598 | 1680 | return point; |
| 1599 | 1681 | } |
| 1600 | 1682 | shared_ptr<PointClass> point(new PointClass()); |
| 1601 | - return point; | |
| 1683 | + return point; | |
| 1602 | 1684 | } |
| 1603 | 1685 | |
| 1604 | 1686 | shared_ptr<PolygonClass> DataCollection::GetDataLine(unsigned char *vc) | ... | ... |
| ... | ... | @@ -259,6 +259,7 @@ upper表示使用大端点,不使用小端点 |
| 259 | 259 | bool MallocForPolygon(PGresult *res); |
| 260 | 260 | bool MallocForMultiPolygon(PGresult* res); |
| 261 | 261 | |
| 262 | + bool MallocForPointGeom(PGresult *res); | |
| 262 | 263 | bool MallocForPolygonForGeom(PGresult *res); |
| 263 | 264 | bool MallocForLineStringGeom(PGresult *res); |
| 264 | 265 | ... | ... |
| ... | ... | @@ -39,7 +39,7 @@ namespace DmapCore_30 |
| 39 | 39 | { |
| 40 | 40 | double r = data->m_dScaleDenominator; |
| 41 | 41 | //double r = r__ / (3779.52755905); |
| 42 | - if (r <m_dLower || (r > m_dUpper && m_dUpper< 100000000) || m_pRen == 0) | |
| 42 | + if (r <m_dLower || (r > m_dUpper && m_dUpper< 10000000000) || m_pRen == 0) | |
| 43 | 43 | return false; |
| 44 | 44 | return m_pRen->DrawData(pClsCS, data, pFlag); |
| 45 | 45 | } | ... | ... |
| ... | ... | @@ -13,184 +13,217 @@ |
| 13 | 13 | #include <string> |
| 14 | 14 | #include <boost/asio.hpp> |
| 15 | 15 | |
| 16 | - | |
| 17 | 16 | using boost::asio::ip::tcp; |
| 18 | 17 | |
| 19 | 18 | namespace mapserver |
| 20 | -{ | |
| 21 | - | |
| 22 | -void DmpMapServerUtil::responseGml(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid) | |
| 23 | 19 | { |
| 24 | - | |
| 25 | -// rs->PrepareFieldhead(); //获得了结果集的字段类型 | |
| 26 | - int shapeType = -1; | |
| 27 | - | |
| 28 | - double xg1, yg1, xg2, yg2; | |
| 29 | - int havegSet = 0; | |
| 30 | - int count = 0; | |
| 31 | - int pointCountTemp = 0; | |
| 32 | - char buff[5000] = {0}; | |
| 33 | - | |
| 34 | - responseData.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><wfs:FeatureCollection "); | |
| 35 | - responseData.append("xmlns:gims=\"http://www.esri.com/esri\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:ogc=\"http://www.opengis.net/ogc\">"); | |
| 36 | - | |
| 37 | - | |
| 38 | - //bool paff = parseString.affine; | |
| 39 | - try | |
| 20 | + | |
| 21 | + void DmpMapServerUtil::responseGml(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData, const string &layerName, const std::string &srid) | |
| 40 | 22 | { |
| 41 | - int fieldsCount = pPgsqlConn->GetFieldCount(); | |
| 42 | - for (; pPgsqlConn->next();) | |
| 23 | + | |
| 24 | + // rs->PrepareFieldhead(); //获得了结果集的字段类型 | |
| 25 | + int shapeType = -1; | |
| 26 | + | |
| 27 | + double xg1, yg1, xg2, yg2; | |
| 28 | + int havegSet = 0; | |
| 29 | + int count = 0; | |
| 30 | + int pointCountTemp = 0; | |
| 31 | + char buff[5000] = {0}; | |
| 32 | + | |
| 33 | + responseData.append("<?xml version=\"1.0\" encoding=\"utf-8\" ?><wfs:FeatureCollection "); | |
| 34 | + responseData.append("xmlns:gims=\"http://www.esri.com/esri\" xmlns:gml=\"http://www.opengis.net/gml\" xmlns:wfs=\"http://www.opengis.net/wfs\" xmlns:ogc=\"http://www.opengis.net/ogc\">"); | |
| 35 | + | |
| 36 | + //bool paff = parseString.affine; | |
| 37 | + try | |
| 43 | 38 | { |
| 44 | - // css++; | |
| 45 | - //if(css!=24)continue; | |
| 46 | - //break; | |
| 47 | - //string geometry = ""; | |
| 48 | - //string properties = ""; | |
| 49 | - responseData.append("<gims:featureMember>"); | |
| 50 | - sprintf(buff, "<gims:%s fid=\"%s.%d\">", layerName.c_str(), layerName.c_str(), count + 1); | |
| 51 | - responseData.append(buff); | |
| 52 | - //responseData.append("\r\n"); | |
| 53 | - | |
| 54 | - //columns[md[ i ].getString(MetaData::ATTR_NAME)] = i; | |
| 55 | - for (int i = 0; i < fieldsCount; i++) | |
| 39 | + int fieldsCount = pPgsqlConn->GetFieldCount(); | |
| 40 | + for (; pPgsqlConn->next();) | |
| 56 | 41 | { |
| 57 | - const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | |
| 58 | - if (sfieldName == 0) | |
| 59 | - { | |
| 60 | - break; | |
| 61 | - } | |
| 62 | - if (strncmp(sfieldName, "RN_RN", 5) == 0) | |
| 63 | - continue; | |
| 64 | - std::string strFieldName = sfieldName; | |
| 65 | - //DmapDll::StringHelp::ToXMLString(strFieldName); | |
| 66 | - | |
| 67 | - if (strFieldName == "geometry_as_gml") | |
| 68 | - { | |
| 69 | - const char* value = pPgsqlConn->getString(i); | |
| 70 | - if(value) | |
| 71 | - responseData.append(value); | |
| 72 | - continue; | |
| 73 | - } | |
| 74 | - else | |
| 42 | + // css++; | |
| 43 | + //if(css!=24)continue; | |
| 44 | + //break; | |
| 45 | + //string geometry = ""; | |
| 46 | + //string properties = ""; | |
| 47 | + responseData.append("<gims:featureMember>"); | |
| 48 | + sprintf(buff, "<gims:%s fid=\"%s.%d\">", layerName.c_str(), layerName.c_str(), count + 1); | |
| 49 | + responseData.append(buff); | |
| 50 | + //responseData.append("\r\n"); | |
| 51 | + | |
| 52 | + //columns[md[ i ].getString(MetaData::ATTR_NAME)] = i; | |
| 53 | + for (int i = 0; i < fieldsCount; i++) | |
| 75 | 54 | { |
| 76 | - const char *v = pPgsqlConn->getString(i); | |
| 77 | - sprintf(buff, "<gims:%s>%s</gims:%s>", strFieldName.c_str(), v, strFieldName.c_str()); | |
| 78 | - //properties += buff; | |
| 79 | - responseData.append(buff); | |
| 55 | + const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | |
| 56 | + if (sfieldName == 0) | |
| 57 | + { | |
| 58 | + break; | |
| 59 | + } | |
| 60 | + if (strncmp(sfieldName, "RN_RN", 5) == 0) | |
| 61 | + continue; | |
| 62 | + std::string strFieldName = sfieldName; | |
| 63 | + //DmapDll::StringHelp::ToXMLString(strFieldName); | |
| 64 | + | |
| 65 | + if (strFieldName == "geometry_as_gml") | |
| 66 | + { | |
| 67 | + const char *value = pPgsqlConn->getString(i); | |
| 68 | + if (value) | |
| 69 | + responseData.append(value); | |
| 70 | + continue; | |
| 71 | + } | |
| 72 | + else | |
| 73 | + { | |
| 74 | + const char *v = pPgsqlConn->getString(i); | |
| 75 | + sprintf(buff, "<gims:%s>%s</gims:%s>", strFieldName.c_str(), v, strFieldName.c_str()); | |
| 76 | + //properties += buff; | |
| 77 | + responseData.append(buff); | |
| 78 | + } | |
| 80 | 79 | } |
| 81 | - | |
| 82 | - } | |
| 83 | - //tickAA=GetTickCount(); | |
| 80 | + //tickAA=GetTickCount(); | |
| 84 | 81 | |
| 85 | - sprintf(buff, "</gims:%s>\r",layerName.c_str()); | |
| 86 | - responseData.append(buff); | |
| 87 | - responseData.append("</gims:featureMember>"); | |
| 82 | + sprintf(buff, "</gims:%s>\r", layerName.c_str()); | |
| 83 | + responseData.append(buff); | |
| 84 | + responseData.append("</gims:featureMember>"); | |
| 88 | 85 | |
| 89 | - count++; | |
| 90 | - //if(pointCount>25)break; | |
| 86 | + count++; | |
| 87 | + //if(pointCount>25)break; | |
| 91 | 88 | |
| 92 | - if (pointCountTemp > 2000) | |
| 93 | - break; | |
| 94 | - //Sleep(5000); | |
| 95 | - // break; | |
| 89 | + if (pointCountTemp > 2000) | |
| 90 | + break; | |
| 91 | + //Sleep(5000); | |
| 92 | + // break; | |
| 93 | + } | |
| 94 | + } | |
| 95 | + catch (...) | |
| 96 | + { | |
| 96 | 97 | } |
| 97 | - } | |
| 98 | - catch (...) | |
| 99 | - { | |
| 100 | - | |
| 101 | - } | |
| 102 | - | |
| 103 | - //sprintf(buff, "numberMatched=\"%ld\" numberReturned=\"%ld\" ", count, count); | |
| 104 | - //responseData.append(insertBuf, sql, strlen(sql)); | |
| 105 | 98 | |
| 106 | - | |
| 99 | + //sprintf(buff, "numberMatched=\"%ld\" numberReturned=\"%ld\" ", count, count); | |
| 100 | + //responseData.append(insertBuf, sql, strlen(sql)); | |
| 107 | 101 | |
| 108 | - responseData.append("</wfs:FeatureCollection>"); | |
| 102 | + responseData.append("</wfs:FeatureCollection>"); | |
| 109 | 103 | |
| 110 | - return; | |
| 111 | -} | |
| 104 | + return; | |
| 105 | + } | |
| 112 | 106 | |
| 113 | - //以GeoJson的形式返回 | |
| 114 | -void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const string& srid) | |
| 115 | -{ | |
| 116 | - double xg1, yg1, xg2, yg2; | |
| 117 | - int havegSet = 0; | |
| 118 | - int count = 0; | |
| 119 | - int pointCountTemp = 0; | |
| 120 | - std::string stringTime; | |
| 121 | - char buff[5000] = {0}; | |
| 122 | - | |
| 123 | - responseData.append(R"({"type":"FeatureCollection","features":[)"); | |
| 124 | - try | |
| 107 | + //以GeoJson的形式返回 | |
| 108 | + void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData, const string &layerName, const string &srid) | |
| 125 | 109 | { |
| 126 | - int fieldsCount = pPgsqlConn->GetFieldCount(); | |
| 127 | - for (int featureIndex = 0; pPgsqlConn->next(); featureIndex++) | |
| 110 | + double xg1, yg1, xg2, yg2; | |
| 111 | + int havegSet = 0; | |
| 112 | + int count = 0; | |
| 113 | + int pointCountTemp = 0; | |
| 114 | + std::string stringTime; | |
| 115 | + char buff[5000] = {0}; | |
| 116 | + | |
| 117 | + responseData.append(R"({"type":"FeatureCollection","features":[)"); | |
| 118 | + try | |
| 128 | 119 | { |
| 129 | - if (featureIndex > 0) | |
| 130 | - responseData.append(","); | |
| 131 | - | |
| 132 | - responseData.append(R"({"type":"Feature")"); | |
| 120 | + int fieldsCount = pPgsqlConn->GetFieldCount(); | |
| 121 | + for (int featureIndex = 0; pPgsqlConn->next(); featureIndex++) | |
| 122 | + { | |
| 123 | + if (featureIndex > 0) | |
| 124 | + responseData.append(","); | |
| 133 | 125 | |
| 134 | - string geometry = ""; | |
| 135 | - string properties = ""; | |
| 126 | + responseData.append(R"({"type":"Feature")"); | |
| 136 | 127 | |
| 137 | - for (int i = 0; i < fieldsCount; i++) | |
| 138 | - { | |
| 139 | - const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | |
| 140 | - if (sfieldName == 0) | |
| 128 | + string geometry = ""; | |
| 129 | + string properties = ""; | |
| 130 | + | |
| 131 | + for (int i = 0; i < fieldsCount; i++) | |
| 141 | 132 | { |
| 142 | - break; | |
| 143 | - } | |
| 144 | - | |
| 133 | + const char *sfieldName = pPgsqlConn->GetFieldName(i); //pPgsqlConn->field_name[i].c_str(); | |
| 134 | + if (sfieldName == 0) | |
| 135 | + { | |
| 136 | + break; | |
| 137 | + } | |
| 145 | 138 | |
| 146 | - if (strncmp(sfieldName, "RN_RN", 5) == 0) | |
| 147 | - continue; | |
| 148 | - std::string strFieldName = sfieldName; | |
| 149 | - //XML转义 | |
| 150 | - DmpMapServerUtil::toJsonString(strFieldName); | |
| 151 | - sfieldName = strFieldName.c_str(); | |
| 139 | + if (strncmp(sfieldName, "RN_RN", 5) == 0) | |
| 140 | + continue; | |
| 141 | + std::string strFieldName = sfieldName; | |
| 142 | + //XML转义 | |
| 143 | + DmpMapServerUtil::toJsonString(strFieldName); | |
| 144 | + sfieldName = strFieldName.c_str(); | |
| 152 | 145 | |
| 153 | - if (strFieldName == "geometry_as_geojson") | |
| 154 | - { | |
| 155 | - geometry = pPgsqlConn->getString(i); | |
| 156 | - continue; | |
| 146 | + if (strFieldName == "geometry_as_geojson") | |
| 147 | + { | |
| 148 | + geometry = pPgsqlConn->getString(i); | |
| 149 | + continue; | |
| 150 | + } | |
| 151 | + else | |
| 152 | + { | |
| 153 | + const char *v = pPgsqlConn->getString(i); | |
| 154 | + std::sprintf(buff, R"(,"%s":"%s")", sfieldName, v); | |
| 155 | + properties += buff; | |
| 156 | + } | |
| 157 | 157 | } |
| 158 | - else | |
| 158 | + | |
| 159 | + if (geometry != "") | |
| 159 | 160 | { |
| 160 | - const char *v = pPgsqlConn->getString(i); | |
| 161 | - std::sprintf(buff, R"(,"%s":"%s")", sfieldName, v); | |
| 162 | - properties += buff; | |
| 161 | + responseData.append(R"(,"geometry":)"); | |
| 162 | + responseData.append(geometry.c_str()); | |
| 163 | 163 | } |
| 164 | - } | |
| 165 | 164 | |
| 166 | - if (geometry != "") | |
| 167 | - { | |
| 168 | - responseData.append(R"(,"geometry":)"); | |
| 169 | - responseData.append(geometry.c_str()); | |
| 170 | - } | |
| 171 | - | |
| 172 | - if (properties != "") | |
| 173 | - { | |
| 174 | - responseData.append(R"(,"properties":)"); | |
| 175 | - properties[0] = '{'; | |
| 176 | - responseData.append(properties.c_str()); | |
| 165 | + if (properties != "") | |
| 166 | + { | |
| 167 | + responseData.append(R"(,"properties":)"); | |
| 168 | + properties[0] = '{'; | |
| 169 | + responseData.append(properties.c_str()); | |
| 170 | + responseData.append("}"); | |
| 171 | + } | |
| 177 | 172 | responseData.append("}"); |
| 173 | + count++; | |
| 178 | 174 | } |
| 179 | - responseData.append("}"); | |
| 180 | - count++; | |
| 181 | 175 | } |
| 176 | + catch (...) | |
| 177 | + { | |
| 178 | + return; | |
| 179 | + } | |
| 180 | + | |
| 181 | + responseData.append("]}"); | |
| 182 | + | |
| 183 | + return; | |
| 182 | 184 | } |
| 183 | - catch (...) | |
| 185 | + | |
| 186 | + void DmpMapServerUtil::toXmlString(std::string &s) | |
| 184 | 187 | { |
| 188 | + const char *str1 = s.c_str(); | |
| 189 | + if (strstr(str1, "&")) | |
| 190 | + { | |
| 191 | + s = replace(s, "&", "&"); | |
| 192 | + str1 = s.c_str(); | |
| 193 | + } | |
| 194 | + if (strstr(str1, "<")) | |
| 195 | + { | |
| 196 | + s = replace(s, "<", "<"); | |
| 197 | + str1 = s.c_str(); | |
| 198 | + } | |
| 199 | + if (strstr(str1, ">")) | |
| 200 | + { | |
| 201 | + s = replace(s, ">", ">"); | |
| 202 | + str1 = s.c_str(); | |
| 203 | + } | |
| 204 | + if (strstr(str1, "\"")) | |
| 205 | + { | |
| 206 | + s = replace(s, "\"", """); | |
| 207 | + str1 = s.c_str(); | |
| 208 | + } | |
| 209 | + if (strstr(str1, "\r")) | |
| 210 | + { | |
| 211 | + s = replace(s, "\r", ""); | |
| 212 | + str1 = s.c_str(); | |
| 213 | + } | |
| 214 | + if (strstr(str1, "\n")) | |
| 215 | + { | |
| 216 | + s = replace(s, "\n", ""); | |
| 217 | + str1 = s.c_str(); | |
| 218 | + } | |
| 219 | + if (strstr(str1, "'")) | |
| 220 | + { | |
| 221 | + s = replace(s, "'", "'"); | |
| 222 | + //str1=s.c_str(); | |
| 223 | + } | |
| 185 | 224 | return; |
| 186 | 225 | } |
| 187 | 226 | |
| 188 | - responseData.append("]}"); | |
| 189 | - | |
| 190 | - return; | |
| 191 | -} | |
| 192 | - | |
| 193 | - | |
| 194 | 227 | void DmpMapServerUtil::toJsonString(std::string &s) |
| 195 | 228 | { |
| 196 | 229 | const char *str1 = s.c_str(); |
| ... | ... | @@ -236,21 +269,19 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str |
| 236 | 269 | return; |
| 237 | 270 | } |
| 238 | 271 | |
| 239 | - std::string DmpMapServerUtil::replace(std::string strsrc, std::string strfind, std::string strrep) | |
| 240 | - { | |
| 241 | - for(std::string::size_type pos(0); pos!=std::string::npos;pos+=strrep.length()) | |
| 242 | - { | |
| 243 | - if((pos=strsrc.find(strfind,pos))!=std::string::npos) | |
| 244 | - strsrc.replace(pos,strfind.length(),strrep); | |
| 245 | - else | |
| 246 | - break; | |
| 247 | - } | |
| 248 | - return strsrc; | |
| 249 | - } | |
| 250 | - | |
| 251 | - | |
| 272 | + std::string DmpMapServerUtil::replace(std::string strsrc, std::string strfind, std::string strrep) | |
| 273 | + { | |
| 274 | + for (std::string::size_type pos(0); pos != std::string::npos; pos += strrep.length()) | |
| 275 | + { | |
| 276 | + if ((pos = strsrc.find(strfind, pos)) != std::string::npos) | |
| 277 | + strsrc.replace(pos, strfind.length(), strrep); | |
| 278 | + else | |
| 279 | + break; | |
| 280 | + } | |
| 281 | + return strsrc; | |
| 282 | + } | |
| 252 | 283 | |
| 253 | - std::vector<std::string> DmpMapServerUtil::stringSplit(const std::string &str, const std::string &pattern) | |
| 284 | + std::vector<std::string> DmpMapServerUtil::stringSplit(const std::string &str, const std::string &pattern) | |
| 254 | 285 | { |
| 255 | 286 | vector<std::string> stringList; |
| 256 | 287 | std::string subStr; |
| ... | ... | @@ -258,15 +289,15 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str |
| 258 | 289 | size_t patternLen = pattern.length(); |
| 259 | 290 | for (size_t i = 0; i < str.length(); i++) |
| 260 | 291 | { |
| 261 | - if(pattern[0] == str[i]) | |
| 292 | + if (pattern[0] == str[i]) | |
| 262 | 293 | { |
| 263 | 294 | tPattern = str.substr(i, patternLen); |
| 264 | - if(tPattern == pattern) | |
| 295 | + if (tPattern == pattern) | |
| 265 | 296 | { |
| 266 | - i += patternLen -1; | |
| 267 | - if(!subStr.empty()) | |
| 297 | + i += patternLen - 1; | |
| 298 | + if (!subStr.empty()) | |
| 268 | 299 | { |
| 269 | - stringList.push_back(subStr); | |
| 300 | + stringList.push_back(subStr); | |
| 270 | 301 | subStr.clear(); |
| 271 | 302 | } |
| 272 | 303 | } |
| ... | ... | @@ -281,18 +312,16 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str |
| 281 | 312 | } |
| 282 | 313 | } |
| 283 | 314 | |
| 284 | - if(!subStr.empty()) | |
| 315 | + if (!subStr.empty()) | |
| 285 | 316 | { |
| 286 | 317 | stringList.push_back(subStr); |
| 287 | 318 | } |
| 288 | 319 | return stringList; |
| 289 | - | |
| 290 | 320 | } |
| 291 | 321 | |
| 292 | - | |
| 293 | - int DmpMapServerUtil::HttpPost(const std::string& url, std::string& postData, std::string &reponse_data) | |
| 322 | + int DmpMapServerUtil::HttpPost(const std::string &url, std::string &postData, std::string &reponse_data) | |
| 294 | 323 | { |
| 295 | - string host, port,path; | |
| 324 | + string host, port, path; | |
| 296 | 325 | const std::string &http_ = "http://"; |
| 297 | 326 | const std::string &https_ = "https://"; |
| 298 | 327 | std::string temp_data = url; |
| ... | ... | @@ -334,7 +363,6 @@ void DmpMapServerUtil::responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::str |
| 334 | 363 | host = host.substr(0, idx); |
| 335 | 364 | } |
| 336 | 365 | |
| 337 | - | |
| 338 | 366 | try |
| 339 | 367 | { |
| 340 | 368 | boost::asio::io_service io_service; | ... | ... |
| ... | ... | @@ -22,6 +22,7 @@ namespace mapserver |
| 22 | 22 | public: |
| 23 | 23 | static void responseGeojson(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid); |
| 24 | 24 | static void responseGml(shared_ptr<DmpPgsql> pPgsqlConn, std::string &responseData,const string& layerName,const std::string &srid); |
| 25 | + static void toXmlString(std::string &s); | |
| 25 | 26 | static void toJsonString(std::string &s); |
| 26 | 27 | static std::string replace(std::string strsrc, std::string strfind, std::string strrep); |
| 27 | 28 | ... | ... |
| ... | ... | @@ -560,7 +560,7 @@ namespace mapserver |
| 560 | 560 | // newPool->m_name = databaseName; |
| 561 | 561 | // newPool->m_alias = alias; |
| 562 | 562 | // newPool->Connect(connStr.c_str()); |
| 563 | - // newPool->Connect("PostgreSQLConn=hostaddr=172.26.99.173 port=5433 dbname='postgres' user='postgres' password='chinadci'"); | |
| 563 | + // newPool->Connect("PostgreSQLConn=hostaddr=172.26.99.173 port=5433 dbname='postgres' user='postgres' password='chinadci'"); | |
| 564 | 564 | // pgsqlPool_[guid] = newPool; |
| 565 | 565 | return true; |
| 566 | 566 | } | ... | ... |
| ... | ... | @@ -52,20 +52,21 @@ namespace DmpMapping |
| 52 | 52 | std::string projectData = project->WriteXml(); |
| 53 | 53 | if(!guid.empty() && !projectData.empty()) |
| 54 | 54 | { |
| 55 | - | |
| 55 | + | |
| 56 | 56 | shared_ptr<DmpProject> project(new DmpProject()); |
| 57 | 57 | if (!project->Read(projectData)) |
| 58 | 58 | { |
| 59 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载DMD符号化失败!\"}"); | |
| 59 | 60 | return false; |
| 60 | 61 | } |
| 61 | - vectorMappingProjects[guid] = project; | |
| 62 | + vectorMappingProjects[guid] = project; | |
| 62 | 63 | |
| 63 | - int i = 0; | |
| 64 | + // int i = 0; | |
| 64 | 65 | double minx, miny, maxx, maxy; |
| 65 | - std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers(); | |
| 66 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++) | |
| 66 | + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers(); | |
| 67 | + for (size_t i = 0; i < vectorLayers.size(); i++) | |
| 67 | 68 | { |
| 68 | - DmpMapLayer *layer = iter->second; | |
| 69 | + DmpMapLayer *layer = vectorLayers[i]; | |
| 69 | 70 | if (i == 0) |
| 70 | 71 | { |
| 71 | 72 | minx = layer->extent().xmin(); |
| ... | ... | @@ -93,16 +94,15 @@ namespace DmpMapping |
| 93 | 94 | std::string json = buff; |
| 94 | 95 | json.append(",\"maplayer\":["); |
| 95 | 96 | |
| 96 | - i = 0; | |
| 97 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++) | |
| 97 | + | |
| 98 | + for (int i=0; i<vectorLayers.size(); i++ ) | |
| 98 | 99 | { |
| 99 | - DmpVectorLayer *layer = (DmpVectorLayer*) iter->second; | |
| 100 | + DmpVectorLayer *layer = (DmpVectorLayer*) vectorLayers[i]; | |
| 100 | 101 | if(i>0) |
| 101 | 102 | { |
| 102 | 103 | json.append(","); |
| 103 | 104 | } |
| 104 | 105 | layer->writejson(json); |
| 105 | - i++; | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | json.append("]}"); |
| ... | ... | @@ -167,12 +167,11 @@ namespace DmpMapping |
| 167 | 167 | } |
| 168 | 168 | vectorMappingProjects[guid] = project; |
| 169 | 169 | |
| 170 | - int i = 0; | |
| 171 | 170 | double minx, miny, maxx, maxy; |
| 172 | - std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers(); | |
| 173 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++) | |
| 171 | + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers(); | |
| 172 | + for (size_t i = 0; i < vectorLayers.size(); i++) | |
| 174 | 173 | { |
| 175 | - DmpMapLayer *layer = iter->second; | |
| 174 | + DmpMapLayer *layer = vectorLayers[i]; | |
| 176 | 175 | if (i == 0) |
| 177 | 176 | { |
| 178 | 177 | minx = layer->extent().xmin(); |
| ... | ... | @@ -200,16 +199,14 @@ namespace DmpMapping |
| 200 | 199 | std::string json = buff; |
| 201 | 200 | json.append(",\"maplayer\":["); |
| 202 | 201 | |
| 203 | - i = 0; | |
| 204 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); iter != mapLayers.end(); iter++) | |
| 202 | + for (int i=0; i<vectorLayers.size(); i++ ) | |
| 205 | 203 | { |
| 206 | - DmpVectorLayer *layer = (DmpVectorLayer*) iter->second; | |
| 204 | + DmpVectorLayer *layer = (DmpVectorLayer*) vectorLayers[i]; | |
| 207 | 205 | if(i>0) |
| 208 | 206 | { |
| 209 | 207 | json.append(","); |
| 210 | 208 | } |
| 211 | 209 | layer->writejson(json); |
| 212 | - i++; | |
| 213 | 210 | } |
| 214 | 211 | |
| 215 | 212 | json.append("]}"); | ... | ... |
| ... | ... | @@ -70,6 +70,19 @@ namespace DmpMapping |
| 70 | 70 | else if (boost::iequals(request,"getimage")) { |
| 71 | 71 | getImage(context); |
| 72 | 72 | } |
| 73 | + else if(boost::iequals(request, "getmaplog")){ | |
| 74 | + const std::string mapGuid = params.MapGuid(); | |
| 75 | + if (vectorMappingProjects_.find(mapGuid) != vectorMappingProjects_.end()) | |
| 76 | + { | |
| 77 | + shared_ptr<DmpProject> project = vectorMappingProjects_.find(mapGuid)->second; | |
| 78 | + const DmpWms::DmpWmsParameters wmsParams(context.request()->serverParameters()); | |
| 79 | + DmpWms::writeGetMapLog(context, wmsParams, project.get()); | |
| 80 | + } | |
| 81 | + else | |
| 82 | + { | |
| 83 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"未找到服务\"}"); | |
| 84 | + } | |
| 85 | + } | |
| 73 | 86 | else if (boost::iequals(request, "getmap")) |
| 74 | 87 | { |
| 75 | 88 | const std::string mapGuid = params.MapGuid(); | ... | ... |
| ... | ... | @@ -143,17 +143,16 @@ namespace DmpWfs |
| 143 | 143 | pt.add_child("DCPType", pt_dcpType); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - void addFeatureTypeList(boost::property_tree::ptree &pt,const DmpProject *project) | |
| 146 | + void addFeatureTypeList(boost::property_tree::ptree &pt, const DmpProject *project) | |
| 147 | 147 | { |
| 148 | 148 | boost::property_tree::ptree ptOperations; |
| 149 | - ptOperations.add("Query",""); | |
| 149 | + ptOperations.add("Query", ""); | |
| 150 | 150 | pt.add_child("Operations", ptOperations); |
| 151 | 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++) | |
| 152 | + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers(); | |
| 153 | + for (int i = 0; i < vectorLayers.size(); i++) | |
| 155 | 154 | { |
| 156 | - DmpVectorLayer *layer = (DmpVectorLayer *)iter->second; | |
| 155 | + DmpVectorLayer *layer = (DmpVectorLayer*) vectorLayers[i]; | |
| 157 | 156 | std::string source = layer->source(); |
| 158 | 157 | shared_ptr<DmpPgsql> pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source()); |
| 159 | 158 | if (pPgsqlConn != nullptr) |
| ... | ... | @@ -188,11 +187,11 @@ namespace DmpWfs |
| 188 | 187 | |
| 189 | 188 | boost::property_tree::ptree ptFields; |
| 190 | 189 | char tablesql_buff[300]; |
| 191 | - sprintf(tablesql_buff, "select column_name,data_type from information_schema.columns where table_schema = '%s' and table_name = '%s'", | |
| 192 | - layer->schema().c_str(), | |
| 193 | - layer->name().c_str()); | |
| 194 | - bool returnResult = pPgsqlConn->ExecWait(tablesql_buff); | |
| 195 | - for (;returnResult && pPgsqlConn->next();) | |
| 190 | + sprintf(tablesql_buff, "select column_name,data_type from information_schema.columns where table_schema = '%s' and table_name = '%s'", | |
| 191 | + layer->schema().c_str(), | |
| 192 | + layer->name().c_str()); | |
| 193 | + bool returnResult = pPgsqlConn->ExecWait(tablesql_buff); | |
| 194 | + for (; returnResult && pPgsqlConn->next();) | |
| 196 | 195 | { |
| 197 | 196 | std::string fieldname = pPgsqlConn->getString(0); |
| 198 | 197 | std::string typeString = pPgsqlConn->getString(1); |
| ... | ... | @@ -259,11 +258,9 @@ namespace DmpWfs |
| 259 | 258 | ptFeatureType.add_child("Fields", ptFields); |
| 260 | 259 | pt.add_child("FeatureType", ptFeatureType); |
| 261 | 260 | } |
| 262 | - | |
| 263 | 261 | } |
| 264 | 262 | } |
| 265 | 263 | |
| 266 | - | |
| 267 | 264 | void addFilterCapabilities(boost::property_tree::ptree &pt,const std::string &hrefUrl) |
| 268 | 265 | { |
| 269 | 266 | boost::property_tree::ptree ptFilterCapabilities; | ... | ... |
| ... | ... | @@ -52,6 +52,10 @@ namespace DmpWms |
| 52 | 52 | { |
| 53 | 53 | writeGetMap(context,params, project); |
| 54 | 54 | } |
| 55 | + else if(boost::iequals(request, "getmaplog")) | |
| 56 | + { | |
| 57 | + writeGetMapLog(context,params, project); | |
| 58 | + } | |
| 55 | 59 | else if(boost::iequals(request,"thumbnail") || boost::iequals(request,"getthumbnail")) |
| 56 | 60 | { |
| 57 | 61 | writeThumbnail(context,params, project); | ... | ... |
| ... | ... | @@ -156,11 +156,11 @@ namespace DmpWms |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | double minx,miny,maxx,maxy; |
| 159 | - int i =0; | |
| 160 | - std::map<std::string, DmpMapLayer*> mapLayers = project->mapLayers(); | |
| 161 | - for (std::map<std::string, DmpMapLayer*>::iterator iter = mapLayers.begin();iter != mapLayers.end(); iter++) | |
| 159 | + | |
| 160 | + std::vector<DmpMapLayer*> vectorLayers = project->vectorLayers(); | |
| 161 | + for (int i=0; i<vectorLayers.size(); i++) | |
| 162 | 162 | { |
| 163 | - DmpMapLayer* layer = iter->second; | |
| 163 | + DmpMapLayer* layer = vectorLayers[i]; | |
| 164 | 164 | if(i ==0) |
| 165 | 165 | { |
| 166 | 166 | minx = layer->extent().xmin(); |
| ... | ... | @@ -175,9 +175,8 @@ namespace DmpWms |
| 175 | 175 | if(maxx < layer->extent().xmax()) maxx = layer->extent().xmax(); |
| 176 | 176 | if(maxy < layer->extent().ymax()) maxy = layer->extent().ymax(); |
| 177 | 177 | } |
| 178 | - i++; | |
| 179 | 178 | } |
| 180 | - | |
| 179 | + | |
| 181 | 180 | boost::property_tree::ptree ptGeographicBoundingbox; |
| 182 | 181 | ptGeographicBoundingbox.add("westBoundLongitude", minx); |
| 183 | 182 | ptGeographicBoundingbox.add("eastBoundLongitude", maxx); |
| ... | ... | @@ -203,9 +202,9 @@ namespace DmpWms |
| 203 | 202 | } |
| 204 | 203 | ptProject.add_child("BoundingBox",ptBoundingbox); |
| 205 | 204 | |
| 206 | - for (std::map<std::string, DmpMapLayer*>::iterator iter= mapLayers.begin();iter != mapLayers.end(); iter++) | |
| 205 | + for (int i=0; i<vectorLayers.size(); i++) | |
| 207 | 206 | { |
| 208 | - DmpMapLayer* layer = iter->second; | |
| 207 | + DmpMapLayer* layer = vectorLayers[i]; | |
| 209 | 208 | addCapabilitiesLayer(ptProject, layer,srs); |
| 210 | 209 | } |
| 211 | 210 | pt.add_child("Layer", ptProject); | ... | ... |
| ... | ... | @@ -22,7 +22,9 @@ namespace DmpWms |
| 22 | 22 | string exception = WmsGetMap(context,params, project,projectSettings); |
| 23 | 23 | if(exception.length() >0) |
| 24 | 24 | { |
| 25 | - | |
| 25 | + context.response()->removeHeader("Content-Type"); | |
| 26 | + context.response()->setHeader("Content-Type", "text/json"); | |
| 27 | + context.response()->writeJson(exception); | |
| 26 | 28 | } |
| 27 | 29 | } |
| 28 | 30 | |
| ... | ... | @@ -32,7 +34,6 @@ namespace DmpWms |
| 32 | 34 | { |
| 33 | 35 | try |
| 34 | 36 | { |
| 35 | - | |
| 36 | 37 | double boxX1, boxY1, boxX2, boxY2; |
| 37 | 38 | std::string srs = params.Srs(); |
| 38 | 39 | std::string recbox = params.BBox(); |
| ... | ... | @@ -70,6 +71,7 @@ namespace DmpWms |
| 70 | 71 | else |
| 71 | 72 | { |
| 72 | 73 | char strlayers[1000] = {0}; |
| 74 | + boost::to_lower(layers); | |
| 73 | 75 | strcpy(strlayers,(char *)layers.c_str()); |
| 74 | 76 | mapRenderer.AddWmsMapLayers(project, strlayers); |
| 75 | 77 | } |
| ... | ... | @@ -92,6 +94,76 @@ namespace DmpWms |
| 92 | 94 | } |
| 93 | 95 | } |
| 94 | 96 | |
| 97 | + | |
| 98 | + void writeGetMapLog(const DmpServerContext &context, const DmpWmsParameters& params, | |
| 99 | + const DmpProject* project, bool projectSettings) | |
| 100 | + { | |
| 101 | + try | |
| 102 | + { | |
| 103 | + | |
| 104 | + double boxX1, boxY1, boxX2, boxY2; | |
| 105 | + std::string srs = params.Srs(); | |
| 106 | + std::string recbox = params.BBox(); | |
| 107 | + | |
| 108 | + int width = params.Width(); | |
| 109 | + int height = params.Height(); | |
| 110 | + std::string layerDefs = params.layerDefs(); | |
| 111 | + std::string regionDefs = params.regionDefs(); | |
| 112 | + std::map<std::string, std::string> mapLayerDefs; | |
| 113 | + std::map<std::string, std::string> mapRegionDefs; | |
| 114 | + StrDefs2Map(mapLayerDefs,layerDefs); | |
| 115 | + StrDefs2Map(mapRegionDefs,regionDefs); | |
| 116 | + | |
| 117 | + stringstream stream; | |
| 118 | + stream << "<getmaplog>"; | |
| 119 | + | |
| 120 | + if (boost::iequals(srs, "CRS:84")|| boost::iequals(srs, "EPSG:4326")) | |
| 121 | + { | |
| 122 | + sscanf(recbox.c_str(), "%lf,%lf,%lf,%lf", &boxY1, &boxX1, &boxY2, &boxX2); | |
| 123 | + } | |
| 124 | + else | |
| 125 | + { | |
| 126 | + sscanf(recbox.c_str(), "%lf,%lf,%lf,%lf", &boxX1, &boxY1, &boxX2, &boxY2); | |
| 127 | + } | |
| 128 | + | |
| 129 | + | |
| 130 | + //stbstb:应该检查大量地方的 width和height不为零 ,char* regionDefs | |
| 131 | + if (width <= 0 || height <= 0) return ;// "width和height 参数错误"; | |
| 132 | + if (width > 8000 || height > 6000) return ;// "参数错误,图片大小 宽不能大于8000像素 高大于6000像素"; | |
| 133 | + | |
| 134 | + DmpWms::DmpWmsRenderer mapRenderer(height, width); | |
| 135 | + | |
| 136 | + std::string layers = params.Layers(); | |
| 137 | + if (layers =="") | |
| 138 | + { | |
| 139 | + mapRenderer.AddWmsMapLayers(project); | |
| 140 | + } | |
| 141 | + else | |
| 142 | + { | |
| 143 | + char strlayers[1000] = {0}; | |
| 144 | + boost::to_lower(layers); | |
| 145 | + strcpy(strlayers,(char *)layers.c_str()); | |
| 146 | + mapRenderer.AddWmsMapLayers(project, strlayers); | |
| 147 | + } | |
| 148 | + | |
| 149 | + | |
| 150 | + shared_ptr<Rect> rect (new Rect(boxY2, boxX2, boxY1, boxX1)); | |
| 151 | + mapRenderer.SetExtent(rect); | |
| 152 | + mapRenderer.GetMapLog(stream, &mapLayerDefs,&mapRegionDefs); | |
| 153 | + stream << "</getmaplog>"; | |
| 154 | + string responseData = stream.str(); | |
| 155 | + | |
| 156 | + context.response()->removeHeader("Content-Type"); | |
| 157 | + context.response()->setHeader("Content-Type", "text/xml"); | |
| 158 | + context.response()->write(responseData); | |
| 159 | + } | |
| 160 | + catch (const std::exception &e) | |
| 161 | + { | |
| 162 | + std::cerr << " GetMap " << e.what() << '\n'; | |
| 163 | + //return e.what(); | |
| 164 | + } | |
| 165 | + } | |
| 166 | + | |
| 95 | 167 | void writeThumbnail(const DmpServerContext &context,const DmpWmsParameters& params, |
| 96 | 168 | const DmpProject* project,bool projectSettings) |
| 97 | 169 | { | ... | ... |
| ... | ... | @@ -24,6 +24,9 @@ namespace DmpWms |
| 24 | 24 | void writeGetMap(const DmpServerContext &context,const DmpWmsParameters& params, |
| 25 | 25 | const DmpProject* project, |
| 26 | 26 | bool projectSettings = false ); |
| 27 | + void writeGetMapLog(const DmpServerContext &context,const DmpWmsParameters& params, | |
| 28 | + const DmpProject* project, | |
| 29 | + bool projectSettings = false ); | |
| 27 | 30 | std::string WmsGetMap(const DmpServerContext &context,const DmpWmsParameters& params, |
| 28 | 31 | const DmpProject* project, |
| 29 | 32 | bool projectSettings = false ); | ... | ... |
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | #include <boost/property_tree/ptree.hpp> |
| 10 | 10 | #include <boost/property_tree/xml_parser.hpp> |
| 11 | 11 | #include <boost/typeof/typeof.hpp> |
| 12 | +#include <boost/algorithm/algorithm.hpp> | |
| 13 | +#include <boost/algorithm/string/case_conv.hpp> | |
| 12 | 14 | #include "dmpwmsrenderer.h" |
| 13 | 15 | #include "dmpmapserverutil.h" |
| 14 | 16 | #include <sstream> |
| ... | ... | @@ -45,7 +47,6 @@ namespace DmpWms |
| 45 | 47 | pRasterBufferObj = rb; |
| 46 | 48 | |
| 47 | 49 | oneInchInLayoutUnits = 0.0254; |
| 48 | - | |
| 49 | 50 | m_dHeight = height; |
| 50 | 51 | m_dWidth = width; |
| 51 | 52 | m_vLayers = {}; |
| ... | ... | @@ -628,11 +629,10 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ |
| 628 | 629 | |
| 629 | 630 | bool DmpWmsRenderer::AddWmsMapLayers(const DmpProject *project) //插入型加入 |
| 630 | 631 | { |
| 631 | - std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers(); | |
| 632 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); | |
| 633 | - iter != mapLayers.end(); iter++) | |
| 632 | + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers(); | |
| 633 | + for (int i =0;i< vectorLayers.size(); i++) | |
| 634 | 634 | { |
| 635 | - this->AddMapLayer(-1, (DmpVectorLayer *)iter->second); | |
| 635 | + this->AddMapLayer(-1, (DmpVectorLayer*)vectorLayers[i]); | |
| 636 | 636 | } |
| 637 | 637 | return true; |
| 638 | 638 | } |
| ... | ... | @@ -669,13 +669,17 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ |
| 669 | 669 | i++; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - std::map<std::string, DmpMapLayer *> mapLayers = project->mapLayers(); | |
| 673 | - for (std::map<std::string, DmpMapLayer *>::iterator iter = mapLayers.begin(); | |
| 674 | - iter != mapLayers.end(); iter++) | |
| 672 | + | |
| 673 | + | |
| 674 | + std::vector<DmpMapLayer *> vectorLayers = project->vectorLayers(); | |
| 675 | + for (std::vector<DmpMapLayer *>::iterator iter = vectorLayers.begin(); | |
| 676 | + iter != vectorLayers.end(); iter++) | |
| 675 | 677 | { |
| 676 | - if (set_layer.find(iter->first) != set_layer.end()) | |
| 678 | + std::string lowname = (*iter)->name(); | |
| 679 | + boost::to_lower(lowname); | |
| 680 | + if (set_layer.find(lowname) != set_layer.end()) | |
| 677 | 681 | { |
| 678 | - this->AddMapLayer(-1, (DmpVectorLayer *)iter->second); | |
| 682 | + this->AddMapLayer(-1, (DmpVectorLayer *)(*iter)); | |
| 679 | 683 | } |
| 680 | 684 | } |
| 681 | 685 | |
| ... | ... | @@ -848,7 +852,8 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ |
| 848 | 852 | } |
| 849 | 853 | return true; |
| 850 | 854 | } |
| 851 | - /* | |
| 855 | + | |
| 856 | +/* | |
| 852 | 857 | bool DmpWmsRenderer::DrawData(DataCollection *data, Renderer *renderer, clsCrSurf *pClsCS) |
| 853 | 858 | { |
| 854 | 859 | |
| ... | ... | @@ -915,6 +920,226 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ |
| 915 | 920 | } |
| 916 | 921 | |
| 917 | 922 | //在DC上绘制时是否使用一个临时的 image_surface, 然后拷上去,这样具体的细节处理就没有区别了 |
| 923 | + bool DmpWmsRenderer::GetMapLog(std::stringstream &outputStream, map<string, string> *map_layerDefs, | |
| 924 | + map<string, string> *map_regionDefs, | |
| 925 | + shared_ptr<Rect> pRect, double r__, double x_dis__, double y_dis__) | |
| 926 | + { | |
| 927 | + char buff[500]; | |
| 928 | + sprintf(buff, "<log>layer count =%ld</log>", m_vLayers.size()); | |
| 929 | + outputStream << buff; | |
| 930 | + | |
| 931 | + bool has_regionDefs = false; | |
| 932 | + string strRegionColDefs = ""; | |
| 933 | + string strRegionLayerNameDefs = ""; | |
| 934 | + | |
| 935 | + if (map_regionDefs) | |
| 936 | + { | |
| 937 | + map<string, string>::iterator iter_regionDef = map_regionDefs->begin(); | |
| 938 | + if (iter_regionDef != map_regionDefs->end()) | |
| 939 | + { | |
| 940 | + strRegionColDefs = iter_regionDef->second.c_str(); | |
| 941 | + strRegionLayerNameDefs = iter_regionDef->first.c_str(); | |
| 942 | + has_regionDefs = true; | |
| 943 | + } | |
| 944 | + } | |
| 945 | + | |
| 946 | + for (int i = 0; i < (int)(m_vLayers.size()); i++) | |
| 947 | + { | |
| 948 | + DmpVectorLayer *layer = m_vLayers[i]; | |
| 949 | + sprintf(buff, "<log>draw layer %s</log>", layer->name().c_str()); | |
| 950 | + outputStream << buff; | |
| 951 | + | |
| 952 | + double r1 = layer->minScale(); // * | |
| 953 | + double r2 = layer->maxScale(); // * | |
| 954 | + | |
| 955 | + shared_ptr<Rect> pExtent; | |
| 956 | + if (pRect == NULL) | |
| 957 | + pExtent = m_pExtent; | |
| 958 | + else | |
| 959 | + pExtent = pRect; | |
| 960 | + | |
| 961 | + sprintf(buff,"<log>显示范围 %f,%f,%f,%f </log>", | |
| 962 | + pExtent->m_dLeft, pExtent->m_dBottom, pExtent->m_dTop, pExtent->m_dRight); | |
| 963 | + outputStream << buff; | |
| 964 | + | |
| 965 | + sprintf(buff,"<log>数据范围 %f,%f,%f,%f </log>", | |
| 966 | + layer->extent().xmin(), layer->extent().ymin(), layer->extent().xmax(), layer->extent().ymax() ); | |
| 967 | + outputStream << buff; | |
| 968 | + | |
| 969 | + double x_dis, y_dis; | |
| 970 | + if (r__ == -1) | |
| 971 | + { | |
| 972 | + x_dis = m_dXdis; | |
| 973 | + y_dis = m_dYdis; | |
| 974 | + } | |
| 975 | + else | |
| 976 | + { | |
| 977 | + x_dis = x_dis__; | |
| 978 | + y_dis = y_dis__; | |
| 979 | + } | |
| 980 | + | |
| 981 | + if ((this->m_dScaleDenominator > r1 || this->m_dScaleDenominator < r2 || layer->GetRenderer30() == nullptr)) | |
| 982 | + { | |
| 983 | + sprintf(buff,"<log>draw not Denominator</log>"); | |
| 984 | + outputStream << buff; | |
| 985 | + continue; | |
| 986 | + } | |
| 987 | + | |
| 988 | + const char *strLayerDef = nullptr; | |
| 989 | + bool has_layerDef = false; | |
| 990 | + if (map_layerDefs) | |
| 991 | + { | |
| 992 | + map<string, string>::iterator iter_layerDef = map_layerDefs->find(layer->name()); | |
| 993 | + if (iter_layerDef != map_layerDefs->end()) | |
| 994 | + { | |
| 995 | + has_layerDef = true; | |
| 996 | + strLayerDef = iter_layerDef->second.c_str(); | |
| 997 | + } | |
| 998 | + } | |
| 999 | + | |
| 1000 | + //绘图操作从始至终不传到 maplayer 那一层 | |
| 1001 | + | |
| 1002 | + /*if (layer->featurecount() <= 0) | |
| 1003 | + { | |
| 1004 | + string sql0 = GetCountSQL(ml.get()); | |
| 1005 | + const char *ss0__ = ""; | |
| 1006 | + const char **pmsg0 = &ss0__; | |
| 1007 | + shared_ptr<DmpPgsql> pWorkspace = DataSourcePools::get_instance()->GetWorkspace(layer->source()); | |
| 1008 | + if (pWorkspace == nullptr) | |
| 1009 | + break; | |
| 1010 | + //CWorkspacePoolZero2 Zero(pWorkspacePool, pWorkspace); | |
| 1011 | + shared_ptr<Recordsets> recss0 = pWorkspace->ExecuteBinary(sql0, "", pmsg0); | |
| 1012 | + if (recss0 != NULL) | |
| 1013 | + { | |
| 1014 | + int dataCount = PQntuples(recss0->m_pPGresult); | |
| 1015 | + | |
| 1016 | + sprintf(buff, "<log>read dataCount</log>"); | |
| 1017 | + outputStream << buff; | |
| 1018 | + sprintf(buff, "<log>dataCount=%d</log>", layer->featurecount()); | |
| 1019 | + outputStream << buff; | |
| 1020 | + } | |
| 1021 | + else | |
| 1022 | + { | |
| 1023 | + sprintf(buff, "<log>read dataCount fail</log>"); | |
| 1024 | + outputStream << buff; | |
| 1025 | + return false; | |
| 1026 | + } | |
| 1027 | + } | |
| 1028 | + else | |
| 1029 | + { | |
| 1030 | + sprintf(buff,"<log>dataCount=%d</log>", layer->featurecount())); | |
| 1031 | + outputStream << buff; | |
| 1032 | + } | |
| 1033 | +*/ | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + sprintf(buff,"<log>load data from dababase</log>"); | |
| 1037 | + outputStream << buff; | |
| 1038 | + | |
| 1039 | + string sql = ""; | |
| 1040 | + shared_ptr<DmpVectorThinLayer> pVectorThinLayer = nullptr; | |
| 1041 | + | |
| 1042 | + shared_ptr<DataCollection> data(new DataCollection()); | |
| 1043 | + | |
| 1044 | + if (!has_regionDefs) | |
| 1045 | + { | |
| 1046 | + sql = GetDrawSQL(layer, pExtent.get(), strLayerDef); | |
| 1047 | + } | |
| 1048 | + else | |
| 1049 | + { | |
| 1050 | + sql = GetRegionQuerySQL(layer, pExtent.get(), format("%d", layer->crs().srid()), strRegionLayerNameDefs, strRegionColDefs, strLayerDef); | |
| 1051 | + } | |
| 1052 | + | |
| 1053 | + pVectorThinLayer = layer->GetCurrentScaleTable(1 / this->m_dR); | |
| 1054 | + | |
| 1055 | + string sqlLog = sql; | |
| 1056 | + DmpMapServerUtil::toXmlString(sqlLog); | |
| 1057 | + | |
| 1058 | + sprintf(buff,"<log>sql = %s</log>", sqlLog.c_str()); | |
| 1059 | + outputStream << buff; | |
| 1060 | + | |
| 1061 | + if (sql == "") | |
| 1062 | + continue; | |
| 1063 | + | |
| 1064 | + string tableName = layer->name(); | |
| 1065 | + | |
| 1066 | + if (pVectorThinLayer != nullptr) | |
| 1067 | + { | |
| 1068 | + tableName = pVectorThinLayer->tableName(); | |
| 1069 | + } | |
| 1070 | + | |
| 1071 | + if (tableName.length() > 32) | |
| 1072 | + { | |
| 1073 | + tableName = tableName.substr(32); | |
| 1074 | + } | |
| 1075 | + | |
| 1076 | + const char *ss__ = ""; | |
| 1077 | + const char **pmsg = &ss__; | |
| 1078 | + try | |
| 1079 | + { | |
| 1080 | + | |
| 1081 | + shared_ptr<DmpPgsql> pPgsqlConn = nullptr; | |
| 1082 | + if (pVectorThinLayer == nullptr) | |
| 1083 | + { | |
| 1084 | + pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source()); | |
| 1085 | + } | |
| 1086 | + else | |
| 1087 | + { | |
| 1088 | + pPgsqlConn = DmpPgsqlSourcePools::get_instance()->GetDefaultPgsqlConn(); | |
| 1089 | + } | |
| 1090 | + | |
| 1091 | + if (pPgsqlConn == nullptr) | |
| 1092 | + { | |
| 1093 | + sprintf(buff,"<log>pWorkspace is null</log>"); | |
| 1094 | + outputStream << buff; | |
| 1095 | + break; | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + if (pPgsqlConn->ExecWaitBinary(sql)) | |
| 1099 | + { | |
| 1100 | + sprintf(buff,"<log>从原始图层获取数据</log>"); | |
| 1101 | + outputStream << buff; | |
| 1102 | + if( pPgsqlConn->GetRowCount()) | |
| 1103 | + continue; | |
| 1104 | + | |
| 1105 | + sprintf(buff,"<log>draw success</log>"); | |
| 1106 | + outputStream << buff; | |
| 1107 | + } | |
| 1108 | + else if (pVectorThinLayer != nullptr) | |
| 1109 | + { | |
| 1110 | + /*shared_ptr<DmpPgsql> pPgsqlConn1 = DmpPgsqlSourcePools::get_instance()->GetPgsqlConn(layer->source()); | |
| 1111 | + sprintf(buff,"<log>从抽稀图层获取数据%s</log>", pMapLayerThinning->m_tableName.c_str()); | |
| 1112 | + if (pPgsqlConn1 == nullptr) | |
| 1113 | + break; | |
| 1114 | + if (pPgsqlConn1->ExecWaitBinary(sql)) | |
| 1115 | + { | |
| 1116 | + PGresult *res = pPgsqlConn1->m_pConn->m_pPGresult; | |
| 1117 | + if (PQntuples(res) == 0) | |
| 1118 | + continue; | |
| 1119 | + //data->InitDataCollection(res, shapeType, this->m_dWidth, this->m_dHeight, (int)ml->subset, m_dR, m_dScaleDenominator, x_dis, y_dis); | |
| 1120 | + sprintf(buff,"<log>draw success</log>"); | |
| 1121 | + outputStream << buff; | |
| 1122 | + } | |
| 1123 | + else | |
| 1124 | + { | |
| 1125 | + sprintf(buff,"<log>获取数据失败,找不到图层</log>"); | |
| 1126 | + //DrawText2("获取数据失败,找不到图层" ,pClsSurfThis,10,10); | |
| 1127 | + }*/ | |
| 1128 | + } | |
| 1129 | + } | |
| 1130 | + catch (const std::exception &e) | |
| 1131 | + { | |
| 1132 | + sprintf(buff,"DrawSimpleData"); | |
| 1133 | + std::cerr << "#DrawSimpleData " << e.what() << '\n'; | |
| 1134 | + } | |
| 1135 | + } | |
| 1136 | + | |
| 1137 | + sprintf(buff,"<log>return</log>"); | |
| 1138 | + | |
| 1139 | + return true; | |
| 1140 | + } | |
| 1141 | + | |
| 1142 | + //在DC上绘制时是否使用一个临时的 image_surface, 然后拷上去,这样具体的细节处理就没有区别了 | |
| 918 | 1143 | bool DmpWmsRenderer::GetMap(map<string, string> *map_layerDefs, map<string, string> *map_regionDefs, clsCrSurf *pClsCS, bool isThumbnail, |
| 919 | 1144 | shared_ptr<Rect> pRect, double r__, double x_dis__, double y_dis__) |
| 920 | 1145 | { |
| ... | ... | @@ -1072,17 +1297,7 @@ ST_GeometryFromText('POLYGON((%f %f, %f %f, %f %f, %f %f, %f %f))',%s),\ |
| 1072 | 1297 | |
| 1073 | 1298 | allDataCount += PQntuples(res); |
| 1074 | 1299 | this->DrawSimpleData(data.get(), layer->GetRenderer30().get(), pClsSurfThis); |
| 1075 | - // DrawText(StringHelp::fmt("data %.0fm",(endTime_data - startTime).count()/1000000.0) | |
| 1076 | - // ,pClsSurfThis,10,50); | |
| 1077 | - | |
| 1078 | - /* | |
| 1079 | - DrawText(tableName ,pClsSurfThis,10,100); | |
| 1080 | - | |
| 1081 | - char ptext[100] = {0}; | |
| 1082 | - sprintf(ptext, "count = %d",allDataCount); | |
| 1083 | - DrawText2(ptext ,pClsSurfThis,10,140); | |
| 1084 | - | |
| 1085 | - */ | |
| 1300 | + | |
| 1086 | 1301 | } |
| 1087 | 1302 | else if (pVectorThinLayer != nullptr) |
| 1088 | 1303 | { | ... | ... |
请
注册
或
登录
后发表评论