-
Notifications
You must be signed in to change notification settings - Fork 71
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
Updated to NTS 2.0 and removed use of GeoAPI where required. Also Fixed 4 Bugs and Fixed most of the Unit Tests #302
base: develop
Are you sure you want to change the base?
Conversation
This should resolve #256 |
@xivk , this should be okay to merge now, let me know if you find anything else. Also please note that the nugets seem to be built for x86 which may have caused some of the other issues I was reporting about OOM |
There was also a reference to the older NTS library from OSM Sharp which I fixed in OsmSharp/core#101 |
Sorry for any inconvenience and please let me know if you need anything else to get this merged easily and thank you for your interest / hard work! |
Also addresses #304 |
…hms. Changed Unit Test to show that TryCalculateWeight gives the same result when using the GetAugmentedWeightHandler
Also wondering a similar fix should be applied @ Line 1176 in 11fe52e
|
@xivk, please let me know when you get a chance to review this and the other PR's submitted. |
Hey @juliusfriedman I appreciate all this hard work but the pull request has multiple changes on different features and some features of a new C# version are introduced. All these things that are great as improvements but it's gotten a bit more difficult for me to review. Is this getting merged something you need urgently? I should be able to check this next week Wednesday. Sorry, struggling to keep up with everything these days. |
No problem, I didn't mean to make your life harder. The fix I would need most importantly relates to reminisce because of the usage of Parallel. The quick fix here would be to lock on the db but it's no longer required after the change in reminisce. The importance of that change is due to differences seen when routing using parallel or outright exceptions. Take your time as I also addressed a distance calculation issue and made a change to use the ManyToMany algorthimm to resolve issues with weight handling which was reported by other users. Next week should be fine. Just let me know if there's anything I can do to make this easier on you (e.g. I didn't see any changes which would require any recent c# features, if you can point them out I'll surely change them up to something which doesn't require a newer compiler) |
@xivk I double and triple checked this and added notes on what was addressed. Please let me know ASAP if this is correct so I can close my PR's and delete my branches. |
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.
@xivk I don't see any usages of any newer C# features or langversion changes to support them, if you are seeing something please point it out to me so I can change it.
Thank you!
src/Itinero/Router.cs
Outdated
@@ -1320,13 +1320,24 @@ public sealed override Result<bool> TryCheckConnectivity(IProfileInstance profil | |||
} | |||
weights = algorithm.Weights; | |||
} | |||
//else if (contracted.HasNodeBasedGraph && |
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.
Was removed and the issue no longer manifested in the simple case
// _db, profileInstance.Profile, | ||
// weightHandler, sources, targets, maxSearch, cancellationToken).Value; | ||
|
||
var algorithm = new Itinero.Algorithms.Default.ManyToMany<float>(_db, weightHandler, sources, targets, maxSearch); |
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.
As you can see from the commented code above CalculateManyToMany was previously being used but returned different results which didn't match that of the non contracted versions. This change fixed both the simple and complex cases I was made aware of.
@juliusfriedman looking through this PR, it looks like you've lumped many different things together. I would recommend making one PR that just does the NTS 2.0 upgrade, since that should be mostly signature changes that happen to affect many files and therefore much easier to review that part of it. Afterward, you can make other changes on top, and each would be easier to review on their own. For example, consider 2fe7e3d. Looking at that, I question the need for it... ignoring the (fixable) problem that the new test provides latitude values outside of the legal range, is the intent to try to improve accuracy over very large distances?
If you also want to fix some bugs, then I'd recommend doing that in other PRs; if those fixes affect code that's tightly coupled to NTS, then maybe it would make sense to wait to submit those until the NTS 2.0 upgrade is merged, since merge conflicts would add friction to that effort. *plus multiple |
What x * x can replaced with the Math.Pow call here?
Perhaps also (more so):
That should be better but AFAIK the JIT recognizes these types patterns and optimizes anyway. The changes were done like this because they required changes in Remininscence, those have been accepted and thus these can now be reviewed and accepted as well. Not sure what you mean by breaking them down into parts all parts effects almost all others. |
Again, my point isn't to specifically resolve this one, but to answer this question: //https://github.com/itinero/routing/issues/279
const double DegreesToRadians = Math.PI / 180.0;
var d1 = latitude1 * DegreesToRadians;
var num1 = longitude1 * DegreesToRadians;
var d2 = latitude2 * DegreesToRadians;
var num2 = longitude2 * DegreesToRadians - num1;
var temp1 = Math.Sin((d2 - d1) / 2.0); // extracted from the expression that produces d3
var temp2 = Math.Sin(num2 / 2.0); // extracted from the expression that produces d3
var d3 = (temp1 * temp1) + Math.Cos(d1) * Math.Cos(d2) * (temp2 * temp2);
return (float)(6376500.0 * (2.0 * Math.Atan2(Math.Sqrt(d3), Math.Sqrt(1.0 - d3))));
One specific suggestion I made was to start with a PR that only does the NTS 2.0 conversion. This would be easier to review and less likely to break things, and it would make the remainder easier to review as well, since it would all stand out on its own.
All that that means is that the tests pass. Every (valid) user-visible bug is further evidence that the automated test suite is either incomplete or incorrect. For example, I already noted that the new test for #279 is providing latitude values outside of the legal range. This test is therefore incorrect (how can the expected value be any number, when the two inputs don't even refer to actual locations?), yet it passes. For now, code review is our primary defense against those kinds of problems.
I would argue the opposite, actually: it takes longer to review more changes that do more things than to review fewer changes that do fewer things, and reviews tend to be overall more effective when they're focused on just one thing. Of course, if that "one thing" is a solution to a complicated problem that truly requires making many changes that affect one another, then it can't be helped. From my perspective, the only potential breakdown I specifically commented on was "NTS 2.0 / everything else", for a couple of reasons:
I don't have merge privileges, so it's not my call. I responded because you invited this kind of feedback:
and
Since it's been a couple of months since @xivk last responded on this thread, I felt like you may benefit from hearing this perspective. Maybe I'm wrong, and this PR is exactly what he wants to see, but after reading his last comment on this thread, I would guess otherwise. |
That comment he made I believe he was referring to at that time which was missing pieces which would not compile and contained local references to the Reminiscence project and those conversations have been resolved AFAIK. The last comment he made was about newer C# features (which are not used anywhere outside of what was already used) so I was confused and applied only the last change for: #306 Which I began to test however I ran into additional problems when resolving as I could no longer contract databases however I can use them after contraction so long as the fix in #306 is applied after the contraction is made. I have no idea why and I have not found a case where it effects me so I did not move further on that. Beyond that it seems there are multiple places that The same seems to occur with The last thing I have to say is that the automated tests are failing because there are incorrect tests in the code for example Let me know how else I can be of assistance @xivk or @airbreather P.S. The changes for distance were for correctness regardless of input, a check to ensure they are valid is technically outside the scope of that function because floats are given and not Finally even when See also #307 |
Everything passes in this PR and I fixed the order of the The only thing which does not pass is |
…ze this to X*X implicity
Finally I also adjusted for your Math.Pow2 calls to X*X but please remember the JIT should optimize Math.Pow these especially in later builds See also dotnet/runtime#31978 |
Waiting for another review or merge @xivk, @airbreather . In my local code I have another few things which are as of yet uncommitted e.g. the use of The odd thing is that if these types of issues don't occur using the Just lmk. |
I just made this because since I am having issues with or without contractions I figured I should help to try and track the issue down, this was a low hanging fruit and gets the later version of NTS in the library.
All tests seemed to pass on my machine so it's possible this threading issue is fixed in the develop branch of reminiscence, I will add a few more tests to make sure but there was already
GetTestRandomRoutesParallel
but it was not being run so I added that to the list of tests to run.