-
Notifications
You must be signed in to change notification settings - Fork 15
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
Parse sub crs #30
Parse sub crs #30
Conversation
wkt.build.js
Outdated
if (wkt.AUTHORITY) { | ||
var authority = Object.keys(wkt.AUTHORITY)[0]; | ||
wkt.title = `${authority}:${wkt.AUTHORITY[authority]}`; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is unrelated, and wkt.build.js
should not be manually modified, because it is auto-built.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit removed. It was the one for my other PR.
About the wkt.build.js change. I thought I had to run 'npm run build' before posting the PR, The changes on that file are from that run...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to update the README and add that file to .gitignore. Sorry that the instructions are currently not clear about that.
fd245d2
to
54a80c3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To understand better what you're trying to achieve, it would be good if you could describe how you'd like to use the API to get components of a compound CRS.
The cleanWKT
method won't make sense for e.g. parsing a datum. It might indeed make sense to parse components of a compound crs, but only if the component is not a vertical crs. And there is a risk of overwriting keys in the root object. Maybe a separate method to dissect compound CRSs would be better?
My idea was that in the case of a compound crs, we have several children crs from the parent compound crs. I noticed from the code that if we parse a GEOGCS we will get wkt.projName = 'longlat'. But indeed, I should probably have removed all the DATUM from getting in the boucle. (I initially copy all case from process.js from line 81 to 101). About the risk of overwriting keys, I might be wrong, but i don't see it happening as we only add properties on the sub objects we are cleaning. |
It seems that what you're looking for is the structure of the WKT as objects. So my suggestion would be to export the import {parseString}, toDef from 'wkt-parser';
import proj4 from 'proj4';
const compound = parseString('COMPD_CS["SRGI2013 + INAGeoid2020 v1 height",GEOGCS["SRGI2013",DATUM["Sistem_Referensi_Geospasial_Indonesia_2013",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","1293"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","9470"]],VERT_CS["INAGeoid2020 v1 height",VERT_DATUM["Indonesian Geoid 2020 version 1",2005,AUTHORITY["EPSG","1294"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Gravity-related height",UP],AUTHORITY["EPSG","9471"]],AUTHORITY["EPSG","9529"]]');
if (compound.GEOGCS && compound.GEOGCS.title) {
const def = toDef(compound.GEOGCS);
proj4.defs(def.title, def);
} |
Indeed, what I want is to be able to extract part of wkt object (a wkt string parsed with (If I get it right So in your case it seems that we only need to have And to do that, we have two options:
I fell like the second solution will be cleaner in terme of API |
The first option is better. Because what you're calling |
Of course the cleanest thing, but more complicated, would be something in between your options 1 and 2 - only add the (more or less proj4 specific) properties that the poorly named |
If proj4js is correct, then the supported object types are That would indeed mean to use this pull request almost as-is, i.e. with recursive |
0e7ca3c
to
80c9080
Compare
I did a first trial to apply PS: I saw that several tests crashed, and i guess it's linked to the renaming of the function. And I wont be able to work on that before monday. |
c211c9a
to
ea5c72d
Compare
I did fix the tests, As nome we 'clean' the 'sub'-crs we had to add the new properties to them, that we previously skipped. Now if we parse a GEOGCS and a PROJCS based on the same GEOCS, we will in both case get the same objet. |
ea5c72d
to
98f24b2
Compare
Most Crs are based on other crs. (ie PROJC use GEOCRS)
In this PR I propose to treat each sub crs as a CRS to not only parse the main crs but laso the subcrs.
The idea behind this would be in case of COMP_CS to be able to directly extract the sub crs (usually the PROJCS and the VERT_CS) instead of spliting the string wk.