package
0.0.0-20230421003525-6adc56603217
Repository: https://github.com/golang/geo.git
Documentation: pkg.go.dev

# Packages

Package s2intersect efficiently finds common areas shared by sets of S2 CellUnions.

# Functions

Angle returns the interior angle at the vertex B in the triangle ABC.
AngleContainsVertex reports if the angle ABC contains its vertex B.
CapFromCenterAngle constructs a cap with the given center and angle.
CapFromCenterArea constructs a cap with the given center and surface area.
CapFromCenterChordAngle constructs a cap where the angle is expressed as an s1.ChordAngle.
CapFromCenterHeight constructs a cap with the given center and height.
CapFromPoint constructs a cap containing a single point.
CellFromCellID constructs a Cell corresponding to the given CellID.
CellFromLatLng constructs a cell for the given LatLng.
CellFromPoint constructs a cell for the given Point.
CellIDFromFace returns the cell corresponding to a given S2 cube face.
CellIDFromFacePosLevel returns a cell given its face in the range [0,5], the 61-bit Hilbert curve position pos within that face, and the level in the range [0,MaxLevel].
CellIDFromLatLng returns the leaf cell containing ll.
CellIDFromString returns a CellID from a string in the form "1/3210".
CellIDFromToken returns a cell given a hex-encoded string of its uint64 ID.
CellIDSnapperForLevel returns a snap function at the given level.
CellUnionFromDifference creates a CellUnion from the difference (x - y) of the given CellUnions.
CellUnionFromIntersection creates a CellUnion from the intersection of the given CellUnions.
CellUnionFromIntersectionWithCellID creates a CellUnion from the intersection of a CellUnion with the given CellID.
CellUnionFromRange creates a CellUnion that covers the half-open range of leaf cells [begin, end).
CellUnionFromUnion creates a CellUnion from the union of the given CellUnions.
ChordAngleBetweenPoints constructs a ChordAngle corresponding to the distance between the two given points.
ClipEdge returns the portion of the edge defined by AB that is contained by the given rectangle.
ClipToFace returns the (u,v) coordinates for the portion of the edge AB that intersects the given face, or false if the edge AB does not intersect.
ClipToPaddedFace returns the (u,v) coordinates for the portion of the edge AB that intersects the given face, but rather than clipping to the square [-1,1]x[-1,1] in (u,v) space, this method clips to [-R,R]x[-R,R] where R=(1+padding).
CompareDistance returns -1, 0, or +1 according to whether the distance XY is respectively less than, equal to, or greater than the provided chord angle.
CompareDistances returns -1, 0, or +1 according to whether AX < BX, A == B, or AX > BX respectively.
CrossingSign reports whether the edge AB intersects the edge CD.
DistanceFraction returns the distance ratio of the point X along an edge AB.
DistanceFromSegment returns the distance of point X from line segment AB.
EdgeOrVertexCrossing is a convenience function that calls CrossingSign to handle cases where all four vertices are distinct, and VertexCrossing to handle cases where two or more vertices are the same.
EdgePairClosestPoints returns the pair of points (a, b) that achieves the minimum distance between edges a0a1 and b0b1, where a is a point on a0a1 and b is a point on b0b1.
EdgeTrueCentroid returns the true centroid of the spherical geodesic edge AB multiplied by the length of the edge AB.
EmptyCap returns a cap that contains no points.
EmptyLoop returns a special "empty" loop.
EmptyRect returns the empty rectangle.
ExpandForSubregions expands a bounding Rect so that it is guaranteed to contain the bounds of any subregion whose bounds are computed using ComputeRectBound.
FaceSegments subdivides the given edge AB at every point where it crosses the boundary between two S2 cube faces and returns the corresponding FaceSegments.
FloodFillRegionCovering returns all edge-connected cells at the same level as the given CellID that intersect the given region, in arbitrary order.
FullCap returns a cap that contains all points.
FullLoop returns a special "full" loop.
FullPolygon returns a special "full" polygon.
FullRect returns the full rectangle.
GirardArea returns the area of the triangle computed using Girard's formula.
Interpolate returns the point X along the line segment AB whose distance from A is the given fraction "t" of the distance AB.
InterpolateAtDistance returns the point X along the line segment AB whose distance from A is the angle ax.
Intersection returns the intersection point of two edges AB and CD that cross (CrossingSign(a,b,c,d) == Crossing).
IsDistanceLess reports whether the distance from X to the edge AB is less than limit.
IsInteriorDistanceLess reports whether the minimum distance from X to the edge AB is attained at an interior point of AB (i.e., not an endpoint), and that distance is less than limit.
LatLngFromDegrees returns a LatLng for the coordinates given in degrees.
LatLngFromPoint returns an LatLng for a given Point.
LaxLoopFromLoop creates a LaxLoop from the given Loop, copying its points.
LaxLoopFromPoints creates a LaxLoop from the given points.
LaxPolygonFromPoints creates a LaxPolygon from the given points.
LaxPolygonFromPolygon creates a LaxPolygon from the given Polygon.
LaxPolylineFromPoints constructs a LaxPolyline from the given points.
LaxPolylineFromPolyline converts the given Polyline into a LaxPolyline.
LoopFromCell constructs a loop corresponding to the given cell.
LoopFromPoints constructs a loop from the given points.
NewCellIDSnapper returns a snap function with the default level set.
NewCellIndexContentsIterator returns a new contents iterator.
NewCellIndexIterator creates an iterator for the given CellIndex.
NewCellIndexNonEmptyRangeIterator creates an iterator for the given CellIndex.
NewCellIndexRangeIterator creates an iterator for the given CellIndex.
NewChainEdgeCrosser is a convenience constructor that uses AB as the fixed edge, and C as the first vertex of the vertex chain (equivalent to calling RestartAt(c)).
NewClosestEdgeQuery returns an EdgeQuery that is used for finding the closest edge(s) to a given Point, Edge, Cell, or geometry collection.
NewClosestEdgeQueryOptions returns a set of edge query options suitable for performing closest edge queries.
NewContainsPointQuery creates a new instance of the ContainsPointQuery for the index and given vertex model choice.
NewContainsVertexQuery returns a new query for the given vertex whose containment will be determined.
NewConvexHullQuery creates a new ConvexHullQuery.
NewCrossingEdgeQuery creates a CrossingEdgeQuery for the given index.
NewEdgeCrosser returns an EdgeCrosser with the fixed edge AB.
NewEdgeIterator creates a new edge iterator for the given index.
NewEdgeTessellator creates a new edge tessellator for the given projection and tolerance.
NewFurthestEdgeQuery returns an EdgeQuery that is used for finding the furthest edge(s) to a given Point, Edge, Cell, or geometry collection.
NewFurthestEdgeQueryOptions returns a set of edge query options suitable for performing furthest edge queries.
NewIdentitySnapper returns an IdentitySnapper with the given snap radius.
NewIntLatLngSnapper returns a Snapper with the specified exponent.
NewMaxDistanceToCellTarget returns a new target for the given Cell.
NewMaxDistanceToEdgeTarget returns a new target for the given Edge.
NewMaxDistanceToPointTarget returns a new target for the given Point.
NewMaxDistanceToShapeIndexTarget returns a new target for the given ShapeIndex.
NewMercatorProjection constructs a Mercator projection with the given maximum longitude axis value corresponding to a range of [-maxLng, maxLng].
NewMinDistanceToCellTarget returns a new target for the given Cell.
NewMinDistanceToEdgeTarget returns a new target for the given Edge.
NewMinDistanceToPointTarget returns a new target for the given Point.
NewMinDistanceToShapeIndexTarget returns a new target for the given ShapeIndex.
NewPlateCarreeProjection constructs a plate carree projection where the x-coordinates (lng) span [-xScale, xScale] and the y coordinates (lat) span [-xScale/2, xScale/2].
NewRectBounder returns a new instance of a RectBounder.
NewRegionCoverer returns a region coverer with the appropriate defaults.
NewShapeIndex creates a new ShapeIndex.
NewShapeIndexCell creates a new cell that is sized to hold the given number of shapes.
NewShapeIndexIterator creates a new iterator for the given index.
OrderedCCW returns true if the edges OA, OB, and OC are encountered in that order while sweeping CCW around the point O.
OriginPoint returns a unique "origin" on the sphere for operations that need a fixed reference point.
OriginReferencePoint returns a ReferencePoint with the given value for contained and the origin point.
Ortho returns a unit-length vector that is orthogonal to "a".
PaddedCellFromCellID constructs a padded cell with the given padding.
PaddedCellFromParentIJ constructs the child of parent with the given (i,j) index.
PlanarCentroid returns the centroid of the planar triangle ABC.
PointArea returns the area of triangle ABC.
PointFromCoords creates a new normalized point from coordinates.
PointFromLatLng returns an Point for the given LatLng.
PolygonFromCell returns a Polygon from a single loop created from the given Cell.
PolygonFromLoops constructs a polygon from the given set of loops.
PolygonFromOrientedLoops returns a Polygon from the given set of loops, like PolygonFromLoops.
PolylineFromLatLngs creates a new Polyline from the given LatLngs.
Project returns the point along the edge AB that is closest to the point X.
RectFromCenterSize constructs a rectangle with the given size and center.
RectFromLatLng constructs a rectangle containing a single point p.
RegularLoop creates a loop with the given number of vertices, all located on a circle of the specified radius around the given center.
RegularLoopForFrame creates a loop centered around the z-axis of the given coordinate frame, with the first vertex in the direction of the positive x-axis.
RobustSign returns a Direction representing the ordering of the points.
Rotate the given point about the given axis by the given angle.
Sign returns true if the points A, B, C are strictly counterclockwise, and returns false if the points are clockwise or collinear (i.e.
SignedArea returns a positive value for counterclockwise triangles and a negative value otherwise (similar to PointArea).
SimpleRegionCovering returns a set of cells at the given level that cover the connected region and a starting point on the boundary or inside the region.
TrueCentroid returns the true centroid of the spherical triangle ABC multiplied by the signed area of spherical triangle ABC.
TurnAngle returns the exterior angle at vertex B in the triangle ABC.
UpdateMaxDistance checks if the distance from X to the edge AB is greater than maxDist, and if so, returns the updated value and true.
UpdateMinDistance checks if the distance from X to the edge AB is less than minDist, and if so, returns the updated value and true.
UpdateMinInteriorDistance reports whether the minimum distance from X to AB is attained at an interior point of AB (i.e., not an endpoint), and that distance is less than minDist.
VertexCrossing reports whether two edges "cross" in such a way that point-in-polygon containment tests can be implemented by counting the number of edge crossings.
WedgeContains reports whether non-empty wedge A=(a0, ab1, a2) contains B=(b0, ab1, b2).
WedgeIntersects reports whether non-empty wedge A=(a0, ab1, a2) intersects B=(b0, ab1, b2).
WedgeRelation reports the relation between two non-empty wedges A=(a0, ab1, a2) and B=(b0, ab1, b2).

# Constants

These are the three options for the direction of a set of points.
These are the three options for the direction of a set of points.
Cross means the edges cross.
CrossingTypeAll reports all intersections, even those where two edges intersect only because they share a common vertex.
CrossingTypeInterior reports intersections that occur at a point interior to both edges (i.e., not at a vertex).
CrossingTypeNonAdjacent reports all intersections except for pairs of the form (AB, BC) where both edges are from the same ShapeIndex.
The possible CellRelations for a ShapeIndex.
DoNotCross means the edges do not cross.
FaceBits is the number of bits used to encode the face number.
These are the three options for the direction of a set of points.
The possible CellRelations for a ShapeIndex.
IteratorBegin specifies the iterator should be positioned at the beginning of the index.
IteratorEnd specifies the iterator should be positioned at the end of the index.
MaxLevel is the number of levels needed to specify a leaf cell.
MaxSize is the maximum index of a valid leaf cell plus one.
MaybeCross means two vertices from different edges are the same.
NumFaces is the number of faces.
PosBits is the total number of position bits.
SentinelCellID is an invalid cell ID guaranteed to be larger than any valid cell ID.
The possible CellRelations for a ShapeIndex.
VertexModelClosed means all shapes contain their vertices (including points and polylines).
VertexModelOpen means no shapes contain their vertices (not even points).
VertexModelSemiOpen means that polygon point containment is defined such that if several polygons tile the region around a vertex, then exactly one of those polygons contains that vertex.
A and B are equal.
A and B are disjoint.
A is a strict subset of B.
A is a strict superset of B.
A-B, B-A, and A intersect B are non-empty.

# Variables

Each cell is bounded by four planes passing through its four edges and the center of the sphere.
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
The maximum diagonal is also the maximum diameter of any cell, and also the maximum geometric width (see the comment for widths).
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
The width of geometric figure is defined as the distance between two parallel bounding lines in a given direction.
Each cell is bounded by four planes passing through its four edges and the center of the sphere.
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
MaxDiagAspect is the maximum diagonal aspect ratio over all cells at any level, where the diagonal aspect ratio of a cell is defined as the ratio of its longest diagonal length to its shortest diagonal length.
The maximum diagonal is also the maximum diameter of any cell, and also the maximum geometric width (see the comment for widths).
MaxEdgeAspect is the maximum edge aspect ratio over all cells at any level, where the edge aspect ratio of a cell is defined as the ratio of its longest edge length to its shortest edge length.
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
The width of geometric figure is defined as the distance between two parallel bounding lines in a given direction.
Each cell is bounded by four planes passing through its four edges and the center of the sphere.
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
The maximum diagonal is also the maximum diameter of any cell, and also the maximum geometric width (see the comment for widths).
The edge length metrics can be used to bound the minimum, maximum, or average distance from the center of one cell to the center of one of its edge neighbors.
The width of geometric figure is defined as the distance between two parallel bounding lines in a given direction.

# Structs

Cap represents a disc-shaped region defined by a center and radius.
Cell is an S2 region object that represents a cell.
CellIDSnapper is a type that snaps vertices to CellID centers.
CellIndex stores a collection of (CellID, label) pairs.
CellIndexContentsIterator is an iterator that visits the (CellID, label) pairs that cover a set of leaf cell ranges (see CellIndexRangeIterator).
CellIndexIterator is an iterator that visits the entire set of indexed (CellID, label) pairs in an unspecified order.
CellIndexRangeIterator is an iterator that seeks and iterates over a set of non-overlapping leaf cell ranges that cover the entire sphere.
Chain represents a range of edge IDs corresponding to a chain of connected edges, specified as a (start, length) pair.
ChainPosition represents the position of an edge within a given edge chain, specified as a (chainID, offset) pair.
ContainsPointQuery determines whether one or more shapes in a ShapeIndex contain a given Point.
ContainsVertexQuery is used to track the edges entering and leaving the given vertex of a Polygon in order to be able to determine if the point is contained by the Polygon.
ConvexHullQuery builds the convex hull of any collection of points, polylines, loops, and polygons.
CrossingEdgeQuery is used to find the Edge IDs of Shapes that are crossed by a given edge(s).
Edge represents a geodesic edge consisting of two vertices.
EdgeCrosser allows edges to be efficiently tested for intersection with a given fixed edge AB.
EdgeIterator is an iterator that advances through all edges in an ShapeIndex.
EdgeQuery is used to find the edge(s) between two geometries that match a given set of options.
EdgeQueryOptions holds the options for controlling how EdgeQuery operates.
EdgeQueryResult represents an edge that meets the target criteria for the query.
EdgeTessellator converts an edge in a given projection (e.g., Mercator) into a chain of spherical geodesic edges such that the maximum distance between the original edge and the geodesic edge chain is at most the requested tolerance.
FaceSegment represents an edge AB clipped to an S2 cube face.
IdentitySnapper is a Snapper that snaps every vertex to itself.
IntLatLngSnapper is a Snapper that snaps vertices to LatLngs in E5, E6, or E7 coordinates.
LatLng represents a point on the unit sphere as a pair of angles.
LaxLoop represents a closed loop of edges surrounding an interior region.
LaxPolygon represents a region defined by a collection of zero or more closed loops.
LaxPolyline represents a polyline.
Loop represents a simple spherical polygon.
MaxDistanceToCellTarget is used for computing the maximum distance to a Cell.
MaxDistanceToEdgeTarget is used for computing the maximum distance to an Edge.
MaxDistanceToPointTarget is used for computing the maximum distance to a Point.
MaxDistanceToShapeIndexTarget is used for computing the maximum distance to a ShapeIndex.
MercatorProjection defines the spherical Mercator projection.
A Metric is a measure for cells.
MinDistanceToCellTarget is a type for computing the minimum distance to a Cell.
MinDistanceToEdgeTarget is a type for computing the minimum distance to an Edge.
MinDistanceToPointTarget is a type for computing the minimum distance to a Point.
MinDistanceToShapeIndexTarget is a type for computing the minimum distance to a ShapeIndex.
PaddedCell represents a Cell whose (u,v)-range has been expanded on all sides by a given amount of "padding".
PlateCarreeProjection defines the "plate carree" (square plate) projection, which converts points on the sphere to (longitude, latitude) pairs.
Point represents a point on the unit sphere as a normalized 3D vector.
Polygon represents a sequence of zero or more loops; recall that the interior of a loop is defined to be its left-hand side (see Loop).
Rect represents a closed latitude-longitude rectangle.
RectBounder is used to compute a bounding rectangle that contains all edges defined by a vertex chain (v0, v1, v2, ...).
A ReferencePoint consists of a point and a boolean indicating whether the point is contained by a particular shape.
RegionCoverer allows arbitrary regions to be approximated as unions of cells (CellUnion).
ShapeEdge represents a ShapeEdgeID with the two endpoints of that Edge.
ShapeEdgeID is a unique identifier for an Edge within an ShapeIndex, consisting of a (shapeID, edgeID) pair.
ShapeIndex indexes a set of Shapes, where a Shape is some collection of edges that optionally defines an interior.
ShapeIndexCell stores the index contents for a particular CellID.
ShapeIndexIterator is an iterator that provides low-level access to the cells of the index.
ShapeIndexRegion wraps a ShapeIndex and implements the Region interface.

# Interfaces

Projection defines an interface for different ways of mapping between s2 and r2 Points.
A Region represents a two-dimensional region on the unit sphere.
Shape represents polygonal geometry in a flexible way.
A Snapper restricts the locations of the output vertices.

# Type aliases

CellID uniquely identifies a cell in the S2 cell decomposition.
CellRelation describes the possible relationships between a target cell and the cells of the ShapeIndex.
A CellUnion is a collection of CellIDs.
A Crossing indicates how edges cross.
CrossingType defines different ways of reporting edge intersections.
Direction is an indication of the ordering of a set of points.
EdgeMap stores a sorted set of edge ids for each shape.
PointVector is a Shape representing a set of Points.
Polyline represents a sequence of zero or more vertices connected by straight edges (geodesics).
A RegionUnion represents a union of possibly overlapping regions.
ShapeIndexIteratorPos defines the set of possible iterator starting positions.
VertexModel defines whether shapes are considered to contain their vertices.
WedgeRel enumerates the possible relation between two wedges A and B.