[FWTools] Help with ogr2ogr on windows

Chetan Tiwari chetan.tiwari at gmail.com
Tue Jun 5 23:29:13 EDT 2007


Greetings!

I've been struggling with a small problem with ogr2ogr and was wondering if
anyone here can provide some pointers. I'm working on a web-based analysis
system for environmental health surveillance and one of the aspects of this
system is the ability to obtain data from multiple data repositories on the
internet. I'm using ogr2ogr to basically convert a set of GML documents into
tables in postgresql. I'm using perl to download GML data and then calling
ogr2ogr using a system() command. I'm using Windows Vista, Apache and Active
perl. Now, I've tested this setup and my scripts on a machine running
Windows 2003 server and Windows XP and everything works perfectly. The move
to Vista seems to be causing problems *only* when the script is called from
a browser (it works perfectly when run from the command line). If it were
incompatibility issues with Vista, then the script should fail everywhere -
the fact that it fails only when called from a browser is what I'm curious
about. Anyway, the relevant portions of the script are as follows:

#!c:\perl\bin\perl.exe -w

# Use LWP::Simple to fetch cafo data from WFS server
use LWP::Simple;

MAIN:
{
 # Define variables
 # Data source
 my $dsource = '
http://localhost/geoserver/wfs?request=getfeature&typename=envdata:cafos';

 # Start script
 # Define content type
 print "Content-type: text/html\n\n";

 # Download data from dsource and store in \uploads\cafo.gml
 eval{

getstore($dsource,'c:\\progra~1\\Apache~1\\Apache2.2\\htdocs\\uploads\\cafo.gml');

 };

 # Print error if any
 if ($@){
  print $@;
 }

 # create ogr2ogr command
my $ogrcmd="c:\\Progra~1\\FWTool~1\.2\\bin\\ogr2ogr.exe -overwrite -s_srs
EPSG\:26915 -t_srs EPSG\:4326 -lco geometry_name=the_geom -f \"PostgreSQL\"
PG:\"host=localhost user=foo password=bar dbname=test\"
c:\\progra~1\\apache~1\\apache2.2\\htdocs\\uploads\\cafo\.gml -nln
public.cafolocations";

 # execute ogr2ogr

if(my $pid = fork){
}
elsif (defined $pid){
        close(STDOUT);
        exec($ogrcmd);
        exit(0);
} else{
        die "Fork Error";
}

# End script
}
Any comments are appreciated. Thanks very much,

Chetan

-- 
Chetan Tiwari, Ph.D. (ABD)
Dept. of Geography, The Univ. of Iowa
316 Jessup Hall, Iowa City, IA 52242
Ph. (319) 335-0165 Fax (319) 335-2725
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20070605/321456ea/attachment.html


More information about the FWTools mailing list