SQL Server Geography Datatype

  • I'm assuming that there's nothing really special or unique that I need to know to use the geography. It simply stores lat & long as

    28.429636,-81.459483 which can then be use for all sorts of actions like get a map from mapquest.com.

  • Well, essentially no.

    It does store the lat,long and you can read them later.

    But it actually creates the logic behind those coordinates allowing the server to compare and use them as coordinates, not just a lat and long number

    Say you have a field called coords, where you've saved some points already, you can use built-in methods to find the distance to a point. In a query you could ask for;

    WHERE coords.STDistance(geography::Point(33.1234, -112.1234, 4326)) < 200

    This would show you any records less than 200 meters from the Point in the query.

    Here are some more methods available ( http://msdn.microsoft.com/en-us/library/bb933917.aspx )

    # STArea

    # STAsBinary

    # STAsText

    # STBuffer

    # STDifference

    # STDimension

    # STDisjoint

    # STDistance

    # STEndpoint

    # STEquals

    # STGeometryN

    # STGeometryType

    # STIntersection

    # STIntersects

    # STIsClosed

    # STIsEmpty

    # STLength

    # STNumGeometries

    # STNumPoints

    # STPointN

    # STSrid

    # STStartPoint

    # STSymDifference

    # STUnion

    In my opinion this is most important update to sqlserver ever, given todays web2.0 mashup and location based information.

    One downside is, many or most sql server administration programs, can't handle editing the goegraphy type. It's not text, It can be read like text but not updated. (speaking of Toad, and mylittleadmin)

  • So its completely different from having a column (of any other data type) that stores the lat and a different on for the long as values. The geography data type is storing (for lack of a better way of describing it) a physical point on Earth that just happens to appear as a lat & long.

    The scenario that I'm looking at is a means by which we can use Mapquest to get directions between any two points. The DB will store the address information (street, city, state, zip) for purposes where that's appropriate and in a separate field a lat & long. The nature of some of the locations are such that only an approximate address can exist.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply