12

I am using the Microsoft.SqlServer.Types DLL in my projects for validating Latitudes and Longitudes.

The Library validates longitude values between -15069 and 15069 degrees instead from -180 to 180. Can anybody explain what is the significance or reason that Microsoft is checking the longitude values to be between -15069 and 15069 degrees?

Microsoft has listed the standards for Geo Spatial standards on this website which mentions the Longitude values MUST be between -15069 and 15069 degrees, inclusive.

https://msdn.microsoft.com/en-us/library/ee301753(v=sql.105).aspx

Your inputs in understanding this concept will be appreciated!

stakx - no longer contributing
  • 77,057
  • 17
  • 151
  • 248
Rohit Surve
  • 121
  • 4
  • 1
    Googling 15069 degrees shows that it is pretty near exactly 263 radians. Don't know if that is significant. – Martin Smith Jun 11 '16 at 00:35
  • 2
    I can't find anything on how google is doing their conversion from 15069 to 40.5700° N, 79.7700° W nor does it work for all values from 0 - 15069. It also doesn't do this conversion on negative integer values. I'm actually intrigued by why they allow those values now. – Dresden Jun 11 '16 at 00:42
  • 3
    I just mapped out a couple of points and it appears that for longitude values outside of the traditional [-180, 180] boundary, it "wraps" at the singularity. That is because -180° = 180°, 200° = -160°. Mathematically speaking, the two numbers are equal modulo 360. I can only speculate as to why the allow the "out of bounds" values. And my speculation is that it's far more likely that you're going to around the world for more than one revolution east-to-west than north-to-south. That is, for latitudes near the poles, the longitudinal circles are small. – Ben Thul Jun 12 '16 at 19:23
  • Thanks guys for all your inputs. @Ben: I thought of the same but wasn't sure if my assumptions were correct, thanks. – Rohit Surve Jun 13 '16 at 16:30

1 Answers1

2

Why is longitude not restricted to [-180°..+180°]?

Here's a brief thought experiment. Which of the following three lines does LINESTRING (-180 0, 180 0) represent?

  1. A line going around the whole globe along the equator in an eastward direction.

  2. A line going around the whole globe along the equator in a westward direction.

  3. A line of length 0, since -180° latitude denotes the same meridian as +180° latitude.

As soon as you decide on any of the three possibilities, you will find that you have no way of modelling the other two cases as LINESTRING (try it!)… at least not when you restrict longitude to the (geographically correct) interval [-180°..+180°]!

Let's see what happens when we relax that restriction:

  • The line going around the globe in an eastward direction can now be modelled as LINESTRING (-180 0, 180 0). (This seems to match our expectations, since increasing degrees of longitude means "going eastward".)

  • The line going around the globe in a westward direction now becomes LINESTRING (-180 0, -540 0). (Decreasing degrees of longitude denotes "going westward".)

  • The line of length 0 becomes LINESTRING (-180 0, -180 0). (No change in coordinates means "no distance travelled".)

Yes, but why did they chose exactly ±15069 degrees?

