locationtech / proj4j

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

More flexible readEpsgFromParameters function #65

Open pomadchin opened 4 years ago

pomadchin commented 4 years ago

In case a bit corrupted proj4 string passed (i.e. “+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs”1 instead of the correct “+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs”). The readEpsgFromParameters function returns null. I would expected it to return the WebMercator EPSG code:

val proj4string = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"
val crsFactory = new CRSCache()
val epsg = crsFactory.readEpsgFromParameters(proj4string) //> null

May be it is possible to make this parser more flexible.

Reference to the discussion: https://github.com/locationtech/geotrellis/issues/3281#issuecomment-674367298