diff --git a/index.js b/index.js index 2ad67c7..9188e29 100644 --- a/index.js +++ b/index.js @@ -160,6 +160,11 @@ function cleanWKT(wkt) { } export default function(wkt) { var lisp = parser(wkt); + // if compound SRS (e.g. COMPD_CS) parse only the PROJCS part (e.g. horizontal SRS) + if (lisp[0] == "COMPD_CS") { + console.warn('COMPD_CS not yet supported. Stripped Vertical datum leaving only PROJCS'); + lisp = lisp[2]; + } var type = lisp.shift(); var name = lisp.shift(); lisp.unshift(['name', name]); diff --git a/parser.js b/parser.js index d7f14b1..0de7b9f 100644 --- a/parser.js +++ b/parser.js @@ -8,7 +8,7 @@ var AFTERQUOTE = 5; var ENDED = -1; var whitespace = /\s/; var latin = /[A-Za-z]/; -var keyword = /[A-Za-z84]/; +var keyword = /[_A-Za-z84]/; var endThings = /[,\]]/; var digets = /[\d\.E\-\+]/; // const ignoredChar = /[\s_\-\/\(\)]/g; diff --git a/test-fixtures.json b/test-fixtures.json index fb5a988..f7f9207 100644 --- a/test-fixtures.json +++ b/test-fixtures.json @@ -388,4 +388,77 @@ "lat2": 0.7280931862903012, "srsCode": "NAD83 / Massachusetts Mainland" } +}, { + "code": "COMPD_CS[\"GCS_WGS_1984\",PROJCS[\"WGS 84 / UTM zone 30N\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"latitude_of_origin\",0],PARAMETER[\"central_meridian\",-3],PARAMETER[\"scale_factor\",0.9996],PARAMETER[\"false_easting\",500000],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"32630\"]],VERT_CS[\"unknown\",VERT_DATUM[\"unknown\",2005],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Up\",UP]]]", + "intermediate": [], + "value": { + "type": "PROJCS", + "name": "WGS 84 / UTM zone 30N", + "GEOGCS": { + "name": "WGS 84", + "DATUM": { + "name": "WGS_1984", + "SPHEROID": { + "name": "WGS 84", + "a": 6378137, + "rf": 298.257223563, + "AUTHORITY": { + "EPSG": "7030" + } + }, + "AUTHORITY": { + "EPSG": "6326" + } + }, + "PRIMEM": { + "name": "greenwich", + "convert": 0, + "AUTHORITY": { + "EPSG": "8901" + } + }, + "UNIT": { + "name": "degree", + "convert": 0.0174532925199433, + "AUTHORITY": { + "EPSG": "9122" + } + }, + "AUTHORITY": { + "EPSG": "4326" + } + }, + "PROJECTION": "Transverse_Mercator", + "latitude_of_origin": 0, + "central_meridian": -3, + "scale_factor": 0.9996, + "false_easting": 500000, + "false_northing": 0, + "UNIT": { + "name": "metre", + "convert": 1, + "AUTHORITY": { + "EPSG": "9001" + } + }, + "AXIS": { + "Northing": "NORTH" + }, + "AUTHORITY": { + "EPSG": "32630" + }, + "projName": "Transverse_Mercator", + "units": "meter", + "to_meter": 1, + "datumCode": "wgs84", + "ellps": "WGS 84", + "a": 6378137, + "rf": 298.257223563, + "k0": 0.9996, + "x0": 500000, + "y0": 0, + "long0": -0.05235987755982989, + "lat0": 0, + "srsCode": "WGS 84 / UTM zone 30N" + } }] diff --git a/wkt.build.js b/wkt.build.js index 4e8e632..6fc4229 100644 --- a/wkt.build.js +++ b/wkt.build.js @@ -8,7 +8,7 @@ var AFTERQUOTE = 5; var ENDED = -1; var whitespace = /\s/; var latin = /[A-Za-z]/; -var keyword = /[A-Za-z84]/; +var keyword = /[_A-Za-z84]/; var endThings = /[,\]]/; var digets = /[\d\.E\-\+]/; // const ignoredChar = /[\s_\-\/\(\)]/g; @@ -430,6 +430,11 @@ function cleanWKT(wkt) { } var index = function(wkt) { var lisp = parseString(wkt); + // if compound SRS (e.g. COMPD_CS) parse only the PROJCS part (e.g. horizontal SRS) + if (lisp[0] == "COMPD_CS") { + console.warn('COMPD_CS not yet supported. Stripped Vertical datum leaving only PROJCS'); + lisp = lisp[2]; + } var type = lisp.shift(); var name = lisp.shift(); lisp.unshift(['name', name]);