locked
The problem with the creation of type Geography (line) RRS feed

  • Question

  • Hi!

    Sorry for my English (Google translate:)

    There is copy LINE of type geography:

    SELECT geography:: STLineFromText
    (' LINESTRING (52.4518199 30.9537200, 52.4518199 30.9523499, 52.4518199 30.9547500) ', 4326) 
    
    Result:
    Msg 6522, Level 16, State 1, Line 1
    A A. NET FRAMEWORK error occurred during execution of user-defined routine or aggregate "geography": 
    System. ArgumentException: 24200: The specified input does not represent a valid geography instance.
    System. ArgumentException: 
       In Microsoft. SqlServer. Types. SqlGeography. ConstructGeographyFromUserInput (GeoData g, Int32 srid)
       In Microsoft. SqlServer. Types. SqlGeography. GeographyFromText (OpenGisType type, SqlChars taggedText, Int32 srid)
       In Microsoft. SqlServer. Types. SqlGeography. STLineFromText (SqlChars lineStringTaggedText, Int32 srid)

    The error, is probably called by that points on which is under construction LINE are allocated the close friend from the friend (latitude same, distinctions of a longitude <0,01 degrees). The data real and them somehow should be loaded in basis. Whether it is valid the matter is that for a SQL SERVER of a point with a difference in coordinates <0,01 degrees are perceived as identical or in something by the friend? Whether it is possible to save somehow this a line in type geography?

    ----------------------------------
    In Russian:
    ----------------------------------
    Создается экземпляр LINE типа geography:

    SELECT geography::STLineFromText
    ('LINESTRING (52.4518199 30.9537200, 52.4518199 30.9523499, 52.4518199 30.9547500)', 4326) 

    Результат:
    Msg 6522, Level 16, State 1, Line 1
    A .NET Framework error occurred during execution of user-defined routine or aggregate "geography": 
    System.ArgumentException: 24200: The specified input does not represent a valid geography instance.
    System.ArgumentException: 
      в Microsoft.SqlServer.Types.SqlGeography.ConstructGeographyFromUserInput(GeoData g, Int32 srid)
      в Microsoft.SqlServer.Types.SqlGeography.GeographyFromText(OpenGisType type, SqlChars taggedText, Int32 srid)
      в Microsoft.SqlServer.Types.SqlGeography.STLineFromText(SqlChars lineStringTaggedText, Int32 srid)

    Ошибка, видимо вызвана тем, что точки, на которых строится LINE расположены близко друг от друга (широта одна и та же, различия долготы < 0,01 градуса). Данные реальные и их как-то надо загрузить в базу. Действительно ли дело в том, что для SQL SERVER точки с разницей в координатах < 0,01 градуса воспринимаются как одинаковые или в чем-то другом? Можно ли эту линия каким-либо образом сохранить в типе geography?
    Wednesday, January 5, 2011 2:51 PM

Answers

  • The problem is not that your points lie too close together, but that your linestring retraces itself. You start at point (52.4518199 30.9537200), go due South to (52.4518199 30.9523499), but then go back North along the path you just took to get to (52.4518199 30.9547500).

    If you swap points 1 and 2 around, you don't have a problem:

    SELECT geography:: STLineFromText
    ('LINESTRING(52.4518199 30.9523499, 52.4518199 30.9537200, 52.4518199 30.9547500)', 4326) 
    


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    • Marked as answer by Jown Wednesday, January 5, 2011 5:15 PM
    Wednesday, January 5, 2011 4:09 PM
    Answerer