Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP GDAL/OGR library usage, which approach is cleaner?

Tags:

php

gdal

ogr

I will be using gdal/ogr for a new project. I want a lean but fully functional app, so will not be using other implementations such as mapserver, because they have extraneous components that I doubt will be needed in the application, even in the future. For the record, it is a GIS, but I am asking here on SO because there as so few examples of a GIS in php that uses GDAL/OGR

I basically have three options in mind:

  • use php's exec() function to run command line conversion utilities

  • Use swig to generate a .dll and load it as an extension on php

  • Use the php wrapper written by geonfr @https://github.com/geonef/php5-gdal/wiki

Which do you think is the most effective way to implement the library?

like image 938
Ego_I Avatar asked Mar 28 '13 09:03

Ego_I


1 Answers

I wound up using the exec functions, mostly because there was no time to get into swig or php extension development, which were the preferred methods for me, personally. // here is a small sample snippet of it's usage, hopefully it will come in handy for someone else

public function convertToNewFormat($format)
        {
                return(
                    exec('ogr2ogr -f '
                        .$format
                        .' '.self::setNewFileLocation()
                        .' '.self::setOldFileLocation()));

        }
like image 74
Ego_I Avatar answered Sep 30 '22 12:09

Ego_I