.. I create shapes (Point, Lines, Rectangle) and position them beside a line (baseline).
To position the shapes I use code from a sample in Code Comunity -> "Offset Point at Right Angle".
This works fine.
But what I now need is the backward way. If a new point is created on the map via my edit functions and the user selects a lineshape as reference line I need to get a point on the line that is in right angle to my new point.
I made some test with Lineshape.GetShortestLineTo() method but this is not exact as I need. If I create a point to a line position via "Offset Point at Right Angle"-Code I should get the same line Position if I try the backward way.
I think this is a mathematic logic problem. I wrote some logics for you, while It only deal with very simple case in which the LineShape will only contains 2 points. Hope it helps.
thanks for your sample code. It works much better than using the GetClosestPoint() method. The point I get via your code is most exactly for my calculation.
But you have allready noticed what I need. How can I detect the point if I have linestrings with more than two points.
Just have a try as following idea, hope it helps. Loop all the points contained in the LineShape and from which find out those two points closest to target point shape in distance, and then call the API listed in previous post.
Any more questions please feel free to let me know.
I amd the original author of the function GetClosestPoint(). I used several examples of line segments to compare the results from GetClosestPoint() and the function GetPerpendicularVertex written by Yale. I always to get the same result regardless of what function I use. Can you give some cases from you where the function GetPerpendicularVertex works much better than using the GetClosestPoint() method? I am curious to see why our GetClosestPoint() is not always adequate in all the situations. Thank you.
you are right. After looking on my code again I saw that I made a mistake. The method I used before I changed to GetPredicularVertex() was GetShortestLineTo() not GetClosestPoint(). If I use GetClosestPoint() I get exactly the position I need.