2

I got 2 layers, each layer containing 1 polygon.

When I use the "Distance Calculator" tool set to find closest point, OR Find farthest point, the result is always the same.

What I want to know is why? How does the tool calculate the "furthest distance"?

If you look at the image here, to me the furhest distance should be calculated between A and B.

Image visualizing the question

1 Answer 1

2

In the MapBasic Reference Guide, the Farthest statement's (which I'm going to assume is what the Distance Calculator uses) purpose is defined as:

Find the object in a table that is farthest from a particular object. The result is a two-point Polyline object representing the farthest distance.

So, the title is a little bit misleading, but it is actually finding the furthest object, not the furthest point within the object. This is then corroborated further down in the Description section:

The types of the objects in the fromtable and totable can be anything except Text objects. For example, if both tables contain Region objects, then the minimum distance between Region objects is found, and the two-point Polyline object produced represents the points on each object used to calculate that distance.

Note the part stating the minimum distance between region objects is found.

If you want to find the furthest point within each object, then I think you are going to need to use some code to compare each node in one object against every other node in the other object and then return the distance for the pair of nodes which are furthest apart. It should be fairly simple to implement if you know a bit of MapBasic but otherwise I'm not sure how you'd go about it!

** update ** I've just checked the source code for the Distance Calculator tool and it does indeed use the Farthest statement to do the distance calculation.

4
  • Thank you, thats what I needed a good description. Question flagged as answered.
    – esset
    Sep 22, 2016 at 13:11
  • Edit: It gets a little bit trickier when the table contains three polygons combined into a single object. Then it oughta find the polygon furthest away, but it doesnt. It only does that if i dissaggregate the three polygons, but thats another story :)
    – esset
    Sep 22, 2016 at 13:17
  • 1
    Ah, but technically they are the same object so it treats all three as part of the same object. ;-)
    – T_Bacon
    Sep 22, 2016 at 13:30
  • 1
    You can use ConnectObjects(object1, object2, min) to find the maximum distance between two objects. If you set the third parameter to FALSE, it will return the maximum distance instead of the minimum Sep 26, 2016 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.