dmppgsqlutils.h 2.8 KB
#ifndef __dmppgsqlutils_h__
#define __dmppgsqlutils_h__

#include <iostream>
#include <map>
#include <boost/property_tree/ptree.hpp>
#include <libpq-fe.h>
#include <string>

    //typedef std::map<int,std::map<std::string,std::string>> resMap;
    struct DMapService
    {
        std::string name;
        std::string alias;
        std::string state;
        std::string create_time;
        std::string update_time;
        std::string type; 
        std::string description;
        std::string node;
        std::string service_guid;
        std::string catalog_guid;
    };
    struct DMapWmtsService
    {
        std::string name;
        std::string type;
        std::string vendor;
        std::string crs;
        std::string create_time;
        std::string datasource;
        std::string metadata_url;
        std::string description;
        std::string layername;
        std::string layer_alias;
        std::string layer_tile;
        std::string layer_style;
        std::string layer_format;
        std::string layer_extent;
        std::string layer_description;
        std::string tile_id;
    };
    struct TileScheme
    {
        std::string guid;
        std::string name;
        std::string alias;
        std::string crs;   
        std::string datasource;
        std::string top_left;
        std::string levels;
        std::string update_time;
        std::string dpi;
        std::string rows;
        std::string cols;
        std::string wkt ;
        std::string layer_extent;
    };
    class  DmpPgsqlUtils
    {
    private:
        const char* conn_;       
        PGconn* basepconn_;
        void FinishConnection(PGconn *conn);
        void Reset();
    public:
        DmpPgsqlUtils(const char* strConn_  ,std::string& Msg_);
        DmpPgsqlUtils();
        ~DmpPgsqlUtils();
        
        void do_exit(PGconn *conn_);
        //bool ExecuteQuery(const std::string& sqlstr,resMap& resMap_,std::string& Msg_);
        bool GetDMapServices(std::map<int,DMapService> &dmapServices_,std::string& Msg_);
        bool GetDMapService(DMapService &dmapService_,const std::string& servicename_,std::string& Msg_);
        bool GetDMapwmts(const std::string& serviceGuid_, DMapWmtsService& resWmts_,std::string& Msg_);
        bool GetDMapwmtsFromName(const std::string& serviceName_, DMapWmtsService& resWmts_,std::string& Msg_);
        bool GetTileScheme(const std::string& guid_, TileScheme& tileScheme_,std::string& Msg_);
        bool CreatServerPTree(const DMapService &dmapServices_,const DMapWmtsService& resWmts_,boost::property_tree::ptree& pt_root);
        bool GetDMapServices(DMapService &dmapService_,const std::string serviceName_,std::string& Msg_);
        std::string StringToVendor(const std::string str);
    };
    
    


#endif //__dmpwmtsutils_h__