[Gdal-dev] Ready to commit first batch of swig-java changes

Andrea Aime aaime at openplans.org
Sun Mar 18 16:31:03 EDT 2007

Tamas Szekeres ha scritto:
> 2007/3/18, Andrea Aime <aaime at openplans.org>:
>> Hi,
>> as you may know, I've been working on making WKB useful as
>> a transfer format to cross the JNI barrier.
>> When I started, things weren't working as expected (JVM crash)
>> because of different interpretation of what a char is on
>> either side (8 bit on the C side, 16 bits character on the java side).
> Just an idea. Can't it be handled by using %typemap(jni) char *wkb_buf
> ... for mapping the original type to the java expected type. As far as
> I can see only the mapping of the type is the problem but the
> implementation of that method is the same.

Hum... I've been using SWIG for 3-4 days total now, so I was happy to 
have something working. Next weekend I'll have a look at your proposal 
thought :-)

>> I had to perform a bit of changes in both the functions returning wkb,
>> and the geometry construction ones that do take wkb as an input.
>> The outcome is not a fully clean extension as I hoped, because
>> the geometry constructor calls a static function that should
>> be defined before it. Anyways, the patch is attached for anyone
>> to review. I do believe a similar patch would be needed for c#
>> to handle geometry creation from wkb, too.
> Would you describe this issue in more detail? I think those static
> functions have already been declared in ogr_api.h.

Sure. The Geometry construction from WKB uses a static function,
CreateGeometryFromWkt( char **val, 
OSRSpatialReferenceShadow *reference=NULL ), and I have to redefine
both. Now, I would have liked to put both in an ogr_java_extend.i much 
like the c# extensions.
Unfortunately, doing so does not work, because SWIG reorders the
declarations, and puts the ogr geometry shadow constructor among
the other geometry shadow methods, leaving the static function
I added after it. The c++ compiler at that point complains that
I cannot call the static one, because it's declared after.

As a result, I had to mix the java specific code in ogr.i, so that
I can preserve the right order.

>> Do you have any kind of procedure I have to follow
>> before committing? In Geoserver I would open a jira issue to
>> record the change, so that the jira changelog contained that change
>> too.
> Those changes doesn't affect the other languages so you can commit the
> changes freely. None of us can be attentive to the java related issues
> as much as you can  :-)

May be, but at the same time you know SWIG a lot more than I do :-)

Many thanks for the feedback

More information about the Gdal-dev mailing list