Pushing the shp2pgsql-gui changes (multi-file, validation, drag-n-drop) pulled from stable branch into trunk.

git-svn-id: http://svn.osgeo.org/postgis/trunk@5809 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Mark Leslie 2010-08-11 09:50:38 +00:00
parent 16cded9aae
commit 8627624d89
16 changed files with 2817 additions and 431 deletions

View file

@ -658,7 +658,7 @@ AC_SUBST([SHLIB_LINK])
dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
dnl Output the relevant files
AC_OUTPUT([liblwgeom/Makefile liblwgeom/cunit/Makefile postgis/Makefile postgis/sqldefines.h loader/Makefile topology/Makefile regress/Makefile doc/Makefile doc/html/image_src/Makefile])
AC_OUTPUT([liblwgeom/Makefile liblwgeom/cunit/Makefile postgis/Makefile postgis/sqldefines.h loader/Makefile loader/cunit/Makefile topology/Makefile regress/Makefile doc/Makefile doc/html/image_src/Makefile])
dnl ===========================================================================
dnl Display the configuration status information

View file

@ -84,10 +84,13 @@ $(PGSQL2SHP): shpopen.o dbfopen.o getopt.o pgsql2shp.o $(LIBLWGEOM)
$(SHP2PGSQL-CLI): shpopen.o dbfopen.o getopt.o shp2pgsql-core.o shp2pgsql-cli.o $(LIBLWGEOM)
$(CC) $(CFLAGS) $^ -o $@ $(ICONV_LDFLAGS) -lm
structure.o: structure.c
$(CC) $(CFLAGS) $(GTK_CFLAGS) -o $@ -c structure.c
shp2pgsql-gui.o: shp2pgsql-gui.c
$(CC) $(CFLAGS) $(PGSQL_FE_CPPFLAGS) $(GTK_CFLAGS) -o $@ -c shp2pgsql-gui.c
$(SHP2PGSQL-GUI): shpopen.o dbfopen.o shp2pgsql-core.o shp2pgsql-gui.o getopt.o $(LIBLWGEOM) $(GTK_WIN32_RES)
$(SHP2PGSQL-GUI): shpopen.o dbfopen.o shp2pgsql-core.o shp2pgsql-gui.o getopt.o structure.o $(LIBLWGEOM) $(GTK_WIN32_RES)
$(CC) $(CFLAGS) $(GTK_WIN32_FLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm
installdir:
@ -104,6 +107,9 @@ uninstall:
@rm -f $(DESTDIR)$(bindir)/$(PGSQL2SHP)
@rm -f $(DESTDIR)$(bindir)/$(SHP2PGSQL-CLI)
check:
make -C cunit check
clean:
@rm -f *.o $(SHP2PGSQL-CLI) $(PGSQL2SHP) $(GTK_WIN32_RES)

70
loader/cunit/Makefile Normal file
View file

@ -0,0 +1,70 @@
# **********************************************************************
# * $Id: Makefile.in
# *
# * PostGIS - Spatial Types for PostgreSQL
# * http://postgis.refractions.net
# * Copyright 2008 Paul Ramsey, Mark Cave-Ayland
# *
# * This is free software; you can redistribute and/or modify it under
# * the terms of the GNU General Public Licence. See the COPYING file.
# *
# **********************************************************************
CC=gcc
CFLAGS=-m32 -Wall -Wmissing-prototypes
CUNIT_LDFLAGS= -lcunit
CUNIT_CPPFLAGS=-m32 -I..
# GTK includes and libraries
GTK_CFLAGS = -mms-bitfields -Ic:/gtkbundle/include/gtk-2.0 -Ic:/gtkbundle/lib/gtk-2.0/include -Ic:/gtkbundle/include/atk-1.0 -Ic:/gtkbundle/include/cairo -Ic:/gtkbundle/include/pango-1.0 -Ic:/gtkbundle/include/glib-2.0 -Ic:/gtkbundle/lib/glib-2.0/include -Ic:/gtkbundle/include/freetype2 -Ic:/gtkbundle/include -Ic:/gtkbundle/include/libpng12
GTK_LIBS = -Lc:/gtkbundle/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl
GTK_WIN32_FLAGS = -mwindows
OBJS= \
cu_list.o \
cu_tester.o
LOADER_OBJS= \
../structure.o
# If we couldn't find the cunit library then display a helpful message
ifeq ($(CUNIT_LDFLAGS),)
all: requirements_not_met_cunit
check: requirements_not_met_cunit
else
$(LOADER_OBJS):
make -C ..
# Build the unit tester
all: cu_tester
# Build and run the unit tester
check: cu_tester
@./cu_tester
endif
# Build the main unit test executable
cu_tester: $(LOADER_OBJS) $(OBJS)
#$(CC) $(GTK_WIN32_FLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm $(CUNIT_LDFLAGS)
$(CC) $^ -o $@ -lm $(CUNIT_LDFLAGS)
# Command to build each of the .o files
$(OBJS): %.o: %.c
$(CC) $(CFLAGS) $(CUNIT_CPPFLAGS) $(GTK_CFLAGS) -c -o $@ $<
# Clean target
clean:
@rm $(OBJS)
@rm cu_tester.exe
# Requirements message
requirements_not_met_cunit:
@echo
@echo "WARNING:"
@echo
@echo "configure was unable to find CUnit which is required for unit testing."
@echo "In order to enable unit testing, you must install CUnit and then re-run configure."
@echo

70
loader/cunit/Makefile.in Normal file
View file

@ -0,0 +1,70 @@
# **********************************************************************
# * $Id: Makefile.in
# *
# * PostGIS - Spatial Types for PostgreSQL
# * http://postgis.refractions.net
# * Copyright 2008 Paul Ramsey, Mark Cave-Ayland
# *
# * This is free software; you can redistribute and/or modify it under
# * the terms of the GNU General Public Licence. See the COPYING file.
# *
# **********************************************************************
CC=@CC@
CFLAGS=@CFLAGS@ @WARNFLAGS@
CUNIT_LDFLAGS=@CUNIT_LDFLAGS@
CUNIT_CPPFLAGS=@CUNIT_CPPFLAGS@ -I..
# GTK includes and libraries
GTK_CFLAGS = @GTK_CFLAGS@ @IGE_MAC_CFLAGS@
GTK_LIBS = @GTK_LIBS@ @IGE_MAC_LIBS@
GTK_WIN32_FLAGS = @GTK_WIN32_FLAGS@
OBJS= \
cu_list.o \
cu_tester.o
LOADER_OBJS= \
../structure.o
# If we couldn't find the cunit library then display a helpful message
ifeq ($(CUNIT_LDFLAGS),)
all: requirements_not_met_cunit
check: requirements_not_met_cunit
else
$(LOADER_OBJS):
make -C ..
# Build the unit tester
all: cu_tester
# Build and run the unit tester
check: cu_tester
@./cu_tester
endif
# Build the main unit test executable
cu_tester: $(LOADER_OBJS) $(OBJS)
#$(CC) $(GTK_WIN32_FLAGS) $^ -o $@ $(GTK_LIBS) $(ICONV_LDFLAGS) $(PGSQL_FE_LDFLAGS) -lm $(CUNIT_LDFLAGS)
$(CC) $^ -o $@ -lm $(CUNIT_LDFLAGS)
# Command to build each of the .o files
$(OBJS): %.o: %.c
$(CC) $(CFLAGS) $(CUNIT_CPPFLAGS) $(GTK_CFLAGS) -c -o $@ $<
# Clean target
clean:
@rm $(OBJS)
@rm cu_tester.exe
# Requirements message
requirements_not_met_cunit:
@echo
@echo "WARNING:"
@echo
@echo "configure was unable to find CUnit which is required for unit testing."
@echo "In order to enable unit testing, you must install CUnit and then re-run configure."
@echo

337
loader/cunit/cu_list.c Normal file
View file

@ -0,0 +1,337 @@
/**********************************************************************
* $Id: cu_list.c 5674 2010-06-03 02:04:15Z mleslie $
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.refractions.net
* Copyright 2010 LISAsoft Pty Ltd
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
*
**********************************************************************/
#include "cu_list.h"
#include "cu_tester.h"
#include "../structure.h"
/*
typedef struct _GtkTreeIter GtkTreeIter;
struct _GtkTreeIter
{
gint stamp;
gpointer user_data;
gpointer user_data2;
gpointer user_data3;
}
*/
/* Test functions */
void test_append_file(void);
void test_find_file(void);
void test_traversal(void);
void test_remove_first(void);
void test_remove_middle(void);
void test_remove_last(void);
void test_find_index(void);
/*
** Called from test harness to register the tests in this file.
*/
CU_pSuite register_list_suite(void)
{
CU_pSuite pSuite;
pSuite = CU_add_suite("GUI Shapefile Loader File List Test", init_list_suite, clean_list_suite);
if (NULL == pSuite)
{
CU_cleanup_registry();
return NULL;
}
if (
(NULL == CU_add_test(pSuite, "test_append_file()", test_append_file))
||
(NULL == CU_add_test(pSuite, "test_find_file()", test_find_file))
||
(NULL == CU_add_test(pSuite, "test_traversal()", test_traversal))
||
(NULL == CU_add_test(pSuite, "test_remove_first()", test_remove_first))
||
(NULL == CU_add_test(pSuite, "test_remove_last()", test_remove_first))
||
(NULL == CU_add_test(pSuite, "test_remove_middle()", test_remove_middle))
||
(NULL == CU_add_test(pSuite, "test_find_index()", test_find_index))
)
{
CU_cleanup_registry();
return NULL;
}
return pSuite;
}
/*
** The suite initialization function.
** Create any re-used objects.
*/
int init_list_suite(void)
{
return 0;
}
/*
** The suite cleanup function.
** Frees any global objects.
*/
int clean_list_suite(void)
{
return 0;
}
void test_append_file(void)
{
FILENODE *node;
GtkTreeIter iter;
init_file_list();
node = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
destroy_file_list();
}
void test_find_file(void)
{
FILENODE *node;
FILENODE *keeper_node;
GtkTreeIter iter;
GtkTreeIter keeper_iter;
init_file_list();
node = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
keeper_node = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &keeper_iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file6", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file7", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = append_file("file8", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node);
node = find_file_by_iter(&keeper_iter);
CU_ASSERT_PTR_NOT_NULL(node);
CU_ASSERT_PTR_EQUAL(node, keeper_node);
destroy_file_list();
}
void test_traversal(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
}
void test_remove_first(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
remove_file(node[0]);
i = 1;
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
CU_ASSERT_EQUAL(i, 5);
}
void test_remove_last(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
remove_file(node[4]);
i = 0;
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 4);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
CU_ASSERT_EQUAL(i, 4);
}
void test_remove_middle(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
}
remove_file(node[3]);
i = 0;
current_node = get_next_node(NULL);
CU_ASSERT_PTR_NOT_NULL(current_node);
while(current_node != NULL)
{
CU_ASSERT_NOT_EQUAL(i, 5);
CU_ASSERT_PTR_EQUAL(current_node, node[i]);
current_node = get_next_node(current_node);
i++;
if(i == 3)
i++;
}
CU_ASSERT_EQUAL(i, 5);
destroy_file_list();
}
void test_find_index(void)
{
FILENODE *node[5];
FILENODE *current_node;
GtkTreeIter iter;
int index[11] = {4, 3, 2, 1, 0, 3, 2, 4, 0, 1, 1};
int i = 0;
init_file_list();
node[0] = append_file("file1", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[0]);
node[1] = append_file("file2", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[1]);
node[2] = append_file("file3", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[2]);
node[3] = append_file("file4", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[3]);
node[4] = append_file("file5", "schema", "table", "geom_column", "-1", 'c', &iter);
CU_ASSERT_PTR_NOT_NULL(node[4]);
for(i = 0; i < 11; i++)
{
current_node = find_file_by_index(index[i]);
CU_ASSERT_PTR_EQUAL(node[index[i]], current_node);
}
destroy_file_list();
}

