<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Michael,</p>
<p>This is likely a design decision from 20 years ago when the "new"
bindings have been added. I wasn't involved, but I can imagine at
least 2 reasons to prefer binding C functions rather than C++
classes:</p>
<p>- make sure that the bindings generated against GDAL X still run
against libgdal Y where Y >= X without being rebuilt, since the
C ABI is backwards compatible. But that doesn't seem to be a very
realistic/common scenario</p>
<p>- avoid exposing to SWIG things that haven't been considered
stable enough to be exposed to C</p>
<p>Maybe other GDAL users, such as people doing Rust or R bindings,
could give us some hints if they'd be interested in binding the
GDALGeoTransform class to their language. If so, making C bindings
would serve everybody.</p>
<p>Even</p>
<div class="moz-cite-prefix">Le 31/08/2026 à 21:50, Michael via
gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CACKw9A9nQukYtXqKMAVjVirH7iT1A3YL4=CX4KDjPUt5Xu7cUg@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">
<div>I want to expose the GDALGeoTransform class. It doesn't
have a C struct representation (like OGREnvelope) or an
opaque C handle type. I could add C interfaces to
GDALGeoTransfor, but that seems absurd since
GDALGeoTransfor is mostly a C++ wrapper of the C routines.</div>
<div><br>
</div>
<div>However, using the GDALGeoTransfor class directly from
the SWIG interfaces works surprisingly well (See below).
What doesn't work is the 'Apply' overloads which accept a
`GDALRasterWindow` type, because SWIG can't
include gdal_rasterband.h while CPL_SUPRESS_CPLUSPLUS is
defined.</div>
<div><br>
</div>
<div>So my questions are: can I use the GDALGeoTransfor c++
class directly from SWIG and, if not, why?
</div>
<div>-------------</div>
<div><br>
</div>
<div>%{<br>
#include "gdal_geotransform.h"<br>
%}</div>
<div><br>
class GDALGeoTransform {<br>
private:<br>
const double *data() const;<br>
~GDALGeoTransform();<br>
public:<br>
%mutable;<br>
GDALGeoTransform();<br>
GDALGeoTransform(const double coeffs[6]);<br>
GDALGeoTransform(double xorigIn, double xscaleIn, double
xrotIn, double yorigIn, double yrotIn, double yscaleIn);<br>
void Rescale(double dfXRatio, double dfYRatio);<br>
%immutable;<br>
void Apply(double dfPixel, double dfLine, double *pdfGeoX,
double *pdfGeoY) const;<br>
bool GetInverse(GDALGeoTransform &inverse) const;<br>
bool IsAxisAligned() const;<br>
};</div>
<br>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">Michael Bucari</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.
LLMs contribute to global warming and brain rot.
Let's guillotine them! "Ah ! ça ira, ça ira, ça ira !"</pre>
</body>
</html>