Skip to content

Commit 4008bc8

Browse files
committed
docs(sedona-gdal): tighten facade API comments
1 parent 167df0e commit 4008bc8

File tree

3 files changed

+28
-72
lines changed

3 files changed

+28
-72
lines changed

c/sedona-gdal/src/gdal.rs

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Gdal {
5151
}
5252

5353
impl Gdal {
54-
/// Create a new `Gdal` instance wrapping the given API reference.
54+
/// Create a `Gdal` wrapper for the given API reference.
5555
pub(crate) fn new(api: &'static GdalApi) -> Self {
5656
Self { api }
5757
}
@@ -63,26 +63,21 @@ impl Gdal {
6363
self.api.name()
6464
}
6565

66-
/// Query GDAL version information.
67-
///
68-
/// `request` is one of the standard `GDALVersionInfo` keys:
69-
/// - `"RELEASE_NAME"` — e.g. `"3.8.4"`
70-
/// - `"VERSION_NUM"` — e.g. `"3080400"`
71-
/// - `"BUILD_INFO"` — multi-line build details
66+
/// Fetch GDAL version information for a standard request key.
7267
pub fn version_info(&self, request: &str) -> String {
7368
self.api.version_info(request)
7469
}
7570

7671
// -- Config --------------------------------------------------------------
7772

78-
/// Set a GDAL library configuration option with **thread-local** scope.
73+
/// Set a thread-local GDAL configuration option.
7974
pub fn set_thread_local_config_option(&self, key: &str, value: &str) -> Result<()> {
8075
config::set_thread_local_config_option(self.api, key, value)
8176
}
8277

8378
// -- Driver --------------------------------------------------------------
8479

85-
/// Look up a GDAL driver by its short name (e.g. `"GTiff"`, `"MEM"`).
80+
/// Fetch a GDAL driver by its short name.
8681
pub fn get_driver_by_name(&self, name: &str) -> Result<Driver> {
8782
DriverManager::get_driver_by_name(self.api, name)
8883
}
@@ -108,21 +103,21 @@ impl Gdal {
108103
)
109104
}
110105

111-
/// Open a dataset using a [`DatasetOptions`] struct (georust-compatible convenience).
106+
/// Open a dataset using a [`DatasetOptions`] struct.
112107
pub fn open_ex_with_options(&self, path: &str, options: DatasetOptions<'_>) -> Result<Dataset> {
113108
Dataset::open_ex_with_options(self.api, path, options)
114109
}
115110

116111
// -- Spatial Reference ---------------------------------------------------
117112

118-
/// Create a new [`SpatialRef`] from a WKT string.
113+
/// Create a spatial reference from a WKT string.
119114
pub fn spatial_ref_from_wkt(&self, wkt: &str) -> Result<SpatialRef> {
120115
SpatialRef::from_wkt(self.api, wkt)
121116
}
122117

123118
// -- VRT -----------------------------------------------------------------
124119

