lixaokui
路人甲
路人甲
  • 注册日期2003-12-25
  • 发帖数768
  • QQ28796446
  • 铜币27枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1817回复:8

欢迎大家贴上用C API操作ArcSDE的源代码

楼主#
更多 发布于:2004-09-09 11:41
<P>用过C API操作ArcSDE的同志,请贴上一个小工程以供大家研究!</P>
喜欢0 评分0
西门吹血,有了鼓风机,就不用吹啦!
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2004-09-10 00:25
帮顶先
举报 回复(0) 喜欢(0)     评分
gisboy
卧底
卧底
  • 注册日期2003-07-26
  • 发帖数162
  • QQ
  • 铜币900枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-09-12 21:25
一直弄不明白arcsde的c的api有什么作用?什么意思??
Our doing are not really as important as we think. Our successes and failures didn't matter after all.
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
3楼#
发布于:2004-09-12 22:02
<b>如何使用C API创建SDE图层?简单
</b><P><FONT face=Courier>BOOL SpatialTable(SE_CONNECTION connect, CHAR * table, CHAR * column, LONG mask, double minx, double miny, double maxx, double maxy)</FONT></P><P><FONT face=Courier>{</FONT></P><P><FONT face=Courier>SE_LAYERINFO   layer;
SE_COORDREF    coordref;
LONG rc =  SE_coordref_create (;coordref);
if(rc != SE_SUCCESS) {
  return FALSE;
}</FONT></P><P><FONT face=Courier>LFLOAT falsex,falsey,xyunits;
LFLOAT dx=maxx-minx, dy=maxy-miny;
if(dx>dy) {
  falsex=minx-dx*0.001;
  falsey=miny-(dx-dy)/2.0-dx*0.001;
  xyunits=ULONG(1L<<31)/dx/1.002;
}
else {
  falsex=minx-(dy-dx)/2.0-dy*0.001;
  falsey=miny-dy*0.001;
  xyunits=ULONG(1L<<31)/dy/1.002;</FONT></P><P><FONT face=Courier>}
rc = SE_coordref_set_xy (coordref,falsex,falsey,xyunits);
rc = SE_layerinfo_create (coordref,;layer);
double grid=ULONG(1L<<31)/xyunits/256.0;
rc = SE_layerinfo_set_grid_sizes (layer,grid,grid*4,grid*16);
rc = SE_layerinfo_set_shape_types (layer,mask);
rc = SE_layerinfo_set_spatial_column (layer,table,column);
rc = SE_layer_create (connect,layer,0,0);
if(rc != SE_SUCCESS) {
  SE_coordref_free (coordref);
  SE_layerinfo_free (layer);
  TRACE0("Error:Create layer failure!\n");
  return FALSE;
}
SE_coordref_free (coordref);
SE_layerinfo_free (layer);
return TRUE;
}</FONT></P><P><FONT face=Courier>SE_CONNECTION connection; </FONT></P><P><FONT face=Courier>SE_ERROR error;
LONG rc = SE_connection_create("gissrv", "esri_sde", "sde",
  user, password, ;error, ;connection);</FONT></P><P><FONT face=Courier>ASSERT(SE_SUCCESS == rc);
</FONT></P><P><FONT face=Courier>BOOL ret = SpatialTable(connect, "TEST_LAYER", "SHAPE",
  SE_AREA_TYPE_MASK|SE_NIL_TYPE_MASK|SE_LINE_TYPE_MASK|SE_POINT_TYPE_MASK,//
  -10000, -10000, 10000, 10000);</FONT></P>
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
4楼#
发布于:2004-09-12 22:03
<a href="http://gisempire.com/bbs/dispbbs.asp?boardID=39;ID=29006;page=1" target="_blank" >http://gisempire.com/bbs/dispbbs.asp?boardID=39;ID=29006;page=1</A>
举报 回复(0) 喜欢(0)     评分
lixaokui
路人甲
路人甲
  • 注册日期2003-12-25
  • 发帖数768
  • QQ28796446
  • 铜币27枚
  • 威望0点
  • 贡献值0点
  • 银元0个
