1424 char *sql_form, *query, *connection_string, *progress_shapefile = NULL;
1429 char *header, *footer, *record;
1435 pgui_seterr(
_(
"ERROR: You haven't specified any files to import"));
1445 pgui_seterr(
_(
"Unable to connect to the database - please check your connection settings"));
1462 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";
1474 sz = strlen(sql_form) + strlen(loader_file_config->
schema) + strlen(loader_file_config->
table) + 1;
1476 snprintf(query, sz, sql_form, loader_file_config->
table, loader_file_config->
schema);
1511 pgui_logf(
"\n==============================");
1512 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);
1523 gtk_widget_set_sensitive(widget,
FALSE);
1526 while (gtk_events_pending())
1527 gtk_main_iteration();
1539 goto import_cleanup;
1543 for (i = strlen(loader_file_config->
shp_file); i >= 0
1544 && loader_file_config->
shp_file[i - 1] !=
'\\' && loader_file_config->
shp_file[i - 1] !=
'/'; i--);
1546 progress_shapefile =
malloc(strlen(loader_file_config->
shp_file));
1547 strcpy(progress_shapefile, &loader_file_config->
shp_file[i]);
1553 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), 0.0);
1570 goto import_cleanup;
1579 goto import_cleanup;
1585 int records_per_tick = (numrecords / 200) - 1;
1587 if ( records_per_tick < 1 )
1588 records_per_tick = 1;
1600 goto import_cleanup;
1608 goto import_cleanup;
1612 for (i = 0; i < numrecords &&
is_running; i++)
1627 pgui_logf(
_(
"Import failed on record number %d"), i);
1635 goto import_cleanup;
1649 pgui_logf(
_(
"Import failed on record number %d"), i);
1664 if ( i % records_per_tick == 0 )
1665 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), (
float)i / numrecords);
1668 while (gtk_events_pending())
1669 gtk_main_iteration();
1676 goto import_cleanup;
1679 if (PQresultStatus(result) != PGRES_COMMAND_OK)
1683 goto import_cleanup;
1698 goto import_cleanup;
1704 gtk_label_set_text(GTK_LABEL(
label_progress),
_(
"Creating spatial index..."));
1707 while (gtk_events_pending())
1708 gtk_main_iteration();
1716 goto import_cleanup;
1737 if (progress_shapefile)
1738 free(progress_shapefile);
1748 gtk_widget_set_sensitive(widget,
TRUE);
1751 gtk_widget_hide(widget);
1752 gtk_widget_show(widget);
1758 while (gtk_events_pending())
1759 gtk_main_iteration();
1762 free(connection_string);
char * ShpDumperGetConnectionStringFromConn(SHPCONNECTIONCONFIG *conn)
const char SHPAPI_CALL1 * SHPTypeName(int nSHPType);const char SHPAPI_CALL1(*) SHPPartTypeName(int nPartType
int ShpLoaderGetRecordCount(SHPLOADERSTATE *state)
void ShpLoaderDestroy(SHPLOADERSTATE *state)
int ShpLoaderGetSQLCopyStatement(SHPLOADERSTATE *state, char **strheader)
int ShpLoaderOpenShape(SHPLOADERSTATE *state)
int ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strrecord)
int ShpLoaderGetSQLFooter(SHPLOADERSTATE *state, char **strfooter)
SHPLOADERSTATE * ShpLoaderCreate(SHPLOADERCONFIG *config)
int ShpLoaderGetSQLHeader(SHPLOADERSTATE *state, char **strheader)
#define SHPLOADERRECISNULL
#define SHPLOADERRECDELETED
static GtkWidget * label_progress
static GtkWidget * progress
static void pgui_seterr(const char *fmt,...)
static int pgui_copy_write(const char *line)
static volatile int is_running
static int validate_remote_loader_columns(SHPLOADERCONFIG *config, PGresult *result)
static int pgui_copy_end(const int rollback)
static PGconn * pg_connection
static void pgui_raise_error_dialogue(void)
static void update_conn_ui_from_conn_config(void)
static int pgui_copy_start(const char *sql)
static GtkWidget * dialog_progress
static int connection_test(void)
GtkListStore * import_file_list_store
#define GUIMSG_LINE_MAXLEN
static int pgui_exec(const char *sql)
static SHPCONNECTIONCONFIG * conn
static GtkWidget * window_conn
static void pgui_logf(const char *fmt,...)
char message[SHPLOADERMSGLEN]