{"id":30,"date":"2013-02-28T13:34:00","date_gmt":"2013-02-28T13:34:00","guid":{"rendered":"https:\/\/wdev-blog.azurewebsites.net\/index.php\/2013\/02\/28\/finds-close-points-by-distance\/"},"modified":"2013-02-28T13:34:00","modified_gmt":"2013-02-28T13:34:00","slug":"finds-close-points-by-distance","status":"publish","type":"post","link":"http:\/\/panahy.nl\/index.php\/2013\/02\/28\/finds-close-points-by-distance\/","title":{"rendered":"Finds Close Points by Distance"},"content":{"rendered":"<p>In this example I am trying to find the distance between the locations in a table and a given point. When I found the distance I will return thee result filtered by a allegible distance.<\/p>\n<pre><span style=\"color: #6aa84f;\">-- =============================================<br \/>-- Author:\t\tAsghar Panahy<br \/>-- Create date: 28-Feb-2013<br \/>-- Description:\tZoekt objecten binnen bereik van gegeven punt<br \/>-- =============================================<br \/><\/span>ALTER PROCEDURE [dbo].[BereikbareObjecten] <br \/>\t<span style=\"color: #6aa84f;\">-- Add the parameters for the stored procedure here<\/span><br \/>\t@orig_lat REAL , <br \/>\t@orig_lng REAL,<br \/>\t@binnenMeter integer<br \/>AS<br \/>BEGIN<br \/>\t<span style=\"color: #6aa84f;\">-- SET NOCOUNT ON added to prevent extra result sets from<br \/>\t-- interfering with SELECT statements.<\/span><br \/>\tSET NOCOUNT ON;<br \/><br \/>\t<span style=\"color: #38761d;\">---------------------------------------------------------<br \/>\t-- Select your SRID wisely. Don't follow me.<br \/>\t-- select * from sys.spatial_reference_systems <br \/><\/span><span style=\"color: #38761d;\">\t-- <\/span><span style=\"color: #38761d;\">where spatial_reference_id in (4937, 4258, 4326, 4269)<\/span><br \/>\tDECLARE @SRID as int = 4326;<br \/>\t<span style=\"color: #38761d;\">---------------------------------------------------------<\/span><br \/>   <br \/>\tDECLARE @orig geography;<br \/>\t<b>SET @orig = <span style=\"color: blue;\">geography::Point<\/span>(@orig_lat, @orig_lng, @SRID);<br \/>\t<\/b><br \/>\tSELECT  *,CONVERT(INT,  <b><span style=\"color: blue;\">@orig.STDistance<\/span><\/b>( geography::Point([object].[Latitude], [object].[Longitude], @SRID))) As [Distance]<br \/>\t  INTO #MyTempTable<br \/>\t  FROM [Object]  <br \/>\t<br \/>\tSELECT * FROM #MyTempTable <br \/>         WHERE [Distance] &lt;= @binnenMeter <br \/>         ORDER BY [Distance]<br \/>\t<br \/>END<br \/><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this example I am trying to find the distance between the locations in a table and a given point. When I found the distance I will return thee result filtered by a allegible distance. &#8212; =============================================&#8211; Author: Asghar Panahy&#8211; Create date: 28-Feb-2013&#8211; Description: Zoekt objecten binnen bereik van gegeven punt&#8211; =============================================ALTER PROCEDURE [dbo].[BereikbareObjecten] &#8212; &hellip; <a href=\"http:\/\/panahy.nl\/index.php\/2013\/02\/28\/finds-close-points-by-distance\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Finds Close Points by Distance&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25,26,24],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"Pouya Panahy","author_link":"http:\/\/panahy.nl\/index.php\/author\/pouya\/"},"uagb_comment_info":0,"uagb_excerpt":"In this example I am trying to find the distance between the locations in a table and a given point. When I found the distance I will return thee result filtered by a allegible distance. -- =============================================-- Author: Asghar Panahy-- Create date: 28-Feb-2013-- Description: Zoekt objecten binnen bereik van gegeven punt-- =============================================ALTER PROCEDURE [dbo].[BereikbareObjecten] --&hellip;","_links":{"self":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/30"}],"collection":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/comments?post=30"}],"version-history":[{"count":0,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/media?parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/categories?post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/panahy.nl\/index.php\/wp-json\/wp\/v2\/tags?post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}