[postgis-commits] svn - r3544 - trunk/loader
postgis-commits at postgis.refractions.net
postgis-commits at postgis.refractions.net
Tue Jan 20 10:43:50 PST 2009
Author: pramsey
Date: 2009-01-20 10:43:50 -0800 (Tue, 20 Jan 2009)
New Revision: 3544
Modified:
trunk/loader/shp2pgsql-core.c
trunk/loader/shp2pgsql-core.h
trunk/loader/shp2pgsql-gui.c
Log:
Put translation_stage into descriptive MACRO names
Modified: trunk/loader/shp2pgsql-core.c
===================================================================
--- trunk/loader/shp2pgsql-core.c 2009-01-20 18:28:59 UTC (rev 3543)
+++ trunk/loader/shp2pgsql-core.c 2009-01-20 18:43:50 UTC (rev 3544)
@@ -36,6 +36,7 @@
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
+
typedef struct
{
double x, y, z, m;
@@ -70,7 +71,7 @@
int sr_id = 0; /* SRID specified */
char *shp_file = NULL; /* the shape file (without the .shp extension) */
int gui_mode = 0; /* 1 = GUI, 0 = commandline */
-int translation_stage = 0;
+int translation_stage = TRANSLATION_IDLE;
/* Private globals */
stringbuffer_t *sb_row; /* stringbuffer to append results to */
@@ -486,7 +487,7 @@
if ( ! CreateTable() )
return 0;
- translation_stage = 2; /* done start */
+ translation_stage = TRANSLATION_LOAD; /* done start */
return 1;
}
@@ -503,7 +504,7 @@
}
else
{
- translation_stage = 3; /* done middle */
+ translation_stage = TRANSLATION_CLEANUP; /* done middle */
}
return 1;
}
@@ -520,7 +521,7 @@
if ( ! pgis_exec("END") ) return 0; /* End the last transaction */
- translation_stage = 4;
+ translation_stage = TRANSLATION_DONE;
return 1;
}
@@ -890,7 +891,7 @@
pgis_copy_end(0);
}
- translation_stage = 3; /* done middle */
+ translation_stage = TRANSLATION_CLEANUP; /* done middle */
return 1;
}
Modified: trunk/loader/shp2pgsql-core.h
===================================================================
--- trunk/loader/shp2pgsql-core.h 2009-01-20 18:28:59 UTC (rev 3543)
+++ trunk/loader/shp2pgsql-core.h 2009-01-20 18:43:50 UTC (rev 3544)
@@ -21,6 +21,12 @@
#define RCSID "$Id: shp2pgsql.c 3450 2008-12-18 20:42:09Z pramsey $"
+#define TRANSLATION_IDLE 0
+#define TRANSLATION_CREATE 1
+#define TRANSLATION_LOAD 2
+#define TRANSLATION_CLEANUP 3
+#define TRANSLATION_DONE 4
+
enum {
insert_null,
skip_null,
Modified: trunk/loader/shp2pgsql-gui.c
===================================================================
--- trunk/loader/shp2pgsql-gui.c 2009-01-20 18:28:59 UTC (rev 3543)
+++ trunk/loader/shp2pgsql-gui.c 2009-01-20 18:43:50 UTC (rev 3544)
@@ -221,39 +221,39 @@
check_translation_stage (gpointer data)
{
int rv = 0;
- if ( translation_stage == 0 ) return FALSE;
- if ( translation_stage == 4 )
+ if ( translation_stage == TRANSLATION_IDLE ) return FALSE;
+ if ( translation_stage == TRANSLATION_DONE )
{
pgui_logf("Import complete.");
return FALSE;
}
- if ( translation_stage == 1 )
+ if ( translation_stage == TRANSLATION_CREATE )
{
rv = translation_start();
if ( ! rv )
{
pgui_logf("Import failed.");
- translation_stage = 0;
+ translation_stage = TRANSLATION_IDLE;
}
return TRUE;
}
- if ( translation_stage == 2 )
+ if ( translation_stage == TRANSLATION_LOAD )
{
rv = translation_middle();
if ( ! rv )
{
pgui_logf("Import failed.");
- translation_stage = 0;
+ translation_stage = TRANSLATION_IDLE;
}
return TRUE;
}
- if ( translation_stage == 3 )
+ if ( translation_stage == TRANSLATION_CLEANUP )
{
rv = translation_end();
if ( ! rv )
{
pgui_logf("Import failed.");
- translation_stage = 0;
+ translation_stage = TRANSLATION_IDLE;
}
return TRUE;
}
@@ -387,7 +387,7 @@
const char *entry_encoding = gtk_entry_get_text(GTK_ENTRY(entry_options_encoding));
/* Do nothing if we're busy */
- if ( translation_stage > 0 && translation_stage < 4 )
+ if ( translation_stage > TRANSLATION_IDLE && translation_stage < TRANSLATION_DONE )
{
return;
}
@@ -483,7 +483,7 @@
/* add the idle action */
cur_entity = -1;
- translation_stage = 1;
+ translation_stage = TRANSLATION_CREATE;
g_idle_add(check_translation_stage, NULL);
free(connection_string);
@@ -497,7 +497,7 @@
pgui_action_options(GtkWidget *widget, gpointer data)
{
/* Do nothing if we're busy */
- if ( translation_stage > 0 && translation_stage < 4 )
+ if ( translation_stage > TRANSLATION_IDLE && translation_stage < TRANSLATION_DONE )
{
return;
}
@@ -510,11 +510,11 @@
static void
pgui_action_cancel(GtkWidget *widget, gpointer data)
{
- if ( translation_stage > 0 && translation_stage < 4 )
+ if ( translation_stage > TRANSLATION_IDLE && translation_stage < TRANSLATION_DONE )
{
pgui_logf("Import stopped.");
- translation_stage = 0; /* return to idle if we are running */
+ translation_stage = TRANSLATION_IDLE; /* return to idle if we are running */
}
else
{
@@ -529,7 +529,7 @@
char *connection_string = NULL;
/* Do nothing if we're busy */
- if ( translation_stage > 0 && translation_stage < 4 )
+ if ( translation_stage > TRANSLATION_IDLE && translation_stage < TRANSLATION_DONE )
{
return;
}
More information about the postgis-commits
mailing list