Advanced

Re: Distance issues

Distance issues
January 18, 2020 01:42PM
Yesterday morning (Friday 18th januari) I released some broken code calculating distances. It might have affected checkers. So if you have received such feedback in form of bug reports, it was my fault. From what I know, everything is fixed now.
Re: Distance issues
January 19, 2020 01:59PM
Hi Magnus,

I still have some trouble with distance based checkers - following code running into a timeout:

local topOB = PGC.GetFavorites(
  'points', 
  { 
    limit = 20, 
    filter = 
    {
      excludeArchived = true,
      radius =
      {
        distance = 3140,
        latitude = 50.210883,
        longitude = 8.555383
      }
    } 
  } 
)

Being used in the following checker:
https://project-gc.com/Challenges/GC442JX/10634

Would be great, if you could have a look!


Thx & best,
Stefan
Re: Distance issues
January 21, 2020 12:53PM
I have been playing around with it. If I understand it correctly, I seem to have missed correcting a variable regarding distance. At least that's how I see it in the Git history.

What I did to start with was this:
* Implemented a new better distance-function in SQL stored procedure. Better math.
* The old one used these arguments: lon1, lat1, lon2, lat2, and km
* The new one used arguments: lat1, lon1, lat2, lon2, and meters.
* When I moved the code to the new function, I totally forgot both the argument order, and the unit. Disaster results.
* I then looked at the commit and which files it had touched, and manually went through those to review the code and correct it.

It seems like I missed the LUA callbacks in the last step, because I can't see that I ever adjusted the distance-parameter there. Also by reviewing the code I can see that it has been using $distance/1000. It should be meters all the way now.

By fixing that, your checker script stopped timing out at least. However, whichever user I have tried gives this error:
[string ""]:9: bad argument #1 to 'pairs' (table expected, got nil)
... and that I don't understand. Is it my fault? I can't see that I have touched anything that should cause this issue.

I will commit this and send to the live servers in a few minutes.
Re: Distance issues
January 21, 2020 05:13PM
magma1447 Wrote:
-------------------------------------------------------
> By fixing that, your checker script stopped timing
> out at least. However, whichever user I have tried
> gives this error:
> [string ""]:9: bad argument #1 to 'pairs' (table
> expected, got nil)
> ... and that I don't understand. Is it my fault? I
> can't see that I have touched anything that should
> cause this issue.


Sorry, my fault - while trying what is causing the timeout I removed some piece of code.
Now everything should be back to original code, however I'm still running into a timeout.

Did you already commit the changes to the productional server?
Re: Distance issues
January 21, 2020 05:38PM
The changes are released, however I know that the new code is slower.

I wanted to compare and test with old code before, but since the script didn't work fully I didn't manage to complete my tests.

The script is disabled now. Is it okay if I enable it? Not even I can run disabled scripts.



Edited 1 time(s). Last edit at 01/21/2020 05:38PM by magma1447. (view changes)
Re: Distance issues
January 21, 2020 05:51PM
The script has been enabled!
Re: Distance issues
January 21, 2020 05:57PM
There is an extreme performance difference, and it's because I have removed a bounding box check.

I will re-add that bounding box, the problem is that I know that it doesn't work correctly. But it's actually only if your circle reaches lat -90, +90 or lon -180 or +180.

For that to work properly, the bounding box function would need to return multiple boxes, and it does not. I guess it's very uncommon though, and that bug/issue has been there for years.

Expect the performance to be back in a few minutes from now.
Sorry, you do not have permission to post/reply in this forum.