google / s2geometry

Computational geometry and spatial indexing on the sphere
http://s2geometry.io/
Apache License 2.0
2.32k stars 308 forks source link

Need more GetDistance() methods #202

Closed jievince closed 3 years ago

jievince commented 3 years ago
S2Polyline::GetDistance(S2Point)
S2Polyline::GetDistance(S2Polyline)

S2Polygon::GetDistance(S2Polyline)
S2Polygon::GetDistance(S2Polygon)

These methods are missed in S2

jmr commented 3 years ago

Use S2ClosestEdgeQuery. If you search for "distance" in s2polygon.h, you'll find this: https://github.com/google/s2geometry/blob/master/src/s2/s2polygon.h#L797

  // For example, to measure the distance from one S2Polygon to another, you
  // can write:
  //   S2ClosestEdgeQuery query(&polygon1.index());
  //   S2ClosestEdgeQuery::ShapeIndexTarget target(&polygon2.index());
  //   S1ChordAngle distance = query.GetDistance(&target);
jievince commented 3 years ago

Thanks!