locationtech / proj4j

Java port of the Proj.4 library for coordinate reprojection
Other
189 stars 73 forks source link

Improve proj4j tests to reflect the recent changes and the moved out EPSG resources #96

Open pomadchin opened 1 year ago

pomadchin commented 1 year ago

After separating the project into two, we may get some confusing errors; i.e.

java.lang.IllegalStateException: Unable to access CRS file: proj4/nad/epsg
  at org.locationtech.proj4j.io.Proj4FileReader.readParametersFromFile(Proj4FileReader.java:44)
  at org.locationtech.proj4j.io.Proj4FileReader.getParameters(Proj4FileReader.java:119)
  at org.locationtech.proj4j.CRSFactory.createFromName(CRSFactory.java:83)
  at org.apache.calcite.runtime.ProjectionTransformer.<init>(ProjectionTransformer.java:57)
  at org.apache.calcite.runtime.SpatialTypeFunctions.ST_Transform(SpatialTypeFunctions.java:[1196]

This task is to improve error messages and documentation.

cc @bchapuis

RoggenRentier commented 3 months ago

For anyone coming across this issue when looking up this error message: The project has been seperated into two and the epsg CRS files are now longer included in the Proj4j library, but in a seperate proj4j-epsg library. The error is fixed by adding this library to your project.

pomadchin commented 3 months ago

Also PRs are welcome! If there is a way to make this more clear we need it!

bchapuis commented 3 months ago

Yes, we should definitively make things clearer. I see that the README has been updated. What about the following ideas:

Add a clearer error message, such as:

java.lang.IllegalStateException: The proj4j-epsg JAR file is not present in the classpath. This dependency is required to access the proj4/nad/epsg file. Please ensure that the proj4j-epsg JAR is added to your project dependencies.

Hard coding a couple of projection definitions in the core library (e.g. epsg:4326, epsg:3857, etc.). Apparently, the following was acceptable from an Apache License perspective.

https://github.com/apache/incubator-baremaps/blob/8dce39f7d87bdc932c832df5418cc2fdcd1add7f/baremaps-openstreetmap/src/main/java/org/apache/baremaps/openstreetmap/utils/CRSUtils.java#L24