dmpvectorlayer.h 2.9 KB
/**************************************************************************
* file:              dmpvectorlayer.h

* Author:            wanzhongping
* Date:              2021-07-05 16:36:44
* Email:             zhongpingw@chinadci.com
* copyright:         广州城市信息研究所有限公司
***************************************************************************/

#ifndef __dmpvectorlayer_h__
#define __dmpvectorlayer_h__

#include "dmap_core.h"
#include "dmprendercontext.h"
#include "dmpmaplayer.h"
#include "dmpwkbtypes.h"
#include "dmpvectordataprovider.h"
#include "dmpvectorthinlayer.h"
#include "Renderer.h"
#include <vector>

class DmpFeatureRenderer;

class CORE_EXPORT DmpVectorLayer : public DmpMapLayer
{
  public:
    struct LayerOptions
    {
      explicit LayerOptions( bool loadDefaultStyle = true,
                             bool readExtentFromXml = false )
        : loadDefaultStyle( loadDefaultStyle )
        , readExtentFromXml( readExtentFromXml )
      {}

      bool loadDefaultStyle = true;
      bool readExtentFromXml = false;
      DmpWkbTypes::Type fallbackWkbType = DmpWkbTypes::Unknown;
      bool skipCrsValidation = false;
    };

    explicit DmpVectorLayer(const std::string &path = "", const std::string &baseName = "",
                            const std::string &providerKey = "ogr", const DmpVectorLayer::LayerOptions &options = DmpVectorLayer::LayerOptions());
    ~DmpVectorLayer();
    DmpMapLayerRenderer *createMapRenderer(DmpRenderContext &rendererContext);
    bool readXml(const boost::property_tree::ptree &layerNode);
    bool writeXml(boost::property_tree::ptree &layerNode);

    DmpFeatureRenderer *renderer() { return renderer_; }
    void setRenderer(DmpFeatureRenderer *renderer);
    void setDataSource(const std::string &dataSource, const std::string &baseName, const std::string &provider, bool loadDefaultStyleFlag);
    DmpWkbTypes::GeometryType GeometryType() const;
    bool setDataProvider(std::string const &provider);
   

    shared_ptr<DmapCore_30::Renderer> GetRenderer30() { return renderer_30_; }
    vector<shared_ptr<DmpVectorThinLayer>> thinLayers() const { return thinLayers_; }
    shared_ptr<DmpVectorThinLayer> GetCurrentScaleTable(double dx);

    std::string  schema() { return schema_;}
    std::string  geom()  { return geom_;} 
    std::string  wherestr() { return wherestr_;} 
    size_t featurecount(){return featurecount_;}
  private:
    bool readExtentFromXml_;
    DmpWkbTypes::Type wkbType_ = DmpWkbTypes::Unknown;
    DmpFeatureRenderer *renderer_ = nullptr;
    DmpVectorDataProvider *dataProvider_ = nullptr;

    std::string  schema_;
    std::string  geom_;
    size_t featurecount_;

    std::string wherestr_;
    shared_ptr<DmapCore_30::Renderer> renderer_30_ = nullptr;
    vector<shared_ptr<DmpVectorThinLayer>> thinLayers_;
    
};
#endif //__dmpvectorlayer_h__