Opened 11 years ago
Closed 11 years ago
#4970 closed defect (fixed)
Calling ogr2ogr from MAMP's php fails
Reported by: | dtarc | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SRS | Version: | unspecified |
Severity: | normal | Keywords: | vsistdout ogr2ogr |
Cc: |
Description
Hi,
I think the issue I am having is with my php configuration as opposed to something ogr2ogr is doing but this seems like the most likely place to get help.
We've been using ogr2ogr to do geodata conversions in a drupal project for over a year now. We have it running on various servers and it was working fine on my dev environment. Recently I rebuilt my dev environment, switching from Mac OS X Lion to Mac OS X Mountain Lion and starting from scratch, and I can no longer get valid info back when calling ogr2ogr from PHP.
I am using MAMP and PHP 5.3.14. Also using the bare bones drupal module (http://drupal.org/project/ogr2ogr). I was using GDAL 1.9.2, but when it wasn't working I downgraded to 1.8.1. I have installed it using Homebrew.
GDAL seems to be installed correctly as I can call ogr2ogr commands from the command line and I get valid data returned. When I call the same command from PHP, I don't get anything back.
Here is the command I am trying to run:
/usr/bin/ogr2ogr -f CSV /vsistdout/ "/path/to/SHAPEFILE.shp" -lco GEOMETRY=AS_WKT -t_srs EPSG:4326
If I run it from the command line, I get valid WKT results returned in CSV format.
Running from PHP, I'm executing the following code:
<code>
Build $command
...
if (($handle = popen($command, "r")) !== FALSE) {
while (($data = fgetcsv($handle)) !== FALSE) {
Process incoming data
}
}
</code>
The popen command seemed to return a valid file handle and gets evaluated as TRUE. Hoever the fgetcsv() call always returns FALSE. I have subbed in fgets() and that will also return FALSE. Again, this is an ogr2ogr command that returns data when called from the shell.
I got a tip to make sure that the php environment variable auto_detect_line_endings was set to TRUE but that did not help.
Does anyone have any suggestions? Thanks in advance.
Change History (1)
comment:1 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Summary: | Can't read /vsistdout/ via php's popen() on Mac OS X Mountain Lion → Calling ogr2ogr from MAMP's php fails |
I have resolved my issue. It turns out the conflict was with MAMP. So currently ogr2ogr called from MAMP php will not work without making a change to MAMP.
Here's the error I had in MAMP's apache error log:
A co-worker got this error:
A similar conflict with MAMP that's well documented is the MAMP-ImageMagick conflict - http://www.maratz.com/blog/archives/2010/05/11/imagemagick-with-mamp/
So the fix is to disable MAMP's DYLD_LIBRARY_PATH variable.
Edit MAMP's environment variable settings file:
Comment out the two lines that set and export the path, which should then look like: