[postgis-devel] Status of shp2pgsql-core/shp2pgsql?

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Sun Apr 12 14:32:32 PDT 2009


Paul Ramsey wrote:

> Just guts. I didn't have the guts to ditch the old one when I put in
> the new ones. Mostly because the workflow of the new ones is slightly
> more complicated, to allow for the GUI to keep it's display thread in
> place as work runs.
> 
> I can flip over to the new core and re-name shp2pgsql-cli to shp2pgsql.

Righto, I've had a look at this and I think that the API needs some work 
  before we can implement the switch.

Firstly, we should change the shp2pgsql core so that instead of using 
#ifdef PGUI... #endif to determine whether not to return a string or 
output to stdout, we should always return a string. Then it is up to the 
CLI or GUI application to use the string and free it when appropriate.

Secondly, the LoadData() function is not setup in a way which is helpful 
for clients making use of the API. I'm thinking perhaps it should be 
re-factored along the following lines so that the main loop of the 
command line and the GUI look something like this:

count = LoadDataFirst();
while ( i < count )
{
	string = LoadDataNext();
	...
	i++;
}

So LoadDataFirst() would output any relevant headers and return a count 
of the total number of rows in the shapefile, while LoadDataNext() would 
return a string containing the output row. If the main loop of the 
command line and GUI tool can be refactored in this way, then it should 
be possible to add an event handler somewhere in there so that the GUI 
can process events and hence prevent the freezing Paul has mentioned 
before. Does this sound reasonable to everyone?


ATB,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063



More information about the postgis-devel mailing list