-
Notifications
You must be signed in to change notification settings - Fork 367
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
DotSpatial Projection with GridShift is Extremely Slow for NAD27 #1333
Comments
Not entirely sure about what is going on, but try to set:
and run the code again. If you happen to see a faster conversion, then it might have something to do with an exception being thrown for each and every point, because the required grid is missing. As far as I have seen, the table you want is the conus grid-shift table. Find the |
Thank you for responding Vector: I spent some time this morning testing out various scenarios around your recommendations. Scenario 1: GridShifts Folder is Empty:
Scenario 2: GridShifts Folder is Still Empty:
Scenario 3: GridShifts Folder has 4 Grid shift files in it: "alaska.lla, conus.lla, ntv1_can.dat, ntv2_0.GSB"
Scenario 4: Use same GridShift files as Step #3 above.
Note that both steps 3 & 4 both reported the debug window as shown in 'Debug Report 2' shown below. Final Note:I tried removing the different files one-by-one in the GridShifts folder with the exceptions flag set to true. The ONLY file it did not throw an exception for was "ntv1_can.dat". So your recommendation for the "conus.lla" unfortunately did not work. Any help you and your team can provide is greatly appreciated. But for now, I cannot use GridShifts for NAD27 in Wyoming because something is wrong with performance. Right answers, but too slow. Thanks for your help! Chris Debug Report 1:... Unrecognized parameter skipped vunits. Actually one for each points, so 1500 times... Debug Report 2nrecognized parameter skipped axis. Unrecognized parameter skipped axis. |
I will try to think a bit more to see if I can come up with something. The thing is, I have tried your code and, given that I have unzipped the files in the GridShifts folder and everything is properly set up, the conversion is almost instantaneous for me in both cases, with or without GridShifts. I will keep looking into this. |
It seems that if you only use conus.lla (remove all other files from the GridShifts folder), it will run almost immediately. However, I was able to reproduce the behavior you describe with ntv1_can.dat! It does take a lot longer, a bit over ~15 sec for a test attempt. One thing that doesn't "exactly" make sense is that the code seems to prioritize grid shifts based on what is found first. I will also try to ascertain that this is the case and I will take a look to try to find the cause for the absurd amount of time. |
It appears that the NadGrids for this Datum are searched in alphabetical order and, for the NAD23 they are conus, ntv1_can, ntv2_0 and alaska. Thus, if conus is found, it is used instead because it is "lexicographically" before all other. The good thing is that I have found the problem. It turns out that this was what I was "afraid" it would be. The grid shifts file is being constantly re-read for data retrieval, while this should properly not needed after the first read. The bad thing is that, if you would like to fix the code, you will have to either edit and recompile the source code, or somehow "hack" your way around it (only if absolutely necessary). I will post the exact source of the problem in a little while. |
@VectorZita Can you create a pull request with a fix? |
The DotSpatial.Projections.Nad.NadTable class contains a Class GbsNadTable overrides the method but forgets to set Class DatNadTable has the same problem. Immediately after line 105, Because @jany-tenaj Unfortunately, I have no experience with making pull requests as yet. Would this be possible for someone else to do? If not, I can give it a shot. |
@cwgrc2 @VectorZita Ok check out the change. |
@jany-tenaj it seems to be fine. I have tested the code outlined above by @cwgrc2 after fixing in a local repository on my machine and it no longer takes 15+ seconds to run, it is executed almost instantly (< ~0.05 secs) for the NAD27 conversion. Good job! @cwgrc2 has to test and check if the results are OK, but they should be, since the only problem was the constant re-reading of the file, the calculations remain otherwise unaffected. |
Thanks all!! Vector I could reproduce your step:
But... I had to set:
else it threw an exception. I tested those results and they look good and it is fast. To get the fix, I have a noob question. I cloned the entire DotSDpatial-master (per @jany-tenaj - #1333) and I have loaded as a seperate Solution in Visual Studio 2019. How do I get that imported into my project as a Nuget package? I show at the bottom (see picture) how I did it originally, but I still see 2.0.0.-rc1 and I presume this is old and does not incorporate the new changes? Thanks!! Chris |
As far as I understand, I think that a Nuget package will have to be re-created first, I don't know how this works for DotSpatial, or who can do it, specifically. However, this shouldn't be necessary for you. You only need to build the project and use the compiled dll files instead, as references in your project. If you open the entire solution, try to build the |
Did you test also using only the ntv1_can.dat? Because this is the specific case that was triggering the problem at all. The conus.lla file never posed a problem, only *.dat and *.gbs grid-shift files did. |
@cwgrc2 Check out this wiki entry. We build a new nuget package with every comit. But this doesn't get uploaded to nuget. |
Got the new release dll included. Works great! Thank you so much for all of your help. Good job. Chris |
No problem! There is another bug I have detected in the I will post a new issue relatively soon. |
@VectorZita I'm guessing there are quite a lot of bugs in DotSpatial.Projections based on the fact that there were a lot of issues raised and it is an old port of proj.4. |
@jany-tenaj Yes, I have traced the error I am referring to in the porting process, back to the original proj4 c++ source code (which is correct). I will try to document all this in a new issue as soon as possible. |
I want to follow your steps in the wiki you pointed me to. I think I follow everything you do but am getting errors. I am trying to point to the continuous build nuget in your wiki. See picture below. I get the error (see below) when I try and install this Dotspatial continuous feed nuget. Any ideas? Our build is failing on Azure DevOps pipelines. Thanks Chris
|
Bug?
Not sure if this is a bug or expected behavior, but using a Projected.StatePlaneNad1927.NAD1927StatePlaneWyomingEastCentralFIPS4902
yields correct results with unacceptable times using a GridShift.
Steps to reproduce
4: create 1500 lat long data points, in the range of Casper Wyoming (see code below)
5: Reproject these points to dest1 and dest2. (see code below)
6: The GridShift has to be turned on and the one I am using is: ntv1_can.dat (see code below)
DotSpatial version: 2.0.0-rc1
Expected behaviour
When I run my C# main with a NAD83 projection vs a NAD27(requiring a grid shift), NAD27 takes about 15 seconds to Reproject.ReprojectPoints for 1500 points. NAD83 is instantaneous. The NAD27 does give the right answer, but the speed is unacceptable.
Expected Behaviour: Instantaneous like the NAD83
Actual behaviour
Time to convert 1500 locations: 14.797 secs. Using NAD27 WITH Gridshifts
Time to convert 1500 locations: 0 secs. Using NAD83
Code in C# if Applicable:
The text was updated successfully, but these errors were encountered: