Below is the sample stored procedure used to find the
rows that are intersected with the POLYGON object
[Created using Coordinates list].
CREATE PROCEDURE [dbo].[GetIntersectingRows]
-- Add the parameters for the stored procedure here
@Coordinates varchar(max)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
Declare @AOIPolygon geography
set @AOIPolygon = geography::STPolyFromText('POLYGON(('+@Coordinates+'))', 4326);
SELECT ID,Quad_Name,State from dbo.USCollared250K_Index
WITH (INDEX(geom_sidx)) WHERE
@AOIPolygon.STIntersects(geom) = 1;
END
Note:
@Coordinates - comma separated pairs of coordinates like
eg. -104.864472 39.764004,-104.864472 39.853945,-105.057976 39.853945,
-105.057976 39.764004,-104.864472 39.764004
No comments:
Post a Comment