29
loader/cunit/cu_list.h Normal file
View file

@ -0,0 +1,29 @@
/**********************************************************************
* $Id: cu_list.h 5674 2010-06-03 02:04:15Z mleslie $
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.refractions.net
* Copyright 2010 LISAsoft Pty Ltd
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
*
**********************************************************************/
#ifndef __cu_list_h__
#define __cu_list_h__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "CUnit/Basic.h"
/***********************************************************************
** for Computational Geometry Suite
*/
/* Admin functions */
int init_list_suite(void);
int clean_list_suite(void);
#endif /* __cu_list_h__ */

44
loader/cunit/cu_tester.c Normal file
View file

@ -0,0 +1,44 @@
/**********************************************************************
* $Id: cu_tester.c 5675 2010-06-03 07:35:41Z mleslie $
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.refractions.net
* Copyright 2008 Paul Ramsey
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
*
**********************************************************************/
#include <stdio.h>
#include <string.h>
#include "CUnit/Basic.h"
#include "cu_tester.h"
/*
** The main() function for setting up and running the tests.
** Returns a CUE_SUCCESS on successful running, another
** CUnit error code on failure.
*/
int main()
{
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
/* Add the algorithms suite to the registry */
if (NULL == register_list_suite())
{
CU_cleanup_registry();
return CU_get_error();
}
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}