5楼#
发布于:2004-09-13 08:51
请上传C API SDE到帝国FTP
西门吹血,有了鼓风机,就不用吹啦!
举报 回复(0) 喜欢(0)     评分
lixaokui
路人甲
路人甲
  • 注册日期2003-12-25
  • 发帖数768
  • QQ28796446
  • 铜币27枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2004-09-13 11:28
找到C API SDE开发包啦,就是在SDE Client目录中。
西门吹血,有了鼓风机,就不用吹啦!
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15947
  • QQ554730525
  • 铜币25339枚
  • 威望15364点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
7楼#
发布于:2004-09-21 12:32
<PRE> SE_table_delete(Connection,"MYTEST"); int num_COL;
SE_COLUMN_DEF *column_defs;
CHAR **attrs;

/* Create business table */
num_COL = 1;
column_defs = (SE_COLUMN_DEF *) calloc (num_COL, sizeof(SE_COLUMN_DEF));

strcpy (column_defs[0].column_name, "MYCOLUMN");
column_defs[0].sde_type = SE_INTEGER_TYPE;
column_defs[0].nulls_allowed = TRUE;

// strcpy (column_defs[1].column_name, "SHAPE");
// column_defs[1].sde_type = SE_INTEGER_TYPE;
// column_defs[1].nulls_allowed = TRUE;

rc = SE_table_create(Connection, "MYTEST", num_COL, column_defs,"DEFAULTS");
check_error (Connection, NULL, rc, "SE_table_create");

attrs = (CHAR **) malloc (sizeof(CHAR *) * 2);
attrs[1] = "MYCOLUMN";
attrs[0] = "SHAPE";


SE_ENVELOPE rect;
LONG part_offsets[2], int_val;
SE_POINT pt[15];

SE_SHAPE shape;

SE_COORDREF coordref;
SE_LAYERINFO layer;


/* Create layer coordinate reference */
rc = SE_coordref_create (;coordref);
check_error (Connection, NULL, rc, "SE_coordref_create");

rc = SE_coordref_set_xy (coordref,0.0,0.0, 10000);
check_error (Connection, NULL, rc, "SE_coordref_set_xy");

rc = SE_layerinfo_create (coordref, ;layer);
check_error (Connection, NULL, rc, "SE_layerinfo_create");

/* Set layer grid sizes, allowed shape types, creation keyword
and spatial column */
rc = SE_layerinfo_set_grid_sizes (layer,1000,0,0);
check_error (Connection, NULL, rc, "SE_layerinfo_set_grid_sizes");

rc = SE_layerinfo_set_shape_types(layer, SE_NIL_TYPE_MASK |
SE_POINT_TYPE_MASK |
SE_LINE_TYPE_MASK |
SE_SIMPLE_LINE_TYPE_MASK |
SE_AREA_TYPE_MASK |
SE_MULTIPART_TYPE_MASK );
check_error(Connection, NULL, rc, "SE_layerinfo_set_shape_types");

rc = SE_layerinfo_set_creation_keyword (layer, "DEFAULTS");
check_error (Connection, NULL, rc, "SE_layerinfo_set_creation_keyword");

rc = SE_layerinfo_set_spatial_column (layer, "MYTEST", "SHAPE");
check_error (Connection, NULL, rc, "SE_layerinfo_set_spatial_column");

/* Create layer */
rc = SE_layer_create (Connection, layer, 0,0);
check_error (Connection, NULL, rc, "SE_layer_create");

/* Create shape */
rc = SE_shape_create (coordref, ;shape);
check_error (Connection, NULL, rc, "SE_shape_create");

rc = SE_stream_insert_table (Stream, "MYTEST", 2, (const CHAR**) attrs);
check_error (Connection, NULL, rc, "SE_stream_insert_table");

