1422 char *sql_form, *query, *connection_string, *progress_shapefile = NULL;
1427 char *header, *footer, *record;
1433 pgui_seterr(
_(
"ERROR: You haven't specified any files to import"));
1443 pgui_seterr(
_(
"Unable to connect to the database - please check your connection settings"));
1460 sql_form =
"SELECT a.attnum, a.attname AS field, t.typname AS type, a.attlen AS length, a.atttypmod AS precision FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n WHERE c.relname = '%s' AND n.nspname = '%s' AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid AND c.relnamespace = n.oid ORDER BY a.attnum";
1471 query =
malloc(strlen(sql_form) + strlen(loader_file_config->
schema) + strlen(loader_file_config->
table) + 1);
1472 sprintf(query, sql_form, loader_file_config->
table, loader_file_config->
schema);
1507 pgui_logf(
"\n==============================");
1508 pgui_logf(
"Importing with configuration: %s, %s, %s, %s, mode=%c, dump=%d, simple=%d, geography=%d, index=%d, shape=%d, srid=%d", loader_file_config->
table, loader_file_config->
schema, loader_file_config->
geo_col, loader_file_config->
shp_file, loader_file_config->
opt, loader_file_config->
dump_format, loader_file_config->
simple_geometries, loader_file_config->
geography, loader_file_config->
createindex, loader_file_config->
readshape, loader_file_config->
sr_id);
1519 gtk_widget_set_sensitive(widget,
FALSE);
1522 while (gtk_events_pending())
1523 gtk_main_iteration();
1535 goto import_cleanup;
1539 for (i = strlen(loader_file_config->
shp_file); i >= 0
1540 && loader_file_config->
shp_file[i - 1] !=
'\\' && loader_file_config->
shp_file[i - 1] !=
'/'; i--);
1542 progress_shapefile =
malloc(strlen(loader_file_config->
shp_file));
1543 strcpy(progress_shapefile, &loader_file_config->
shp_file[i]);
1549 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), 0.0);
1566 goto import_cleanup;
1575 goto import_cleanup;
1581 int records_per_tick = (numrecords / 200) - 1;
1583 if ( records_per_tick < 1 )
1584 records_per_tick = 1;
1596 goto import_cleanup;
1604 goto import_cleanup;
1608 for (i = 0; i < numrecords &&
is_running; i++)
1623 pgui_logf(
_(
"Import failed on record number %d"), i);
1631 goto import_cleanup;
1645 pgui_logf(
_(
"Import failed on record number %d"), i);
1660 if ( i % records_per_tick == 0 )
1661 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), (
float)i / numrecords);
1664 while (gtk_events_pending())
1665 gtk_main_iteration();
1672 goto import_cleanup;
1675 if (PQresultStatus(result) != PGRES_COMMAND_OK)
1679 goto import_cleanup;
1694 goto import_cleanup;
1700 gtk_label_set_text(GTK_LABEL(
label_progress),
_(
"Creating spatial index..."));
1703 while (gtk_events_pending())
1704 gtk_main_iteration();
1712 goto import_cleanup;
1733 if (progress_shapefile)
1734 free(progress_shapefile);
1744 gtk_widget_set_sensitive(widget,
TRUE);
1747 gtk_widget_hide(widget);
1748 gtk_widget_show(widget);
1754 while (gtk_events_pending())
1755 gtk_main_iteration();
1758 free(connection_string);
static int connection_test(void)
int ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter)
static int pgui_copy_write(const char *line)
int ShpLoaderOpenShape(SHPLOADERSTATE *state)
static int validate_remote_loader_columns(SHPLOADERCONFIG *config, PGresult *result)
#define SHPLOADERRECISNULL
static int pgui_exec(const char *sql)
static void pgui_logf(const char *fmt,...)
#define SHPLOADERRECDELETED
int ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader)
static GtkWidget * progress
static SHPCONNECTIONCONFIG * conn
void ShpLoaderDestroy(SHPLOADERSTATE *state)
static void pgui_seterr(const char *fmt,...)
static int pgui_copy_start(const char *sql)
int ShpLoaderGetRecordCount(SHPLOADERSTATE *state)
SHPLOADERSTATE * ShpLoaderCreate(SHPLOADERCONFIG *config)
static volatile int is_running
#define GUIMSG_LINE_MAXLEN
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType
GtkListStore * import_file_list_store
char message[SHPLOADERMSGLEN]
static void update_conn_ui_from_conn_config(void)
static GtkWidget * label_progress
int ShpLoaderGetSQLCopyStatement(SHPLOADERSTATE *state, char **strheader)
int ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strrecord)
static GtkWidget * window_conn
static void pgui_raise_error_dialogue(void)
static int pgui_copy_end(const int rollback)
static PGconn * pg_connection
static GtkWidget * dialog_progress