locked
Is there a way to find the closet point to a poly, ON the poly? RRS feed

  • Question

  • Hi folks,

    lets say i have a linestring and a POI like this ...

    is there a way i can calculate the closest point on that linestring, to that POI? In this picture, it's where the RED ARROW is pointing, on that linestring.


    -Pure Krome-
    Monday, January 24, 2011 4:37 AM

Answers

  • Hi Krome,

    The title of your post said closest point to a poly , but then your image shows a a line - is that the exterior ring of the poly?

    Either way, you'll probably find the discussion here and the proposed workaround by JasonFollas helpful:

    http://social.msdn.microsoft.com/Forums/en/sqlspatial/thread/cb094fb8-07ba-4219-8d3d-572874c271b5


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    • Marked as answer by Pure Krome Monday, January 24, 2011 10:58 PM
    Monday, January 24, 2011 8:56 AM
    Answerer

All replies

  • Hi Krome,

    The title of your post said closest point to a poly , but then your image shows a a line - is that the exterior ring of the poly?

    Either way, you'll probably find the discussion here and the proposed workaround by JasonFollas helpful:

    http://social.msdn.microsoft.com/Forums/en/sqlspatial/thread/cb094fb8-07ba-4219-8d3d-572874c271b5


    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    • Marked as answer by Pure Krome Monday, January 24, 2011 10:58 PM
    Monday, January 24, 2011 8:56 AM
    Answerer
  • Hi Tanoshimi :)

    yep - perfect! that's exactly what I was after ... and it's also in Denali! ShortestLineTo() :) Cheers to Ed for the blogpost about it. (But i have to wait for Denali, though).

    I'll use Jason Follas' workaround. tres bien!


    -Pure Krome-
    Monday, January 24, 2011 10:59 PM
  • Oh - as a side note, for Jason's workaround, he does an STIntersection() .. in the end of that Sql text. For polys that were linestrings, I always got a Collection Empty - because I read somewhere that STIntersection will always returns an empty collection if the target is a 2d poly or linestring. So i just STBuffer(0.1) to make sure any linestrings are now polys.
    -Pure Krome-
    Monday, January 24, 2011 11:40 PM