OSGeo / PROJ-JNI

Java Native Interface for PROJ

Home Page:https://osgeo.github.io/PROJ-JNI/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New feature: get list of all CRS from database

FilipGh opened this issue · comments

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 :

  • CRS code
  • CRS name
  • CRS projection method,
  • CRS type,
  • ...

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

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.

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. 😁

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