dmpvectorlayer.h 2.2 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"

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);
  private:
    bool readExtentFromXml_;
    DmpWkbTypes::Type wkbType_ = DmpWkbTypes::Unknown;
    DmpFeatureRenderer *renderer_ = nullptr;
    DmpVectorDataProvider *dataProvider_ = nullptr;
};
#endif //__dmpvectorlayer_h__