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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
//! OxiGDAL Algorithms - High-Performance Raster and Vector Operations
//!
//! This crate provides production-ready geospatial algorithms for raster and vector processing,
//! with a focus on performance, correctness, and Pure Rust implementation.
//!
//! # Features
//!
//! ## Resampling Algorithms
//!
//! - Nearest neighbor (fast, preserves exact values)
//! - Bilinear interpolation (smooth, good for continuous data)
//! - Bicubic interpolation (high quality, slower)
//! - Lanczos resampling (highest quality, expensive)
//!
//! ## Raster Operations
//!
//! - Raster calculator (map algebra with expression evaluation)
//! - Hillshade generation (3D terrain visualization)
//! - Slope and aspect calculation (terrain analysis)
//! - Reclassification (value mapping and binning)
//! - Zonal statistics (aggregate statistics by zones)
//!
//! ## Vector Operations
//!
//! ### Geometric Operations
//! - Buffer generation (fixed and variable distance, multiple cap/join styles)
//! - Intersection (geometric intersection with sweep line algorithm)
//! - Union (geometric union, cascaded union, convex hull)
//! - Difference (geometric difference, symmetric difference, clip to box)
//!
//! ### Simplification
//! - Douglas-Peucker simplification (perpendicular distance based)
//! - Visvalingam-Whyatt simplification (area based)
//! - Topology-preserving simplification
//!
//! ### Geometric Analysis
//! - Centroid calculation (geometric and area-weighted, all geometry types)
//! - Area calculation (planar and geodetic methods)
//! - Distance measurement (Euclidean, Haversine, Vincenty)
//!
//! ### Spatial Predicates
//! - Contains, Within (point-in-polygon tests)
//! - Intersects, Disjoint (intersection tests)
//! - Touches, Overlaps (boundary relationships)
//!
//! ### Validation
//! - Geometry validation (OGC Simple Features compliance)
//! - Self-intersection detection
//! - Duplicate vertex detection
//! - Ring orientation and closure checks
//!
//! ## SIMD Optimizations
//!
//! Many algorithms use SIMD instructions (when enabled) for maximum performance.
//! Enable the `simd` feature for best performance.
//!
//! # Examples
//!
//! ## Raster Resampling
//!
//! ```
//! use oxigdal_algorithms::resampling::{ResamplingMethod, Resampler};
//! use oxigdal_core::buffer::RasterBuffer;
//! use oxigdal_core::types::RasterDataType;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create source raster
//! let src = RasterBuffer::zeros(1000, 1000, RasterDataType::Float32);
//!
//! // Resample to half size using bilinear interpolation
//! let resampler = Resampler::new(ResamplingMethod::Bilinear);
//! let dst = resampler.resample(&src, 500, 500)?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Vector Operations
//!
//! ```
//! use oxigdal_algorithms::{
//! Coordinate, LineString, Point, Polygon,
//! buffer_point, BufferOptions,
//! area, area_polygon, AreaMethod,
//! centroid_polygon, simplify_linestring, SimplifyMethod,
//! validate_polygon,
//! };
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a point and buffer it
//! let point = Point::new(0.0, 0.0);
//! let options = BufferOptions::default();
//! let buffered = buffer_point(&point, 10.0, &options)?;
//!
//! // Calculate area of a polygon
//! let coords = vec![
//! Coordinate::new_2d(0.0, 0.0),
//! Coordinate::new_2d(10.0, 0.0),
//! Coordinate::new_2d(10.0, 10.0),
//! Coordinate::new_2d(0.0, 10.0),
//! Coordinate::new_2d(0.0, 0.0),
//! ];
//! let exterior = LineString::new(coords)?;
//! let polygon = Polygon::new(exterior, vec![])?;
//! let area_value = area_polygon(&polygon, AreaMethod::Planar)?;
//! # assert!((area_value - 100.0).abs() < 1e-10);
//!
//! // Simplify a linestring
//! let line_coords = vec![
//! Coordinate::new_2d(0.0, 0.0),
//! Coordinate::new_2d(1.0, 0.1),
//! Coordinate::new_2d(2.0, -0.05),
//! Coordinate::new_2d(3.0, 0.0),
//! ];
//! let linestring = LineString::new(line_coords)?;
//! let simplified = simplify_linestring(&linestring, 0.15, SimplifyMethod::DouglasPeucker)?;
//!
//! // Validate a polygon
//! let issues = validate_polygon(&polygon)?;
//! assert!(issues.is_empty()); // Valid square has no issues
//! # Ok(())
//! # }
//! ```
//!
//! # Performance
//!
//! All algorithms are designed for production use with:
//!
//! - Zero-copy operations where possible
//! - SIMD vectorization (x86_64 AVX2, ARM NEON)
//! - Cache-friendly memory access patterns
//! - Optional parallel processing via `rayon`
//!
//! # COOLJAPAN Policy Compliance
//!
//! - Pure Rust (no C/Fortran dependencies)
//! - No `unwrap()` or `expect()` in production code
//! - Comprehensive error handling
//! - no_std compatible core algorithms (with `alloc`)
// Pedantic disabled to reduce noise - default clippy::all is sufficient
// #![warn(clippy::pedantic)]
// Allow loop indexing patterns common in geospatial algorithms
// Allow expect() for internal invariants that shouldn't fail
// Allow more arguments for complex geospatial operations
// Allow manual implementations for clarity in algorithms
// Allow dead code for internal algorithm structures
// Allow partial documentation for complex algorithm modules
// Allow non-canonical partial_cmp for custom ordering
// Allow unused variables in algorithm code
// Allow collapsible match for algorithm clarity
// Allow manual_strip for path handling
// Allow should_implement_trait for builder patterns
// Allow method names that match trait names but with different signatures
// Allow iter_with_drain for performance patterns
// Allow map_values for explicit iteration
// Allow loop over option for clarity in algorithm code
// Allow first element access with get(0)
// Allow redundant closure for clarity
// Allow field assignment outside initializer
// Allow manual iterator find implementations
// Allow identical blocks in if statements for algorithm clarity
// Allow elided lifetime confusion
// Allow unused assignments for algorithm control flow
// Allow impls that can be derived (explicit implementations preferred)
// Allow explicit counter loop for clarity
// Allow clone where from_ref could be used
// Allow doc list item overindentation in complex formulas
// Allow useless vec for clarity in algorithm tests
// Allow slice from ref pattern for geometry operations
// Tutorial documentation
// Re-export commonly used items
pub use ;
pub use ;
// Re-export vector operations for convenience
pub use ;
/// Crate version
pub const VERSION: &str = env!;
/// Crate name
pub const NAME: &str = env!;