-
Notifications
You must be signed in to change notification settings - Fork 803
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
Add capability to get SQL statements to add custom CRS in the database #2577
Conversation
CC @hobu |
Interesting feature, @rouault. Do you mind sharing the motivation behind this? I haven't really looked at the code but at least the docs looks alright to me. |
|
Yeah, so much was clear to me :-)
That would be great. Just to be clear, I think this is a great idea and a good replacement for custom init-files. Thinking a bit further, it might also be nice to be able to do custom transformations, e.g. by running |
agreed, but not in my current scope of work. The "easy" solution would be to put them in the other_transformation table directly as PROJ strings. You might still need to customize the SQL or add switches to specify the accuracy, scope and extent. |
I wasn't suggesting that you do it, just thinking out loud. One thing that comes to mind though is, how are the custom CRS added with this new feature usable without also registering transformations to this new CRS?
Yeah, it could get complicated to capture everything in one projinfo call. Existing switches could be overridden as implied in my example above that uses |
For the use cases I was provided they use existing EPSG datums. They are typically projected CRS using us-ft as units but reyling on NAD83(2011). So the current set of EPSG transformations is fine to deal with them. |
I guess that works because of the |
the actual use cases are for CRS instanciated from WKT1 or WKT2
Yes. It will try to re-use existing intermediate objects by using the CRS::identify() method as much as possible.
outputs INSERT INTO conversion VALUES('HOBU','CONVERSION_MY_CRS','unnamed','','EPSG','9807','Transverse Mercator','EPSG','8801','Latitude of natural origin',0,'EPSG','9122','EPSG','8802','Longitude of natural origin',4,'EPSG','9122','EPSG','8805','Scale factor at natural origin',0.9996,'EPSG','9201','EPSG','8806','False easting',500000,'EPSG','9001','EPSG','8807','False northing',0,'EPSG','9001',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,0);
INSERT INTO usage VALUES('HOBU','USAGE_CONVERSION_MY_CRS','conversion','HOBU','CONVERSION_MY_CRS','PROJ','EXTENT_UNKNOWN','PROJ','SCOPE_UNKNOWN');
INSERT INTO projected_crs VALUES('HOBU','MY_CRS','my CRS','','EPSG','4400','EPSG','4326','HOBU','CONVERSION_MY_CRS',NULL,0);
INSERT INTO usage VALUES('HOBU','USAGE_PROJECTED_CRS_MY_CRS','projected_crs','HOBU','MY_CRS','PROJ','EXTENT_UNKNOWN','PROJ','SCOPE_UNKNOWN'); which shows that it re-uses EPSG:4326 |
There are just too many situations that depend up on single codes where WKT of any flavor won't do. OGC services are a big culprit, but there are other cases as well. In the US, many high precision engineering coordinate systems are either not in EPSG, are somewhere in the process of becoming registered with EPSG, or are registered EPSG CRSs that are bastardized by their users to modify things like parameters and transforms. /me shakes his fist at COMP_CS users of horizontal meters and vertical feet. The old init file relief valve of sticking a code in there isn't such a good thing to do with PROJ 6+, and this approach gives us a more sustainable way to do such a thing. An alternative that would also be fine with me is some sort of ADDITIONAL custom proj.db being used with an environment variable denoting its location. The nice thing about the latter approach is your custom CRSs would survive software upgrades and such. |
The mechanics for that is already in place at the API level (we have a proj_context_set_database_path() function that can take a path to the main DB and auxiliary DBs). Maybe proj_context_create() could look at a |
Thanks for the elaboration, Howard.
That would be quite useful, yes. It would certainly make it easier to distribute a set of custom CRS's to users, especially in cases where it is not fitting to put it in the main PROJ distribution. |
One thought I had was that if you are not doing so already, it would be nice to prevent users from using the official authorities such as |
I would not enforce that. This is the responsibility of the users. They might need to mess with official authorities as workarounds if some software is only able to support EPSG:XXXX codes. |
done |
Since this is a new feature, they would likely need to update the underlying software anyway. I think helping direct the users towards intended usage patterns would be a good idea. Otherwise, it gets messy/confusing. |
Is it PROJ's burden to support that? I vote no. They could still manually edit the database to do what they needed. We don't really want them adding EPSG codes. EPSG:900913 wasn't such a good thing 😉 |
How would we determine which authorities are allowed to have new definitions from those who aren't ? Currently in proj.db, we have EPSG, ESRI, IGNF, OGC, NKG and PROJ. And this new capability might potentially be used in the future for the ingestion scripts that populate proj.db with some of those official authorities. I think your concern would be best addressed by some note in the documentation. I'll let you follow-up in a later PR with such doc addition if you wish. |
I was actually thinking of only allowing one. Maybe just call it |
I'd say don't allow reuse of authorities already in |
There's still too much opportunity for clashing in this case. Your |
That's true. Maybe use it as a prefix: |
The last comments are really about debating how a tool might be misused. There are so many ways that PROJ can be misused. In ancient times, people could easily add a new line to the 'epsg' file... And we won't prevent them to edit the existing proj.db with new EPSG definitions, whatever technological barrier we put, if they are sufficiently determined to do so |
Let's go with this for now:
|
Two things can be true at the same time. It is true someone can hack the |
…-coded WGS84-based CRSs
…look for intermediate objects
…valid auxiliary DB
…ne or several auxiliary DBs
See my last commit in this PR |
…ries and use auxiliary databases
-o SQL --output-id AUTH:NAME
to get the SQL statements for a CRS object--dump-db-structure
switchExample:
outputs