<div dir="ltr">Even,<div><br></div><div>Does this look okay as part of my typemap declaration? It is the only part I am confused about. I am very unfamiliar with this "(DDDDDL...." stuff And the L and V after each parameter. Where can I learn what this stuff means?</div><div><br></div><div>%typemap(argout) (int *nDimensions, GDALDimenion const **pDimensions )<br>{<br>  const jclass dimensionClass = jenv->FindClass("org/gdal/gdal/Dimension");<br>  const jclass vectorClass = jenv->FindClass("java/util/Vector");<br>  const jmethodID add = jenv->GetMethodID(vectorClass, "add", "(Ljava/lang/Object;)Z");<br>  const jmethodID dimensionCon = jenv->GetMethodID(dimensionClass, "<init>",<br>    "(DDDDDLjava/lang/Long;Ljava/lang/Boolean;)V");<br><br>  for( int i = 0; i < *$1; i++ ) {<br>    jobject dimensionObj = jenv->NewObject(dimensionClass, dimensionCon,<br>                                &((*$2)[i]),<br>                                true);<br>    jenv->CallBooleanMethod($input, add, dimensionObj);<br>  }<br>}<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 3, 2023 at 11:26 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p><br>
    </p>
    <div>Le 03/06/2023 à 18:16, Barry DeZonia a
      écrit :<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Ok, thanks. I will consider this for some of my
        future weekend-playtime-programming days. Yes, I'm a masochist.</div>
    </blockquote>
    great, we'd definitely welcome a few ones :-)<br>
    <blockquote type="cite">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Are there other typemaps needed that would further
          strengthen the Java api support?</div>
      </div>
    </blockquote>
    <p>Basically most #if defined(SWIGPYTHON) in <a href="https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i#L159" target="_blank">https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i</a>
      around a method are an indication that a typemap is missing. <br>
    </p>
    <p>Like:</p>
    <p>-
<a href="https://github.com/OSGeo/gdal/blob/92f9cee9a9ed3f114d3e6a63d095ceb09ce85eec/swig/include/MultiDimensional.i#L210" target="_blank">https://github.com/OSGeo/gdal/blob/92f9cee9a9ed3f114d3e6a63d095ceb09ce85eec/swig/include/MultiDimensional.i#L210</a>
      for CreateMDArray() (resolution of that one should be close to the
      existing "(int object_list_count, GDALRasterBandShadow
      **poObjects)" Java typemap)<br>
    </p>
    <p>-
<a href="https://github.com/OSGeo/gdal/blob/92f9cee9a9ed3f114d3e6a63d095ceb09ce85eec/swig/include/MultiDimensional.i#L464" target="_blank">https://github.com/OSGeo/gdal/blob/92f9cee9a9ed3f114d3e6a63d095ceb09ce85eec/swig/include/MultiDimensional.i#L464</a>
      for GetCoordinateVariables() (resolution of that one should be
      very close to the GetDimensions() one)</p>
    <p>-
