|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件: 格式转换类
|
|
|
//主要功能:
|
|
|
// 读取GDBX格式
|
|
|
//
|
|
|
//程序编写: 2024-11-14
|
|
|
//
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
#pragma once
|
|
|
#include ".\otherformat.h"
|
|
|
#include ".\EmbellishBaseLib.h"
|
|
|
#include "afxcoll.h"
|
|
|
#include "..\Layer.h"
|
|
|
#include "..\Xy.h"
|
|
|
#include "..\Utils.h"
|
|
|
|
|
|
#include "..\GdbxDefine.h"
|
|
|
#include "ProjectionLib/Projection.h"
|
|
|
|
|
|
namespace NFormatReader
|
|
|
{
|
|
|
class CGdbxFile :
|
|
|
public CEmbellishBaseLib
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
CGdbxFile(void);
|
|
|
virtual ~CGdbxFile(void);
|
|
|
|
|
|
public:
|
|
|
int Read(CFile& fr, short ver = -1); //XML文件读写
|
|
|
int Read(LPCTSTR lpszPathName, short ver = -1);
|
|
|
|
|
|
int SetMapUnit(int gm_unit);
|
|
|
|
|
|
protected:
|
|
|
int ReadData(CFile& fr, short ver = -1); //XML文件读写(详细字段)
|
|
|
int ReadCoordSys(CFile& fr, short ver, void* pXmlParse); //投影
|
|
|
int ReadMapInfoHead(CFile& fr, short ver, void* pXmlParse); //地图的基本信息
|
|
|
int ReadMeasure(CFile& fr, short ver, void* pXmlParse); //描述地图的度量单位和精度
|
|
|
int ReadSectionSymbols(CFile& fr, short ver); //符号
|
|
|
int ReadSectionLayers(CFile& fr, short ver = -1); //图层路径元素填充
|
|
|
|
|
|
int ReadRectInfo(void* pXmlParse, GDBXRectInfo * info); //读取外框信息
|
|
|
int ReadSectionLayersName(const CString &str); //图层添加
|
|
|
int ReadCustomTool(void* pXmlParse, GDBXCustomTool * info); //符号基本信息
|
|
|
int ReadRectangle(void* pXmlParse, GDBXCustomTool * info); //矩形信息
|
|
|
int ReadEllipse(void* pXmlParse, GDBXCustomTool * info); //椭圆信息(圆)
|
|
|
int ReadPolyline(void* pXmlParse, GDBXCustomTool * info); //折线信息
|
|
|
int ReadPolygon(void* pXmlParse, GDBXCustomTool * info); //多边形信息
|
|
|
int ReadIsoFault(void* pXmlParse, GDBXCustomTool * info); //断层线
|
|
|
|
|
|
int ReadLayers(void* pXmlParse, GDBXLayers * info); //图层总数
|
|
|
int ReadLayer(void* pXmlParse, GDBXLayerInfo * info); //当前图层信息
|
|
|
int ReadLayerInfo(void* pXmlParse, GDBXLayerInfo * info); //当前图层信息
|
|
|
|
|
|
int ReadGridInfo(void* pXmlParse, GDBXLLGridInfo * info); //当前图框(直角网,经纬网)
|
|
|
int ReadText(void* pXmlParse, GDBXTextInfo * info); //当前文字
|
|
|
int ReadText(void* pXmlParse, GDBXAnchor * info); //
|
|
|
int ReadText(void* pXmlParse, GDBXGMFONT * info); //
|
|
|
int ReadLableOffset(void* pXmlParse, GDBXLableOffset * info);
|
|
|
|
|
|
int ReadScale(void* pXmlParse, GDBXScaleInfo * info); //比例尺
|
|
|
|
|
|
int ReadImage(void* pXmlParse, GDBXImageInfo * info); //图片(gif等)
|
|
|
|
|
|
int ReadInserMap(void *pXmlParse, GDBXInserMapInfo *info); //图框GDBX文件名称
|
|
|
|
|
|
int ReadWell(void* pXmlParse, GDBXWellInfo * info); //符号井
|
|
|
|
|
|
int ReadTown(void* pXmlParse, GDBXRectInfo * info); //符号市县
|
|
|
int ReadAnchorT(void* pXmlParse, GDBXRectInfo * info); //
|
|
|
|
|
|
int ReadFontInfo(void* pXmlParse, GDBXFontInfo * info); //字体修饰信息
|
|
|
int ReadFillInfoModify(void* pXmlParse, GDBXFillInfo * info); //个性修饰属性
|
|
|
|
|
|
int ReadSegments(void* pXmlParse, GDBXSegments * info); //线段 多边形相关属性
|
|
|
int ReadSegMemoryBlock(CFile& fr, void* pXmlParse, GDBXMemoryBlock * info); //线段 多边形相关属性(base64 压缩)
|
|
|
|
|
|
vector<GDBXLINETO> ReadBigPts(const GDBXSegments &info); //读取明码2进制数据块
|
|
|
vector<GDBXLINETO> ReadMemoryBlock(const GDBXMemoryBlock &info);
|
|
|
|
|
|
int ReadOilWater(void* pXmlParse, GDBXOilWaterInfo * info); //油水气柱子
|
|
|
int ReadOilWaterGroup(void* pXmlParse, GDBXOilWaterGroupInfo * info); //
|
|
|
|
|
|
int InitMapInfo(const GDBXMapInfo &info);
|
|
|
int InitProjection(const GDBXProjection &pro);
|
|
|
|
|
|
|
|
|
void *DrawGDBXRectF(const GDBXCustomTool &rInfo, const GDBXFillInfo &info); //绘制符号矩形
|
|
|
void *DrawGDBXEllipseF(const GDBXCustomTool &eInfo, const GDBXFillInfo &info); //绘制符号椭圆 圆 圆弧等
|
|
|
void *DrawGDBXPolylineF(const GDBXCustomTool &pInfo, const GDBXFillInfo &info, //绘制符号折线
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo);
|
|
|
void *DrawGDBXPolygonF(const GDBXCustomTool &pInfo, const GDBXFillInfo &info, //绘制符号多边形
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo);
|
|
|
|
|
|
int DrawGDBXRect(const GDBXCustomTool &rInfo, const GDBXFillInfo &info, //绘制矩形
|
|
|
const GDBXLayerInfo &lInfo);
|
|
|
int DrawGDBXEllipse(const GDBXCustomTool &eInfo, const GDBXFillInfo &info, //绘制椭圆 圆 圆弧等
|
|
|
const GDBXLayerInfo &lInfo);
|
|
|
int DrawGDBXPolyline(const GDBXCustomTool &pInfo, const GDBXFillInfo &info, //绘制折线
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo, const GDBXLayerInfo &lInfo);
|
|
|
int DrawGDBXPolygon(const GDBXCustomTool &pInfo, const GDBXFillInfo &info, //绘制多边形
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo, const GDBXLayerInfo &lInfo);
|
|
|
int DrawGDBXIsoFault(const GDBXCustomTool &iInfo, const GDBXFillInfo &info, //绘制断层线
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo, const GDBXLayerInfo &lInfo);
|
|
|
int DrawGDBXIsoLine(const GDBXCustomTool &iInfo, const GDBXFillInfo &info, //绘制名字线
|
|
|
const GDBXSegments &sInfo, const GDBXMemoryBlock &mInfo, const GDBXLayerInfo &lInfo, const GDBXFontInfo &fInfo);
|
|
|
int DrawGDBXGrid(const GDBXLLGridInfo & gInfo, const GDBXFillInfo &info, //图框()
|
|
|
const GDBXGMFONT &xMaInfo, const GDBXGMFONT &xMiInfo, const GDBXGMFONT &yMaInfo,
|
|
|
const GDBXGMFONT &yMiInfo, const GDBXLableOffset &lInfo, const GDBXLayerInfo &layerInfo);
|
|
|
int DrawGDBXScale(const GDBXScaleInfo &sInfo, const GDBXFillInfo &info, //比例尺
|
|
|
const GDBXAnchor &aInfo, const GDBXLayerInfo &layerInfo);
|
|
|
int DrawGDBXImage(const GDBXImageInfo &iInfo, const GDBXFillInfo &info, //图片(gif等)
|
|
|
const GDBXLayerInfo &layerInfo);
|
|
|
|
|
|
int DrawGDBXInserMap(const GDBXInserMapInfo &iInfo, const GDBXFillInfo &info, //图框GDBX文件
|
|
|
const GDBXLayerInfo &layerInfo);
|
|
|
|
|
|
int DrawGDBXText(const GDBXTextInfo &tInfo, const GDBXFillInfo &info, //绘制文字
|
|
|
const GDBXAnchor &aInfo, const GDBXLayerInfo &layerInfo, const GDBXLLGridInfo & gInfo);
|
|
|
int DrawGDBXWell(const GDBXWellInfo &wInfo, const GDBXFontInfo &fInfo, //绘制井图上符号
|
|
|
const GDBXFillInfo & info, const GDBXLayerInfo &layerInfo);
|
|
|
int DrawGDBXTownAnchor(const GDBXTextInfo &textInfo, const GDBXAnchor &aInfo, //绘制市县图上符号
|
|
|
const GDBXAnchor & jaInfo, const GDBXFillInfo & info, const GDBXLayerInfo &layerInfo);
|
|
|
int DrawGDBXLegendAnchor(const GDBXAnchor & jaInfo, const GDBXFillInfo & info, //绘制图列图上符号
|
|
|
const GDBXLayerInfo &layerInfo);
|
|
|
|
|
|
int DrawGDBXJGAnchor(const GDBXRectInfo &aInfo, const GDBXAnchor & jaInfo, //绘制单独符号
|
|
|
const GDBXFillInfo &info, const GDBXLayerInfo &layerInfo);
|
|
|
int DrawGDBXOilWater(const GDBXOilWaterInfo &oilInfo, const GDBXOilWaterGroupInfo &owgInfo,
|
|
|
const GDBXFillInfo &info, const GDBXFontInfo &fInfo, const GDBXLayerInfo &layerInfo); //绘制油水柱子
|
|
|
private:
|
|
|
void DeSerialize(CArchive& ar);
|
|
|
|
|
|
vector<CString> SplitByLine(const CString& input); //Layers 按照 \r\n 分割字符串为多个部分
|
|
|
CString ChangeEncoding(const CString &str, const CString &enc, int type = 0); //编码转换
|
|
|
|
|
|
CString Utf8ToGb2312(const CString& utf8Str, int type = 0); //转码
|
|
|
wchar_t* ReplaceLineBreaks(wchar_t* pWideChar, int type = 0); //去除字符中的\\r\\n
|
|
|
|
|
|
int StringToSize(const CString &str, CSize8 &size); //字符(-202682.400000,4875329.100000)取数据
|
|
|
int StringToRect(const CString &str, CRect8 &rect); //矩形
|
|
|
int StringToRect(const CString &str, CRect8 &rect, int num);
|
|
|
|
|
|
bool IsOutsideModelSpace(double x0, double y0, const CRect8 &rect); //处理不合理坐标值
|
|
|
|
|
|
BYTE* HexStringToByteArray(CString hexString, size_t& byteArraySize);
|
|
|
|
|
|
COLORREF PenColorReverse(uint64_t color);
|
|
|
CString SuperAndSubConversion(CString cmd, int& bScript); //上下标转换(文字)
|
|
|
|
|
|
/**
|
|
|
* libarchive 解压文件
|
|
|
*
|
|
|
* \param gdbxPath gdbx全路径
|
|
|
* \param outPath 解压文件夹全路径 (运行目录)
|
|
|
* \return
|
|
|
*/
|
|
|
int GdbxExtractZip(const CString &gdbxPath, const CString &outPath);
|
|
|
|
|
|
int RemoveAllGDBXFile(); //删除解压后的文件
|
|
|
|
|
|
bool IsDirectoryExist(const CString& path);
|
|
|
private:
|
|
|
struct GDBXInfo
|
|
|
{
|
|
|
int m_version; //读取的版本号
|
|
|
long m_color;
|
|
|
|
|
|
CString m_projection;
|
|
|
CString m_fileEncCoding; //文件编码格式(utf-8)
|
|
|
CString m_gdbxXmlPath; //保存解压后xml临时路径名
|
|
|
|
|
|
double dCentre_x;
|
|
|
double dCentre_y; //符号中心位置
|
|
|
double m_dScaleFactor; //比例因子,当前图件的比例值,1:m_dScaleFactor
|
|
|
CRect8 m_modelSpace;
|
|
|
|
|
|
CProjection m_ExchangeXYZ; //投影
|
|
|
CXy *m_pXyMark; //存储临时符号指针(线段等符号)
|
|
|
CLayer* m_pLayer; //CLayer*CXy
|
|
|
};
|
|
|
|
|
|
GDBXInfo m_info;
|
|
|
|
|
|
};
|
|
|
}; |