bugra9 / gdal3.js

Convert raster and vector geospatial data to various formats and coordinate systems entirely in the browser.
https://gdal3.js.org
GNU Lesser General Public License v2.1
311 stars 46 forks source link

Implementing an srsinfo function? #79

Open mthh opened 1 month ago

mthh commented 1 month ago

In the same way as ogrinfo and gdalinfo are implemented in https://github.com/bugra9/gdal3.js/tree/master/src/allJsFunctions/application, we could have a srsinfo function that offers roughly the same functionality as gdalsrsinfo (https://gdal.org/programs/gdalsrsinfo.html).

This would seem useful to me, as there doesn't seem to be a good parser for WKT2 projection definitions in JavaScript, and gdal can convert srs definitions into many formats (proj4, projjson, wkt1, various flavors of wkt2, etc.).

Given the code of gdalsrsinfo (https://github.com/OSGeo/gdal/blob/master/apps/gdalsrsinfo.cpp) it seems to require a bit of work to port it but I can take a look if you're interested in such a feature.

bugra9 commented 1 month ago

Hi @mthh,

Sorry for the late reply. I have been working on the v3.0.0 version with the new architecture for a long time and it is almost done.

It would be very nice if the gdal3.js supported all the features of Gdal :).

For gdalinfo there are gdalinfo_bin.cpp and gdalinfo_lib.cpp files. gdalinfo_lib.cpp does the actual work and is included in the gdal library. gdalinfo_bin.cpp compiles to binary using gdalinfo_lib.cpp and is not included in the gdal library.

For the gdalsrsinfo file there is only the gdalsrsinfo.cpp file which is compiled to binary, not included in the gdal library. This makes things difficult.

In the current version, we were writing the codes that are not in the gdal library with javascript, and it looks like it will be necessary to write the entire gdalsrsinfo.cpp file with javascript.

In v3.0.0, I moved all javascript code to c++ and now we can directly access the code written by c++. In this system, if we change the main function in gdalsrsinfo.cpp to another name, it will be called by js and simply implemented.

If you want to add it to the version with v2.x and open PR, I will merge it directly. If you haven't done any work yet, I will release v3.0.0 alpha in 1-2 weeks and I can add it to new version. But it may cause issues because it will be in alpha version and may require migration in the code due to the new architecture.

https://github.com/users/bugra9/projects/10?pane=info

What do you think about it?

mthh commented 1 month ago

Hi @bugra9,

I have been working on the v3.0.0 version with the new architecture for a long time and it is almost done.

Great news!

If you want to add it to the version with v2.x and open PR, I will merge it directly. If you haven't done any work yet, I will release v3.0.0 alpha in 1-2 weeks and I can add it to new version. But it may cause issues because it will be in alpha version and may require migration in the code due to the new architecture.

I haven't done any work on it yet. But it would be great if you could include this in v3.0.0 (and if you can't include it as soon as v3.0.0, I might try to contribute it for a later version). By the way, count on me to test the alpha / beta versions of the v3.0.0 (I notably rely on gdal3.js in https://github.com/riatelab/magrit, a thematic cartography application I'm developing, to import / export user datasets).

bugra9 commented 1 month ago

I will include it in v3.0.0-alpha and try to release it as soon as possible.

bugra9 commented 2 weeks ago

@mthh, I created a branch for v3.0.0 and opened PR. Your feedback is very important to me.

Main features:

V3.0.0 branch: https://github.com/bugra9/gdal3.js/tree/v3.0.0-cpp.js-integration

Web: https://gdal3.js.org/v3/ iOS Beta App Invitation: https://testflight.apple.com/join/X47Va3wd Android App: https://play.google.com/store/apps/details?id=org.js.gdal3

Dependencies: Docker, node.js, cmake > 3.28