您好,欢迎光临本网站![请登录][注册会员]  
文件名称: xml解析实例
  所属分类: C++
  开发工具:
  文件大小: 60kb
  下载次数: 0
  上传时间: 2012-12-29
  提 供 者: jiab****
 详细说明: #pragma once #include "xmlhelper/easyxml.hpp" #include "vtString.h" #include "vtMathTypes.h" struct vtBandInfo { vtString name; vtString colorInterpretation; vtString nodata; int type;//1为数据波段;2为掩码波段 }; class vtPyramidInfo: public XMLVisitor { public: vtPyramidInfo(void); ~vtPyramidInfo(void); int WriteToXMLFile(const char* pydFileName); wstring initName; int LoadFromXMLFile(const char* pydFileName); private: //xml visitor void startXML() { level =0; bandsInfo.clear(); } void startElement(const char *name, const XMLAttributes &atts;) { level++; m_currentElementName+="."; m_currentElementName+=name; if (m_currentElementName==".vtPyramidInfo.Bands.Band") { vtString name = atts.getName(0); vtString val = atts.getValue(0); bandinfo.name = val; } } void endElement(const char *name) { level--; if (m_currentElementName==".vtPyramidInfo.Bands.Band") { bandsInfo.push_back(bandinfo); } else if (m_currentElementName==".vtPyramidInfo.PixelType") { sscanf(valueStr, "%d", &pixelType;); } else if (m_currentElementName==".vtPyramidInfo.Origin") { sscanf(valueStr, "%lf,%lf", origin.xPtr(),origin.yPtr()); } else if (m_currentElementName==".vtPyramidInfo.FinestResolution") { sscanf(valueStr, "%lf,%lf", finestResolution.xPtr(),finestResolution.yPtr()); } else if (m_currentElementName==".vtPyramidInfo.FinestSize") { sscanf(valueStr, "%d,%d",finestSize.xPtr(),finestSize.yPtr()); } else if (m_currentElementName==".vtPyramidInfo.BlockSize") { sscanf(valueStr, "%d,%d", blockSize.xPtr(),blockSize.yPtr()); } else if (m_currentElementName==".vtPyramidInfo.lzts") { sscanf(valueStr, "%lf", &lzts;); } else if (m_currentElementName==".vtPyramidInfo.ShareEdge") { sscanf(valueStr, "%d", &shareEdge;); } else if (m_currentElementName==".vtPyramidInfo.MinLevel") { sscanf(valueStr, "%d", &minLevel;); } else if (m_currentElementName==".vtPyramidInfo.MaxLevel") { sscanf(valueStr, "%d", &maxLevel;); } else if (m_currentElementName==".vtPyramidInfo.SpatialReference") { SRS = valueStr; } else if (m_currentElementName==".vtPyramidInfo.PixelLayout") { sscanf(valueStr, "%d",&pixelLayout;); } int size = strlen(name)+1;//plus a dot m_currentElementName = m_currentElementName.Left(m_currentElementName.GetLength()-size); } void data(const char* s, int length) { vtString typeStr(s,length); if (m_currentElementName==".vtPyramidInfo.Bands.Band.ColorInterpretation") { bandinfo.colorInterpretation = typeStr; }else if (m_currentElementName==".vtPyramidInfo.Bands.Band.Type") { sscanf(typeStr, "%d", &bandinfo;.type); }else if (m_currentElementName==".vtPyramidInfo.Bands.Band.NoDataVal") { bandinfo.nodata = vtString(s,length); } else { valueStr = typeStr; } } vtString m_currentElementName; int level; vtBandInfo bandinfo; vtString valueStr; public: /* 作者 :zjb 创建日期 :16:12:2012 9:58 功能业务说明: pixelType PIXELTYPEENUM_UNKNOWN = 0, //"未知类型" PIXELTYPEENUM_BYTE = 1, //"字节" size=1字节 PIXELTYPEENUM_USHORT16 = 2, //"无符号位整数" size=2字节 PIXELTYPEENUM_SHORT16 = 3, //"16位整数" size=2字节 PIXELTYPEENUM_UINT32 = 4, //"无符号位整数" size=4字节 PIXELTYPEENUM_INT32 = 5, //"32位整数" size=4字节 PIXELTYPEENUM_FLOAT32 = 6, //"32位浮点数" size=4字节 PIXELTYPEENUM_DOUBLE64 = 7, //"64位浮点数" size=8字节 PIXELTYPEENUM_CSHORT16 = 8, //"复合位整数" size=2字节*2个 PIXELTYPEENUM_CINT32 = 9, //"复合位整数" size=4字节*2个 PIXELTYPEENUM_CFLOAT32 = 10, //"复合位浮点数" size=4字节*2个 PIXELTYPEENUM_CDOUBLE64 = 11, //"复合位浮点数" size=8字节*2个 PIXELTYPEENUM_TYPECOUNT = 12 //"类型的数目" */ int pixelType; DPoint2 origin; DPoint2 finestResolution; IPoint2 finestSize;//最高level的栅格大小 IPoint2 blockSize; double lzts; int shareEdge;//是否共享边界 int minLevel; int maxLevel; vtString SRS; /* 作者 :zjb 创建日期 :16:12:2012 9:57 功能业务说明:pixelLayout PIXELLAYOUTTYPEENUM_BSQ = 0, //Band SeQuential also "BAND":Band sequential format stores information for the image one band at a time. In other words, data for all the pixels for band 1 is stored first, then data for all pixels for band 2, and so on. PIXELLAYOUTTYPEENUM_BIP = 1, //Band Interleaved by Pixel ,also "PIXEL":Band interleaved by pixel data is similar to BIL data, except that the data for each pixel is written band by band PIXELLAYOUTTYPEENUM_BIL = 2 //Band Interleaved by Line ,aslo "LINE":Band interleaved by line data stores pixel information band by band for each line, or row, of the image */ int pixelLayout; vector bandsInfo; }; ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: xml解析 示例
 输入关键字,在本站1000多万海量源码库中尽情搜索: