Package com.google.common.geometry
Interface S2Shape
-
- All Known Subinterfaces:
S2LaxPolygonShape
,S2LaxPolylineShape
,S2ShapeAspect.EdgeAspect.Closed
,S2ShapeAspect.EdgeAspect.Open
,S2ShapeAspect.Mixed
- All Known Implementing Classes:
S2Edge
,S2LaxPolygonShape.MultiArray
,S2LaxPolygonShape.MultiList
,S2LaxPolygonShape.MultiPacked
,S2LaxPolygonShape.MultiSnapped
,S2LaxPolygonShape.SimpleArray
,S2LaxPolygonShape.SimpleList
,S2LaxPolygonShape.SimplePacked
,S2LaxPolygonShape.SimpleSnapped
,S2LaxPolylineShape.MultiArray
,S2LaxPolylineShape.MultiPacked
,S2LaxPolylineShape.MultiSnapped
,S2LaxPolylineShape.SimpleArray
,S2LaxPolylineShape.SimpleList
,S2LaxPolylineShape.SimplePacked
,S2LaxPolylineShape.SimpleSnapped
,S2Loop
,S2Point.Shape
,S2Polygon.Shape
,S2Polyline
,S2ShapeAspect.ChainAspect.Multi
,S2ShapeAspect.ChainAspect.Multi.Array
,S2ShapeAspect.ChainAspect.Multi.Packed
,S2ShapeAspect.ChainAspect.Multi.Snapped
,S2ShapeAspect.ChainAspect.Simple
,S2ShapeAspect.ChainAspect.Simple.Array
,S2ShapeAspect.ChainAspect.Simple.Packed
,S2ShapeAspect.ChainAspect.Simple.Snapped
,S2ShapeUtil.S2EdgeVectorShape
@GwtCompatible public interface S2Shape
S2Shape is an abstract base class that defines a shape. Typically it wraps some other geometric object in order to provide access to its edges without duplicating the edge data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
S2Shape.MutableEdge
A simple receiver for the endpoints of an edge.static class
S2Shape.ReferencePoint
A point with a known containment relationship.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.List<S2Point>
chain(int chain)
Returns a view of the vertices in the given chain.default java.util.List<java.util.List<S2Point>>
chains()
Returns a view of thechains
in this shape.boolean
containsOrigin()
Returns true if this shape containsS2.origin()
.int
dimension()
Returns the dimension of the geometry represented by this shape.void
getChainEdge(int chainId, int offset, S2Shape.MutableEdge result)
Returns the edge for the given chain id and offset inresult
.int
getChainLength(int chainId)
Returns the number of edge ids corresponding to the edge chain for the given chain id.int
getChainStart(int chainId)
Returns the first edge id corresponding to the edge chain for the given chain id.S2Point
getChainVertex(int chainId, int edgeOffset)
Returns the start point of the edge that would be returned bygetChainEdge(int, int, com.google.common.geometry.S2Shape.MutableEdge)
, or the endpoint of the last edge ifedgeOffset==getChainLength(chainId)
.void
getEdge(int index, S2Shape.MutableEdge result)
Returns the edge for the given index inresult
.default S2Shape.ReferencePoint
getReferencePoint()
Returns a point referenced to, i.e.boolean
hasInterior()
Returns true if this shape has an interior, i.e.int
numChains()
Returns the number of contiguous edge chains in the shape.int
numEdges()
Returns the number of edges in this shape.
-
-
-
Method Detail
-
numEdges
int numEdges()
Returns the number of edges in this shape.
-
getEdge
void getEdge(int index, S2Shape.MutableEdge result)
Returns the edge for the given index inresult
. Must not return zero-length edges.- Parameters:
index
- which edge to set intoresult
, from 0 tonumEdges()
- 1
-
hasInterior
boolean hasInterior()
Returns true if this shape has an interior, i.e. the shape consists of one or more closed non-intersecting loops.
-
containsOrigin
boolean containsOrigin()
Returns true if this shape containsS2.origin()
. Should return false for shapes that do not have an interior.
-
numChains
int numChains()
Returns the number of contiguous edge chains in the shape. For example, a shape whose edges are [AB, BC, CD, AE, EF] may consist of two chains [A, B, C, D] and [A, E, F]. Every chain is assigned a chain id numbered sequentially starting from zero.An empty shape has no chains. A full shape (which contains the entire globe) has one chain with no edges. Other shapes should have at least one chain, and the sum of all valid
chain lengths
should equalnumEdges()
(that is, edges may only be used by a single chain).Note that it is always acceptable to implement this method by returning
numEdges()
(i.e. every chain consists of a single edge), but this may reduce the efficiency of some algorithms.
-
getChainStart
int getChainStart(int chainId)
Returns the first edge id corresponding to the edge chain for the given chain id. The edge chains must form contiguous, non-overlapping ranges that cover the entire range of edge ids.- Parameters:
chainId
- which edge chain to return its start, from 0 tonumChains()
- 1
-
getChainLength
int getChainLength(int chainId)
Returns the number of edge ids corresponding to the edge chain for the given chain id. The edge chains must form contiguous, non-overlapping ranges that cover the entire range of edge ids.- Parameters:
chainId
- which edge chain to return its length, from 0 tonumChains()
- 1
-
getChainEdge
void getChainEdge(int chainId, int offset, S2Shape.MutableEdge result)
Returns the edge for the given chain id and offset inresult
. Must not return zero-length edges.- Parameters:
chainId
- which chain contains the edge to return, from 0 tonumChains()
- 1offset
- position from chain start for the edge to return, from 0 togetChainLength(int)
- 1
-
getChainVertex
S2Point getChainVertex(int chainId, int edgeOffset)
Returns the start point of the edge that would be returned bygetChainEdge(int, int, com.google.common.geometry.S2Shape.MutableEdge)
, or the endpoint of the last edge ifedgeOffset==getChainLength(chainId)
.
-
chain
default java.util.List<S2Point> chain(int chain)
Returns a view of the vertices in the given chain. Note2D
shapes omit the last vertex, as it's a duplicate of the first.
-
chains
default java.util.List<java.util.List<S2Point>> chains()
Returns a view of thechains
in this shape.
-
dimension
int dimension()
Returns the dimension of the geometry represented by this shape.- 0 - Point geometry. Each point is represented as a degenerate edge.
- 1 - Polyline geometry. Polyline edges may be degenerate. A shape may represent any number of polylines. Polylines edges may intersect.
- 2 - Polygon geometry. Edges should be oriented such that the polygon interior is always on the left. In theory the edges may be returned in any order, but typically the edges are organized as a collection of edge chains where each chain represents one polygon loop. Polygons may have degeneracies, e.g., degenerate edges or sibling pairs consisting of an edge and its corresponding reversed edge. A polygon loop may also be full (containing all points on the sphere); by convention this is represented as a chain with no edges.
Note that this method allows degenerate geometry of different dimensions to be distinguished, e.g., it allows a point to be distinguished from a polyline or polygon that has been simplified to a single point.
-
getReferencePoint
default S2Shape.ReferencePoint getReferencePoint()
Returns a point referenced to, i.e. indicating containment by, this shape.
-
-