S2CrossingEdgeQuery

S2CrossingEdgeQuery is used to find edges or shapes that are crossed by an edge. Here is an example showing how to index a set of polylines, and then find the polylines that are crossed by a given edge AB:

void Test(const vector<S2Polyline*>& polylines,` const S2Point& a0, const S2Point &a1) { MutableS2ShapeIndex index; for (S2Polyline* polyline : polylines) { index.Add(absl::make_unique<S2Polyline::Shape>(polyline)); } S2CrossingEdgeQuery query(&index); for (const auto& edge : query.GetCrossingEdges(a, b, CrossingType::ALL)) { CHECK_GE(S2::CrossingSign(a0, a1, edge.v0(), edge.v1()), 0); } }

Note that if you need to query many edges, it is more efficient to declare a single S2CrossingEdgeQuery object and reuse it so that temporary storage does not need to be reallocated each time.

If you want to find *all* pairs of crossing edges, use s2shapeutil::VisitCrossingEdgePairs() instead.

class S2CrossingEdgeQuery {}

Constructors

this
this()

Default constructor; requires Init() to be called.

this
this(S2ShapeIndex index)

Convenience constructor that calls Init().

Members

Aliases

CellVisitor
alias CellVisitor = bool delegate(in S2ShapeIndexCell)
Undocumented in source.
EdgeMap
alias EdgeMap = int[][S2Shape]

////////////////// DEPRECATED METHODS //////////////////////////////

ShapeEdgeIdVisitor
alias ShapeEdgeIdVisitor = bool delegate(in ShapeEdgeId id)
Undocumented in source.

Functions

getCandidates
ShapeEdgeId[] getCandidates(S2Point a0, S2Point a1)

//////////////////////// Low-Level Methods ////////////////////////////

getCandidates
ShapeEdgeId[] getCandidates(S2Point a0, S2Point a1, S2Shape shape)
Undocumented in source. Be warned that the author may not have intended to support it.
getCandidates
void getCandidates(S2Point a0, S2Point a1, ShapeEdgeId[] edges)
Undocumented in source. Be warned that the author may not have intended to support it.
getCandidates
void getCandidates(S2Point a0, S2Point a1, S2Shape shape, ShapeEdgeId[] edges)
Undocumented in source. Be warned that the author may not have intended to support it.
getCandidates
deprecated bool getCandidates(S2Point a0, S2Point a1, EdgeMap edge_map)
Undocumented in source. Be warned that the author may not have intended to support it.
getCandidates
deprecated bool getCandidates(S2Point a0, S2Point a1, S2Shape shape, int[] edges)
Undocumented in source. Be warned that the author may not have intended to support it.
getCells
void getCells(S2Point a0, S2Point a1, S2PaddedCell root, const(S2ShapeIndexCell)[] cells)
Undocumented in source. Be warned that the author may not have intended to support it.
getCrossingEdges
ShapeEdge[] getCrossingEdges(S2Point a0, S2Point a1, CrossingType type)

Returns all edges that intersect the given query edge (a0,a1) and that have the given CrossingType (ALL or INTERIOR). Edges are sorted and unique.

getCrossingEdges
ShapeEdge[] getCrossingEdges(S2Point a0, S2Point a1, S2Shape shape, CrossingType type)

A specialized version of GetCrossingEdges() that only returns the edges that belong to a particular S2Shape.

getCrossingEdges
void getCrossingEdges(S2Point a0, S2Point a1, CrossingType type, ShapeEdge[] edges)

These versions can be more efficient when they are called many times, since they do not require allocating a new vector on each call.

getCrossingEdges
void getCrossingEdges(S2Point a0, S2Point a1, S2Shape shape, CrossingType type, ShapeEdge[] edges)
Undocumented in source. Be warned that the author may not have intended to support it.
getCrossings
deprecated bool getCrossings(S2Point a0, S2Point a1, S2Shape shape, CrossingType type, int[] edges)
Undocumented in source. Be warned that the author may not have intended to support it.
getCrossings
deprecated bool getCrossings(S2Point a0, S2Point a1, CrossingType type, EdgeMap edge_map)
Undocumented in source. Be warned that the author may not have intended to support it.
index
inout(S2ShapeIndex) index()
Undocumented in source. Be warned that the author may not have intended to support it.
initialize
void initialize(S2ShapeIndex index)

REQUIRES: "index" is not modified after this method is called.

visitCells
bool visitCells(S2Point a0, S2Point a1, CellVisitor visitor)
Undocumented in source. Be warned that the author may not have intended to support it.
visitCells
bool visitCells(S2Point a0, S2Point a1, S2PaddedCell root, CellVisitor visitor)
Undocumented in source. Be warned that the author may not have intended to support it.
visitRawCandidates
bool visitRawCandidates(S2Point a0, S2Point a1, ShapeEdgeIdVisitor visitor)
Undocumented in source. Be warned that the author may not have intended to support it.
visitRawCandidates
bool visitRawCandidates(S2Point a0, S2Point a1, S2Shape shape, ShapeEdgeIdVisitor visitor)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta