ArcSDE C-API 开发:读取属性数据
2009-07-22 10:42
369 查看
很难得看到的Arcsde C API的sample,连官方网站上都是提供的java的,特此收录,转自http://www.gispower.org/article/arcgis/ao/2007/1113/0711132158575H3JBA9K9D4202D084ED.htm
SE_CONNECTION Connection;
SE_STREAM Stream;
SE_SQL_CONSTRUCT *sqlc
SE_ERROR Connect_error;
LONG rc, population;
SHORT num_cols;
LFLOAT area;
CHAR *server, *instance, *database, *user, *passwd;
CHAR **attrs, *name;
/* Connect to ArcSDE */
rc = SE_connection_create
(server, instance, database, user, passwd, &Connect_error, &Connection);
/* See Error handling section for check_error function code. */
check_error(Connection, NULL, rc, "SE_connection_create");
/* Create a stream for the query */
rc = SE_stream_create (Connection, &Stream);
check_error(Connection, NULL, rc, "SE_stream_create");
/* Allocate an SE_SQL_CONSTRUCT */
rc = SE_sql_construct_alloc (1, &sqlc);
check_error(Connection, NULL, rc, "SE_sql_construct_alloc");
/* Fill in the details of the SQL query */
sqlc->where = malloc(20);
sqlc->num_tables = 1;
strcpy (sqlc->tables[0], "cities");
strcpy (sqlc->where, "population < 10000");
/* Define the number and names of the table columns to be returned */
num_cols = 3;
attrs = (CHAR **) malloc (num_cols * sizeof(CHAR *));
attrs[0] = "city_name";
attrs[1] = "area";
attrs[2] = "population";
/* Define the stream query */
rc = SE_stream_query (Stream, num_cols, attrs, sqlc);
check_error(NULL, Stream, rc, "SE_stream_query");
rc = SE_stream_execute (Stream);
/* Iterate over the results */
while (rc == SE_SUCCESS)
{
rc = SE_stream_fetch (Stream);
if (rc == SE_SUCCESS)
{
rc = SE_stream_get_string (Stream,1,name);
check_error(NULL, Stream, rc, "SE_stream_get_string");
rc = SE_stream_get_double (Stream,2,&area);
check_error(NULL, Stream, rc, "SE_stream_get_double");
rc = SE_stream_get_integer (Stream,3,&population);
check_error(NULL, Stream, rc, "SE_stream_get_integer");
/* Now do something with the name, area and population */
}
}
/* Release the stream when it is no longer needed */
rc = SE_stream_free (Stream);
free (attrs);
free (sqlc->where);
undefined undefined undefined undefinedSE_sql_construct_free (sqlc);
/* Disconnect from ArcSDE */
undefined undefined undefined undefinedSE_connection_free (Connection);
本篇文章来源于GIS动力站|www.gispower.org 原文链接:http://www.gispower.org/article/arcgis/ao/2007/1113/0711132158575H3JBA9K9D4202D084ED.htm
SE_CONNECTION Connection;
SE_STREAM Stream;
SE_SQL_CONSTRUCT *sqlc
SE_ERROR Connect_error;
LONG rc, population;
SHORT num_cols;
LFLOAT area;
CHAR *server, *instance, *database, *user, *passwd;
CHAR **attrs, *name;
/* Connect to ArcSDE */
rc = SE_connection_create
(server, instance, database, user, passwd, &Connect_error, &Connection);
/* See Error handling section for check_error function code. */
check_error(Connection, NULL, rc, "SE_connection_create");
/* Create a stream for the query */
rc = SE_stream_create (Connection, &Stream);
check_error(Connection, NULL, rc, "SE_stream_create");
/* Allocate an SE_SQL_CONSTRUCT */
rc = SE_sql_construct_alloc (1, &sqlc);
check_error(Connection, NULL, rc, "SE_sql_construct_alloc");
/* Fill in the details of the SQL query */
sqlc->where = malloc(20);
sqlc->num_tables = 1;
strcpy (sqlc->tables[0], "cities");
strcpy (sqlc->where, "population < 10000");
/* Define the number and names of the table columns to be returned */
num_cols = 3;
attrs = (CHAR **) malloc (num_cols * sizeof(CHAR *));
attrs[0] = "city_name";
attrs[1] = "area";
attrs[2] = "population";
/* Define the stream query */
rc = SE_stream_query (Stream, num_cols, attrs, sqlc);
check_error(NULL, Stream, rc, "SE_stream_query");
rc = SE_stream_execute (Stream);
/* Iterate over the results */
while (rc == SE_SUCCESS)
{
rc = SE_stream_fetch (Stream);
if (rc == SE_SUCCESS)
{
rc = SE_stream_get_string (Stream,1,name);
check_error(NULL, Stream, rc, "SE_stream_get_string");
rc = SE_stream_get_double (Stream,2,&area);
check_error(NULL, Stream, rc, "SE_stream_get_double");
rc = SE_stream_get_integer (Stream,3,&population);
check_error(NULL, Stream, rc, "SE_stream_get_integer");
/* Now do something with the name, area and population */
}
}
/* Release the stream when it is no longer needed */
rc = SE_stream_free (Stream);
free (attrs);
free (sqlc->where);
undefined undefined undefined undefinedSE_sql_construct_free (sqlc);
/* Disconnect from ArcSDE */
undefined undefined undefined undefinedSE_connection_free (Connection);
本篇文章来源于GIS动力站|www.gispower.org 原文链接:http://www.gispower.org/article/arcgis/ao/2007/1113/0711132158575H3JBA9K9D4202D084ED.htm
相关文章推荐
- ArcSDE C-API 开发:读取属性数据
- 【.Net码农】【淘宝API】淘宝API开发系列--读取实体类的属性的备注作为表头的应用
- 【UWP通用应用开发】文件选取器、获取文件属性、写入和读取、保存读取和删除应用数据
- 【Qt开发】V4L2 API详解 <三> Buffer的准备和数据读取
- Knockout开发中文API系列2–创建数据模型和监控属性
- ASP.NET Core教程【三】实体字段属性、链接标签、并发数据异常、文件上传及读取
- 【转】iOS开发24:使用SQLite3存储和读取数据
- Android开发(小属性)积累------------解决软键盘显示时listview的最后一条数据无法显示
- POI实战-java开发excel详解之常用操作-单元格合并与数据读取
- ios开发之---将数据写入和读取与沙盒的具体理解和实现。
- drupal7 常用的数据读取API
- hbase学习-- 5 使用HBase客户端API读取,删除数据,扫描数据
- OC数据储存本地(二)-----iOS----属性列表plist 写如何存储和读取
- HBase-scan API 通过scan读取表中数据
- ios开发中数据库读取数据牵涉到的日期处理:前一天、今天、后天、一周等
- [转] iOS开发24:使用SQLite3存储和读取数据
- iOS开发UI篇—ios应用数据存储方式(XML属性列表-plist
- ios开发UI篇-iOS应用数据存储方式(XML属性列表 -plist)e二
- V4L2 API详解 <三> Buffer的准备和数据读取
- C#——正式开始自己的AE开发,先做一个button进行读取特定数据