1426 char *sql_form, *query, *connection_string, *progress_shapefile = NULL;
1431 char *header, *footer, *record;
1437 pgui_seterr(
_(
"ERROR: You haven't specified any files to import"));
1447 pgui_seterr(
_(
"Unable to connect to the database - please check your connection settings"));
1464 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";
1476 sz = strlen(sql_form) + strlen(loader_file_config->
schema) + strlen(loader_file_config->
table) + 1;
1478 snprintf(query, sz, sql_form, loader_file_config->
table, loader_file_config->
schema);
1513 pgui_logf(
"\n==============================");
1514 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);
1525 gtk_widget_set_sensitive(widget,
FALSE);
1528 while (gtk_events_pending())
1529 gtk_main_iteration();
1541 goto import_cleanup;
1545 for (i = strlen(loader_file_config->
shp_file); i >= 0
1546 && loader_file_config->
shp_file[i - 1] !=
'\\' && loader_file_config->
shp_file[i - 1] !=
'/'; i--);
1548 progress_shapefile =
malloc(strlen(loader_file_config->
shp_file));
1549 strcpy(progress_shapefile, &loader_file_config->
shp_file[i]);
1555 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), 0.0);
1572 goto import_cleanup;
1581 goto import_cleanup;
1587 int records_per_tick = (numrecords / 200) - 1;
1589 if ( records_per_tick < 1 )
1590 records_per_tick = 1;
1602 goto import_cleanup;
1610 goto import_cleanup;
1614 for (i = 0; i < numrecords &&
is_running; i++)
1629 pgui_logf(
_(
"Import failed on record number %d"), i);
1637 goto import_cleanup;
1651 pgui_logf(
_(
"Import failed on record number %d"), i);
1666 if ( i % records_per_tick == 0 )
1667 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(
progress), (
float)i / numrecords);
1670 while (gtk_events_pending())
1671 gtk_main_iteration();
1678 goto import_cleanup;
1681 if (PQresultStatus(
result) != PGRES_COMMAND_OK)
1685 goto import_cleanup;
1700 goto import_cleanup;
1706 gtk_label_set_text(GTK_LABEL(
label_progress),
_(
"Creating spatial index..."));
1709 while (gtk_events_pending())
1710 gtk_main_iteration();
1718 goto import_cleanup;
1739 if (progress_shapefile)
1740 free(progress_shapefile);
1750 gtk_widget_set_sensitive(widget,
TRUE);
1753 gtk_widget_hide(widget);
1754 gtk_widget_show(widget);
1760 while (gtk_events_pending())
1761 gtk_main_iteration();
1764 free(connection_string);
char result[OUT_DOUBLE_BUFFER_SIZE]
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 static void static void static void pgui_seterr(const char *fmt,...) __attribute__((format(printf
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 void static void static void pgui_logf(const char *fmt,...) __attribute__((format(printf
static PGconn * pg_connection
static void pgui_raise_error_dialogue(void)
static void static void static void static 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
char message[SHPLOADERMSGLEN]