/******************************************************************************* * *N {accessingrastertable.c} -- Example of accessing the properties of * the raster table, sde_ras_. * *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * How to compile:: * This program provides programming examples of * * * 1. Add {ibm ICU installation directory}/lib to your library paths * 2. Add {ibm ICU installation directory}/include to your include paths * 3. Add {$SDEHOME}/lib to your library paths; * 4. Compile and link with icuuc.lib and other needed SDE libraries *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: *X Legalese: * * Copyright © 2006-2007 ESRI * * All rights reserved under the copyright laws of the United States and * applicable international laws, treaties, and conventions. * * You may freely redistribute and use this sample code, with or without * modification, provided you include the original copyright notice and use * restrictions. * * Disclaimer: THE SAMPLE CODE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ESRI OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) SUSTAINED BY YOU OR A THIRD PARTY, HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR * TORT ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE CODE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * For additional information, contact: * Environmental Systems Research Institute, Inc. * Attn: Contracts and Legal Services Department * 380 New York Street * Redlands, California, 92373 * USA * * email: contracts@esri.com * *E ****************************************************************************/ #include "sdetype.h" #include "sderaster.h" #include "sdeerno.h" #include #include "raster_source.h" void main(void) { SE_CONNECTION connection; SE_ERROR error; CHAR table_name [SE_MAX_TABLE_LEN], column_name [SE_MAX_COLUMN_LEN], raster_description [SE_MAX_DESCRIPTION_LEN], name_value[64], *server, *instance, *database, *username, *password; SE_RASCOLINFO rastercolumn; SE_RASTERINFO raster; LONG rastercolumn_id, raster_id, rc; /* Set the ArcSDE server connection parameters. */ server = "jolex"; instance = "9000"; database = NULL; username = "mark"; password = "mark"; /* Set the tablename and column. */ strcpy(table_name,"myrastertable"); strcpy(column_name,"raster"); /* Connect to the ArcSDE server. */ rc = SE_connection_create (server, instance, database, username, password, &error,&connection); check_error (rc, connection, NULL, "SE_connection_create"); /* Initialize the SE_RASCOLINFO structure. */ rc = SE_rascolinfo_create (&rastercolumn); check_error (rc, NULL, NULL, "SE_rascolinfo_create"); /* Populate the raster column info structure based on the business table name and the */ /* raster column name. */ rc = SE_rastercolumn_get_info_by_name (connection, table_name, column_name, rastercolumn); check_error (rc, connection, NULL, "SE_rastercolumn_get_info_by_name"); /* Fetch the rastercolumn ID from the raster column info structure. */ rc = SE_rascolinfo_get_id (rastercolumn, &rastercolumn_id); check_error (rc, NULL, NULL, "SE_rascolinfo_get_id"); /* Free the raster column info structure. */ SE_rascolinfo_free (rastercolumn); /* Initialize the SE_RASTERINFO structure. */ rc = SE_rasterinfo_create (&raster); check_error (rc, NULL, NULL, "SE_rasterinfo_create"); /* Set the name value to query on. The name value will */ /* form the where clause. */ strcpy (name_value, "europe"); /* Fetch the raster if based on the name value. */ fetch_rasterid_on_raster_name (connection, table_name, name_value, &raster_id); if (raster_id==-1) { printf("The myrastertable does not contain the 'Europe' raster.\n"); return; } /* Populate the SE_RASTERINFO structure based on the raster ID. */ rc = SE_raster_get_info_by_id ( connection, rastercolumn_id, raster_id, raster); check_error (rc, connection, NULL, "SE_raster_get_info_by_id"); /* Get the description of the raster. */ rc = SE_rasterinfo_get_description (raster, raster_description); check_error (rc, NULL, NULL, "SE_rasterinfo_get_description"); /* Print the description of the raster. */ printf ("The raster description is %s.\n",raster_description); /* Release the rasterinfo structure */ SE_rasterinfo_free(raster); /* Release the connection to the ArcSDE server */ SE_connection_free (connection); return; }