[Gdal-dev] PHP-OGR Extension- OGR_DS_GetLayer() doesn't always
return the same layer handle
Frank Warmerdam
warmerdam at pobox.com
Thu May 15 18:00:38 EDT 2003
Normand Savard wrote:
> Hi Frank,
>
> I have built php unit tests to verify the php-ogr extension functions.
> In order to perform data comparison against validation data, I need to
> get some specific layers. I used "OGR_DS_GetLayer()" function to get an
> handle to a specific layer. As you know, this function takes two
> arguments: a data source handle and a layer number.
>
> I was believing that giving the same layer number, this function will
> always return me the same layer handle. But when I copied a data
> directory to a new directory the order of the layers changed. So, when
> I call the "OGR_DS_GetLayer()" function with a specific layer number,
> the return layer handle did not correspond to the layer into the source
> directory.
>
> As a workaround, I used "OGR_DS_GetLayerByName()" function. Is there a
> plan to modify the "OGR_DS_GetLayer()" function to always return the
> same layer handle giving a specific layer number?
Normand,
Some drivers, such as the directory based Shapefile driver read the files
in the directories and return the layer list in the order that the files
are returned from the directory. This can, as you have encountered, vary
when the files are copied.
I do not anticipate making any changes to the driver(s) to alleviate this
situations. The layer numbers are not guaranteed to be stable, so you will
have to use layer names as you have seen.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list