20
loader/cunit/cu_tester.h Normal file
View file

@ -0,0 +1,20 @@
/**********************************************************************
* $Id: cu_tester.h 5674 2010-06-03 02:04:15Z mleslie $
*
* PostGIS - Spatial Types for PostgreSQL
* http://postgis.refractions.net
* Copyright 2010 Mark Leslie
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU General Public Licence. See the COPYING file.
*
**********************************************************************/
#ifndef __cu_tester_h__
#define __cu_tester_h__
CU_pSuite register_list_suite(void);
#endif /* __cu_tester_h__ */

BIN
loader/image/error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 360 B

BIN
loader/image/good.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

View file

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="744.09448819"
height="1052.3622047"
id="svg2"
sodipodi:version="0.32"
inkscape:version="0.46"
sodipodi:docname="icon_source.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 526.18109 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="744.09448 : 526.18109 : 1"
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
id="perspective10" />
<filter
inkscape:collect="always"
id="filter3281">
<feGaussianBlur
inkscape:collect="always"
stdDeviation="0.21022492"
id="feGaussianBlur3283" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
gridtolerance="10000"
guidetolerance="10"
objecttolerance="10"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1"
inkscape:cx="129.38312"
inkscape:cy="649.49455"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1030"
inkscape:window-height="870"
inkscape:window-x="77"
inkscape:window-y="15" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<path
sodipodi:type="arc"
style="fill:#e3dbdb;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.4662433;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path4791"
sodipodi:cx="100.40916"
sodipodi:cy="325.63318"
sodipodi:rx="18.738329"
sodipodi:ry="18.561554"
d="M 119.14749,325.63318 A 18.738329,18.561554 0 1 1 81.670828,325.63318 A 18.738329,18.561554 0 1 1 119.14749,325.63318 z"
transform="matrix(1.7130004,0,0,1.7293146,-24.388978,-160.06425)"
inkscape:export-filename="C:\src\postgis-working\loader\good.png"
inkscape:export-xdpi="20.721062"
inkscape:export-ydpi="20.721062" />
<rect
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
id="rect2383"
width="99.212372"
height="99.212379"
x="100.39381"
y="352.75598" />
<rect
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3155"
width="99.212372"
height="99.212379"
x="201"
y="352.14981" />
<rect
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect3157"
width="99.212372"
height="99.212379"
x="301"
y="352.14981" />
<path
sodipodi:type="star"
style="fill:none;stroke-width:2;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none"
id="path3159"
sodipodi:sides="5"
sodipodi:cx="130.5"
sodipodi:cy="381.36218"
sodipodi:r1="65.103763"
sodipodi:r2="32.551882"
sodipodi:arg1="0.93804749"
sodipodi:arg2="1.566366"
inkscape:flatsided="false"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 169,433.86218 L 130.64422,413.91375 L 92.466689,434.20125 L 99.586188,391.55833 L 68.494123,361.51852 L 111.25,355.11218 L 130.21157,316.25906 L 149.51666,354.94265 L 192.32762,360.9699 L 161.50294,391.28401 L 169,433.86218 z" />
<g
id="g3295"
inkscape:export-filename="C:\src\postgis-working\loader\warn.png"
inkscape:export-xdpi="20.249985"
inkscape:export-ydpi="20.249985">
<path
transform="matrix(2.0869716,0,0,2.0869716,-183.04661,-199.56007)"
d="M 207.5,304.18971 L 189.33347,303.35063 L 197.69007,287.19842 L 207.5,271.88528 L 217.30993,287.19842 L 225.66653,303.35063 L 207.5,304.18971 z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="false"
sodipodi:arg2="2.6179938"
sodipodi:arg1="1.5707963"
sodipodi:r2="20.9769"
sodipodi:r1="11.327526"
sodipodi:cy="292.86218"
sodipodi:cx="207.5"
sodipodi:sides="3"
id="path3161"
style="fill:#edf130;fill-opacity:1;stroke:#000000;stroke-width:2.00002722000000020;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;stroke-linejoin:bevel"
sodipodi:type="star" />
<path
transform="matrix(2.0869716,0,0,2.0869716,-183.04661,-199.7641)"
d="M 207.5,304.18971 L 189.33347,303.35063 L 197.69007,287.19842 L 207.5,271.88528 L 217.30993,287.19842 L 225.66653,303.35063 L 207.5,304.18971 z"
inkscape:randomized="0"
inkscape:rounded="0"
inkscape:flatsided="false"
sodipodi:arg2="2.6179938"
sodipodi:arg1="1.5707963"
sodipodi:r2="20.9769"
sodipodi:r1="11.327526"
sodipodi:cy="292.86218"
sodipodi:cx="207.5"
sodipodi:sides="3"
id="path3163"
style="fill:none;stroke:#edf130;stroke-width:0.71874481;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter3281)"
sodipodi:type="star" />
<text
id="text3285"
y="425.36218"
x="242.13867"
style="font-size:40px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream Vera Sans"
xml:space="preserve"><tspan
style="font-size:56px"
y="425.36218"
x="242.13867"
id="tspan3287"
sodipodi:role="line">!</tspan></text>
</g>
<path
sodipodi:type="star"
style="fill:#ff0012;fill-opacity:1;stroke:#050505;stroke-width:0.40000001;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3333"
sodipodi:sides="8"
sodipodi:cx="221"
sodipodi:cy="236.36218"
sodipodi:r1="6.7082038"
sodipodi:r2="3.6224301"
sodipodi:arg1="0.46364761"
sodipodi:arg2="0.85634669"
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 227,239.36218 L 223.12132,242.72614 L 218,242.36218 L 214.63604,238.4835 L 215,233.36218 L 218.87868,229.99822 L 224,230.36218 L 227.36396,234.24086 L 227,239.36218 z"
transform="matrix(6.2343571,-0.4361074,0.4361074,6.2343571,-1130.8722,-974.82434)"
inkscape:export-filename="C:\src\postgis-working\loader\error.png"
inkscape:export-xdpi="18"
inkscape:export-ydpi="18" />
<path
sodipodi:type="star"
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.40000001;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.4"
id="path3335"
sodipodi:sides="8"
sodipodi:cx="221"
sodipodi:cy="236.36218"
sodipodi:r1="6.7082038"
sodipodi:r2="3.6224301"
sodipodi:arg1="0.46364761"
sodipodi:arg2="0.85634669"
inkscape:flatsided="true"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 227,239.36218 L 223.12132,242.72614 L 218,242.36218 L 214.63604,238.4835 L 215,233.36218 L 218.87868,229.99822 L 224,230.36218 L 227.36396,234.24086 L 227,239.36218 z"
transform="matrix(5.9226393,-0.414302,0.414302,5.9226393,-1056.8286,-905.96503)"
inkscape:export-filename="C:\src\postgis-working\loader\error.png"
inkscape:export-xdpi="18"
inkscape:export-ydpi="18" />
<path
style="fill:#280b0b;fill-opacity:1;stroke:#3f1b1b;stroke-width:1;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3351"
d="M -334.29836,24.946084 C -330.50703,25.725974 -326.73602,26.514605 -322.88639,26.976402 C -319.49057,27.581046 -316.09898,28.311197 -313.61622,30.830574 C -311.893,32.498343 -310.70244,34.63655 -309.42275,36.648007 C -307.71906,38.969016 -306.84976,41.633032 -306.32158,44.42702 C -306.35172,45.768241 -303.50661,51.909626 -305.89192,46.742021 C -337.68773,66.746241 -332.3812,66.953537 -326.8578,56.605246 C -324.25788,51.734197 -321.46498,46.998947 -318.68168,42.229053 C -313.20389,32.940722 -307.90823,23.55739 -301.81471,14.656051 C -296.70775,7.6011666 -290.74148,1.284571 -284.68903,-4.9473821 C -281.28722,-8.4874295 -277.59469,-11.705444 -273.57395,-14.517804 C -264.33666,-21.138468 -254.93875,-29.404098 -243.45986,-30.516745 L -265.55476,-13.849707 C -266.61357,-13.556678 -266.91443,-13.522197 -267.91161,-13.051923 C -268.29584,-12.870717 -269.39878,-12.230164 -269.032,-12.444498 C -244.33751,-26.874916 -239.44054,-29.874513 -248.04598,-24.625701 C -252.13931,-21.544727 -256.61753,-18.947136 -260.13687,-15.126855 C -266.38231,-8.970826 -272.62486,-2.7879896 -277.88374,4.2669092 C -284.35122,13.088407 -289.89514,22.53082 -295.55544,31.881467 C -297.27881,35.185436 -299.16549,38.405343 -300.80039,41.753967 C -301.3662,42.912873 -301.84467,44.113945 -302.29861,45.321069 C -302.345,45.444439 -303.40249,49.033071 -303.59909,49.1651 C -311.50808,54.476488 -319.72774,59.309986 -327.79206,64.382428 C -328.32176,63.789068 -328.91035,63.243435 -329.38116,62.602347 C -330.10713,61.613812 -330.00629,58.518285 -330.74173,57.389631 C -331.10429,54.912737 -331.77611,52.602172 -333.38422,50.618017 C -334.54222,48.792749 -335.65575,46.893772 -337.23988,45.399193 C -339.41181,43.588309 -342.41416,43.219701 -345.09189,42.665944 C -349.16984,42.072653 -353.22505,41.340634 -357.31297,40.820653 L -334.29836,24.946084 z" />
<path
style="fill:#008000;fill-opacity:0.70196078;fill-rule:nonzero;stroke:none;stroke-width:0.69216907;stroke-linecap:square;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path3353"
d="M 135.79895,398.66751 C 137.81098,399.12597 139.81221,399.58957 141.85518,399.86103 C 143.65731,400.21648 145.4572,400.6457 146.77478,402.12672 C 147.68927,403.10713 148.32109,404.36408 149.00021,405.54652 C 149.90435,406.91093 150.36568,408.47698 150.64598,410.11944 C 150.62999,410.90788 152.13986,414.51811 150.874,411.48032 C 134.00024,423.23986 136.81637,423.36172 139.74759,417.27844 C 141.12735,414.41498 142.60951,411.63135 144.08658,408.82736 C 146.9936,403.36718 149.80396,397.85116 153.03773,392.61847 C 155.74795,388.47124 158.9142,384.75801 162.12618,381.09453 C 163.93149,379.01351 165.89108,377.12179 168.02485,375.46854 C 172.927,371.57655 177.91438,366.71758 184.00613,366.0635 L 172.28057,375.86128 C 171.71866,376.03353 171.559,376.05381 171.0298,376.33026 C 170.8259,376.43678 170.24058,376.81333 170.43522,376.68733 C 183.54037,368.20437 186.13915,366.44105 181.57232,369.52658 C 179.40002,371.33774 177.02347,372.86474 175.15579,375.1105 C 171.8414,378.72934 168.52853,382.36394 165.73768,386.51119 C 162.30545,391.69693 159.36334,397.24769 156.35947,402.7445 C 155.44489,404.68674 154.44365,406.57957 153.57602,408.54808 C 153.27576,409.22935 153.02184,409.9354 152.78093,410.645 C 152.75631,410.71753 152.19511,412.82711 152.09078,412.90473 C 147.89355,416.02705 143.53145,418.86844 139.25179,421.85029 C 138.97068,421.50148 138.65832,421.18073 138.40847,420.80386 C 138.0232,420.22274 138.07671,418.40303 137.68643,417.73955 C 137.49401,416.2835 137.13749,414.92522 136.28408,413.75884 C 135.66953,412.68584 135.07859,411.56953 134.23792,410.69093 C 133.08529,409.6264 131.49197,409.40971 130.07092,409.08419 C 127.90679,408.73542 125.75473,408.3051 123.5853,407.99943 L 135.79895,398.66751 z"
inkscape:export-filename="C:\src\postgis-working\loader\good.png"
inkscape:export-xdpi="20.721062"
inkscape:export-ydpi="20.721062" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 13 KiB

