OSGeo / PROJ-JNI

Java Native Interface for PROJ
https://osgeo.github.io/PROJ-JNI/
MIT License
23 stars 15 forks source link

New feature: get list of all CRS from database #32

Closed FilipGh closed 4 years ago

FilipGh commented 4 years ago

It would be nice to have an interface which gives the list of CRS abjects contained in the database. I wrote a small C++ test program, based on proj_get_crs_info_list_from_database() C function. Using this "high level" function, I managed to parse, display, manage the various CRS elements the database contains. For each CRS element, I dump :

Would it be possible to add these functionalities into the PROJ-JNI interfaces ? Thanks.

P.S.: I wanted to tag this issue as "enhancement", since it is definitely not a bug. But I didn't find any way to do it. testProj6.zip

desruisseaux commented 4 years ago

Yes we can add such features. In the meantime a subset of this feature is also available from the CRSAuthorityFactory interface:

CRSAuthorityFactory factory = Proj.getAuthorityFactory​("EPSG");
Set<String> codes = factory.getAuthorityCodes(CoordinateReferenceSystem.class);
String name = factory.getDescriptionText("4326");   // For example.

The getAuthorityCodes method should return all EPSG codes for CRS in the database. Those code can in turn be given to getDescriptionText for getting the CRS name without instantiating the full CoordinateReferenceSystem object. But I agree that proj_get_crs_info_list_from_database may give more information.

FilipGh commented 4 years ago

You are right. I am not sure this will be enough for our use-case, but it is already a good start.

In fact, I didn't try using AuthorityFactory::getAuthorityCodes(Class), since it is mentionned as "not yet implemented in this binding" on this package page. :grin:

desruisseaux commented 4 years ago

You are right. I though that getAuthorityCodes(Class) was implemented, but I just checked the source code and it is not the case.