-
Notifications
You must be signed in to change notification settings - Fork 797
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
Fix slowness on proj_create_crs_to_crs() on WGS 84 <--> UTM conversions #4319
Comments
Have you tried adding |
proj_create_crs_to_crs() automatically adds its
Well 16 ms is not so bad for something that involves looking in a database. In that particular case, we could perhaps avoid the database lookups given both CRS involve unknown datums, but haven't looked more closely. The general advice is that you should keep the objet returned by proj_create_crs_to_crs() to transform many points, rather than recreating it each time |
…ically PROJ strings) using unknown datums Fixes OSGeo#4319 With that improvement, the runtime of the following snippet goes from 25.4 second to 0.9 second: ```c for(int i = 0; i < 2000; ++i) { PJ_CONTEXT *C = proj_context_create(); PJ *P = proj_create_crs_to_crs(C, "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs", "+proj=utm +zone=31 +ellps=GRS80 +units=m +no_defs", NULL); proj_destroy(P); proj_context_destroy(C); } ```
…ically PROJ strings) using unknown datums Fixes OSGeo#4319 With that improvement, the runtime of the following snippet goes from 25.4 second to 0.9 second: ```c for(int i = 0; i < 2000; ++i) { PJ_CONTEXT *C = proj_context_create(); PJ *P = proj_create_crs_to_crs(C, "+proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs", "+proj=utm +zone=31 +ellps=GRS80 +units=m +no_defs", NULL); proj_destroy(P); proj_context_destroy(C); } ```
First of all, thank you very much for your reply. I understand everything you said, but my current requirement is a one-time conversion tool to convert the coordinates of several points, and the positions of the points are not regular, in other words, their zone numbers are random. I used version 7.1.0 before and it was great to use. The code is as follows:
But now, after upgrading to 9.5.0, I find that the previous code cannot run, and I eventually realize that this time-consuming process is very troublesome. Can you improve it? Thank you. |
they can not be that random. They must be between 1 and 60, so you could pre-compute 60 transform objects and re-use them
Cf #4320 |
Haha, I definitely know, it must be within 1-60! |
How can I pull the latest code for verification? |
Good idea, I can improve it later! |
https://github.com/rouault/PROJ/archive/refs/heads/fix_4319.zip |
|
@plumewind if you don't mind, what sort of use case do you have where a 16 ms one-time wait is critical? |
Well, we use it in pose estimation scenarios for high-speed moving objects. However, just now, I have changed this tool to singleton mode. |
problem
When using proj-9.5.0, find very slow on proj_create_crs_to_crs().
My code like this:
Problem description
When I was processing the conversion, I found that the process was very slow. Then, I counted the time taken for each process and found the following:
Expected Output
Normally, this process on proj_create_crs_to_crs() should be very fast, almost 0 milliseconds.
Environment Information
proj-9.5.0
)ubuntu 20.04
)Installation method
The text was updated successfully, but these errors were encountered: