Skip to content

Documentation example code invalid for latest library version #628

Description

@jmal0

From https://s2geometry.io/devguide/s2shapeindex.html:

void TestContainment(const vector<S2Point>& points,
                     const vector<S2Polygon*>& polygons) {
  MutableS2ShapeIndex index;
  for (auto polygon : polygons) {
    index.Add(absl::make_unique<S2Polygon::Shape>(polygon));
  }
  auto query = MakeS2ContainsPointQuery(&index);
  for (const auto& point: points) {
    for (S2Shape* shape : query.GetContainingShapes(point)) {
      S2Polygon* polygon = polygons[shape->id()];
      ... do something with (point, polygon) ...
    }
  }
}

This code does not compile for several reasons:

  • GetContainingShapes now returns std::vector<const S2Shape*>
  • There is no id() function in S2Shape (removed in this commit: 84bfd2c)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions