Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?

Closest Point on pline : trouver un point proche sur une polyligne

Manuel en français

Trouve le point le plus proche sur une polyligne d'un point donné

English Manual

Closest Point on a Polyline

Paul Crisp (Paul.CRISP@syntegra.com) posted ro mapinfo-l on July 3, 2002 some VB code to find the closest point from a given point to a polyline (it could be the “foot” of the shortest perpendicular line from the point to every segment of the polyline, or an end point of the polyline if no perpendicular can be traced that would intersects a segment between its 2 nodes). As the translation to pure MapBasic code is not obvious, I have decided, with Paul's entire support, to offer my solution for inspection and download.

The essence of Paul's code is contained in 3 functions: returnPointOfShortestPerpendicular(), FindClosestPointOnLineSegment() and PointIsBetween(). These functions need also a sub, ErrorHandler, that is not despite its name a standard MB procedure. It is useful to locate the source of an error in one of the functions.

I have added a small interface that shows a way to use these functions and that allows for some experimenting but is not a “production” tool. It is mainly made of “traps” to make sure that valid data is entered. It does not exclude working with “degrees” tables but the results are probably incorrect then.

The way I have used the SelChangedHandler is most primitive but it suffices for that kind of application. I would be most interested to learn of another way to code for successive selections of different objects.

You can download the following code as a MapBasic listing in the ClstPntOnPline.zip file

 
main/logiciels/mapinfo/outils/closest_point_on_pline.txt · Dernière modification: 2009/04/15 20:59 (modification externe)
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki