提交 4e460711731cc294c86a5ed65c563f2183173f90
Merge branch 'master' of http://gitlab.ctune.cn/DMapServer/DMapServer4.1
正在显示
5 个修改的文件
包含
287 行增加
和
7 行删除
| ... | ... | @@ -24,8 +24,35 @@ SET(DMAP_CORE_SRCS |
| 24 | 24 | dmptilematrixset.cpp |
| 25 | 25 | dmpvectordataprovider.cpp |
| 26 | 26 | dmpvectorlayer.cpp |
| 27 | + dmpvectorthinlayer.cpp | |
| 27 | 28 | dmpvectorlayerrenderer.cpp |
| 28 | 29 | dmpxmlutils.cpp |
| 30 | + | |
| 31 | + renderer/clsMalloc.cpp | |
| 32 | + renderer/clsStruct.cpp | |
| 33 | + renderer/clsJson.cpp | |
| 34 | + renderer/clsXML.cpp | |
| 35 | + renderer/clsUtil.cpp | |
| 36 | + renderer/clsRect.cpp | |
| 37 | + renderer/AppendBuffer.cpp | |
| 38 | + renderer/clsCrSurf.cpp | |
| 39 | + renderer/legendParamater.cpp | |
| 40 | + renderer/DataCollection.cpp | |
| 41 | + | |
| 42 | + renderer/SimpleLineSymbol.cpp | |
| 43 | + renderer/SimpleMarkerSymbol.cpp | |
| 44 | + renderer/TrueTypeMarkerSymbol.cpp | |
| 45 | + renderer/TextSymbol.cpp | |
| 46 | + renderer/SimplePolygonSymbol.cpp | |
| 47 | + | |
| 48 | + # renderer/ScaleDependentRenderer.cpp | |
| 49 | + # renderer/RangeLabelRenderer.cpp | |
| 50 | + renderer/SimpleLabelRenderer.cpp | |
| 51 | + renderer/SimpleRenderer.cpp | |
| 52 | + renderer/Renderer.cpp | |
| 53 | + renderer/ValueMapRendererComponent.cpp | |
| 54 | + renderer/ValueMapRenderer.cpp | |
| 55 | + renderer/GroupRenderer.cpp | |
| 29 | 56 | ) |
| 30 | 57 | |
| 31 | 58 | SET(DMAP_CORE_HDRS |
| ... | ... | @@ -48,8 +75,36 @@ SET(DMAP_CORE_HDRS |
| 48 | 75 | dmptilematrixset.h |
| 49 | 76 | dmpvectordataprovider.h |
| 50 | 77 | dmpvectorlayer.h |
| 78 | + dmpvectorthinlayer.h | |
| 51 | 79 | dmpvectorlayerrenderer.h |
| 52 | 80 | dmpxmlutils.h |
| 81 | + | |
| 82 | + renderer/clsMalloc.h | |
| 83 | + renderer/clsStruct.h | |
| 84 | + renderer/clsJson.h | |
| 85 | + renderer/clsXML.h | |
| 86 | + renderer/clsUtil.h | |
| 87 | + renderer/clsRect.h | |
| 88 | + renderer/AppendBuffer.h | |
| 89 | + renderer/clsCrSurf.h | |
| 90 | + renderer/legendParamater.h | |
| 91 | + renderer/DataCollection.h | |
| 92 | + | |
| 93 | + renderer/SimpleLineSymbol.h | |
| 94 | + renderer/SimpleMarkerSymbol.h | |
| 95 | + renderer/TrueTypeMarkerSymbol.h | |
| 96 | + renderer/TextSymbol.h | |
| 97 | + renderer/SimplePolygonSymbol.h | |
| 98 | + #renderer/RangMapRenderer.h | |
| 99 | + #renderer/RangeMapRenderer.h | |
| 100 | + #renderer/ScaleDependentRenderer.h | |
| 101 | + #renderer/RangeLabelRenderer.h | |
| 102 | + renderer/SimpleLabelRenderer.h | |
| 103 | + renderer/SimpleRenderer.h | |
| 104 | + renderer/Renderer.h | |
| 105 | + renderer/ValueMapRendererComponent.h | |
| 106 | + renderer/ValueMapRenderer.h | |
| 107 | + renderer/GroupRenderer.h | |
| 53 | 108 | ) |
| 54 | 109 | |
| 55 | 110 | INCLUDE_DIRECTORIES( | ... | ... |
| ... | ... | @@ -7,8 +7,10 @@ |
| 7 | 7 | * copyright: 广州城市信息研究所有限公司 |
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | #include "dmpvectorlayer.h" |
| 10 | +#include "dmpxmlutils.h" | |
| 10 | 11 | #include "dmpvectorlayerrenderer.h" |
| 11 | 12 | #include "dmpproviderregistry.h" |
| 13 | +#include "libpq-fe.h" | |
| 12 | 14 | |
| 13 | 15 | DmpVectorLayer::DmpVectorLayer(const std::string &path, |
| 14 | 16 | const std::string &baseName, |
| ... | ... | @@ -37,7 +39,34 @@ DmpMapLayerRenderer *DmpVectorLayer::createMapRenderer(DmpRenderContext &rendere |
| 37 | 39 | |
| 38 | 40 | bool DmpVectorLayer::readXml(const boost::property_tree::ptree &layerNode) |
| 39 | 41 | { |
| 40 | - return false; | |
| 42 | + //id="gzxxd_aabe200b_5b63_4b82_8546_af1fc99e4ec6" name="gzxxd" alias="中学" type="1" | |
| 43 | + // geometry="Point" alwaysShow="true" maxScale="0" maxScale="50000" | |
| 44 | + id_ = layerNode.get<std::string>("<xmlattr>.id"); | |
| 45 | + name_ = layerNode.get<std::string>("<xmlattr>.name"); | |
| 46 | + title_ = layerNode.get<std::string>("<xmlattr>.alias"); | |
| 47 | + boost::property_tree::ptree pExtent = layerNode.get_child("extent"); | |
| 48 | + extent_ = DmpXmlUtils::readRectangle(pExtent); | |
| 49 | + dataSource_ = layerNode.get<std::string>("datasource"); | |
| 50 | + | |
| 51 | + setDataProvider("postgres"); | |
| 52 | + | |
| 53 | + // boost::property_tree::ptree pResourceMetadata = layerNode.get_child("resourcemetadata"); | |
| 54 | + // schema_ = layerNode.get<std::string>("schema"); | |
| 55 | + // geom_ = layerNode.get<std::string>("geom"); | |
| 56 | + // featurecount_ = layerNode.get<unsigned int>("featurecount"); | |
| 57 | + | |
| 58 | + boost::property_tree::ptree pRenderer = layerNode.get_child("renderer"); | |
| 59 | + auto pIter = pRenderer.begin(); | |
| 60 | + if(pIter == pRenderer.end())return false; | |
| 61 | + DmapCore_30::Renderer* renderer_30 = nullptr; | |
| 62 | + DmapCore_30::clsXML::XMLParse(pIter->first, pIter->second, &renderer_30); | |
| 63 | + renderer_30_ = shared_ptr<DmapCore_30::Renderer>(renderer_30); | |
| 64 | + | |
| 65 | + // geom_ = "geom"; | |
| 66 | + // schema_ = "public"; | |
| 67 | + // wkbType_ = DmpWkbTypes::MultiLineString; | |
| 68 | + | |
| 69 | + return true; | |
| 41 | 70 | } |
| 42 | 71 | |
| 43 | 72 | bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) |
| ... | ... | @@ -47,12 +76,11 @@ bool DmpVectorLayer::writeXml(boost::property_tree::ptree &layerNode) |
| 47 | 76 | |
| 48 | 77 | void DmpVectorLayer::setRenderer(DmpFeatureRenderer *renderer) |
| 49 | 78 | { |
| 50 | - | |
| 79 | + | |
| 51 | 80 | } |
| 52 | 81 | |
| 53 | 82 | void DmpVectorLayer::setDataSource(const std::string &dataSource, const std::string &baseName, const std::string &provider, bool loadDefaultStyleFlag) |
| 54 | 83 | { |
| 55 | - | |
| 56 | 84 | DmpWkbTypes::GeometryType geomType = GeometryType(); |
| 57 | 85 | } |
| 58 | 86 | |
| ... | ... | @@ -63,21 +91,100 @@ DmpWkbTypes::GeometryType DmpVectorLayer::GeometryType() const |
| 63 | 91 | |
| 64 | 92 | bool DmpVectorLayer::setDataProvider(std::string const &provider) |
| 65 | 93 | { |
| 94 | + //临时测试使用 | |
| 95 | + PGconn* pPGconn = PQconnectdb(dataSource_.c_str()); | |
| 96 | + ConnStatusType t = PQstatus(pPGconn); | |
| 97 | + if (t != CONNECTION_OK) | |
| 98 | + return false; | |
| 99 | + int re = PQsetClientEncoding(pPGconn, "UTF-8"); | |
| 100 | + | |
| 101 | + std::string sql = "select t.f_geometry_column, t.type ,f_table_schema,t.srid from public.geometry_columns t where lower( t.f_table_name) = lower('" + name_ + "');"; | |
| 102 | + PGresult* pPGresult= PQexec(pPGconn, sql.c_str()); | |
| 103 | + char *sz = PQerrorMessage(pPGconn); | |
| 104 | + if(sz != nullptr && strcmp(sz,"") !=0) | |
| 105 | + { | |
| 106 | + PQfinish(pPGconn); return false; | |
| 107 | + } | |
| 108 | + | |
| 109 | + int rowCount = PQntuples(pPGresult); | |
| 110 | + if(rowCount<1) | |
| 111 | + { | |
| 112 | + PQfinish(pPGconn); return false; | |
| 113 | + } | |
| 114 | + | |
| 115 | + geom_ = PQgetvalue(pPGresult, 0, 0); | |
| 116 | + const char* geomtype = PQgetvalue(pPGresult, 0, 1); | |
| 117 | + schema_ = PQgetvalue(pPGresult, 0, 2); | |
| 118 | + //std::string srid = PQgetvalue(pPGresult, 0, 3); | |
| 119 | + | |
| 120 | + if (!geomtype) | |
| 121 | + return false; | |
| 122 | + if (!strcmp(geomtype, "POINT")) wkbType_ = DmpWkbTypes::Point; | |
| 123 | + else if (!strcmp(geomtype, "MULTIPOINT")) wkbType_ = DmpWkbTypes::MultiPoint; | |
| 124 | + else if (!strcmp(geomtype, "LINESTRING")) wkbType_ = DmpWkbTypes::LineString; | |
| 125 | + else if (!strcmp(geomtype, "MULTILINESTRING"))wkbType_ = DmpWkbTypes::MultiLineString; | |
| 126 | + else if (!strcmp(geomtype, "POLYGON")) wkbType_ = DmpWkbTypes::Polygon; | |
| 127 | + else if (!strcmp(geomtype, "MULTIPOLYGON")) wkbType_ = DmpWkbTypes::MultiPolygon; | |
| 128 | + else if (!strcmp(geomtype, "GEOMETRY")) wkbType_ = DmpWkbTypes::Unknown; | |
| 129 | + PQclear(pPGresult); pPGresult = NULL; | |
| 130 | + PQfinish(pPGconn); | |
| 131 | + | |
| 132 | + return true; | |
| 133 | + | |
| 134 | + | |
| 66 | 135 | providerKey_ = provider; |
| 67 | 136 | delete dataProvider_; |
| 68 | 137 | |
| 69 | - dataProvider_ = dynamic_cast<DmpVectorDataProvider *>(DmpProviderRegistry::Instance()->CreateProvider(provider, dataSource_)); | |
| 138 | + dataProvider_ = dynamic_cast<DmpVectorDataProvider *>(DmpProviderRegistry::Instance(provider)->CreateProvider(provider, dataSource_)); | |
| 70 | 139 | if (!dataProvider_) |
| 71 | 140 | { |
| 72 | 141 | isValid_ = false; |
| 73 | 142 | return false; |
| 74 | 143 | } |
| 75 | - isValid_ = dataProvider_->IsValid(); | |
| 144 | + isValid_ = dataProvider_->IsValid() | |
| 145 | + ; | |
| 76 | 146 | if (!isValid_) |
| 77 | 147 | { |
| 78 | 148 | return false; |
| 79 | 149 | } |
| 80 | 150 | wkbType_ = dataProvider_->WkbType(); |
| 81 | - | |
| 82 | 151 | return true; |
| 83 | -} | |
| \ No newline at end of file | ||
| 152 | +} | |
| 153 | + | |
| 154 | + shared_ptr<DmpVectorThinLayer> DmpVectorLayer::GetCurrentScaleTable(double dx) | |
| 155 | + { | |
| 156 | + | |
| 157 | +/* | |
| 158 | + int outTime = 600; | |
| 159 | + if(this->dataCount >500000 && this->m_pDataset->m_MapLayerThinning.size() ==0) | |
| 160 | + { | |
| 161 | + outTime = 20; | |
| 162 | + } | |
| 163 | + | |
| 164 | + clsLockClass lock(_wlock); | |
| 165 | + time_t now = time(0); | |
| 166 | + //shared_ptr<WMSServer> wmsServer = this->m_mapWmsServer[servicename]; | |
| 167 | + if(now - this->m_pDataset->m_loadMapLayerThinning > outTime) | |
| 168 | + { | |
| 169 | + this->m_pDataset->m_loadMapLayerThinning = now; | |
| 170 | + shared_ptr<Workspace> pWorkspaceDef = DataSourcePools::get_instance()->GetDefaultWorkspace(); | |
| 171 | + | |
| 172 | + this->m_pDataset->InitMapLayerThinning(pWorkspaceDef.get(),this->m_layerName, this->m_dbSource); | |
| 173 | + } | |
| 174 | + else | |
| 175 | + { | |
| 176 | + this->m_pDataset->m_loadMapLayerThinning = now; | |
| 177 | + } | |
| 178 | +*/ | |
| 179 | + | |
| 180 | + for(int i =0; i< this->thinLayers_.size(); i++) | |
| 181 | + { | |
| 182 | + shared_ptr<DmpVectorThinLayer> mapLayerThinning = this->thinLayers_[i]; | |
| 183 | + | |
| 184 | + if(mapLayerThinning->IsCurrentLayer(dx)) | |
| 185 | + { | |
| 186 | + return mapLayerThinning; | |
| 187 | + } | |
| 188 | + } | |
| 189 | + return nullptr; | |
| 190 | + } | |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -15,6 +15,9 @@ |
| 15 | 15 | #include "dmpmaplayer.h" |
| 16 | 16 | #include "dmpwkbtypes.h" |
| 17 | 17 | #include "dmpvectordataprovider.h" |
| 18 | +#include "dmpvectorthinlayer.h" | |
| 19 | +#include "Renderer.h" | |
| 20 | +#include <vector> | |
| 18 | 21 | |
| 19 | 22 | class DmpFeatureRenderer; |
| 20 | 23 | |
| ... | ... | @@ -47,10 +50,29 @@ class CORE_EXPORT DmpVectorLayer : public DmpMapLayer |
| 47 | 50 | void setDataSource(const std::string &dataSource, const std::string &baseName, const std::string &provider, bool loadDefaultStyleFlag); |
| 48 | 51 | DmpWkbTypes::GeometryType GeometryType() const; |
| 49 | 52 | bool setDataProvider(std::string const &provider); |
| 53 | + | |
| 54 | + | |
| 55 | + shared_ptr<DmapCore_30::Renderer> GetRenderer30() { return renderer_30_; } | |
| 56 | + vector<shared_ptr<DmpVectorThinLayer>> thinLayers() const { return thinLayers_; } | |
| 57 | + shared_ptr<DmpVectorThinLayer> GetCurrentScaleTable(double dx); | |
| 58 | + | |
| 59 | + std::string schema() { return schema_;} | |
| 60 | + std::string geom() { return geom_;} | |
| 61 | + std::string wherestr() { return wherestr_;} | |
| 62 | + size_t featurecount(){return featurecount_;} | |
| 50 | 63 | private: |
| 51 | 64 | bool readExtentFromXml_; |
| 52 | 65 | DmpWkbTypes::Type wkbType_ = DmpWkbTypes::Unknown; |
| 53 | 66 | DmpFeatureRenderer *renderer_ = nullptr; |
| 54 | 67 | DmpVectorDataProvider *dataProvider_ = nullptr; |
| 68 | + | |
| 69 | + std::string schema_; | |
| 70 | + std::string geom_; | |
| 71 | + size_t featurecount_; | |
| 72 | + | |
| 73 | + std::string wherestr_; | |
| 74 | + shared_ptr<DmapCore_30::Renderer> renderer_30_ = nullptr; | |
| 75 | + vector<shared_ptr<DmpVectorThinLayer>> thinLayers_; | |
| 76 | + | |
| 55 | 77 | }; |
| 56 | 78 | #endif //__dmpvectorlayer_h__ | ... | ... |
src/core/dmpvectorthinlayer.cpp
0 → 100644
| 1 | +/************************************************************************** | |
| 2 | +* file: dmpvectorthinlayer.cpp | |
| 3 | + | |
| 4 | +* Author: qingxiongf | |
| 5 | +* Date: 2021-12-13 10:05:35 | |
| 6 | +* Email: qingxiongf@chinadci.com | |
| 7 | +* copyright: 广州城市信息研究所有限公司 | |
| 8 | +***************************************************************************/ | |
| 9 | +#include "dmpvectorthinlayer.h" | |
| 10 | + | |
| 11 | +DmpVectorThinLayer::DmpVectorThinLayer(/* args */) | |
| 12 | +{ | |
| 13 | + | |
| 14 | +} | |
| 15 | + | |
| 16 | +DmpVectorThinLayer::~DmpVectorThinLayer() | |
| 17 | +{ | |
| 18 | + | |
| 19 | +} | |
| 20 | + | |
| 21 | + bool DmpVectorThinLayer::IsCurrentLayer(double d) | |
| 22 | +{ | |
| 23 | + if(d > m_ddis) | |
| 24 | + { | |
| 25 | + return true; | |
| 26 | + } | |
| 27 | + return false; | |
| 28 | +} | |
| 29 | + | |
| 30 | +bool DmpVectorThinLayer::Init(double minX, double minY, double maxX, double maxY, int dxCount, int dyCount,std::string tableName) | |
| 31 | +{ | |
| 32 | + m_ddis = std::max( (maxX - minX)/ dxCount, (maxY - minY)/ dyCount); | |
| 33 | + m_tableName = tableName; | |
| 34 | + return true; | |
| 35 | +} | |
| 36 | + | |
| 37 | +bool DmpVectorThinLayer::Init(double dis,std::string tableName) | |
| 38 | +{ | |
| 39 | + m_ddis =dis; | |
| 40 | + m_tableName = tableName; | |
| 41 | + return true; | |
| 42 | +} | |
| 43 | + | |
| 44 | +double DmpVectorThinLayer::GeDisPix() | |
| 45 | +{ | |
| 46 | + return this->m_ddis; | |
| 47 | +} | |
| \ No newline at end of file | ... | ... |
src/core/dmpvectorthinlayer.h
0 → 100644
| 1 | +/************************************************************************** | |
| 2 | +* file: dmpvectorthinlayer.h | |
| 3 | + | |
| 4 | +* Author: qingxiongf | |
| 5 | +* Date: 2021-12-13 10:05:42 | |
| 6 | +* Email: qingxiongf@chinadci.com | |
| 7 | +* copyright: 广州城市信息研究所有限公司 | |
| 8 | +***************************************************************************/ | |
| 9 | + | |
| 10 | +#ifndef __dmpvectorthinlayer_h__ | |
| 11 | +#define __dmpvectorthinlayer_h__ | |
| 12 | + | |
| 13 | +#include "dmap_core.h" | |
| 14 | +#include <string> | |
| 15 | + | |
| 16 | +class CORE_EXPORT DmpVectorThinLayer | |
| 17 | +{ | |
| 18 | + public: | |
| 19 | + DmpVectorThinLayer(/* args */); | |
| 20 | + | |
| 21 | + ~DmpVectorThinLayer(); | |
| 22 | + | |
| 23 | + bool IsCurrentLayer(double d); | |
| 24 | + | |
| 25 | + bool Init(double minX, double minY, | |
| 26 | + double maxX, double maxY, | |
| 27 | + int dxCount, int dyCount, | |
| 28 | + std::string tableName); | |
| 29 | + | |
| 30 | + bool Init(double minX, | |
| 31 | + std::string tableName); | |
| 32 | + | |
| 33 | + double GeDisPix(); | |
| 34 | + | |
| 35 | + std::string tableName()const { return m_tableName;} | |
| 36 | + | |
| 37 | + private: | |
| 38 | + int m_indexLevel; | |
| 39 | + int m_dataCount; | |
| 40 | + double m_dxCount; | |
| 41 | + double m_dyCount; | |
| 42 | + double m_dR; | |
| 43 | + double m_dScaleDenominator; | |
| 44 | + double m_ddis; | |
| 45 | + std::string m_tableName; | |
| 46 | + std::string polygon_area = "geodmap_area"; | |
| 47 | +}; | |
| 48 | + | |
| 49 | +#endif // __dmpvectorthinlayer_h__ | ... | ... |
请
注册
或
登录
后发表评论