0

With the following spatial constraint:

ALTER TABLE [dbo].[TRANS_TRAILS_LN]  WITH CHECK ADD  CONSTRAINT [g10_ck] CHECK  (([SHAPE].[STSrid]=(4269)))
GO

ALTER TABLE [dbo].[TRANS_TRAILS_LN] CHECK CONSTRAINT [g10_ck]
GO

and index:

CREATE SPATIAL INDEX [S10_idx] ON [dbo].[TRANS_TRAILS_LN] 
(
    [SHAPE]
)USING  GEOGRAPHY_GRID 
WITH (
GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 = MEDIUM), 
CELLS_PER_OBJECT = 16, PAD_INDEX  = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO

on a table with a Geography Column

[SHAPE] [geography] NOT NULL,

I am able to add features throughout the eastern US. Soon as I hit -90 deg and further west, I get the following error:

A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": 
System.FormatException: 24201: Latitude values must be between -90 and 90 degrees.
System.FormatException: 
   at Microsoft.SqlServer.Types.GeographyValidator.ValidatePoint(Double x, Double y, Nullable`1 z, Nullable`1 m)
   at Microsoft.SqlServer.Types.Validator.AddLine(Double x, Double y, Nullable`1 z, Nullable`1 m)
   at Microsoft.SqlServer.Types.F]

I get the whole single hemisphere limitation, but this isn't the problem: I'm in a single hemisphere. Is it the SRID (GCS NAD83)? Can one not use this SRID with the SQL Geography data type?

SQL 2008 R2

Update: The following show that lat values fall well within -90 and 90.

SELECT a.OBJECTID, b.n, 
    a.SHAPE.STPointN(b.n).Lat AS Lattitude,
    a.SHAPE.STPointN(b.n).Long AS Longitude
FROM dbo.TRANS_TRAILS_LN_2 AS a, num_seq AS b
WHERE b.n <= a.SHAPE.STNumPoints() 
ORDER BY a.SHAPE.STPointN(b.n).Lat, b.n;

Bottom range:

OBJECTID    n   Lattitude   Longitude
9033    983 33.466981284    -119.038116174
9033    1000    33.4669817430001    -119.037982757
9033    982 33.4669820330001    -119.038128214
9033    984 33.4669823350001    -119.038103865

Top Range:

OBJECTID    n   Lattitude   Longitude
19  180 63.751484675    -149.291076228
19  177 63.7515265970001    -149.291518977
19  178 63.7515650700001    -149.291457788
19  179 63.751576146    -149.291381612
tpcolson
  • 716
  • 1
  • 11
  • 27
  • 1
    Your error message says latitude is out of range. Latitude is north south. You can't go any more than +-90 degrees until you reach the poles. – Laurence Oct 06 '14 at 22:11
  • The features I'm adding are well between the poles. California, for example, triggers the error. – tpcolson Oct 06 '14 at 22:43
  • 1
    it's very hard to point to the specific error as you haven't pasted an insert. But it just looks like you're passing longitude where the API expects latitude and vice-versa. – Laurence Oct 06 '14 at 22:58
  • Here's a quick test showing the SRID is fine: http://sqlfiddle.com/#!3/2350ac/1 – Laurence Oct 06 '14 at 23:15
  • The problem will be that you have lat and lon the wrong way round. It is lon, lat, think x then y. This is a common mistake because everyone refers to it as lat/lon. There are some restrictions on geometries spanning more than one hemisphere, which have been fixed in SQL Server 2012 with the fullglobe object. There is no issue using 4326 with geography, though it is automatically implied. – John Powell Oct 07 '14 at 08:11
  • http://en.m.wikipedia.org/wiki/Right-hand_rule – Micromega Oct 07 '14 at 08:30
  • Definitely don't have lat/lon the wrong way around. Edited original post to show... – tpcolson Oct 13 '14 at 17:08
  • ..and get the same error from 2008 R2 and 2012 SP2.... – tpcolson Oct 13 '14 at 17:11

0 Answers0