Jean
Jean

Reputation: 19

boost calculate distance (of various geometry)

Recently I am on a project to calculate distance between various geometries, eg a polygon to polygon, ring to ring.

Now I have some questions:

  1. When define a polygon or a ring, I need to append the exactly first point to the defiened polygon to make them enclosed? (I have seen some examples like this)

  2. When calculate distance, it always calculate a point to points of another geometry? It could be linestring or something others?

Upvotes: 1

Views: 638

Answers (1)

sehe
sehe

Reputation: 393134

It all depends on the parameterization of your models. Specifcally you can configure the orientation (CW/CCW) and openness (open/closed) of your Ring type.

As far as the algorithms go, the documentation lists what concepts are suited: https://www.boost.org/doc/libs/1_69_0/libs/geometry/doc/html/geometry/reference/algorithms/distance/distance_2.html#geometry.reference.algorithms.distance.distance_2.supported_geometries.

enter image description here

Pro tip:

Use bg::is_valid and or bg::correct to automatically fix common issues (like unclosed polygons)

Upvotes: 2

Related Questions