Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow COMPD_CS parsing stripping it #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
73 changes: 73 additions & 0 deletions test-fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not clear how it is used

"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"
}
}]
7 changes: 6 additions & 1 deletion wkt.build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down