proj4js icon indicating copy to clipboard operation
proj4js copied to clipboard

proj4 fails for WGS84 WKT string starting with `GEOGCRS`

Open kylebarron opened this issue 5 years ago • 1 comments

This file has the following WKT CRS string:

> ogrinfo countries.fgb countries -so
Layer SRS WKT:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["unknown"],
        AREA["World"],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]

However this fails to parse using proj4.js:

var proj4 = require('proj4');
var wkt = `GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["unknown"],
        AREA["World"],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]
`;
var projection = proj4(wkt, 'WGS84');

the proj4 call does not return a value, and instead just prints the input string

string: 'GEOGCRS["WGS 84",\n' +
  '    DATUM["World Geodetic System 1984",\n' +
  '        ELLIPSOID["WGS 84",6378137,298.257223563,\n' +
  '            LENGTHUNIT["metre",1]]],\n' +
  '    PRIMEM["Greenwich",0,\n' +
  '        ANGLEUNIT["degree",0.0174532925199433]],\n' +
  '    CS[ellipsoidal,2],\n' +
  '        AXIS["geodetic latitude (Lat)",north,\n' +
  '            ORDER[1],\n' +
  '            ANGLEUNIT["degree",0.0174532925199433]],\n' +
  '        AXIS["geodetic longitude (Lon)",east,\n' +
  '            ORDER[2],\n' +
  '            ANGLEUNIT["degree",0.0174532925199433]],\n' +
  '    USAGE[\n' +
  '        SCOPE["unknown"],\n' +
  '        AREA["World"],\n' +
  '        BBOX[-90,-180,90,180]],\n' +
  '    ID["EPSG",4326]]\n'

I hadn't seen the GEOGCRS prefix before, so I changed GEOGCRS -> GEOGCS and it worked. Is GEOGCRS incorrect here? It seems to be defined in the WKT CRS spec. Is it a bug in proj4.js then?

kylebarron avatar Nov 25 '20 01:11 kylebarron

This is something that could be fixed in https://github.com/proj4js/wkt-parser. Would you be able to provide a pull request?

ahocevar avatar Nov 25 '20 12:11 ahocevar