您的位置:首页 > 其它

mapgis6.7二次开发vc6_demo 之五(输出VCT函数之面图层)

2012-04-20 17:04 267 查看
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  OutVctPloygonBeginEnd.cpp
/*
bool OutVctPloygonBeginEnd(short *ptALst);    //输出vct面坐标
*/
//------------------------------------------------------------
//实现 输出VCT面几何图形功能 OK
bool OutVctPloygonBeginEnd(short *ptALst)
{
bool rbc = false;
char* GeoVctType;
char* FeatClassName;
char* FeatureCode;
char* FeatureName;

short ai;
//输出面坐标
long i,ln;

long  len;
double   x,y;
char* tmp;
char* Lfilename;
short LayerType;

//ShowMsg(this, "正在输出面坐标信息");
//输出面坐标

f_WriteLine("PolygonBegin");
for(int k=1;k<=ptALst[0];k++)
{       //获取一个工作区
ai=ptALst[k];
//获取图层类型
LayerType=_GetAreaType(ptALst[k]);
if(LayerType==REG)
{  //输出vct面要素几何图形
//获取面层图元总个数
_GetRegNum(ai,&i,&ln);
//获取工作区文件名
Lfilename=_GetAreaFileName(ai);
//获取图层类型
GeoVctType=GetGeoVctType(ai);
//
FeatClassName =getfilenameNoExt_lc(Lfilename,"\\");;

FeatureCode =FeatClassName;//a3u(GeoVctType,"_",i2cp(1));
FeatureName =FeatClassName;//FeatureCode;
//
D_DOT *pRegDot=NULL;
long  lRegDotNum=0;
REG_INFO inf;
long *rdat;
double centerX = 0, centerY = 0;
long lineNum = 0;
for(i=1;i<ln;i++)  //线要素总个数
{
//short WINAPI _GetReg(short ai,long ri,long **rdat,long *len,REG_INFO *inf);
if(_GetReg(ai,i,&rdat,&len,&inf)<=0)
{
continue;
}
lineNum += 1;
f_WriteLine(l2cp(lineNum)); //第一行序号(目标标识码)
f_WriteLine(FeatureCode);        //第二行要素代码
f_WriteLine(FeatureName);        //第三行要素名称
centerX = 0; centerY = 0;
f_WriteLine(a3u(d2cp(centerX) , "," , d2cp(centerY)));   //第四行几何中心点坐标(标识点坐标)
//short WINAPI _GetLin(short ai,long li,D_DOT **dat,long *len,LIN_INFO *inf,short *dim=NULL);
_GetLin(ai,rdat[1], &pRegDot,&lRegDotNum, NULL); //获取面中环
f_WriteLine(l2cp(lRegDotNum)); //第五行点数
for (k = 0; k<lRegDotNum; k++)
{
x=pRegDot[k].x;
y=pRegDot[k].y;
//写入到文本中
char* x_s=d2cp(x);
char* y_s=d2cp(y);
tmp=a2u(x_s,",");
tmp=a2u(tmp,y_s);
//
f_WriteLine(tmp);  //第六行点坐标
}
f_WriteLine("0");   //最后用一个独占一行的0(点数为0)表示此面状要素数据的结束
if (lineNum % 100 == 0)
{
f_FlushFile();
}
}//end while
}//end reg
}
f_WriteLine("PolygonEnd");
f_WriteLine("");
f_FlushFile();
//ShowMsg(this, "完成输出面坐标信息");
rbc = true;
return rbc;
}


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