BIN
loader/image/warn.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 712 B

File diff suppressed because it is too large Load diff

237
loader/structure.c Normal file
View file

@ -0,0 +1,237 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "structure.h"
FILENODE *file_list_head = NULL;
FILENODE *file_list_tail = NULL;
void
init_file_list(void)
{
file_list_head = malloc(sizeof(FILENODE));
file_list_tail = malloc(sizeof(FILENODE));
file_list_head->filename = NULL;
file_list_head->schema = NULL;
file_list_head->table = NULL;
file_list_head->geom_column = NULL;
file_list_head->srid = NULL;
file_list_head->mode = '\0';
file_list_head->prev = NULL;
file_list_head->next = file_list_tail;
file_list_tail->filename = NULL;
file_list_tail->schema = NULL;
file_list_tail->table = NULL;
file_list_tail->geom_column = NULL;
file_list_tail->srid = NULL;
file_list_tail->mode = '\0';
file_list_tail->prev = file_list_head;
file_list_tail->next = NULL;
}
void
destroy_file_list(void)
{
FILENODE *node = get_next_node(NULL);
while(node != NULL)
{
remove_file(node);
node = get_next_node(NULL);
}
if(file_list_head != NULL)
{
file_list_head->next = NULL;
file_list_head->prev = NULL;
free(file_list_head);
}
if(file_list_tail != NULL)
{
file_list_tail->next = NULL;
file_list_tail->prev = NULL;
free(file_list_tail);
}
}
FILENODE*
append_file_node(void)
{
if(file_list_head == NULL || file_list_tail == NULL)
{
init_file_list();
}
FILENODE *new_node = malloc(sizeof(FILENODE));
new_node->filename = NULL;
new_node->schema = NULL;
new_node->table = NULL;
new_node->geom_column = NULL;
new_node->srid = NULL;
new_node->mode = '\0';
new_node->tree_iterator = NULL;
new_node->next = file_list_tail;
new_node->prev = file_list_tail->prev;
file_list_tail->prev->next = new_node;
file_list_tail->prev = new_node;
return new_node;
}
FILENODE*
append_file(char *filename, char *schema, char *table,
char *geom_column, char *srid, char mode,
GtkTreeIter *tree_iterator)
{
FILENODE *new_file = append_file_node();
/*
* I have no reason to believe that freeing char*'s in the struct will
* not harm the ui and vice versa, so I'm avoiding the problem by dup'ing.
*/
new_file->filename = strdup(filename);
new_file->schema = strdup(schema);
new_file->table = strdup(table);
new_file->geom_column = strdup(geom_column);
new_file->srid = strdup(srid);
new_file->mode = mode;
new_file->tree_iterator = tree_iterator;
return new_file;
}
FILENODE*
find_file_by_iter(GtkTreeIter *tree_iterator)
{
FILENODE *current_node;
if(file_list_head == NULL)
{
return NULL;
}
current_node = file_list_head->next;
while(current_node != NULL && current_node != file_list_tail)
{
if(current_node->tree_iterator == tree_iterator)
{
return current_node;
}
current_node = current_node->next;
}
return NULL;
}
FILENODE*
find_file_by_index(int index)
{
FILENODE *current_node;
int i = 0;
if(file_list_head == NULL)
{
return NULL;
}
current_node = file_list_head->next;
while(current_node != NULL && current_node != file_list_tail)
{
if(i == index)
{
return current_node;
}
current_node = current_node->next;
i++;
}
return NULL;
}
void
remove_file(FILENODE *remove_node)
{
if(remove_node == NULL
|| remove_node->next == NULL
|| remove_node->prev == NULL)
{
return;
}
remove_node->next->prev = remove_node->prev;
remove_node->prev->next = remove_node->next;
remove_node->next = NULL;
remove_node->prev = NULL;
if(remove_node->filename == NULL)
{
free(remove_node->filename);
remove_node->filename = NULL;
}
if(remove_node->schema == NULL)
{
free(remove_node->schema);
remove_node->schema = NULL;
}
if(remove_node->table == NULL)
{
free(remove_node->table);
remove_node->table = NULL;
}
if(remove_node->geom_column == NULL)
{
free(remove_node->geom_column);
remove_node->geom_column = NULL;
}
if(remove_node->srid == NULL)
{
free(remove_node->srid);
remove_node->srid = NULL;
}
free(remove_node);
}
FILENODE*
get_next_node(FILENODE *current)
{
if(file_list_head == NULL)
return NULL;
if(current == NULL)
current = file_list_head;
return (current->next != file_list_tail) ? current->next : NULL;
}
void
print_file_list_delegate(void (*printer)(const char *fmta, va_list apa), const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
(*printer)(fmt, ap);
va_end(ap);
return;
}
void
print_file_list(void (*printer)(const char *fmt, va_list ap))
{
FILENODE *current_node;
int i = 0;
print_file_list_delegate(printer, "File List:\n");
print_file_list_delegate(printer, "Head %p <-- %p --> %p\n", file_list_head->prev, file_list_head, file_list_head->next);
current_node = get_next_node(NULL);
while(current_node != NULL)
{
print_file_list_delegate(printer, " Node %d: %s\n", i++, current_node->filename);
print_file_list_delegate(printer, " %p <-- %p --> %p\n", current_node->prev, current_node, current_node->next);
current_node = get_next_node(current_node);
}
print_file_list_delegate(printer, "Tail %p <-- %p --> %p\n", file_list_tail->prev, file_list_tail, file_list_tail->next);
}

