No rows returned with an STIntersects Query create Polygon to be around most of the data in Table RRS feed

All replies

  • Hi there,

    The issue you are having relates to co-ordinate ordering. Specifically, it relates to the fact that you are mixing WKT (which expects longitude-latitude ordering) and GML (which expects latitude-longitude ordering).

    Your GML NavStreets data describes an approximate location at 41.8 degrees latitude, 12.5 degrees longitude - somewhere in Rome, Italy.

    Your WKT SearchRectangle describes a location at approximately 12.4 degrees latitude, 41.9 degrees longitude - somewhere in North-East Ethiopia.

    I suspect what you meant to do was this:
    DECLARE @SearchRectangleString VARCHAR(MAX);  
    SET @SearchRectangleString = 'POLYGON((12.4 41.9,12.4 41.8 ,12.6 41.8 ,12.6 41.9 ,12.4 41.9 ))'   
    DECLARE @SearchRectangle Geography;  
    SET @SearchRectangle = Geography::STPolyFromText(@SearchRectangleString, 4326) 

    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Monday, February 16, 2009 8:01 PM