dmpmaplayer.h 3.1 KB
/**************************************************************************
* file:              dmpmaplayer.h

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

#ifndef __dmpmaplayer_h__
#define __dmpmaplayer_h__

#include "dmap_core.h"
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
// #include "dmprendercontext.h"
#include "dmpcoordinatereferencesystem.h"
#include "dmpmaplayerrenderer.h"
#include "dmprectangle.h"

class DmpDataProvider;
// class DmpMapLayerRenderer;

enum class DmpMapLayerType : int
{
  VectorLayer,
  RasterLayer,
  TileLayer
};

class CORE_EXPORT DmpMapLayer
{
  public:
    DmpMapLayer(DmpMapLayerType type = DmpMapLayerType::VectorLayer, const std::string &name = "", const std::string &source = "");
    ~DmpMapLayer();
    DmpMapLayer(DmpMapLayer const &) = delete;
    DmpMapLayer &operator = (DmpMapLayer const &) = delete;

    std::string id() const { return id_;}
    std::string name() const { return name_; }
    DmpMapLayerType type() const ;
    std::string source() const;
    DmpRectangle extent() const;
    void setTitle(const std::string &title) { title_ = title; }
    std::string title() const { return title_; }
    void setAbstract(const std::string &abstract) { abstract_ = abstract; }
    std::string abstract() const { return abstract_; }
    void setKeywordList(const std::string &keywordList) { keywordList_ = keywordList; }
    std::string keywordList() const { return keywordList_; }
    DmpCoordinateReferenceSystem crs() const { return crs_;}
    void setCrs( const DmpCoordinateReferenceSystem &srs) { crs_ = srs; }
    double minScale() const { return maxScale_; }
    void setMinScale( double scale ) { maxScale_ = scale; }
    double maxScale() const { return minScale_; }
    void setMaxScale( double scale ) { minScale_ = scale; }
    void setProviderType( const std::string &providerType ) { providerKey_ = providerType; }
    void setExtent(const DmpRectangle &r);

    virtual DmpMapLayerRenderer *createMapRenderer(DmpRenderContext &rendererContext);
    virtual DmpDataProvider *dataProvider();
    virtual bool readXml(const boost::property_tree::ptree &layerNode);
    virtual bool writeXml(boost::property_tree::ptree &layerNode);
    bool writeLayerXml(boost::property_tree::ptree &layerElement) const;

  protected:
    std::string id_;
    std::string name_;
    std::string title_;
    std::string abstract_;
    std::string keywordList_;
    //! Data provider key (name of the data provider)
    std::string providerKey_;
    bool isValid_ = false;
    std::string dataSource_;
    DmpRectangle extent_;

  private:
    std::string GenerateId(const std::string &layerName);
    DmpMapLayerType layerType_;
    DmpCoordinateReferenceSystem crs_;
    double minScale_ = 0;
    double maxScale_ = 100000000;
};

#endif //__dmpmaplayer_h__