Re: [gdal-dev] Is source Dataset array to `GDALWarp` mutable?

2024-01-10 Thread Fitch, Simeon via gdal-dev
Even,

Thanks so much for the helpful information. I know the updated docs (and
tests!!!) will help others as well.

Simepno

On Tue, Jan 9, 2024 at 2:26 PM Even Rouault via gdal-dev <
gdal-dev@lists.osgeo.org> wrote:

>
> https://github.com/OSGeo/gdal/pull/9045 will clarify it for posterity
>
> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
> ___
> gdal-dev mailing list
> gdal-dev@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>

-- 
The content of this email is intended for the person or entity to which it 
is addressed only. This email may contain confidential information. If you 
are not the person to whom this message is addressed, be aware that any 
use, reproduction, or distribution of this message is strictly prohibited. 
If you received this in error, please contact the sender and immediately 
delete this email and any attachments.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Is source Dataset array to `GDALWarp` mutable?

2024-01-09 Thread Even Rouault via gdal-dev


https://github.com/OSGeo/gdal/pull/9045 will clarify it for posterity

--
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Is source Dataset array to `GDALWarp` mutable?

2024-01-09 Thread Even Rouault via gdal-dev


Le 09/01/2024 à 19:45, Fitch, Simeon via gdal-dev a écrit :
I have a question about the mutability of the `pahSrcDS` argument to 
`GDALWarp`.


The `GDALWarp` function has the following signature:

```
GDALDatasetH GDALWarp(const char *pszDest, GDALDatasetH hDstDS, int 
nSrcCount,

                      GDALDatasetH *pahSrcDS,
                      const GDALWarpAppOptions *psOptionsIn, int 
*pbUsageError)

```
Source: 
https://github.com/OSGeo/gdal/blob/895e9fbd63b2aa22471f4f8c69efd5ba4e700e9c/apps/gdalwarp_lib.cpp#L1379-L1381


I was curious to see that `pahSrcDS` was not `const GDALDatasetH 
*pahSrcDS` or `const GDALDatasetH * const pahSrcDS`.


What mutability and ownership conclusions should I draw from it (if any)?

* Might the `GDALWarp` mutate the array and/or the pointed Datasets?
No. The const correctness could have indeed be done better (although a 
reason for that is that in C, a  "T**" is not implicitly cast as "const 
T* const*", contrary to C++)
* Is it correct to assume the caller maintains ownership of the 
elements of `pahSrcDS`?


Yes

Note that if the output format is VRT, then the return VRT dataset will 
reference the input dataset handle (a single one is allowed in that 
case). Hence, in that particular case (works also in the general case), 
you should close first the output dataset and then source dataset(s), as 
done by gdalwarp_bin.cpp


Even

--
http://www.spatialys.com
My software is free, but my time generally not.
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev