S2Index
S2 is a geographical indexing system where all geographical data is represented on a sphere (similar to a globe). In the S2 library points are represented as the S2 Index - a specific number which encodes internally a point on the surface of a unit sphere, unlike traditional (latitude, longitude) pairs. To get the S2 point index for a given point specified in the format (latitude, longitude) use the geoToS2 function. Also, you can use the s2ToGeo function for getting geographical coordinates corresponding to the specified S2 point index.geoToS2
Returns S2 point index corresponding to the provided coordinates(longitude, latitude).
Syntax
- S2 point index. UInt64.
Query
Response
s2ToGeo
Returns geo coordinates(longitude, latitude) corresponding to the provided S2 point index.
Syntax
s2indexβ S2 Index. UInt64.
Query
Response
s2GetNeighbors
Returns S2 neighbor indexes corresponding to the provided S2. Each cell in the S2 system is a quadrilateral bounded by four geodesics. So, each cell has 4 neighbors. Syntaxs2indexβ S2 Index. UInt64.
- An array consisting of 4 neighbor indexes:
array[s2index1, s2index3, s2index2, s2index4]. Array(UInt64).
Query
Response
s2CellsIntersect
Determines if the two provided S2 cells intersect or not. SyntaxsiIndex1,s2index2β S2 Index. UInt64.
Query
Response
s2CapContains
Determines if a cap contains a S2 point. A cap represents a part of the sphere that has been cut off by a plane. It is defined by a point on a sphere and a radius in degrees. Syntaxcenterβ S2 point index corresponding to the cap. UInt64.degreesβ Radius of the cap in degrees. Float64.pointβ S2 point index. UInt64.
1β If the cap contains the S2 point index. UInt8.0β If the cap doesnβt contain the S2 point index. UInt8.
Query
Response
s2CapUnion
Determines the smallest cap that contains the given two input caps. A cap represents a portion of the sphere that has been cut off by a plane. It is defined by a point on a sphere and a radius in degrees. Syntaxcenter1,center2β S2 point indexes corresponding to the two input caps. UInt64.radius1,radius2β Radius of the two input caps in degrees. Float64.
centerβ S2 point index corresponding the center of the smallest cap containing the two input caps. UInt64.radiusβ Radius of the smallest cap containing the two input caps. Float64.
Query
Response
s2RectAdd
Increases the size of the bounding rectangle to include the given S2 point. In the S2 system, a rectangle is represented by a type of S2Region called aS2LatLngRect that represents a rectangle in latitude-longitude space.
Syntax
s2PointLowβ Low S2 point index corresponding to the rectangle. UInt64.s2PointHighβ High S2 point index corresponding to the rectangle. UInt64.s2Pointβ Target S2 point index that the bound rectangle should be grown to include. UInt64.
s2PointLowβ Low S2 cell id corresponding to the grown rectangle. UInt64.s2PointHighβ Height S2 cell id corresponding to the grown rectangle. UInt64.
Query
Response
s2RectContains
Determines if a given rectangle contains a S2 point. In the S2 system, a rectangle is represented by a type of S2Region called aS2LatLngRect that represents a rectangle in latitude-longitude space.
Syntax
s2PointLowβ Low S2 point index corresponding to the rectangle. UInt64.s2PointHighβ High S2 point index corresponding to the rectangle. UInt64.s2Pointβ Target S2 point index. UInt64.
1β If the rectangle contains the given S2 point.0β If the rectangle doesnβt contain the given S2 point.
Query
Response
s2RectUnion
Returns the smallest rectangle containing the union of this rectangle and the given rectangle. In the S2 system, a rectangle is represented by a type of S2Region called aS2LatLngRect that represents a rectangle in latitude-longitude space.
Syntax
s2Rect1PointLow,s2Rect1PointHiβ Low and High S2 point indexes corresponding to the first rectangle. UInt64.s2Rect2PointLow,s2Rect2PointHiβ Low and High S2 point indexes corresponding to the second rectangle. UInt64.
s2UnionRect2PointLowβ Low S2 cell id corresponding to the union rectangle. UInt64.s2UnionRect2PointHiβ High S2 cell id corresponding to the union rectangle. UInt64.
Query
Response
s2RectIntersection
Returns the smallest rectangle containing the intersection of this rectangle and the given rectangle. In the S2 system, a rectangle is represented by a type of S2Region called aS2LatLngRect that represents a rectangle in latitude-longitude space.
Syntax
s2Rect1PointLow,s2Rect1PointHiβ Low and High S2 point indexes corresponding to the first rectangle. UInt64.s2Rect2PointLow,s2Rect2PointHiβ Low and High S2 point indexes corresponding to the second rectangle. UInt64.
s2UnionRect2PointLowβ Low S2 cell id corresponding to the rectangle containing the intersection of the given rectangles. UInt64.s2UnionRect2PointHiβ High S2 cell id corresponding to the rectangle containing the intersection of the given rectangles. UInt64.
Query
Response