|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
//文件: 格式转换类
|
|
|
//主要功能:
|
|
|
// 转换MapGis的明码与二进制格式
|
|
|
//
|
|
|
//程序编写: 2008-7-09
|
|
|
//
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
#include "otherformat.h"
|
|
|
#include "afxtempl.h"
|
|
|
#include ".\symbolbaselib.h"
|
|
|
#include "DrawOperator\curveex.h"
|
|
|
|
|
|
namespace NFormatReader
|
|
|
{
|
|
|
|
|
|
namespace NMapGisReader
|
|
|
{
|
|
|
|
|
|
//颜色库
|
|
|
class CMGColorLib
|
|
|
{
|
|
|
public:
|
|
|
CMGColorLib();
|
|
|
|
|
|
BOOL Read(LPCTSTR lpszColorFile);
|
|
|
BOOL Write(LPCTSTR lpszColorFile, LPCTSTR lpDefaultColorFile);
|
|
|
BOOL WriteColorDFD(LPCTSTR lpszFileName);
|
|
|
|
|
|
BOOL CreateColorFillCurve(void* pxy);
|
|
|
|
|
|
void SortColorWithID(void);
|
|
|
|
|
|
void GetColorMap(CMap<DWORD, DWORD, int, int>& arrColorMap);
|
|
|
void SetColorMap(CMap<DWORD, DWORD, int, int>& arrColorMap, bool bResetID);
|
|
|
|
|
|
//根据颜色值排序,排序后可根据颜色值二分法快速查找
|
|
|
void SortColorWithColor(void);
|
|
|
int FindColorID(COLORREF col); //二分法快速查找,需要先根据颜色值排序
|
|
|
|
|
|
int Add(int nID, COLORREF col);
|
|
|
COLORREF GetColor(int nIndex);
|
|
|
|
|
|
// MapGis颜色为CMYK结构,按K、C、M、Y 顺序存储,每个分量一个字节,共四个字节
|
|
|
struct stuColorCMYK
|
|
|
{
|
|
|
BYTE k,c,m,y;
|
|
|
};
|
|
|
|
|
|
class CMGColorItem
|
|
|
{
|
|
|
public:
|
|
|
CMGColorItem(void);
|
|
|
|
|
|
long m_nColorID; //颜色索引号,基于1开始
|
|
|
stuColorCMYK color; //颜色值
|
|
|
|
|
|
int ReadColor(CFile& fr);
|
|
|
int WriteColor(CFile& fw);
|
|
|
|
|
|
CString GetMessage(int nIndex);
|
|
|
COLORREF GetColor();
|
|
|
void SetColor(COLORREF col);
|
|
|
};
|
|
|
CArray<CMGColorItem, CMGColorItem> arrColor;
|
|
|
|
|
|
protected:
|
|
|
static int _compare_MapGis_ArrayID(const void *d1,const void *d2);
|
|
|
static int _compare_MapGis_ArrayColor(const void *d1,const void *d2);
|
|
|
};
|
|
|
|
|
|
//符号库(子图库)
|
|
|
class CMGSymbolLib : public CSymbolBaseLib
|
|
|
{
|
|
|
public:
|
|
|
CMGSymbolLib();
|
|
|
virtual ~CMGSymbolLib();
|
|
|
|
|
|
virtual BOOL Read(LPCTSTR lpszFileName);
|
|
|
|
|
|
struct stuElementHead // 图元描述,每个占10个字节
|
|
|
{
|
|
|
short type; // 图元类别(=0)
|
|
|
short FillColor; // 填充颜色
|
|
|
short LineColor; // 轮廓线颜色(未用)
|
|
|
short LineWidth; // 轮廓线宽度(未用) (宽度序号:0=0.05毫米,2=0.08,3=0.1,…,9=0.4,10=0.5)
|
|
|
short SubElementCount; // 组成边界的弧段个数
|
|
|
};
|
|
|
struct stuOneElement
|
|
|
{
|
|
|
stuElementHead head;
|
|
|
|
|
|
short *eleArcCoorNum; //每个弧段的坐标点数,仅当类型为填充区域或折线时有用
|
|
|
int eleArcCoorNumTotal; //所有弧段的总坐标点数
|
|
|
};
|
|
|
|
|
|
CMGColorLib* m_pColorLib; //颜色库,由外部指定
|
|
|
|
|
|
protected:
|
|
|
void* ReadOneSymbol(CFile& fr); //读取一个符号的内容,返回CXy*指针
|
|
|
COLORREF GetColor(int nIndex);
|
|
|
void AddArcLine(void* pxy, stuOneElement* pOneElement, float* pCoorAll);
|
|
|
double GetLineWidth(int nIndex);
|
|
|
};
|
|
|
|
|
|
//线型符号库
|
|
|
class CMGLineTypeLib : public CMGSymbolLib
|
|
|
{
|
|
|
public:
|
|
|
CMGLineTypeLib(void);
|
|
|
virtual ~CMGLineTypeLib(void);
|
|
|
|
|
|
struct stuDataInfo
|
|
|
{
|
|
|
int dataOffset; //表示辅助线型索引数据的起始位置
|
|
|
short eleNum; //表示辅助线型的个数
|
|
|
};
|
|
|
virtual BOOL Read(LPCTSTR lpszFileName);
|
|
|
void* ReadOneLineType(CFile& fr, stuDataInfo* pInfo);
|
|
|
};
|
|
|
|
|
|
//图案填充库
|
|
|
class CMGFillGrphLib : public CMGSymbolLib
|
|
|
{
|
|
|
public:
|
|
|
CMGFillGrphLib(void);
|
|
|
virtual ~CMGFillGrphLib(void);
|
|
|
|
|
|
virtual BOOL Read(LPCTSTR lpszFileName);
|
|
|
};
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
//工作区文件MPJ中使用到的结构定义
|
|
|
|
|
|
/***********************************************
|
|
|
// 注意:设置结构成员对齐方式为单字节(/Zp1),或用宏#pragma pack(1)
|
|
|
//***********************************************/
|
|
|
#pragma pack(1)
|
|
|
|
|
|
//双精度矩形
|
|
|
struct MapGisRect8
|
|
|
{
|
|
|
double x1;
|
|
|
double y1;
|
|
|
double x2;
|
|
|
double y2;
|
|
|
};
|
|
|
|
|
|
// MapGis环境
|
|
|
struct MapGisEnv
|
|
|
{
|
|
|
char clib[128]; //汉字库目录
|
|
|
char sys[128]; //系统目录
|
|
|
char cur[128]; //当前工作目录
|
|
|
char temp[128]; //临时工作目录(工作区使用)
|
|
|
char slib[128]; //系统库目录
|
|
|
};
|
|
|
|
|
|
////1、坐标系类型(MAP_PARA结构的type字段值)
|
|
|
enum EMapGis_CoorType
|
|
|
{
|
|
|
COOR_CUSTOM = 0, /*用户自定义坐标系*/
|
|
|
COOR_JWD = 1, /*地理坐标系*/
|
|
|
COOR_BL = 2, /*大地坐标系*/
|
|
|
COOR_PRJ = 3, /*投影平面直角坐标系*/
|
|
|
COOR_XYZ = 4 /*地心大地直角坐标系*/
|
|
|
};
|
|
|
|
|
|
////2、坐标单位(MapGisMap结构的unit字段值)
|
|
|
////2.1 长度单位
|
|
|
enum EMapGis_UnitType
|
|
|
{
|
|
|
MG_UNIT_MM =0x00, //毫米
|
|
|
MG_UNIT_MilliMeter =0x01, //毫米
|
|
|
MG_UNIT_Meter =0x02, //米
|
|
|
MG_UNIT_Second =0x03, //秒
|
|
|
MG_UNIT_Degree =0x04, //度
|
|
|
MG_UNIT_DMS =0x05, //度分秒,即±DDDMMSS.SSSS格式
|
|
|
MG_UNIT_Foot =0x06, //英尺
|
|
|
MG_UNIT_Minute =0x07, //分(60分之一度)
|
|
|
MG_UNIT_Radian =0x08, //弧度
|
|
|
MG_UNIT_GRAD =0x09, //梯度 1梯度=0.015707963267949弧度
|
|
|
|
|
|
MG_UNIT_KM =0x0A, //公里
|
|
|
MG_UNIT_DM =0x0B, //分米
|
|
|
MG_UNIT_CM =0x0C, //厘米
|
|
|
|
|
|
MG_UNIT_Inch =0x0D, //英寸
|
|
|
MG_UNIT_Yard =0x0E, //码
|
|
|
MG_UNIT_SeaMile =0x0F, //海里
|
|
|
MG_UNIT_Mile =0x10 //英里
|
|
|
};
|
|
|
//
|
|
|
////2.2 面积单位
|
|
|
//#define UNIT_SQ_MM 0x20 //平方毫米(Square Millimeter)
|
|
|
//#define UNIT_SQ_CM 0x21 //平方厘米(Square Centimeter)
|
|
|
//#define UNIT_SQ_DM 0x22 //平方分米(Square Millimeter)
|
|
|
//#define UNIT_SQ_M 0x23 //平方米(Square DeciMeter)
|
|
|
//#define UNIT_SQ_KM 0x24 //平方公里(Square KiloMeter)
|
|
|
//#define UNIT_SQ_Inch 0x25 //平方英寸(Square Inch)
|
|
|
//#define UNIT_SQ_Foot 0x26 //平方英尺(Square Foot)
|
|
|
//#define UNIT_SQ_Yard 0x27 //平方码(Square Yard)
|
|
|
//#define UNIT_Are 0x28 //公亩(Are)
|
|
|
//#define UNIT_Acre 0x29 //英亩(Acre)
|
|
|
//#define UNIT_Hectare 0x2A //公顷(Hectare)
|
|
|
//#define UNIT_SQ_Mile 0x2B //平方英里(Square Mile)
|
|
|
//
|
|
|
////2.3 体积单位
|
|
|
//#define UNIT_CU_MM 0x40 //立方毫米(Cubic Millimeter)
|
|
|
//#define UNIT_CU_CM 0x41 //立方厘米(Cubic Centimeter)
|
|
|
//#define UNIT_CU_DM 0x42 //立方分米(Cubic Millimeter)
|
|
|
//#define UNIT_CU_M 0x43 //立方米(Cubic DeciMeter)
|
|
|
//#define UNIT_CU_Inch 0x45 //立方英寸(Cubic Inch)
|
|
|
//#define UNIT_CU_Foot 0x46 //立方英尺(Cubic Foot)
|
|
|
//#define UNIT_CU_Yard 0x47 //立方码(Cubic Yard)
|
|
|
//
|
|
|
////3、参考椭球体参数类型(MAP_PARA结构的earthParam字段值)
|
|
|
enum EMapGis_EarthType
|
|
|
{
|
|
|
EP_UnDefine =0, //未指定"参考椭球体参数类型"
|
|
|
EP_Beijing54 =1, //" 1:北京54/克拉索夫斯基(1940年)椭球", //"Krasovsky"
|
|
|
EP_Xian80 =2, //" 2:西安80/1975 年I.U.G.G推荐椭球 ",
|
|
|
EP_IUGG1979 =3, //" 3:1979 年I.U.G.G推荐椭球 ",
|
|
|
EP_IUGG1983 =4, //" 4:1983 年I.U.G.G推荐椭球",
|
|
|
EP_UserDefine =5, //" 5:新的椭球参数(自定义) ",
|
|
|
EP_IUGG1967 =6, //" 6:1967 年I.U.G.G推荐椭球",
|
|
|
EP_WGS84 =7, //" 7:WGS-84 ",
|
|
|
EP_GRS80 =8, //" 8:GRS-80 ",
|
|
|
EP_WGS72 =9, //" 9:WGS-72 ",
|
|
|
EP_Australia =10, //" 10:澳大利亚1965年椭球",
|
|
|
EP_11 =11, //" 11:海福特1910年椭球",
|
|
|
EP_12 =12, //" 12:克拉克1880年椭球",
|
|
|
EP_13 =13, //" 13:克拉克1866年椭球",
|
|
|
EP_14 =14, //" 14:白塞尔1841年椭球",
|
|
|
};
|
|
|
|
|
|
////4、投影类型(MAP_PARA结构的projType字段)
|
|
|
enum EMapGis_ProjType
|
|
|
{
|
|
|
PRJ_LonLat =0, //地理坐标系(经纬度)
|
|
|
PRJ_UTM =1, //通用横向墨卡托投影坐标系(UTM)",
|
|
|
PRJ_Albers_Conical_EQ_Area =2, //亚尔勃斯等积圆锥投影坐标系",ALBERS CONICAL EQUAL AREA
|
|
|
PRJ_Lambert_Conformal_Conic =3, //兰伯特等角圆锥投影坐标系",LAMBERT CONFORMAL CONIC
|
|
|
PRJ_Mercator =4, //墨卡托(正轴等角圆柱)投影坐标系",MERCATOR
|
|
|
PRJ_Gauss_Kruger =5, //高斯-克吕格(横切椭圆柱等角)投影",GAUSS-KRUGER
|
|
|
PRJ_Polyconic =6, //普通多圆锥投影坐标系",POLYCONIC
|
|
|
PRJ_EQ_Dist_Conic =7, //等距圆锥投影坐标系",EQUIDISTANT CONIC
|
|
|
PRJ_Transverse_Mecator =8, //横向墨卡托(横切圆柱等角)投影",TRANSVERSE MECATOR
|
|
|
PRJ_StereoGraphic =9, //球面投影(视点在球面)坐标系",STEREOGRAPHIC
|
|
|
PRJ_Lambert_Azimuthal_EQ_Area =10, //兰伯特等积方位投影坐标系",LAMBERT AZIMUTHAL EQUAL_AREA
|
|
|
PRJ_Azimuthal_EQ_Dist =11, //等距方位投影坐标系",AZIMUTHAL EQUIDISTANT
|
|
|
PRJ_Gnomonic =12, //心射切面(球心)投影坐标系",GNOMONIC
|
|
|
PRJ_Orthographic =13, //正射投影(视点无穷远)坐标系",ORTHOGRAPHIC
|
|
|
PRJ_General_VER_NS_Perspective =14, //通用垂直近距透视(外心)投影",GENERAL VERTICAL NEAR_SIDE PERSPECTIVE
|
|
|
PRJ_Sinusoidal =15, //正弦投影(伪圆柱)坐标系",SINUSOIDAL
|
|
|
PRJ_Equirectangular =16, //等距离切圆柱(方格)投影坐标系",EQUIRECTANGULAR
|
|
|
PRJ_Miller_Cylindrical =17, //米勒圆柱(透视正圆柱)投影坐标系",MILLER CYLINDRICAL
|
|
|
PRJ_V_D_Grinten_I =18, //范德格林顿I投影坐标系",VAN DER GRINTEN I
|
|
|
PRJ_Oblique_Mercator =19, //斜轴墨卡托投影坐标系",OBLIQUE MERCATOR (HOTINE)
|
|
|
PRJ_Polar_Srereographic =20 //极点球面投影坐标系",POLAR SREREOGRAPHIC
|
|
|
};
|
|
|
|
|
|
//地图参数
|
|
|
struct MapGisMap
|
|
|
{
|
|
|
char type; //空间数据:水平坐标系类型
|
|
|
char unit; //空间数据:水平坐标单位,
|
|
|
double mapw; //空间数据:图幅理论宽 type坐标系,unit单位.
|
|
|
double maph; //..................高 type坐标系,unit单位.
|
|
|
|
|
|
char projType; //空间数据:投影类型
|
|
|
char earthParam; //空间数据:参考椭球体参数类型
|
|
|
double jd0; //空间数据:数据左下角经度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double wd0; //空间数据:数据......纬度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double djd; //空间数据:数据经度跨度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double dwd; //空间数据:数据纬度跨度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double rate; //空间数据:数据水平比例尺倒数, 无单位
|
|
|
|
|
|
double lon; //空间数据:中央经线经度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double lon1; //空间数据:双经线1 经度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double lon2; //空间数据:双经线2 经度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double lat; //空间数据:投影原点纬度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double lat1; //空间数据:双纬线1 纬度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double lat2; //空间数据:双纬线2 纬度 , 数据单位统一采用UNIT_DMS格式
|
|
|
double dx; //空间数据:图纸坐标原点在投影坐标系中的X偏移值 ,type坐标系,unit单位.
|
|
|
double dy; //....................................Y偏移 ,type坐标系,unit单位.
|
|
|
|
|
|
char levelType; //空间数据:大地水准面类型
|
|
|
double h; //空间数据:大地水准面与参考椭球面之间的高差, 单位为
|
|
|
double H; //空间数据:投影平面与大地水准面的高差, 单位为
|
|
|
|
|
|
double vRate; //空间数据:垂向比例尺倒数
|
|
|
char vUnit; //空间数据:垂向数据单位
|
|
|
char TICtype; //TIC点理论坐标系类型
|
|
|
char TICunit; //TIC点理论坐标单位
|
|
|
char infoUnit; //图形显示参数单位
|
|
|
double infoRatex; //图形显示参数单位值相对于当前数据单位值的x比例系数, 初始值必须赋0或1
|
|
|
double infoRatey; //........................................y比例系数, 初始值必须赋0或1
|
|
|
};
|
|
|
|
|
|
// MapGis工程
|
|
|
struct MapGisMpj
|
|
|
{
|
|
|
short FileNum; //图层个数
|
|
|
MapGisRect8 Prj_Rect; //图形坐标范围
|
|
|
MapGisEnv Env; //图形环境
|
|
|
char Title[60]; //图形标题
|
|
|
int lLayerDictOffset; //图层字典位置
|
|
|
int lFirstFile; //图层条目开始位置
|
|
|
//输出页面及位置描述
|
|
|
double TranX,TranY; //位移
|
|
|
double ScaleX,ScaleY; //比例
|
|
|
double Angle; //旋转角度
|
|
|
double VerW,VerH; //版面宽高
|
|
|
short PrjType;
|
|
|
int lFirstCLN; //图例条目开始位置
|
|
|
MapGisMap PrjMapParam; //工程预设的地图参数
|
|
|
char UnUsed[128];
|
|
|
};
|
|
|
|
|
|
//工程文件中的图层文件索引信息结构(0x190=400字节)
|
|
|
struct MapGisFile
|
|
|
{
|
|
|
char Filetype; //文件类型(点/线/区/影像)
|
|
|
char FileState; //文件状态(关闭/打开/编辑/当前编辑)
|
|
|
char Filename[128]; //文件名(全路径)
|
|
|
char Describe[128]; //文件的描述
|
|
|
MapGisRect8 rect; //坐标范围
|
|
|
char UserType; //用户自定义类型
|
|
|
char GroupCode; //组代码
|
|
|
char DataSource[32]; //网络数据的数据源(单机文件此项为空)
|
|
|
double MinDispRate; //最小显示比例(<MinDispRate,不显示)
|
|
|
double MaxDispRate; //最大显示比例(>MaxDispRate,不显示)
|
|
|
char NoteFlg; //标志是否进行字段动态标注,以及是否跟随放大
|
|
|
char NoteField[21]; //标注字段名称
|
|
|
float NoteHeight; //标注字高
|
|
|
short NoteColor; //标注颜色
|
|
|
char NoteFont; //标注字体
|
|
|
::byte CLNClassCode; //图例分类信息
|
|
|
char UnUsed[30]; //保留
|
|
|
};
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// 图层文件中的各部分(共16个)数据索引结构
|
|
|
struct MapGisIndex
|
|
|
{
|
|
|
int pos; // 位置偏移量(相对文件开始位置)
|
|
|
int len; // 字节长度
|
|
|
short unknow; // 未知(0xFFFF)
|
|
|
};
|
|
|
|
|
|
//弧段基本数据结构
|
|
|
struct MapGisArc
|
|
|
{
|
|
|
short LineType; // 线型
|
|
|
::byte AuxLineType; // 辅助线型
|
|
|
::byte isTrans; // 是否透明
|
|
|
int LineColor; // 线色
|
|
|
float LineWidth; // 线宽
|
|
|
::byte isSmooth; // 是否平滑(0=折线、1=贝塞尔曲线)
|
|
|
float XParam; // X系数
|
|
|
float YParam; // Y系数
|
|
|
int AuxColor; // 辅助色
|
|
|
short LayerID; // 图层序号
|
|
|
int res0; // 保留(=0)
|
|
|
int res1; // 保留(=0)
|
|
|
int ID; // 弧段的ID
|
|
|
MapGisRect8 rect; // 坐标范围
|
|
|
};
|
|
|
|
|
|
// 区基本数据结构
|
|
|
struct MapGisPoly
|
|
|
{
|
|
|
int FillColor; // 填充颜色
|
|
|
short FillSymbol; // 填充图案
|
|
|
float SymWidth; // 图案宽度
|
|
|
float SymHeight; // 图案高度
|
|
|
int SymColor; // 图案颜色
|
|
|
short LayerID; // 图层序号
|
|
|
::byte isTrans; // 是否透明
|
|
|
short basLN; // 构成斜坡基线的弧段数
|
|
|
long res0; // 保留(=0)
|
|
|
long res1; // 保留(=0)
|
|
|
MapGisRect8 rect; // 坐标范围
|
|
|
};
|
|
|
|
|
|
|
|
|
// 字段属性结构(0x27=39个字节)
|
|
|
struct MapGisField
|
|
|
{
|
|
|
char name[20]; // 字段名称
|
|
|
::byte type; // 字段类型
|
|
|
int offset; // 字段偏移
|
|
|
short len; // 字段长度(字节长度)
|
|
|
short lenc; // 字段长度(字符长度)
|
|
|
::byte prec; // 字段精度(小数位数)
|
|
|
short enable; // 编辑使能标志(0/1/2=不能/能/禁止)
|
|
|
::byte flg; // 打印标志
|
|
|
short ptc_pos; // 字段序号,依次为0,1,2...
|
|
|
int unknow; // 未知(?)
|
|
|
};
|
|
|
|
|
|
// MapGisField结构中enable定义: (0-->0x00FF为MapGis系统保留)
|
|
|
#define MG_FLDEDT_NO 0x0000 //字段可编辑状态,不能
|
|
|
#define MG_FLDEDT_YES 0x0001 //字段可编辑状态,能
|
|
|
#define MG_FLDEDT_FORBID 0x0002 //字段可编辑状态,禁止
|
|
|
#define MG_FLD_VIS 0x0004 //字段可见状态(编辑或浏览时的临时状态)
|
|
|
#define MG_FLD_MSK 0x0008 //字段屏蔽状态
|
|
|
#define MG_FLD_EXT 0x0010 //该字段是扩展类型(TEXT_TYPE--EXT_TYPE)
|
|
|
#define MG_FLD_REPEL 0x0020 //该字段值互异
|
|
|
#define MG_FLD_DBSKEY 0x0040 //该字段是外挂数据库关键字段
|
|
|
#define MG_FLD_EDT (MG_FLDEDT_NO|MG_FLDEDT_YES|MG_FLDEDT_FORBID) /*字段编辑状态*/
|
|
|
|
|
|
////点类型定义
|
|
|
#define PNT_NOTE 0 // 节点/字符串
|
|
|
#define PNT_SUB 1 // 子图/符号
|
|
|
#define PNT_CIR 2 // 圆
|
|
|
#define PNT_ARC 3 // 弧
|
|
|
#define PNT_IMAGE 4 // MSI图像
|
|
|
#define PNT_TEXT 5 // 版面文字
|
|
|
#define PNT_TYPE_NUM 6 // 点类型数
|
|
|
|
|
|
//点基本数据结构
|
|
|
// 正常情况下联合体的长度为最大变量长度的整数倍,
|
|
|
// 下面的联合体最大变量长度为double型,所以该联合体的长度为40个字节,
|
|
|
// 但是由于指定了“#pragma pack(1)”对齐方式为1字节,所以该结构体长度为最大字节数34字节
|
|
|
union infoPoint
|
|
|
{
|
|
|
struct str // 字符串(22 Bytes)
|
|
|
{
|
|
|
float height; //高度
|
|
|
float width; //宽度
|
|
|
float space; //间隔
|
|
|
float angle; //字符串角度,以360度制为单位表示
|
|
|
short ifnt; //中文字体
|
|
|
short chnt; //西文字体
|
|
|
::byte ifnx; //字形:0=正体,1=左斜,2=右斜,3=右耸,4=左耸,64=正体阴影,65=左斜阴影,66=右斜阴影,67=右耸阴影,68=左耸阴影
|
|
|
::byte hvpl; //水平或垂直排列0=水平排列 1=垂直排列
|
|
|
};
|
|
|
struct text // 版面文字(34 Bytes)
|
|
|
{
|
|
|
float height; //高度
|
|
|
float width; //宽度
|
|
|
float space; //字间距(横向间距)
|
|
|
float angle; //以360度制度为单位表示
|
|
|
short ifnt; //中文字体
|
|
|
short chnt; //西文字体
|
|
|
::byte ifnx; //字形:0=正体,1=左斜,2=右斜,3=右耸,4=左耸,64=正体阴影,65=左斜阴影,66=右斜阴影,67=右耸阴影,68=左耸阴影
|
|
|
float lspace; //行间距(纵向间距)
|
|
|
float dx; //版面长
|
|
|
float dy; //版面宽
|
|
|
::byte hvpl; //水平或垂直排列0=水平排列 1=垂直排列
|
|
|
};
|
|
|
struct submap // 子图(24 Bytes)
|
|
|
{
|
|
|
int subno; //子图号
|
|
|
float height; //高度
|
|
|
float width; //宽度
|
|
|
float angle; //角度
|
|
|
float penw; //线宽(未用)
|
|
|
int fclr; //辅助色(未用)
|
|
|
};
|
|
|
struct circle // 圆(17 Bytes)
|
|
|
{
|
|
|
double radiu; //radiu>0, <=0为非法 [float-->double]
|
|
|
int lcol; //边线颜色,填充色为icol [short-->int]
|
|
|
float penw; //线宽(6.0以前为short)
|
|
|
::byte fflag; //4.1版开始 1=填充圆 0=空心圆
|
|
|
};
|
|
|
struct arc // 弧(20 Bytes)
|
|
|
{
|
|
|
double radiu; //radiu>0, <=0为非法 [float-->double]
|
|
|
float begang; //起始角度
|
|
|
float endang; //终止角度
|
|
|
float penw; //线宽度(6.0以前为short)
|
|
|
};
|
|
|
struct image // 图像(20 Bytes)
|
|
|
{
|
|
|
double width; // [float-->double]
|
|
|
double height; // [float-->double]
|
|
|
float angle; //角度(未用)
|
|
|
};
|
|
|
};
|
|
|
|
|
|
struct MapGisPoint
|
|
|
{
|
|
|
::byte type; // 点类型
|
|
|
::byte isTrans; // 是否透明,0=不透明,1=透明
|
|
|
char infoPointData[34]; //联合体数据参数,如果有问题时可以改为40字节
|
|
|
float infoDx; // [new, 点参数偏移dx]
|
|
|
float infoDy; // [new, 点参数偏移dy],如果为40字节时,则定义1个short型变量才能对齐
|
|
|
int iColor; // [short-->int]
|
|
|
int linNo; // 点所属的线号
|
|
|
int layer; // 图层号
|
|
|
short res1; // 保留
|
|
|
short res2; // 保留
|
|
|
short res3; // 保留
|
|
|
};
|
|
|
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
|
// 字符串类型最大长度
|
|
|
#define MG_MAX_STRING_LEN 512
|
|
|
|
|
|
|
|
|
class CMapGisFile :
|
|
|
public COtherFormat
|
|
|
{
|
|
|
public:
|
|
|
CMapGisFile(void);
|
|
|
virtual ~CMapGisFile(void);
|
|
|
|
|
|
BOOL Read(LPCTSTR lpszPathName);
|
|
|
BOOL B_ReadMpj(LPCTSTR lpszPathName); //读取工作区文件
|
|
|
BOOL B_ReadBinary(LPCTSTR lpszPathName);//点(*.wt)、线(*.wl)、区(*.wp)
|
|
|
BOOL A_ReadAscii(LPCTSTR lpszPathName); //点(*.wat)、线(*.wal)、区(*.wap)
|
|
|
|
|
|
protected:
|
|
|
//文本格式
|
|
|
BOOL A_ReadWatPoint(CFile& fr); //点
|
|
|
BOOL A_ReadWalLine(CFile& fr); //线
|
|
|
BOOL A_ReadWapRegion(CFile& fr); //区
|
|
|
|
|
|
CString GetFontName(int nType);
|
|
|
COLORREF GetColor(int nIndex);
|
|
|
|
|
|
virtual void SetCurrentLayer(CString strLayer);
|
|
|
|
|
|
public:
|
|
|
class CMGPoint : public CPoint2D
|
|
|
{
|
|
|
public:
|
|
|
CMGPoint();
|
|
|
~CMGPoint();
|
|
|
|
|
|
CStringArray arrCommand;
|
|
|
int id; //ID号
|
|
|
int type; //类型=0 字符串,1 子图,2 圆,3 弧,4 图象,5 文本
|
|
|
int layer; //图层
|
|
|
int transparen; //透明输出
|
|
|
int color; //颜色
|
|
|
|
|
|
BOOL Read(CFile& fr);
|
|
|
};
|
|
|
|
|
|
class CMGLine //曲线
|
|
|
{
|
|
|
public:
|
|
|
CMGLine();
|
|
|
~CMGLine();
|
|
|
|
|
|
BOOL Read(CFile& fr);
|
|
|
void ClearCurve();
|
|
|
|
|
|
MapGisArc m_par; //曲线参数
|
|
|
|
|
|
bool isValid = false;//是否是有效元素
|
|
|
CCurveEx* m_pCurve; //线坐标及点数
|
|
|
double length; //线长度
|
|
|
|
|
|
protected:
|
|
|
BOOL ReadParameter(CFile& fr);
|
|
|
BOOL ReadCurve(CFile& fr);
|
|
|
};
|
|
|
|
|
|
class CMGLineSegment : public CMGLine //弧段
|
|
|
{
|
|
|
public:
|
|
|
CMGLineSegment();
|
|
|
~CMGLineSegment();
|
|
|
|
|
|
BOOL Read(CFile& fr);
|
|
|
|
|
|
int frontNode; //前节点号
|
|
|
int backNode; //后节点号
|
|
|
|
|
|
int leftRegion; //左区号
|
|
|
int rightRegion; //右区号
|
|
|
};
|
|
|
|
|
|
class CMGNode : public CPoint2D //节点
|
|
|
{
|
|
|
public:
|
|
|
CMGNode();
|
|
|
~CMGNode();
|
|
|
|
|
|
BOOL Read(CFile& fr);
|
|
|
CArray<long,long> m_arrLineSegment; //弧段列表
|
|
|
};
|
|
|
class CMGRegion //区
|
|
|
{
|
|
|
public:
|
|
|
CMGRegion();
|
|
|
~CMGRegion();
|
|
|
|
|
|
BOOL Read(CFile& fr);
|
|
|
CArray<long,long> m_arrLineSegment; //弧段列表
|
|
|
|
|
|
MapGisPoly m_par;
|
|
|
|
|
|
bool isValid; //是否是有效元素
|
|
|
double penWidth; //笔宽
|
|
|
int id; //ID号
|
|
|
double area; //面积
|
|
|
double length; //周长
|
|
|
};
|
|
|
|
|
|
//二进制格式
|
|
|
MapGisIndex m_IndexTable[16];
|
|
|
void B_ReadPoint(CFile& fr, int m_nEle); // 读取点数据
|
|
|
void B_ReadAttData(CFile& fr, int start,int len); // 读取属性数据(文件开始位置,属性数据字节长度)
|
|
|
void B_ReadArcLine(CFile& fr, int m_nArc, CList<CMGLineSegment*, CMGLineSegment*> &lineList); // 读取弧段数据
|
|
|
void B_ReadPoly(CFile& fr, int nPoly, CList<CMGRegion*, CMGRegion*> &polyList); // 读取面数据
|
|
|
|
|
|
void toCurveSolid(CMGRegion& rgn, CPointList& dp);
|
|
|
void toCurveSolid(CMGRegion& rgn, CList<CMGLineSegment*, CMGLineSegment*> &arcLine);
|
|
|
void Clear(CList<CMGLineSegment*, CMGLineSegment*> &line);
|
|
|
void Clear(CList<CMGRegion*, CMGRegion*> &poly);
|
|
|
|
|
|
CMGColorLib m_mgColorLib; //颜色库
|
|
|
CMGSymbolLib m_mgSymbolLib; //符号库
|
|
|
CMGFillGrphLib m_mgFillGrphLib; //填充符号库
|
|
|
CMGLineTypeLib m_mgLineTypeLib; //线型库
|
|
|
|
|
|
int ProcessScript(CString& str);
|
|
|
void WriteColorDFD(LPCTSTR lpszFileName);
|
|
|
CString FindSymbol(int nIndex, COLORREF col);
|
|
|
CString FindFillSymbol(int nIndex, COLORREF col);
|
|
|
void SetMapInfo(MapGisMap& map);
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
using namespace NMapGisReader;
|