<a href="https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i#L477" target="_blank">https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i#L477</a>
      for GetProcessingChunkSize() (resolution should be close to the
      existing "(int* pnCountOut, int** outErrorCodes)" java typemap</p>
    <p>- etc..<br>
    </p>
    <blockquote type="cite"><br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Sat, Jun 3, 2023 at
          11:03 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            <p><br>
            </p>
            <div>Le 03/06/2023 à 17:45, Barry DeZonia a écrit :<br>
            </div>
            <blockquote type="cite">
              <div dir="ltr">Thanks Even.
                <div><br>
                </div>
                <div>I might be able to find some time to do the SWIG
                  work depending upon the amount of development time
                  needed. I am a long time developer with experience in
                  Java, C, and C++ (but have not used SWIG before). Is
                  it just a few signatures I need to write or do I need
                  to write full support for a GDALDimension class? Can
                  you comment on this?</div>
              </div>
            </blockquote>
            <p>Yes this is "just" a few signatures to map a C array of
              (existing) GDALDimensionH objects to a vector of Java
              counterpart org.gdal.gdal.Dimension objects. The
              org.gdal.gdal.Dimension class already exists, with a
              "Dimension(long cPtr, boolean cMemoryOwn)" constructor
              taking the value of the underlying C pointer as a Java
              long. The cMemoryOwn boolean should probably be passed to
              true in that context, since the C GDALDimensionH objects
              need to be freed at the finalization of the Java Dimension
              object. This is really about glueing stuff, but that said
              writing SWIG typemaps is a whole adventure in itself...
              You may find relevant documentation at <a href="https://www.swig.org/Doc4.1/SWIGDocumentation.html#Java_typemaps" target="_blank">https://www.swig.org/Doc4.1/SWIGDocumentation.html#Java_typemaps</a>
              .  The hint I gave for the existing closest typemap should
              hopefully put you on the right track, or at least as close
              as possible. <br>
            </p>
            <blockquote type="cite">
              <div dir="ltr">
                <div><br>
                </div>
                <div>Am I right in understanding that, as of the current
                  Java implementation, one really can't use MDArrays for
                  much? Like if I can't find the number of (... z
                  planes, t steps, channels, etc.) of data I will not be
                  able to reconstruct the data?</div>
              </div>
            </blockquote>
            <p>Yes the multidim API is probably currently hardly usable
              outside C, C++ and Python due to the lack of a few
              critical typemaps for the other languages.<br>
            </p>
            <p>Even<br>
            </p>
            <blockquote type="cite"><br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Sat, Jun 3, 2023 at
                  6:09 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div>
                    <p>Barry,</p>
                    <p>This method is indeed not available currently in
                      the Java bindings. It is only available currently
                      in the Python bindings (see <a href="https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i#L159" target="_blank">https://github.com/OSGeo/gdal/blob/master/swig/include/MultiDimensional.i#L159</a>
                      ) , since it requires writing a specific SWIG
                      typemap for each binding language when a method
                      returns (or takes as argument) a new non-primitive
                      type such as here, with an array of dimensions.
                      The closest existing Java typemap I found that can
                      be used to take inspiration from is <a href="https://github.com/OSGeo/gdal/blob/master/swig/include/java/typemaps_java.i#L235" target="_blank">https://github.com/OSGeo/gdal/blob/master/swig/include/java/typemaps_java.i#L235</a>
                      but there would be changes to call the
                      "Dimension(long cPtr, boolean cMemoryOwn)"
                      constructor.  Whether you want to try to tackle
                      that yourself or not, you may create a ticket
                      about that</p>
                    <p>Even<br>
                    </p>
                    <div>Le 03/06/2023 à 09:09, Barry DeZonia a écrit :<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">On a related note is the Java api
                        code in a public repo somewhere? It would be
                        helpful to look at that code sometimes. (Like is
                        GetDimensions() present in the Java code but not
                        exposed as a public method?)</div>
                      <br>
                      <div class="gmail_quote">
                        <div dir="ltr" class="gmail_attr">On Sat, Jun 3,
                          2023 at 12:18 AM Barry DeZonia <<a href="mailto:bdezonia@gmail.com" target="_blank">bdezonia@gmail.com</a>>
                          wrote:<br>
                        </div>
                        <blockquote class="gmail_quote">
                          <div dir="ltr">Hi all,
                            <div><br>
                            </div>
                            <div>I have access to an MDArray. I am
                              trying to find its dimensions. In the C++
                              API I can see that GDALMDArray has a
                              method called GetDimensions() to find the
                              info I need. But I am programming in Java
                              and the Java API does not show such a call
                              for MDArray. Is there some way in Java to
                              find the info I need?</div>
                          </div>
                        </blockquote>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
                    </blockquote>
                    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
                  </div>
                </blockquote>
              </div>
            </blockquote>
            <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

</blockquote></div>