您的位置:首页 > 其它

mapgis6.7二次开发vc6_demo 之五(输出VCT函数之表属性段)

2012-04-20 17:06 351 查看
mapgis6.7二次开发vc6_demo 之五(输出VCT函数之表属性段)

//////////////////////////////////////////////
//
//输出vct属性值 version=1, topo=0
//vp:hsg
//create date:2012-04-20
//
//////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include <math.h>
#include "win_area.h"
#include "win_oper.h"
#include "map_out.h"
#include "demo.h"
//-------------------------------------------------------
extern char* AppTitle;                    //应用程序名称
extern AREA_HINST    AHInst;
extern HWND         MainWnd;              //主窗口句柄
extern HWND         GrpWnd;               //图形窗口句柄
//-------------------------------------------------------
//------------------------------------------------------------
//define function style  OutVctAttributeBeginEnd.cpp
/*
bool OutVctAttributeBeginEnd(short *ptALst);    //输出vct属性值
*/
//------------------------------------------------------------
//输出vct属性值 OK
bool OutVctAttributeBeginEnd(short *ptALst)
{
bool rbc = false;
short ai;
char* GeoVctType = "";
char* FeatClassName = "";
char* FeatureCode = "";
char* FeatureName = "";

long i,ln;
short LayerType;

//this.ShowMsg(this, "正在输出属性值信息");
//输出属性值
f_WriteLine("AttributeBegin");
for(int k=1;k<=ptALst[0];k++)
{   //获取一个工作区
ai=ptALst[k];
//获取图层类型
LayerType=_GetAreaType(ai);
switch(LayerType)
{
case LIN:
_GetLinNum(ai,&i,&ln); //获取线层总个数
break;
case REG:
_GetRegNum(ai,&i,&ln); //获取面层总个数
break;
case PNT:
_GetPntNum(ai,&i,&ln); //获取点层总个数
break;
default:
break;
}
GeoVctType=GetGeoVctType(ai);
//获取工作区文件名
char* Lfilename=_GetAreaFileName(ai);
//
FeatClassName =getfilenameNoExt_lc(Lfilename,"\\");

FeatureCode =FeatClassName;//a3u(GeoVctType,"_",i2cp(1));
FeatureName =FeatClassName;//FeatureCode;

f_WriteLine(FeatClassName);
if (ln > 0)
{   //有要素个数>0
char* AttrLine =NULL;
char* fdval = NULL;
long lineNum = 0;
CATT_STRU *stru=NULL;
char *att=NULL;
short numbfield=0;
short ret_gt;
//
for(i=1;i<ln;i++)  //线要素总个数
{
lineNum += 1;
AttrLine = l2cp(lineNum);
//获取属性值
ret_gt=_GetAtt(ai,LayerType,i,&stru,&att);
short numbfield=stru->hd.numbfield;  //字段个数
CFIELD_HEAD *pfd=stru[0].fldEntry;
//
for(short k=0;k<numbfield;k++)
{
//获取属性值的方法
fdval=new char[pfd[k].msk_leng];
memset(fdval,0,pfd[k].msk_leng);
//_CvtFldToString(stru,att,k,fdval,pfd[k].msk_leng,NULL,NULL);
_CvtFldToString1(stru,att,pfd[k].fieldname,fdval,pfd[k].msk_leng,NULL,NULL);
//
char* t_val=trim_lc(fdval);  //去掉空格
if (strlen(AttrLine) <= 0)
{
AttrLine = t_val;
}
else
{
AttrLine =a3u(AttrLine,"," , t_val);
}
}
f_WriteLine(AttrLine);
if (lineNum % 100 == 0)
{
f_FlushFile();
}
}
}
}
f_WriteLine("TableEnd");
f_WriteLine("");
f_WriteLine("AttributeEnd");
//this.ShowMsg(this, "完成输出属性值信息");
f_FlushFile();
rbc = true;
return rbc;
}
//


--the--end---
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: