Constructs an S2LaxPolygonShape from an S2Polygon, by copying its data. Full and empty S2Polygons are supported.
Initializes an S2LaxPolygonShape from the given vertex loops.
Initializes an S2LaxPolygonShape from an S2Polygon, by copying its data. Full and empty S2Polygons are supported.
An edge, consisting of two vertices "v0" and "v1". Zero-length edges are allowed, and can be used to represent points.
A range of edge ids corresponding to a chain of zero or more connected edges, specified as a (start, length) pair. The chain is defined to consist of edge ids {start, start + 1, ..., start + length - 1}.
The position of an edge within a given edge chain, specified as a (chain_id, offset) pair. Chains are numbered sequentially starting from zero, and offsets are measured from the start of each chain.
A ReferencePoint consists of a point P and a boolean indicating whether P is contained by a particular shape.
Returns the number of edges in this shape. Edges have ids ranging from 0 to num_edges() - 1.
Returns the endpoints of the given edge id.
Returns the dimension of the geometry represented by this shape.
Convenience function that returns true if this shape has an interior.
Returns an arbitrary point P along with a boolean indicating whether P is contained by the shape. (The boolean value must be false for shapes that do not have an interior.)
Returns the number of contiguous edge chains in the shape. For example, a shape whose edges are [AB, BC, CD, AE, EF] would consist of two chains (AB,BC,CD and AE,EF). Every chain is assigned a "chain id" numbered sequentially starting from zero.
Returns the range of edge ids corresponding to the given edge chain. The edge chains must form contiguous, non-overlapping ranges that cover the entire range of edge ids. This is spelled out more formally below:
Returns the edge at offset "offset" within edge chain "chain_id". Equivalent to "shape.edge(shape.chain(chain_id).start + offset)" but may be more efficient.
Finds the chain containing the given edge, and returns the position of that edge as a (chain_id, offset) pair.
A unique id assigned to this shape by S2ShapeIndex. Shape ids are assigned sequentially starting from 0 in the order shapes are added.
Virtual methods that return pointers of your choice.
Assigned by MutableS2ShapeIndex when the shape is added.
S2LaxPolygonShape represents a region defined by a collection of zero or more closed loops. The interior is the region to the left of all loops. This is similar to S2Polygon::Shape except that this class supports polygons with degeneracies. Degeneracies are of two types: degenerate edges (from a vertex to itself) and sibling edge pairs (consisting of two oppositely oriented edges). Degeneracies can represent either "shells" or "holes" depending on the loop they are contained by. For example, a degenerate edge or sibling pair contained by a "shell" would be interpreted as a degenerate hole. Such edges form part of the boundary of the polygon.
Loops with fewer than three vertices are interpreted as follows: - A loop with two vertices defines two edges (in opposite directions). - A loop with one vertex defines a single degenerate edge. - A loop with no vertices is interpreted as the "full loop" containing all points on the sphere. If this loop is present, then all other loops must form degeneracies (i.e., degenerate edges or sibling pairs). For example, two loops {} and {X} would be interpreted as the full polygon with a degenerate single-point hole at X.
S2LaxPolygonShape does not have any error checking, and it is perfectly fine to create S2LaxPolygonShape objects that do not meet the requirements below (e.g., in order to analyze or fix those problems). However, S2LaxPolygonShapes must satisfy some additional conditions in order to perform certain operations:
- In order to be valid for point containment tests, the polygon must satisfy the "interior is on the left" rule. This means that there must not be any crossing edges, and if there are duplicate edges then all but at most one of thm must belong to a sibling pair (i.e., the number of edges in opposite directions must differ by at most one).
- To be valid for boolean operations (S2BooleanOperation), degenerate edges and sibling pairs cannot coincide with any other edges. For example, the following situations are not allowed:
{AA, AA} // degenerate edge coincides with another edge {AA, AB} // degenerate edge coincides with another edge {AB, BA, AB} // sibling pair coincides with another edge
Note that S2LaxPolygonShape is must faster to initialize and is more compact than S2Polygon, but unlike S2Polygon it does not have any built-in operations. Instead you should use S2ShapeIndex operations (S2BooleanOperation, S2ClosestEdgeQuery, etc).