[gdal-dev] Two questions about Java API

Even Rouault even.rouault at spatialys.com
Wed Jun 7 09:21:51 PDT 2023


Sorry, missed the question

You need to create a typemap for "(int nList, GUIntBig* pList)" that can 
be mapped to an a long[] in Java. You probably don't care about the 
range of uint64_t (GUIntBig is a GDAL specific alias of uint64_t) that 
cannot be mapped to a int64_t, so no need to go with Biginteger[]

Such typemap should be similar to the existing "(int nList, int* pList)" one

SWIG indeed generates rather dummy SWIGTYPE_p_xxxx types when there are 
missing typemaps. When such types appear in the Java API it means that a 
typemap is missing

Even


Le 07/06/2023 à 18:03, Barry DeZonia a écrit :
> Thanks Even. I'll look at this later. But you only answered one of my 
> questions. The type SWIGTYPE_p_GUIntBig is specified in the Java API 
> for CreateAttribute(). No such thing is shown in the python tests you 
> showed me. I would suspect because python has unlimited range integers 
> and an array for them will work just fine, But this weird SWIG type in 
> Java seems misplaced. What should the signature be? dimensions as 
> lon[]? dimensions as Biginteger[]? And if so then why is the current 
> signature so messy with this SWIG type. If it is supposed to be this 
> weird SWIG type then how do I create it? The Java api javadoc does not 
> show it has any useful methods.
>
> On Wed, Jun 7, 2023 at 3:47 AM Even Rouault 
> <even.rouault at spatialys.com> wrote:
>
>     Barry,
>
>     you can't instantiate the objects directly. They are tied to an
>     underlying driver.
>
>     You could for example port this subset of those tests of the MEM
>     driver:
>     https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/memmultidim.py#L85
>
>     and
>     https://github.com/OSGeo/gdal/blob/master/autotest/gdrivers/memmultidim.py#L188
>
>     . Note that they test a bit more than just the API, but also the
>     implementation of the MEM driver, so you don't need to test all error
>     cases for example
>
>     Even
>
>     Le 07/06/2023 à 04:54, Barry DeZonia a écrit :
>     > Hello,
>     >
>     > I am trying to extend the Java API so that the MDArray code is more
>     > full featured. Right now I am working on extending Attribute to
>     return
>     > a Vector<Dimension> when Attribute::GetDimensions() is called.
>     Much of
>     > this support is missing and I am in the process of wiring it up.
>     I am
>     > starting to write test code to drive development and have two
>     > questions about my test code. I am pasting the code below with
>     > questions inlined.
>     >
>     > private static void testGetDimensions() {
>     >
>     >     // QUESTION 1:
>     >     // how do I create a Group programmatically?
>     >
>     >     Group group1 = new Group("universe1");  // NOPE
>     >
>     >     Group group2 = Group.CreateGroup("universe2");  // NOPE
>     >
>     >     // QUESTION 2:
>     >     // What is a SWIGTYPE_p_GUIntBig?
>     >     //  Is this type exposed in MDArray API as a flaw in the
>     current
>     > Java API?
>     >     //  See API docs for MDArray::CreateAttribute()
>     >
>     >     group1.CreateAttribute("jane",
>     >                                 1,
>     >                                 null,  // wants an array of
>     > SWIGTYPE_p_GUIntBig
>     > ExtendedDataType.Create(gdalconst.GDT_UInt16));
>     >
>     >     Attribute attribute = group.GetAttribute("jane");
>     >
>     >     Vector<Dimension> dims = attribute.GetDimensions();
>     > }
>     >
>     > So can anyone answer my two questions? Am I approaching this right?
>     > Thanks for any info.
>     >
>     >
>     > _______________________________________________
>     > gdal-dev mailing list
>     > gdal-dev at lists.osgeo.org
>     > https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>     -- 
>     http://www.spatialys.com
>     My software is free, but my time generally not.
>
-- 
http://www.spatialys.com
My software is free, but my time generally not.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230607/9b5dd2e1/attachment.htm>


More information about the gdal-dev mailing list