|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F>ļ<EFBFBD>: <20><>ʽת<CABD><D7AA><EFBFBD><EFBFBD>
|
|
|
|
|
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>:
|
|
|
|
|
|
// <09><>ȡKML<4D><4C>ʽ
|
|
|
|
|
|
//
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2025-8-21
|
|
|
|
|
|
//
|
|
|
|
|
|
//
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#include ".\otherformat.h"
|
|
|
|
|
|
#include ".\EmbellishBaseLib.h"
|
|
|
|
|
|
#include "afxcoll.h"
|
|
|
|
|
|
#include "..\Layer.h"
|
|
|
|
|
|
#include "..\Xy.h"
|
|
|
|
|
|
#include "..\Utils.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "..\GdbxDefine.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace NFormatReader
|
|
|
|
|
|
{
|
|
|
|
|
|
class CKMLFile
|
|
|
|
|
|
: public CEmbellishBaseLib
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
CKMLFile(void);
|
|
|
|
|
|
virtual ~CKMLFile(void);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
struct KMLInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
double m_dScaleFactor; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><>ǰͼ<C7B0><CDBC><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>ֵ<EFBFBD><D6B5>1<EFBFBD><31>m_dScaleFactor
|
|
|
|
|
|
|
|
|
|
|
|
CString m_kmlXmlns; //kml<6D>汾 Ŀǰ<C4BF><C7B0>2.1 2.2 2.3
|
|
|
|
|
|
CString m_kmlXmlnsA; //kml<6D>汾 Ŀǰ<C4BF><C7B0>2.2 2.3
|
|
|
|
|
|
CString m_kmlXmlnsG; //kml<6D>汾 Ŀǰ<C4BF><C7B0>2.2 2.3
|
|
|
|
|
|
|
|
|
|
|
|
CString m_fileEncCoding; //<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>utf-8<><38>
|
|
|
|
|
|
CRect8 m_modelSpace;
|
|
|
|
|
|
int m_version; //<2F><>ȡ<EFBFBD>İ汾<C4B0><E6B1BE>
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct KMLPoint
|
|
|
|
|
|
{
|
|
|
|
|
|
double x; //<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
|
double y; //γ<><CEB3>
|
|
|
|
|
|
double z; //<2F>߳<EFBFBD>
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct PointStyle
|
|
|
|
|
|
{
|
|
|
|
|
|
double m_scale;
|
|
|
|
|
|
COLORREF m_pointColor;
|
|
|
|
|
|
COLORREF m_lableColor;
|
|
|
|
|
|
|
|
|
|
|
|
COLORREF m_lineColor;//<2F>߶<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ʽҲ<CABD><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2.1<EFBFBD>汾
|
|
|
|
|
|
COLORREF m_polyColor;
|
|
|
|
|
|
|
|
|
|
|
|
CString m_id;
|
|
|
|
|
|
CString m_iconUrl;
|
|
|
|
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_scale = 0;
|
|
|
|
|
|
m_pointColor = -1;
|
|
|
|
|
|
m_lableColor = -1;
|
|
|
|
|
|
m_lineColor = -1;
|
|
|
|
|
|
m_polyColor = -1;
|
|
|
|
|
|
m_id = "";
|
|
|
|
|
|
m_iconUrl = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct KMLStyleMap
|
|
|
|
|
|
{
|
|
|
|
|
|
CString m_id;
|
|
|
|
|
|
CString m_pairKey; //
|
|
|
|
|
|
CString m_pairStyleUrl; //<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD> <20>㼯ʹ<E3BCAF><CAB9>
|
|
|
|
|
|
std::unordered_map<std::string, PointStyle> m_pointStyle;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct KMLPlacemark
|
|
|
|
|
|
{
|
|
|
|
|
|
double m_lineWidth;
|
|
|
|
|
|
COLORREF m_lineColor;
|
|
|
|
|
|
COLORREF m_polyColor;
|
|
|
|
|
|
|
|
|
|
|
|
CString m_name;
|
|
|
|
|
|
CString m_styleUrl;
|
|
|
|
|
|
std::vector<KMLPoint> m_point;
|
|
|
|
|
|
|
|
|
|
|
|
void clear()
|
|
|
|
|
|
{
|
|
|
|
|
|
m_lineWidth = 0;
|
|
|
|
|
|
m_name = "";
|
|
|
|
|
|
m_lineColor = -1;
|
|
|
|
|
|
m_polyColor = -1;
|
|
|
|
|
|
m_point.clear();
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct KMLDocument
|
|
|
|
|
|
{
|
|
|
|
|
|
CString m_layerName;
|
|
|
|
|
|
KMLStyleMap m_styleInfo; //ÿ<><C3BF>Document<6E><74><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
KMLInfo m_info;
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
int Read(CFile& fr, short ver = -1); //XML<4D>ļ<EFBFBD><C4BC><EFBFBD>д
|
|
|
|
|
|
int Read(LPCTSTR lpszPathName, short ver = -1);
|
|
|
|
|
|
int SetMapUnit(int gm_unit);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
int ReadData(CFile& fr, short ver = -1); //XML<4D>ļ<EFBFBD><C4BC><EFBFBD>д(<28><>ϸ<EFBFBD>ֶ<EFBFBD>)
|
|
|
|
|
|
int ReadKMLInfoHead(CFile& fr, short ver, void* pXmlParse); //kml<6D>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
|
int ReadKMLDocument(CFile& fr, short ver = -1);
|
|
|
|
|
|
int ReadKMLPlacemark(CFile& fr, const KMLDocument &dInfo, short ver = -1);
|
|
|
|
|
|
int ReadKMLStyle(CFile& fr, KMLPlacemark &info, short ver = -1);
|
|
|
|
|
|
int ReadKMLStyle(CFile& fr, PointStyle &pInfo, short ver = -1);
|
|
|
|
|
|
int ReadKMLLineStyle(CFile& fr, KMLPlacemark &info, short ver = -1);
|
|
|
|
|
|
int ReadKMLPolyStyle(CFile& fr, KMLPlacemark &info, short ver = -1);
|
|
|
|
|
|
int ReadKMLIconStyle(CFile& fr, PointStyle &info, short ver = -1);
|
|
|
|
|
|
|
|
|
|
|
|
int ReadKMLColorStyle(CFile& fr, COLORREF& color, short ver = -1);
|
|
|
|
|
|
|
|
|
|
|
|
int InitMapInfo();
|
|
|
|
|
|
|
|
|
|
|
|
int DrawKMLLine(const KMLPlacemark &pInfo, const KMLDocument &dInfo); //<2F><><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
|
|
|
|
|
|
int DrawKMLPolygon(const KMLPlacemark &pInfo, const KMLDocument &dInfo); //<2F><><EFBFBD>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
int DrawKMLPoint(const KMLPlacemark &pInfo, const KMLDocument &dInfo); //<2F><><EFBFBD>Ƶ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
void DeSerialize(CArchive& ar);
|
|
|
|
|
|
|
|
|
|
|
|
vector<CString> SplitByLine(const CString& input); //Layers <20><><EFBFBD><EFBFBD> \r\n <20>ָ<EFBFBD><D6B8>ַ<EFBFBD><D6B7><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
CString ChangeEncoding(const CString &str, const CString &enc, int type = 0); //<2F><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>
|
|
|
|
|
|
|
|
|
|
|
|
CString Utf8ToGb2312(const CString& utf8Str, int type = 0); //ת<><D7AA>
|
|
|
|
|
|
wchar_t* ReplaceLineBreaks(wchar_t* pWideChar, int type = 0); //ȥ<><C8A5><EFBFBD>ַ<EFBFBD><D6B7>е<EFBFBD>\\r\\n
|
|
|
|
|
|
|
|
|
|
|
|
COLORREF KMLColorToCOLORREF(const CString& colorStr);
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|