Re: [postgis-users] Size of .dbf file produced with pgsql2shp
Denis Rykov wrote: I've try to get exit code with my python script: import os code = os.system(pgsql2shp -f dagestan.shp -h gis-lab.info http://gis-lab.info/ -u labinfo -P *** osm \SELECT ^^ st_intersection as geom from dagestan_point_attr WHERE highway='bus_stop') print code At result I've got 256 (not 2 as expected). H looks like you're missing an escaped quote somewhere? If your svn up worked, the exit code should be either 0 or 1. To test from bash: pgsql2shp -f dagestan.shp SELECT st_intersection as geom from dagestan_point_attr WHERE highway='bus_stop' echo $? HTH, 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
Mark, thanks for quick response, I've try to do it with bash: [...@gis ~/gl/projects/osmrus]$ pgsql2shp -u pgsql -f dagestan.shp osm SELECT st_intersection as geom from dagestan_point_attr WHERE highway='bus_stop' Initializing... ERROR: Could not determine table metadata (empty table) [...@gis ~/gl/projects/osmrus]$ echo $? 1 But you wrote that exit code of 0 on success, and 2 if 0 records were processed Why I get 1, but not 2? On Mon, Sep 13, 2010 at 11:06 PM, Mark Cave-Ayland mark.cave-ayl...@siriusit.co.uk wrote: Denis Rykov wrote: I've try to get exit code with my python script: import os code = os.system(pgsql2shp -f dagestan.shp -h gis-lab.info http://gis-lab.info/ -u labinfo -P *** osm \SELECT ^^ st_intersection as geom from dagestan_point_attr WHERE highway='bus_stop') print code At result I've got 256 (not 2 as expected). H looks like you're missing an escaped quote somewhere? If your svn up worked, the exit code should be either 0 or 1. To test from bash: pgsql2shp -f dagestan.shp SELECT st_intersection as geom from dagestan_point_attr WHERE highway='bus_stop' echo $? HTH, 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
On Thu, Sep 02, 2010 at 12:48:17AM +0100, Mark Cave-Ayland wrote: Mark Cave-Ayland wrote: Ah wait a second, you're right - I've been looking in the wrong place. It looks like there is still some (old) pgsql2shp code which hasn't been updated to use the new error handling, and hence it doesn't get propagated back up to the main function correctly :( Will fix later, as I have to head out now. Okay - I've just committed a better fix as r5892 which makes sure that in the case of a 0 row result, pgsql2shp will terminate returning an error code of 1 (failure) as opposed to 0 (success) when dumping tables into shapefiles (serves me right for trying to fix things in a rush when I'm just about to head out). Denis, please can you try again after an svn up? Just to stress my point out, I was suggesting NOT to look at number of rows to tell success/failure. Granted, pgsql2shp is currently unable to produce a 0-row valid shapefile, but maybe such thing exists. It is fine for me throwing different non-zero return codes for different errors. Just I think this error is: Can't determine geometry type and not: There are no rows Clearer now ? --strk; () Free GIS Flash consultant/developer /\ http://strk.keybit.net/services.html ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
Denis Rykov wrote: Just updated pgsql2shp from svn and try to use it: pgsql2shp -f arkhan.shp osm SELECT st_intersection as geom from arkhan_line_attr WHERE tourism'' If SELECT returns empty table I get notice: ERROR: Could not determine geometry type (empty table). Done (postgis major version: 2). Output shape: Null Shape Dumping: [0 rows]. At result pgsql2shp produce one .dbf file with 256 Bytes size. Some days ago, before updating pgsql2shp, size of such .dbf file was 1 Byte. I use size of this empty *.dbf file in my script. Need I change this value to 226 or this is a bug? Checking the resulting file size is not the right way to be trying to detect whether the query returned 0 rows. It strikes me that the best way to detect this would be to return a different exit code from pgsql2shp if no rows are returned - would this work for you? 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
On Wed, Sep 01, 2010 at 12:03:36PM +0100, Mark Cave-Ayland wrote: Denis Rykov wrote: ERROR: Could not determine geometry type (empty table). Done (postgis major version: 2). Output shape: Null Shape Dumping: [0 rows]. Checking the resulting file size is not the right way to be trying to detect whether the query returned 0 rows. It strikes me that the best way to detect this would be to return a different exit code from pgsql2shp if no rows are returned - would this work for you? I'd go stricter to if an ERROR occurred rather than if no rows are returned. Just in case one day we'll add a flag to specify the geometry type thus allowing creation of empty-but-structuted shapefiles starting from a table template. --strk; () Free GIS Flash consultant/developer /\ http://strk.keybit.net/services.html ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
It would be great if you can add an exit code for 0 records dbfs, it'll make my life so much easier. 2010/9/1 Mark Cave-Ayland mark.cave-ayl...@siriusit.co.uk: Denis Rykov wrote: Just updated pgsql2shp from svn and try to use it: pgsql2shp -f arkhan.shp osm SELECT st_intersection as geom from arkhan_line_attr WHERE tourism'' If SELECT returns empty table I get notice: ERROR: Could not determine geometry type (empty table). Done (postgis major version: 2). Output shape: Null Shape Dumping: [0 rows]. At result pgsql2shp produce one .dbf file with 256 Bytes size. Some days ago, before updating pgsql2shp, size of such .dbf file was 1 Byte. I use size of this empty *.dbf file in my script. Need I change this value to 226 or this is a bug? Checking the resulting file size is not the right way to be trying to detect whether the query returned 0 rows. It strikes me that the best way to detect this would be to return a different exit code from pgsql2shp if no rows are returned - would this work for you? 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
strk wrote: Checking the resulting file size is not the right way to be trying to detect whether the query returned 0 rows. It strikes me that the best way to detect this would be to return a different exit code from pgsql2shp if no rows are returned - would this work for you? I'd go stricter to if an ERROR occurred rather than if no rows are returned. Just in case one day we'll add a flag to specify the geometry type thus allowing creation of empty-but-structuted shapefiles starting from a table template. --strk; This is exactly how the new code in trunk currently works - you get an exit code of 0 to indicate success, and an exit code of 1 if an error occurred. I was thinking of adding a new exit code of 2 to indicate success, but also that 0 records were processed. 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
Denis Rykov wrote: It would be great if you can add an exit code for 0 records dbfs, it'll make my life so much easier. Okay done - it was quite a simple patch in the end. Can you update to SVN r5888 and confirm that you get an exit code of 0 on success, and 2 if 0 records were processed? 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
On Wed, Sep 01, 2010 at 06:29:56PM +0100, Mark Cave-Ayland wrote: strk wrote: Checking the resulting file size is not the right way to be trying to detect whether the query returned 0 rows. It strikes me that the best way to detect this would be to return a different exit code from pgsql2shp if no rows are returned - would this work for you? I'd go stricter to if an ERROR occurred rather than if no rows are returned. Just in case one day we'll add a flag to specify the geometry type thus allowing creation of empty-but-structuted shapefiles starting from a table template. --strk; This is exactly how the new code in trunk currently works - you get an exit code of 0 to indicate success, and an exit code of 1 if an error occurred. I was thinking of adding a new exit code of 2 to indicate success, but also that 0 records were processed. I can't see how this was a success in the reporter's case. Could not determine a geometry type, so what could it have written in the .shp file ? It even printed an ERROR message. How's that a success ? --strk; () Free GIS Flash consultant/developer /\ http://strk.keybit.net/services.html ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
strk wrote: I can't see how this was a success in the reporter's case. Could not determine a geometry type, so what could it have written in the .shp file ? It even printed an ERROR message. How's that a success ? --strk; Ah wait a second, you're right - I've been looking in the wrong place. It looks like there is still some (old) pgsql2shp code which hasn't been updated to use the new error handling, and hence it doesn't get propagated back up to the main function correctly :( Will fix later, as I have to head out now. 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
Re: [postgis-users] Size of .dbf file produced with pgsql2shp
Mark Cave-Ayland wrote: Ah wait a second, you're right - I've been looking in the wrong place. It looks like there is still some (old) pgsql2shp code which hasn't been updated to use the new error handling, and hence it doesn't get propagated back up to the main function correctly :( Will fix later, as I have to head out now. Okay - I've just committed a better fix as r5892 which makes sure that in the case of a 0 row result, pgsql2shp will terminate returning an error code of 1 (failure) as opposed to 0 (success) when dumping tables into shapefiles (serves me right for trying to fix things in a rush when I'm just about to head out). Denis, please can you try again after an svn up? 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 Sirius Labs: http://www.siriusit.co.uk/labs ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users
[postgis-users] Size of .dbf file produced with pgsql2shp
Just updated pgsql2shp from svn and try to use it: pgsql2shp -f arkhan.shp osm SELECT st_intersection as geom from arkhan_line_attr WHERE tourism'' If SELECT returns empty table I get notice: ERROR: Could not determine geometry type (empty table). Done (postgis major version: 2). Output shape: Null Shape Dumping: [0 rows]. At result pgsql2shp produce one .dbf file with 256 Bytes size. Some days ago, before updating pgsql2shp, size of such .dbf file was 1 Byte. I use size of this empty *.dbf file in my script. Need I change this value to 226 or this is a bug? ___ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users