Problem with Max & Min, Latitude & Longitude due to international date line & Poles
Hi, just to give you a bit of background about the issue, I'm a computer programmer and therefore not really a maths expert. I used to run queries on a database which would let me work out if point b was with x distance of point a and allow me to filter the results accordingly. However I am no longer able to use the database to perform this pre-filter which means I know have to bring back all the results and then find out if each one is within the required distance after returning the results. The problem with this is it means that I will end up bringing back a LOT of data and the filtering through it after.
So I devised a plan to get the points of a Square(Polygon) by getting the points at X distance North, South, West and East of point A getting the Max and Min Latitude and Longitude of all the points and then pre-filtering the results based on whether the Min < Latitude < Max. applying the same logic to the Longitude I though I was on to a winner.
Then one of colleagues asked me what happens with Western Alaska and Eastern Russia. As they are very so close to the critical on 180 / -180 longitude line this would cause a distinct problem as we would be crossing this point and returning in effect all the longitude lines that are not in the area I'm interested in, so the equation at this point would need to be Longitude > Max OR Longitude < Min. So my real question at this point would be how would I know mathematically that I had crossed this line. I did think that if could I use following expression I may be in luck but not sure its really accurate enough: (Longitude.Start - Longitude.West) / (Longitude East - Longitude.Start) > +/- 1.33 = true.
There maybe a wayof drawing on Tan to see if one of the points had crossed but not sure, it's beyond my levels of mathematics I'm afraid
Equally there is a similar problem at the poles with my latitude crossing over the poles if crossing over the north pole I would want the upper latitude range to be 180. this sounds like more of a cos / sin issue but I'm completely lost at this point and feel myself leaning over to pick the nearest pack of Asprin.
Any input would be much appreciated. I've been looking at this for close to 16 hours straight and my colleagues think I've gone mad, problem is I have OCD about my OCD's and cannot let it go
I have written all this in c# / .NET so not sure it really has a place here in the mathematics forums however I'm to put it in if anyone so wishes.
Many Many thanks in advance just for reading this hope I managed to explain the problem well enough for you to understand the issue
Lloydz1
Hi, just to give you a bit of background about the issue, I'm a computer programmer and therefore not really a maths expert. I used to run queries on a database which would let me work out if point b was with x distance of point a and allow me to filter the results accordingly. However I am no longer able to use the database to perform this pre-filter which means I know have to bring back all the results and then find out if each one is within the required distance after returning the results. The problem with this is it means that I will end up bringing back a LOT of data and the filtering through it after.
So I devised a plan to get the points of a Square(Polygon) by getting the points at X distance North, South, West and East of point A getting the Max and Min Latitude and Longitude of all the points and then pre-filtering the results based on whether the Min < Latitude < Max. applying the same logic to the Longitude I though I was on to a winner.
Then one of colleagues asked me what happens with Western Alaska and Eastern Russia. As they are very so close to the critical on 180 / -180 longitude line this would cause a distinct problem as we would be crossing this point and returning in effect all the longitude lines that are not in the area I'm interested in, so the equation at this point would need to be Longitude > Max OR Longitude < Min. So my real question at this point would be how would I know mathematically that I had crossed this line. I did think that if could I use following expression I may be in luck but not sure its really accurate enough: (Longitude.Start - Longitude.West) / (Longitude East - Longitude.Start) > +/- 1.33 = true.
There maybe a wayof drawing on Tan to see if one of the points had crossed but not sure, it's beyond my levels of mathematics I'm afraid
Equally there is a similar problem at the poles with my latitude crossing over the poles if crossing over the north pole I would want the upper latitude range to be 180. this sounds like more of a cos / sin issue but I'm completely lost at this point and feel myself leaning over to pick the nearest pack of Asprin.
Any input would be much appreciated. I've been looking at this for close to 16 hours straight and my colleagues think I've gone mad, problem is I have OCD about my OCD's and cannot let it go
I have written all this in c# / .NET so not sure it really has a place here in the mathematics forums however I'm to put it in if anyone so wishes.
Many Many thanks in advance just for reading this hope I managed to explain the problem well enough for you to understand the issue
Lloydz1