/* Set min and max for the rectangle and generate shape */
rect.minx = 5000.0;
rect.miny = 1000.0;
rect.maxx = 8000.0;
rect.maxy = 4000.0;

rc = SE_shape_generate_rectangle (;rect, shape);
check_error (Connection, NULL, rc, "SE_shape_generate_rectangle");


/* Set shape and attribute column */
rc = SE_stream_set_shape (Stream, 1, shape);
check_error (NULL, Stream, rc, "SE_stream_set_shape");

int_val = 1;
rc = SE_stream_set_integer (Stream, 2, ;int_val);
check_error (NULL, Stream, rc, "SE_stream_set_integer");


/* Insert row */
rc = SE_stream_execute (Stream);
check_error (NULL, Stream, rc, "SE_stream_execute");


/* Set coordinate array for area shape - a box with a donut hole.
Generate the area shape. */
part_offsets[0] = 0;
part_offsets[1] = 10;
pt[0].x = 1000.; pt[0].y = 1000.;
pt[1].x = 4000.; pt[1].y = 1000.;
pt[2].x = 4000.; pt[2].y = 4000.;
pt[3].x = 1000.; pt[3].y = 4000.;
pt[4].x = 1000.; pt[4].y = 1000.;
pt[5].x = 2000.; pt[5].y = 2000.;
pt[6].x = 2000.; pt[6].y = 3000.;
pt[7].x = 3000.; pt[7].y = 3000.;
pt[8].x = 3000.; pt[8].y = 2000.;
pt[9].x = 2000.; pt[9].y = 2000.;
pt[10].x = 1000.; pt[10].y = 5000.;
pt[11].x = 4000.; pt[11].y = 5000.;
pt[12].x = 4000.; pt[12].y = 6000.;
pt[13].x = 1000.; pt[13].y = 6000.;
pt[14].x = 1000.; pt[14].y = 5000.;


rc = SE_shape_generate_polygon (15,2,part_offsets,pt,NULL,NULL,shape);
check_error (Connection, NULL, rc, "SE_shape_generate_polygon");

/* Set shape and attribute column */
rc = SE_stream_set_shape (Stream, 1 ,shape);
check_error (NULL, Stream, rc, "SE_stream_set_shape");

int_val = 2;
rc=SE_stream_set_integer (Stream, 2, ;int_val);
check_error (NULL, Stream, rc, "SE_stream_set_integer");

/* Insert row */
rc = SE_stream_execute (Stream);
check_error (NULL, Stream, rc, "SE_stream_execute");

SE_POINT point_array[2];
point_array[0].x = 1500.0; point_array[0].y = 1500.0;
point_array[1].x = 5000.0;point_array[1].y = 2500.0;

rc = SE_shape_generate_line(2,1,NULL,point_array,NULL,NULL,shape);
check_error (Connection, NULL, rc, "SE_shape_generate_line");

/* Set shape and attribute column */
rc = SE_stream_set_shape (Stream, 1 ,shape);
check_error (NULL, Stream, rc, "SE_stream_set_shape");

int_val = 3;
rc=SE_stream_set_integer (Stream, 2, ;int_val);
check_error (NULL, Stream, rc, "SE_stream_set_integer");

/* Insert row */
rc = SE_stream_execute (Stream);
check_error (NULL, Stream, rc, "SE_stream_execute");


SE_shape_free (shape);

SE_coordref_free (coordref);

</PRE>
[此贴子已经被作者于2004-9-21 12:35:51编辑过]
举报 回复(0) 喜欢(0)     评分
lixaokui
路人甲
路人甲
  • 注册日期2003-12-25
  • 发帖数768
  • QQ28796446
  • 铜币27枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2004-09-21 15:18
<img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em05.gif" />
西门吹血,有了鼓风机,就不用吹啦!
举报 回复(0) 喜欢(0)     评分
游客

返回顶部