代码之家  ›  专栏  ›  技术社区  ›  Alex Hope O'Connor

SQL Server地理位置点

  •  1
  • Alex Hope O'Connor  · 技术社区  · 14 年前

    我最近一直在研究SQL Server空间数据类型,并决定尝试将我的长lat点存储在地理字段中。

    我也很好奇地理函数中指定的ID参数的用途。

    谢谢,

    2 回复  |  直到 14 年前
        1
  •  2
  •   Oded    14 年前

    你看过MSDN的例子吗?

    geography (Transact-SQL) :

    IF OBJECT_ID ( 'dbo.SpatialTable', 'U' ) IS NOT NULL 
        DROP TABLE dbo.SpatialTable;
    GO
    
    CREATE TABLE SpatialTable 
        ( id int IDENTITY (1,1),
        GeogCol1 geography, 
        GeogCol2 AS GeogCol1.STAsText() );
    GO
    
    INSERT INTO SpatialTable (GeogCol1)
    VALUES (geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656 )', 4326));
    
    INSERT INTO SpatialTable (GeogCol1)
    VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));
    GO
    

    Point :

    DECLARE @g geometry;
    SET @g = geometry::STGeomFromText('POINT (3 4)', 0);
    SET @g = geometry::Parse('POINT(3 4 7 2.5)');
    
        2
  •  0
  •   doekman    9 年前
    DECLARE @g geography;  
    SET @g = geography::Point(4, 3, 4326);
    

    通知

    推荐文章