利用ArcSde c Api 向sqlserver空間數(shù)據(jù)庫實體圖形-_第1頁
利用ArcSde c Api 向sqlserver空間數(shù)據(jù)庫實體圖形-_第2頁
利用ArcSde c Api 向sqlserver空間數(shù)據(jù)庫實體圖形-_第3頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、利用ArcSDE C API向SQL SERVER空間數(shù)據(jù)庫中添加實體圖形收藏此頁 打印【IT168知識庫】 摘要:本文以一個C/C+實例分步講述了利用ArcSDE C API向空間數(shù)據(jù)庫中添加實體圖形的方法。 利用ArcSDE8.1 C API向空間數(shù)據(jù)庫中添加實體圖形大致可分為六步。步驟如下: 第一步:與空間數(shù)據(jù)庫建立連接。 SE_CONNECTION handle; /空間數(shù)據(jù)庫連接對象 SE_ERROR Connect_error; /錯誤狀態(tài) LONG rc; /執(zhí)行結果狀態(tài) CHAR server30 = "LCR" /空間數(shù)據(jù)庫服務器名 CHAR instan

2、ce30 = "esri_sde" /空間數(shù)據(jù)庫實例名 CHAR database30 = "" /數(shù)據(jù)庫名 CHAR user30 = "sa" /用戶名 CHAR passwd30 = "sapassword" /密碼 /* 創(chuàng)建連接 */ rc = SE_connection_create( server, instance, database, user, passwd, &Connect_error, &handle; /*錯誤檢查 */ check_error (handle, NULL

3、, rc, "SE_connection_create" 第二步:建立用戶定義屬性表。 LONG num_cols; /列數(shù) SE_SHAPE shape; /形 SE_ENVELOPE rect; /矩形范圍 LONG part_offsets2, int_val; CHAR *attrs; /屬性列 CHAR column32, table32; /列與表 SE_COORDREF coordref; /坐標系引用 SE_POINT pt10; /坐標點 SE_LAYERINFO layer; /層信息 SE_COLUMN_DEF *column_defs; /列定義對象

4、 SE_STREAM stream; /數(shù)據(jù)流 /* 創(chuàng)建數(shù)據(jù)流連接 */ SE_stream_create (handle, &stream; check_error (handle, NULL, rc, "SE_stream_create" /* 創(chuàng)建用戶表 */ strcpy(table, "MYTABLE" num_cols = 1; column_defs = (SE_COLUMN_DEF * calloc (num_cols, sizeof(SE_COLUMN_DEF; strcpy (column_defs0.column_name

5、, "ATTR_COL" column_defs0.sde_type = SE_INTEGER_TYPE; /為整形列 column_defs0.nulls_allowed = TRUE; /允許為空 rc = SE_table_create(handle, table, num_cols, column_defs,"DEFAULTS" check_error (handle, NULL, rc, "SE_table_create" 第三步:創(chuàng)建并設置圖層信息。 /* 創(chuàng)建層的坐標系參考 */ rc = SE_coordref_cre

6、ate (&coordref; check_error (handle, NULL, rc, "SE_coordref_create" /設置假定坐標源點與比例尺 rc = SE_coordref_set_xy (coordref,0,0,10000; check_error (handle, NULL, rc, "SE_coordref_set_xy" /分配并初始化層信息結構layer rc = SE_layerinfo_create (coordref, &layer; check_error (handle, NULL, rc,

7、"SE_layerinfo_create" /設置層的格網尺寸、允許的形類型、創(chuàng)建關鍵字和空間列 rc = SE_layerinfo_set_grid_sizes (layer,1000,0,0; check_error (handle, 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

8、_MASK | SE_AREA_TYPE_MASK | SE_MULTIPART_TYPE_MASK ; check_error(handle, NULL, rc, "SE_layerinfo_set_shape_types" rc = SE_layerinfo_set_creation_keyword (layer, "DEFAULTS" check_error (handle, NULL, rc, "SE_layerinfo_set_creation_keyword" strcpy(column, "SPATIAL_CO

9、L" rc = SE_layerinfo_set_spatial_column (layer, table, column; check_error (handle, NULL, rc, "SE_layerinfo_set_spatial_column" /* 創(chuàng)建層 */ rc = SE_layer_create (handle, layer, 0,0; check_error (handle, NULL, rc, "SE_layer_create" 第四步:創(chuàng)建圖形實體對象,并設置屬性與空間列。 /* 創(chuàng)建形 */ rc = SE_shap

10、e_create (coordref, &shape; check_error (handle, NULL, rc, "SE_shape_create" /* 將表插入數(shù)據(jù)流 */ attrs = (CHAR * malloc (sizeof(CHAR * * 2; attrs0 = "ATTR_COL" attrs1 = column; rc = SE_stream_insert_table (stream, table, 2, (const CHAR* attrs; check_error (handle, NULL, rc, "S

11、E_stream_insert_table" free (attrs; /* 設置矩形的最值并產生矩形*/ 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 (handle, NULL, rc, "SE_shape_generate_rectangle" /* 設定形和屬性列 */ int_val = 2; rc =

12、SE_stream_set_integer (stream, 1, &int_val; check_error (NULL, stream, rc, "SE_stream_set_integer" rc = SE_stream_set_shape (stream, 2, shape; check_error (NULL, stream, rc, "SE_stream_set_shape" /*插入行 */ rc = SE_stream_execute (stream; check_error (NULL, stream, rc, "SE

13、_stream_execute" /* 對面域設定坐標數(shù)組 一個中間有洞的矩形,并生成多邊形 */ part_offsets0 = 0; pt0.x = 1000.; pt0.y = 1000.; pt1.x = 4000.; pt1.y = 1000.; pt2.x = 4000.; pt2.y = 4000.; pt3.x = 1000.; pt3.y = 4000.; pt4.x = 1000.; pt4.y = 1000.; pt5.x = 2000.; pt5.y = 2000.; pt6.x = 2000.; pt6.y = 3000.; pt7.x = 3000.; p

14、t7.y = 3000.; pt8.x = 3000.; pt8.y = 2000.; pt9.x = 2000.; pt9.y = 2000.; /生成多邊形 rc = SE_shape_generate_polygon (10,1,part_offsets,pt,NULL,NULL,shape; check_error (handle, NULL, rc, "SE_shape_generate_polygon" /* 設定形及屬性列 */ int_val = 3; rc=SE_stream_set_integer (stream, 1, &int_val; check_error (NULL, stream, rc, "SE_stream_set_integer" rc = SE_stream_set_shape (stream, 2, shape; check_error (NULL, stream, rc, "SE_stream_set_shape" /* 插入行 */ rc = SE_str

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論