locked
Help with storing location RRS feed

  • Question

  • I'm trying to store this japanese location (38.309401,140.650356) into my spacial column:

    DECLARE @G As GEOGRAPHY

    SET @G = GEOGRAPHY::STPointFromText('POINT(38.309401 140.650356)', 4326)

     

    but get this 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.

     

    What am I doing wrong? Do I have to convert this position in some way?

    Monday, January 30, 2012 1:21 PM

Answers

  • WKT coordinates are listed in longitude/latitude order. So, assuming you meant a point at longitude of 140'E, latitude of 38'N:

    DECLARE @G As geography
    SET @G = geography::STPointFromText('POINT(140.650356 38.309401)', 4326);
    


     


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by energia Monday, January 30, 2012 3:35 PM
    Monday, January 30, 2012 2:43 PM
    Answerer

All replies

  • WKT coordinates are listed in longitude/latitude order. So, assuming you meant a point at longitude of 140'E, latitude of 38'N:

    DECLARE @G As geography
    SET @G = geography::STPointFromText('POINT(140.650356 38.309401)', 4326);
    


     


    twitter: @alastaira blog: http://alastaira.wordpress.com/
    • Marked as answer by energia Monday, January 30, 2012 3:35 PM
    Monday, January 30, 2012 2:43 PM
    Answerer
  • Yes, that is correct. The location is @ lat=38.309401, long=140.650356 

    I'm confused as the documentation says:

    Point ( Lat, Long, SRID )



    You have specified it as Long, Lat, SRID? 

     

    **Edit, I see now that the documentation is wrong. Arghh **

    • Edited by energia Monday, January 30, 2012 3:35 PM
    Monday, January 30, 2012 3:31 PM
  • The documentation isn't wrong:- The page you linked to describes the Point() method. The method you're using is the STPointFromText() method.
    twitter: @alastaira blog: http://alastaira.wordpress.com/
    Monday, January 30, 2012 3:41 PM
    Answerer
  • I blame the documentation for  STPointFromText() for mentioning the Point...

    However, thanks for pointing me in the right direction, as my problem now is solved :)

    Monday, January 30, 2012 3:55 PM