That, I cannot say. It might have to do with floating-point precision (i.e. spatial computations becoming too imprecise if you specified a point that's "wrapped around" the globe more than 15,069° ÷ 360° = 41,8583… times) or simply a arbitrary limit (i.e. they thought noone will need to be able to construct a spiral that goes around the globe more than approx. 42 times).

Why was latitude restricted to [-90°..+90°], if longitude wasn't restricted?

Let's repeat the above thought experiment: What does LINESTRING (0 90, 0 -90) mean?

  1. A line going around half the globe along the prime meridian in a southward direction.

  2. A line going around half the globe along the prime meridian in a northward direction.

  3. A line of length 0.

We can rule out (3), since POINT (0 90) and POINT (0 -90) are distinct points: namely, the north pole and the south pole. A line going from one to the other definitely does not have zero length.

We can also rule out (2), simply because it does not make any sense to say "going northward" when starting at the north pole. You can only stay there, or go south, which is already covered by (1).

So we end up unambiguously with (1). The reason, therefore, why latitude was restricted to the geographically meaningful [-90°..+90°] is because there is never any ambiguity when modelling lines that touch or cross the geographic poles. This is because there are no sudden degree "jumps" like there are with longitude (where one and the same meridian is described both by -180° and +180°).

stakx - no longer contributing
  • 77,057
  • 17
  • 151
  • 248
  • I'm not sure I understand this reasoning. From any point on the equator, the *shortest* path to complete a circle around the planet and return to that point should be by going over the poles, not following the equator. So why should a linestring between two effectively equal points on the equator describe an equatorial route at all? And once you're going over the poles, how does knowing which of the equivalent points is "more east" or "more west" help in knowing whether you started the navigation by heading due north or due south? – Damien_The_Unbeliever May 08 '17 at 14:20
  • Or to put it another way - why is there a "requirement" to be able to describe a circumnavigation of the globe using a `LINESTRING` with just two co-ordinates at all? If we want to describe a particular great-circle route, then surely providing 3 distinct co-ordinates, equally spaced and a return to the first co-ordinate allows any route to be unambiguously specified? – Damien_The_Unbeliever May 08 '17 at 14:26
  • @Damien_The_Unbeliever: You can also do a slightly different thought experiment using `LINESTRING (-179.5 0, 179.5 0)`. It doesn't have to be a full circumnavigation of the globe, ambiguity also appears when you want a line that crosses the +/-180° meridian. The kind of ambiguity (whether your options go along the equator or across the pole) is irrelevant. What's important is that there *is* ambiguity when you're restricted to -180°..+180°. – stakx - no longer contributing May 08 '17 at 14:41
  • But that ambiguity is easily solved by stating that you take the shortest great-circle route between any two pairs of points and, if that's not what you want/meant, you *insert more coordinates*. I.e. change your second thought-experiment in-question to also be a *full* circumnavigation, starting at say the South Pole. If we just have the South Pole coordinate twice, how do we know which meridian we follow first? In short, I can't see how `LINESTRING(coord, same coord)` can be unambiguously resolved so I can't believe that's the intention. – Damien_The_Unbeliever May 08 '17 at 14:46
  • I'm not sure I understand what you're saying. Are you referring to the 1st section in my answer (like you 1st comment above suggests)? If so, then how *would* you represent a single line segment from (-179 0) westward (along the equator) to (179 0)? If you're referring to the 3rd section (like your last comment suggests), then yes, perhaps your reasoning is the more sound. I tried to keep geographical terms such as "great circle" out of my explanation because I can't remember my geography lessons too well, TBH. – stakx - no longer contributing May 08 '17 at 15:04
  • Finally gotten around to testing your "thought experiment two" - "what does `LINESTRING (0 90, 0 -90)` mean?" - the answer, it turns out, is horrible ambiguity, as I've been trying to tell you - run `select geography::STGeomFromText('LINESTRING(0 90, 0 -90)',4326)` and you'll get an error "The specified input cannot be accepted because it contains an edge with antipodal points...". This further implies that what I've been suggesting is true - no `LINESTRING` containing only two points can describe a line that extends around more than half a hemisphere. – Damien_The_Unbeliever May 09 '17 at 14:22
  • And for though experiment 1, all three of your examples report a length of 0, E.g. `select geography::STGeomFromText('LINESTRING (-180 0, 180 0)',4326).STLength()` returns `0`. – Damien_The_Unbeliever May 09 '17 at 14:32
  • @Damien_The_Unbeliever: Since you seem to know a thing or two that I may have missed (though I'd like to stress again that my answer contains only *thought experiments*, i.e. scenarios that are supposed to make you think... I don't claim perfect technical accuracy), I would like to invite you to write an answer that is better and more accurate than mine. I'll be happy to upvote. – stakx - no longer contributing May 09 '17 at 19:43