1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2026 Torgeir Børresen <tb@starkad.no>
// Part of a Rust port of Google's S2 Geometry library — a derivative work of the
// upstream Apache-2.0 implementations (Copyright Google Inc.):
// - C++: google/s2geometry
// - Go: golang/geo
// - Java: google/s2-geometry-library-java
// See LICENSE.
//! Spherical geometry on the unit sphere (S²).
//!
//! This is the main module of the library. It provides types and algorithms
//! for representing, indexing, and manipulating geometry on the surface of a
//! unit sphere. All edges are geodesics (great-circle arcs), so operations
//! work uniformly across the entire sphere with no singularities at the poles
//! or discontinuities at the antimeridian.
//!
//! # Geometry types
//!
//! The core geometry types are re-exported at the top of this module:
//!
//! | Type | Description |
//! |------|-------------|
//! | [`Point`] | A point on the unit sphere (unit-length 3D vector). |
//! | [`LatLng`] | A point expressed as a latitude-longitude pair. |
//! | [`CellId`] | A 64-bit identifier for a cell in the S2 hierarchy. |
//! | [`Cell`] | A concrete cell with precomputed vertices and bounds. |
//! | [`CellUnion`] | A sorted, normalized collection of `CellId`s approximating a region. |
//! | [`Cap`] | A spherical cap (disc-shaped region defined by center and radius). |
//! | [`Rect`] | A closed latitude-longitude rectangle. |
//! | [`Loop`] | A simple spherical polygon (single closed boundary). |
//! | [`Polygon`] | A multi-loop polygon, possibly with holes. |
//! | [`Region`] | A trait for any region that supports bounding and containment tests. |
//!
//! Additional geometry types include [`polyline::Polyline`] (open paths),
//! [`lax_polygon::LaxPolygon`] and [`lax_polyline::LaxPolyline`] (relaxed
//! validity), and [`edge_vector_shape::EdgeVectorShape`] (arbitrary edge
//! collections).
//!
//! # The S2 cell hierarchy
//!
//! The sphere is decomposed into a hierarchy of cells by projecting the six
//! faces of a cube onto the sphere. Each face is recursively subdivided into
//! four children, producing 31 levels of cells (level 0 = face cells, level
//! 30 = leaf cells roughly 1 cm across on Earth). Cells at each level tile the
//! sphere without gaps or overlaps.
//!
//! Cell identifiers ([`CellId`]) are 64-bit integers that encode both the face
//! and the position along a space-filling Hilbert curve. Cells that are close
//! in `CellId` order are also spatially close, which makes range scans over
//! sorted cell IDs efficient for spatial queries. The [`coords`] module
//! documents the coordinate systems used internally: `(face, i, j)`,
//! `(face, s, t)`, `(face, u, v)`, and `(x, y, z)`.
//!
//! # The Shape interface and `ShapeIndex`
//!
//! All geometry can be viewed through the [`shape::Shape`] trait, which
//! presents geometry as a collection of edges optionally defining an interior.
//! A [`shape_index::ShapeIndex`] indexes one or more shapes for fast spatial
//! lookups — given a point or region, it can quickly determine which shapes
//! contain it or are nearby.
//!
//! # Spatial queries
//!
//! - [`closest_edge_query`] — find the nearest edges or test distance
//! thresholds between geometries.
//! - [`contains_point_query`] — determine which shapes contain a given point,
//! with configurable boundary semantics (open, semi-open, closed).
//! - [`crossing_edge_query`] — find edges in an index that cross a given edge.
//! - [`convex_hull_query`] — compute the spherical convex hull.
//! - [`hausdorff_distance_query`] — compute the Hausdorff distance between
//! edge chains.
//!
//! # Constructive operations
//!
//! - [`boolean_operation`] — compute union, intersection, difference, or
//! symmetric difference of regions.
//! - [`winding_operation`] — N-way boolean operations using winding numbers.
//! - [`buffer_operation`] — expand or contract geometry by a fixed radius.
//! - [`builder`] — assemble edges into valid geometry with vertex snapping and
//! topological repair.
//!
//! # Covering and indexing
//!
//! - [`region_coverer`] — approximate any [`Region`] as a [`CellUnion`] for
//! use in spatial database indexes.
//! - [`region_term_indexer`] — generate index/query terms for point or region
//! containment queries in inverted indexes.
/// Find closest cells in a `CellIndex` to a given target.
/// Find closest points in an `S2PointIndex` to a given target.
/// Shared supertrait for all distance query targets.
/// An index of points on the sphere for nearest-neighbor queries.
/// Tracks and limits memory usage of S2 operations.
/// Spatial index for S2 points with associated data.
pub use Cap;
pub use ;
pub use ;
pub use CellUnion;
pub use ;
pub use LatLng;
pub use ;
pub use Polygon;
pub use ;
pub use Region;
pub use Loop;