44
loader/structure.h Normal file
View file

@ -0,0 +1,44 @@
#ifndef __PGIS_STRUCTURE_H__
#define __PGIS_STRUCTURE_H__
#include <gtk/gtktreemodel.h>
typedef struct file_node
{
char *filename;
char *schema;
char *table;
char *geom_column;
char *srid;
char mode;
GtkTreeIter *tree_iterator;
struct file_node *next;
struct file_node *prev;
} FILENODE;
void init_file_list(void);
void destroy_file_list(void);
FILENODE *append_file_node(void);
FILENODE *append_file(char *filename, char *schema, char *table,
char *geom_column, char *srid, char mode,
GtkTreeIter *tree_iterator);
FILENODE *find_file_by_iter(GtkTreeIter *tree_iterator);
FILENODE *find_file_by_index(int index);
void remove_file(FILENODE *remove_node);
/*
* This is a debugging function, it shouldn't really be used for
* general status output. It takes a function pointer of the same
* signature as vprintf (hint).
*/
void print_file_list(void (*printer)(const char *fmt, va_list ap));
/*
* This will return the next node after the current node.
* If the current is null, it will return the first node. Returns NULL
* if the list is uninitialised, empty or if the current node is the last node.
*/
FILENODE *get_next_node(FILENODE *current);
#endif /* __PGIS_STRUCTURE_H__ */

BIN
loader/structure.o Normal file

Binary file not shown.