125-
/// Create a new empty VRT dataset with the given dimensions.
120+
/// Create an empty VRT dataset with the given raster size.
126121
pub fn create_vrt(&self, x_size: usize, y_size: usize) -> Result<VrtDataset> {
127122
VrtDataset::create(self.api, x_size, y_size)
128123
}
@@ -141,40 +136,32 @@ impl Gdal {
141136

142137
// -- Vector --------------------------------------------------------------
143138

144-
/// Create a new OGR field definition.
139+
/// Create an OGR field definition.
145140
pub fn create_field_defn(&self, name: &str, field_type: OGRFieldType) -> Result<FieldDefn> {
146141
FieldDefn::new(self.api, name, field_type)
147142
}
148143

149144
// -- VSI (Virtual File System) -------------------------------------------
150145

151-
/// Create a new VSI in-memory file from a given buffer.
152-
pub fn create_mem_file(&self, file_name: &str, data: Vec<u8>) -> Result<()> {
146+
/// Create a VSI in-memory file from the given bytes.
147+
pub fn create_mem_file(&self, file_name: &str, data: &[u8]) -> Result<()> {
153148
vsi::create_mem_file(self.api, file_name, data)
154149
}
155150

156-
/// Unlink (delete) a VSI in-memory file.
151+
/// Delete a VSI in-memory file.
157152
pub fn unlink_mem_file(&self, file_name: &str) -> Result<()> {
158153
vsi::unlink_mem_file(self.api, file_name)
159154
}
160155

161-
/// Copy the bytes of a VSI in-memory file, taking ownership and freeing the
162-
/// GDAL memory.
156+
/// Copy the bytes of a VSI in-memory file, taking ownership of the GDAL buffer.
163157
pub fn get_vsi_mem_file_bytes_owned(&self, file_name: &str) -> Result<Vec<u8>> {
164158
vsi::get_vsi_mem_file_bytes_owned(self.api, file_name)
165159
}
166160

167161
// -- Raster operations ---------------------------------------------------
168162

169-
/// Create a bare in-memory (MEM) GDAL dataset via `MEMDataset::Create`.
170-
///
171-
/// This bypasses GDAL's open-dataset-list mutex for better concurrency.
172-
/// The returned dataset has `n_owned_bands` bands of type
173-
/// `owned_bands_data_type` whose pixel data is owned by GDAL.
174-
///
175-
/// For a higher-level builder that also attaches zero-copy external bands,
176-
/// geo-transforms, projections, and nodata values, see
177-
/// [`MemDatasetBuilder`].
163+
/// Create a bare in-memory MEM dataset with GDAL-owned bands.
164+
/// For a higher-level builder with external bands and metadata, use `MemDatasetBuilder`.
178165
pub fn create_mem_dataset(
179166
&self,
180167
width: usize,
@@ -191,8 +178,7 @@ impl Gdal {
191178
)
192179
}
193180

194-
/// Rasterize geometries with an affine transformer derived from the
195-
/// destination dataset.
181+
/// Rasterize geometries using the dataset geotransform as the transformer.
196182
pub fn rasterize_affine(
197183
&self,
198184
dataset: &Dataset,
@@ -211,7 +197,7 @@ impl Gdal {
211197
)
212198
}
213199

214-
/// Rasterize geometries onto a dataset.
200+
/// Rasterize geometries into the selected dataset bands.
215201
pub fn rasterize(
216202
&self,
217203
dataset: &Dataset,

c/sedona-gdal/src/global.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,8 @@ where
204204
Ok(func(api))
205205
}
206206

207-
/// Execute a closure with a high-level [`Gdal`] handle backed by the
208-
/// process-global [`GdalApi`].
209-
///
210-
/// This is the ergonomic entry-point for most GDAL operations. The global API
211-
/// is initialized lazily on the first call; subsequent calls reuse the same
212-
/// `&'static GdalApi` under the hood.
207+
/// Execute a closure with the process-global high-level [`Gdal`] handle.
208+
/// The global API is initialized lazily on first use and then reused.
213209
pub fn with_global_gdal<F, R>(func: F) -> Result<R, GdalInitLibraryError>
214210
where
215211
F: FnOnce(&Gdal) -> R,

c/sedona-gdal/src/mem.rs

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub struct MemDatasetBuilder {
9595
}
9696

9797
impl MemDatasetBuilder {
98-
/// Create a new builder for a MEM dataset with the given dimensions.
98+
/// Create a builder for a MEM dataset with the given dimensions.
9999
pub fn new(width: usize, height: usize) -> Self {
100100
Self {
101101
width,
@@ -108,7 +108,7 @@ impl MemDatasetBuilder {
108108
}
109109
}
110110

111-
/// Create a new builder for a MEM dataset with the given dimensions and number of owned bands.
111+
/// Create a builder for a MEM dataset with GDAL-owned bands.
112112
pub fn new_with_owned_bands(
113113
width: usize,
114114
height: usize,
@@ -126,13 +126,8 @@ impl MemDatasetBuilder {
126126
}
127127
}
128128

129-
/// Create a MEM dataset with owned bands.
130-
///
131-
/// This is a convenience shortcut equivalent to
132-
/// `MemDatasetBuilder::new_with_owned_bands(...).build(gdal)`.
133-
///
134-
/// Unlike [`build`](Self::build), this method is safe because datasets created
135-
/// with only owned bands do not reference any external memory.
129+
/// Create a MEM dataset with GDAL-owned bands.
130+
/// This is a safe shortcut for `new_with_owned_bands(...).build(gdal)`.
136131
pub fn create(
137132
gdal: &Gdal,
138133
width: usize,
@@ -149,8 +144,7 @@ impl MemDatasetBuilder {
149144
}
150145

151146
/// Add a zero-copy band from a raw data pointer.
152-
///
153-
/// Uses default pixel and line offsets (contiguous, row-major layout).
147+
/// Use default contiguous row-major pixel and line offsets.
154148
///
155149
/// # Safety
156150
///
@@ -163,15 +157,6 @@ impl MemDatasetBuilder {
163157

164158
/// Add a zero-copy band with custom offsets and optional nodata.
165159
///
166-
/// # Arguments
167-
/// * `data_type` - The GDAL data type of the band.
168-
/// * `data_ptr` - Pointer to the band pixel data.
169-
/// * `pixel_offset` - Byte offset between consecutive pixels. `None` defaults to
170-
/// the byte size of `data_type`.
171-
/// * `line_offset` - Byte offset between consecutive lines. `None` defaults to
172-
/// `pixel_offset * width`.
173-
/// * `nodata` - Optional nodata value for the band.
174-
///
175160
/// # Safety
176161
///
177162
/// The caller must ensure `data_ptr` points to a valid buffer of sufficient size
@@ -195,24 +180,19 @@ impl MemDatasetBuilder {
195180
self
196181
}
197182

198-
/// Set the geo-transform for the dataset.
199-
///
200-
/// The array is `[origin_x, pixel_width, rotation_x, origin_y, rotation_y, pixel_height]`.
183+
/// Set the dataset geotransform coefficients.
201184
pub fn geo_transform(mut self, gt: [f64; 6]) -> Self {
202185
self.geo_transform = Some(gt);
203186
self
204187
}
205188

206-
/// Set the projection (CRS) for the dataset as a WKT or PROJ string.
189+
/// Set the dataset projection definition string.
207190
pub fn projection(mut self, wkt: impl Into<String>) -> Self {
208191
self.projection = Some(wkt.into());
209192
self
210193
}
211194

212-
/// Build the GDAL MEM dataset.
213-
///
214-
/// Creates an empty MEM dataset using [`create_mem_dataset`], then attaches
215-
/// bands, sets the geo-transform, projection, and per-band nodata values.
195+
/// Build the MEM dataset and attach the configured bands and metadata.
216196
///
217197
/// # Safety
218198
///
@@ -263,14 +243,8 @@ impl MemDatasetBuilder {
263243
}
264244
}
265245

266-
/// Create a bare in-memory (MEM) GDAL dataset via `MEMDataset::Create`.
267-
///
268-
/// This bypasses GDAL's open-dataset-list mutex for better concurrency.
269-
/// The returned dataset has `n_owned_bands` bands of type
270-
/// `owned_bands_data_type` whose pixel data is owned by GDAL.
271-
///
272-
/// For a higher-level builder that also attaches zero-copy external bands,
273-
/// geo-transforms, projections, and nodata values, see [`MemDatasetBuilder`].
246+
/// Create a bare in-memory MEM dataset with GDAL-owned bands.
247+
/// For a higher-level builder with external bands and metadata, use `MemDatasetBuilder`.
274248
pub(crate) fn create_mem_dataset(
275249
api: &'static GdalApi,
276250
width: usize,

0 commit comments

Comments
 (0)