• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geo-engine / geoengine / 7006568925

27 Nov 2023 02:07PM UTC coverage: 89.651% (+0.2%) from 89.498%
7006568925

push

github

web-flow
Merge pull request #888 from geo-engine/raster_stacks

raster stacking

4032 of 4274 new or added lines in 107 files covered. (94.34%)

12 existing lines in 8 files now uncovered.

113020 of 126066 relevant lines covered (89.65%)

59901.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.52
/operators/src/processing/reprojection.rs
1
use std::marker::PhantomData;
2

3
use super::map_query::MapQueryProcessor;
4
use crate::{
5
    adapters::{
6
        fold_by_coordinate_lookup_future, FillerTileCacheExpirationStrategy, RasterSubQueryAdapter,
7
        SparseTilesFillAdapter, TileReprojectionSubQuery,
8
    },
9
    engine::{
10
        CanonicOperatorName, ExecutionContext, InitializedRasterOperator, InitializedSources,
11
        InitializedVectorOperator, Operator, OperatorName, QueryContext, QueryProcessor,
12
        RasterOperator, RasterQueryProcessor, RasterResultDescriptor, SingleRasterOrVectorSource,
13
        TypedRasterQueryProcessor, TypedVectorQueryProcessor, VectorOperator, VectorQueryProcessor,
14
        VectorResultDescriptor, WorkflowOperatorPath,
15
    },
16
    error::{self, Error},
17
    util::Result,
18
};
19
use async_trait::async_trait;
20
use futures::stream::BoxStream;
21
use futures::{stream, StreamExt};
22
use geoengine_datatypes::{
23
    collections::FeatureCollection,
24
    operations::reproject::{
25
        reproject_and_unify_bbox, reproject_query, suggest_pixel_size_from_diag_cross_projected,
26
        CoordinateProjection, CoordinateProjector, Reproject, ReprojectClipped,
27
    },
28
    primitives::{
29
        BandSelection, BoundingBox2D, ColumnSelection, Geometry, RasterQueryRectangle,
30
        SpatialPartition2D, SpatialPartitioned, SpatialResolution, VectorQueryRectangle,
31
    },
32
    raster::{Pixel, RasterTile2D, TilingSpecification},
33
    spatial_reference::SpatialReference,
34
    util::arrow::ArrowTyped,
35
};
36
use serde::{Deserialize, Serialize};
37
use snafu::ensure;
38

39
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
13✔
40
#[serde(rename_all = "camelCase")]
41
pub struct ReprojectionParams {
42
    pub target_spatial_reference: SpatialReference,
43
}
44

45
#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
×
46
pub struct ReprojectionBounds {
47
    valid_in_bounds: SpatialPartition2D,
48
    valid_out_bounds: SpatialPartition2D,
49
}
50

51
pub type Reprojection = Operator<ReprojectionParams, SingleRasterOrVectorSource>;
52

53
impl Reprojection {}
54

55
impl OperatorName for Reprojection {
56
    const TYPE_NAME: &'static str = "Reprojection";
57
}
58

59
pub struct InitializedVectorReprojection {
60
    name: CanonicOperatorName,
61
    result_descriptor: VectorResultDescriptor,
62
    source: Box<dyn InitializedVectorOperator>,
63
    source_srs: SpatialReference,
64
    target_srs: SpatialReference,
65
}
66

67
pub struct InitializedRasterReprojection {
68
    name: CanonicOperatorName,
69
    result_descriptor: RasterResultDescriptor,
70
    source: Box<dyn InitializedRasterOperator>,
71
    state: Option<ReprojectionBounds>,
72
    source_srs: SpatialReference,
73
    target_srs: SpatialReference,
74
    tiling_spec: TilingSpecification,
75
}
76

77
impl InitializedVectorReprojection {
78
    /// Create a new `InitializedVectorReprojection` instance.
79
    /// The `source` must have the same `SpatialReference` as `source_srs`.
80
    ///
81
    /// # Errors
82
    /// This function errors if the `source`'s `SpatialReference` is `None`.
83
    /// This function errors if the source's bounding box cannot be reprojected to the target's `SpatialReference`.
84
    pub fn try_new_with_input(
6✔
85
        name: CanonicOperatorName,
6✔
86
        params: ReprojectionParams,
6✔
87
        source_vector_operator: Box<dyn InitializedVectorOperator>,
6✔
88
    ) -> Result<Self> {
6✔
89
        let in_desc: VectorResultDescriptor = source_vector_operator.result_descriptor().clone();
6✔
90

91
        let in_srs = Into::<Option<SpatialReference>>::into(in_desc.spatial_reference)
6✔
92
            .ok_or(Error::AllSourcesMustHaveSameSpatialReference)?;
6✔
93

94
        let bbox = if let Some(bbox) = in_desc.bbox {
6✔
95
            let projector =
×
96
                CoordinateProjector::from_known_srs(in_srs, params.target_spatial_reference)?;
×
97

98
            bbox.reproject_clipped(&projector)? // TODO: if this is none then we could skip the whole reprojection similar to raster?
×
99
        } else {
100
            None
6✔
101
        };
102

103
        let out_desc = VectorResultDescriptor {
6✔
104
            spatial_reference: params.target_spatial_reference.into(),
6✔
105
            data_type: in_desc.data_type,
6✔
106
            columns: in_desc.columns.clone(),
6✔
107
            time: in_desc.time,
6✔
108
            bbox,
6✔
109
        };
6✔
110

6✔
111
        Ok(InitializedVectorReprojection {
6✔
112
            name,
6✔
113
            result_descriptor: out_desc,
6✔
114
            source: source_vector_operator,
6✔
115
            source_srs: in_srs,
6✔
116
            target_srs: params.target_spatial_reference,
6✔
117
        })
6✔
118
    }
6✔
119
}
120

121
impl InitializedRasterReprojection {
122
    pub fn try_new_with_input(
6✔
123
        name: CanonicOperatorName,
6✔
124
        params: ReprojectionParams,
6✔
125
        source_raster_operator: Box<dyn InitializedRasterOperator>,
6✔
126
        tiling_spec: TilingSpecification,
6✔
127
    ) -> Result<Self> {
6✔
128
        let in_desc: RasterResultDescriptor = source_raster_operator.result_descriptor().clone();
6✔
129

130
        let in_srs = Into::<Option<SpatialReference>>::into(in_desc.spatial_reference)
6✔
131
            .ok_or(Error::AllSourcesMustHaveSameSpatialReference)?;
6✔
132

133
        // calculate the intersection of input and output srs in both coordinate systems
134
        let (in_bounds, out_bounds, out_res) = Self::derive_raster_in_bounds_out_bounds_out_res(
6✔
135
            in_srs,
6✔
136
            params.target_spatial_reference,
6✔
137
            in_desc.resolution,
6✔
138
            in_desc.bbox,
6✔
139
        )?;
6✔
140

141
        let result_descriptor = RasterResultDescriptor {
4✔
142
            spatial_reference: params.target_spatial_reference.into(),
4✔
143
            data_type: in_desc.data_type,
4✔
144
            time: in_desc.time,
4✔
145
            bbox: out_bounds,
4✔
146
            resolution: out_res,
4✔
147
            bands: in_desc.bands.clone(),
4✔
148
        };
4✔
149

150
        let state = match (in_bounds, out_bounds) {
4✔
151
            (Some(in_bounds), Some(out_bounds)) => Some(ReprojectionBounds {
4✔
152
                valid_in_bounds: in_bounds,
4✔
153
                valid_out_bounds: out_bounds,
4✔
154
            }),
4✔
155
            _ => None,
×
156
        };
157

158
        Ok(InitializedRasterReprojection {
4✔
159
            name,
4✔
160
            result_descriptor,
4✔
161
            source: source_raster_operator,
4✔
162
            state,
4✔
163
            source_srs: in_srs,
4✔
164
            target_srs: params.target_spatial_reference,
4✔
165
            tiling_spec,
4✔
166
        })
4✔
167
    }
6✔
168

169
    fn derive_raster_in_bounds_out_bounds_out_res(
7✔
170
        source_srs: SpatialReference,
7✔
171
        target_srs: SpatialReference,
7✔
172
        source_spatial_resolution: Option<SpatialResolution>,
7✔
173
        source_bbox: Option<SpatialPartition2D>,
7✔
174
    ) -> Result<(
7✔
175
        Option<SpatialPartition2D>,
7✔
176
        Option<SpatialPartition2D>,
7✔
177
        Option<SpatialResolution>,
7✔
178
    )> {
7✔
179
        let (in_bbox, out_bbox) = if let Some(bbox) = source_bbox {
7✔
180
            reproject_and_unify_bbox(bbox, source_srs, target_srs)?
4✔
181
        } else {
182
            // use the parts of the area of use that are valid in both spatial references
183
            let valid_bounds_in = source_srs.area_of_use_intersection(&target_srs)?;
3✔
184
            let valid_bounds_out = target_srs.area_of_use_intersection(&source_srs)?;
3✔
185

186
            (valid_bounds_in, valid_bounds_out)
3✔
187
        };
188

189
        let out_res = match (source_spatial_resolution, in_bbox, out_bbox) {
5✔
190
            (Some(in_res), Some(in_bbox), Some(out_bbox)) => {
3✔
191
                suggest_pixel_size_from_diag_cross_projected(in_bbox, out_bbox, in_res).ok()
3✔
192
            }
193
            _ => None,
2✔
194
        };
195

196
        Ok((in_bbox, out_bbox, out_res))
5✔
197
    }
7✔
198
}
199

200
#[typetag::serde]
1✔
201
#[async_trait]
202
impl VectorOperator for Reprojection {
203
    async fn _initialize(
7✔
204
        self: Box<Self>,
7✔
205
        path: WorkflowOperatorPath,
7✔
206
        context: &dyn ExecutionContext,
7✔
207
    ) -> Result<Box<dyn InitializedVectorOperator>> {
7✔
208
        let name = CanonicOperatorName::from(&self);
7✔
209

210
        let vector_source =
6✔
211
            self.sources
7✔
212
                .vector()
7✔
213
                .ok_or_else(|| error::Error::InvalidOperatorType {
7✔
214
                    expected: "Vector".to_owned(),
1✔
215
                    found: "Raster".to_owned(),
1✔
216
                })?;
7✔
217

218
        let initialized_source = vector_source.initialize_sources(path, context).await?;
6✔
219

220
        let initialized_operator = InitializedVectorReprojection::try_new_with_input(
6✔
221
            name,
6✔
222
            self.params,
6✔
223
            initialized_source.vector,
6✔
224
        )?;
6✔
225

226
        Ok(initialized_operator.boxed())
6✔
227
    }
14✔
228

229
    span_fn!(Reprojection);
×
230
}
231

232
impl InitializedVectorOperator for InitializedVectorReprojection {
233
    fn result_descriptor(&self) -> &VectorResultDescriptor {
×
234
        &self.result_descriptor
×
235
    }
×
236

237
    fn query_processor(&self) -> Result<TypedVectorQueryProcessor> {
6✔
238
        let source_srs = self.source_srs;
6✔
239
        let target_srs = self.target_srs;
6✔
240
        match self.source.query_processor()? {
6✔
241
            TypedVectorQueryProcessor::Data(source) => Ok(TypedVectorQueryProcessor::Data(
×
242
                MapQueryProcessor::new(
×
243
                    source,
×
244
                    move |query| reproject_query(query, source_srs, target_srs).map_err(From::from),
×
245
                    (),
×
246
                )
×
247
                .boxed(),
×
248
            )),
×
249
            TypedVectorQueryProcessor::MultiPoint(source) => {
4✔
250
                Ok(TypedVectorQueryProcessor::MultiPoint(
4✔
251
                    VectorReprojectionProcessor::new(source, source_srs, target_srs).boxed(),
4✔
252
                ))
4✔
253
            }
254
            TypedVectorQueryProcessor::MultiLineString(source) => {
1✔
255
                Ok(TypedVectorQueryProcessor::MultiLineString(
1✔
256
                    VectorReprojectionProcessor::new(source, source_srs, target_srs).boxed(),
1✔
257
                ))
1✔
258
            }
259
            TypedVectorQueryProcessor::MultiPolygon(source) => {
1✔
260
                Ok(TypedVectorQueryProcessor::MultiPolygon(
1✔
261
                    VectorReprojectionProcessor::new(source, source_srs, target_srs).boxed(),
1✔
262
                ))
1✔
263
            }
264
        }
265
    }
6✔
266

267
    fn canonic_name(&self) -> CanonicOperatorName {
×
268
        self.name.clone()
×
269
    }
×
270
}
271

272
struct VectorReprojectionProcessor<Q, G>
273
where
274
    Q: VectorQueryProcessor<VectorType = FeatureCollection<G>>,
275
{
276
    source: Q,
277
    from: SpatialReference,
278
    to: SpatialReference,
279
}
280

281
impl<Q, G> VectorReprojectionProcessor<Q, G>
282
where
283
    Q: VectorQueryProcessor<VectorType = FeatureCollection<G>>,
284
{
285
    pub fn new(source: Q, from: SpatialReference, to: SpatialReference) -> Self {
6✔
286
        Self { source, from, to }
6✔
287
    }
6✔
288
}
289

290
#[async_trait]
291
impl<Q, G> QueryProcessor for VectorReprojectionProcessor<Q, G>
292
where
293
    Q: QueryProcessor<
294
        Output = FeatureCollection<G>,
295
        SpatialBounds = BoundingBox2D,
296
        Selection = ColumnSelection,
297
    >,
298
    FeatureCollection<G>: Reproject<CoordinateProjector, Out = FeatureCollection<G>>,
299
    G: Geometry + ArrowTyped,
300
{
301
    type Output = FeatureCollection<G>;
302
    type SpatialBounds = BoundingBox2D;
303
    type Selection = ColumnSelection;
304

305
    async fn _query<'a>(
6✔
306
        &'a self,
6✔
307
        query: VectorQueryRectangle,
6✔
308
        ctx: &'a dyn QueryContext,
6✔
309
    ) -> Result<BoxStream<'a, Result<Self::Output>>> {
6✔
310
        let rewritten_query = reproject_query(query, self.from, self.to)?;
6✔
311

312
        if let Some(rewritten_query) = rewritten_query {
6✔
313
            Ok(self
5✔
314
                .source
5✔
315
                .query(rewritten_query, ctx)
5✔
316
                .await?
×
317
                .map(move |collection_result| {
5✔
318
                    collection_result.and_then(|collection| {
5✔
319
                        CoordinateProjector::from_known_srs(self.from, self.to)
5✔
320
                            .and_then(|projector| collection.reproject(projector.as_ref()))
5✔
321
                            .map_err(Into::into)
5✔
322
                    })
5✔
323
                })
5✔
324
                .boxed())
5✔
325
        } else {
326
            let res = Ok(FeatureCollection::empty());
1✔
327
            Ok(Box::pin(stream::once(async { res })))
1✔
328
        }
329
    }
12✔
330
}
331

332
#[typetag::serde]
×
333
#[async_trait]
334
impl RasterOperator for Reprojection {
335
    async fn _initialize(
4✔
336
        self: Box<Self>,
4✔
337
        path: WorkflowOperatorPath,
4✔
338
        context: &dyn ExecutionContext,
4✔
339
    ) -> Result<Box<dyn InitializedRasterOperator>> {
4✔
340
        let name = CanonicOperatorName::from(&self);
4✔
341

342
        let raster_source =
4✔
343
            self.sources
4✔
344
                .raster()
4✔
345
                .ok_or_else(|| error::Error::InvalidOperatorType {
4✔
346
                    expected: "Raster".to_owned(),
×
347
                    found: "Vector".to_owned(),
×
348
                })?;
4✔
349

350
        let initialized_source = raster_source.initialize_sources(path, context).await?;
4✔
351

352
        // TODO: implement multi-band functionality and remove this check
353
        ensure!(
4✔
354
            initialized_source.raster.result_descriptor().bands.len() == 1,
4✔
NEW
355
            crate::error::OperatorDoesNotSupportMultiBandsSourcesYet {
×
NEW
356
                operator: Reprojection::TYPE_NAME
×
NEW
357
            }
×
358
        );
359

360
        let initialized_operator = InitializedRasterReprojection::try_new_with_input(
4✔
361
            name,
4✔
362
            self.params,
4✔
363
            initialized_source.raster,
4✔
364
            context.tiling_specification(),
4✔
365
        )?;
4✔
366

367
        Ok(initialized_operator.boxed())
4✔
368
    }
8✔
369

370
    span_fn!(Reprojection);
×
371
}
372

373
impl InitializedRasterOperator for InitializedRasterReprojection {
374
    fn result_descriptor(&self) -> &RasterResultDescriptor {
×
375
        &self.result_descriptor
×
376
    }
×
377

378
    // i know there is a macro somewhere. we need to re-work this when we have the no-data value anyway.
379
    #[allow(clippy::too_many_lines)]
380
    fn query_processor(&self) -> Result<TypedRasterQueryProcessor> {
4✔
381
        let q = self.source.query_processor()?;
4✔
382

383
        Ok(match self.result_descriptor.data_type {
4✔
384
            geoengine_datatypes::raster::RasterDataType::U8 => {
385
                let qt = q.get_u8().unwrap();
4✔
386
                TypedRasterQueryProcessor::U8(Box::new(RasterReprojectionProcessor::new(
4✔
387
                    qt,
4✔
388
                    self.source_srs,
4✔
389
                    self.target_srs,
4✔
390
                    self.tiling_spec,
4✔
391
                    self.state,
4✔
392
                )))
4✔
393
            }
394
            geoengine_datatypes::raster::RasterDataType::U16 => {
395
                let qt = q.get_u16().unwrap();
×
396
                TypedRasterQueryProcessor::U16(Box::new(RasterReprojectionProcessor::new(
×
397
                    qt,
×
398
                    self.source_srs,
×
399
                    self.target_srs,
×
400
                    self.tiling_spec,
×
401
                    self.state,
×
402
                )))
×
403
            }
404

405
            geoengine_datatypes::raster::RasterDataType::U32 => {
406
                let qt = q.get_u32().unwrap();
×
407
                TypedRasterQueryProcessor::U32(Box::new(RasterReprojectionProcessor::new(
×
408
                    qt,
×
409
                    self.source_srs,
×
410
                    self.target_srs,
×
411
                    self.tiling_spec,
×
412
                    self.state,
×
413
                )))
×
414
            }
415
            geoengine_datatypes::raster::RasterDataType::U64 => {
416
                let qt = q.get_u64().unwrap();
×
417
                TypedRasterQueryProcessor::U64(Box::new(RasterReprojectionProcessor::new(
×
418
                    qt,
×
419
                    self.source_srs,
×
420
                    self.target_srs,
×
421
                    self.tiling_spec,
×
422
                    self.state,
×
423
                )))
×
424
            }
425
            geoengine_datatypes::raster::RasterDataType::I8 => {
426
                let qt = q.get_i8().unwrap();
×
427
                TypedRasterQueryProcessor::I8(Box::new(RasterReprojectionProcessor::new(
×
428
                    qt,
×
429
                    self.source_srs,
×
430
                    self.target_srs,
×
431
                    self.tiling_spec,
×
432
                    self.state,
×
433
                )))
×
434
            }
435
            geoengine_datatypes::raster::RasterDataType::I16 => {
436
                let qt = q.get_i16().unwrap();
×
437
                TypedRasterQueryProcessor::I16(Box::new(RasterReprojectionProcessor::new(
×
438
                    qt,
×
439
                    self.source_srs,
×
440
                    self.target_srs,
×
441
                    self.tiling_spec,
×
442
                    self.state,
×
443
                )))
×
444
            }
445
            geoengine_datatypes::raster::RasterDataType::I32 => {
446
                let qt = q.get_i32().unwrap();
×
447
                TypedRasterQueryProcessor::I32(Box::new(RasterReprojectionProcessor::new(
×
448
                    qt,
×
449
                    self.source_srs,
×
450
                    self.target_srs,
×
451
                    self.tiling_spec,
×
452
                    self.state,
×
453
                )))
×
454
            }
455
            geoengine_datatypes::raster::RasterDataType::I64 => {
456
                let qt = q.get_i64().unwrap();
×
457
                TypedRasterQueryProcessor::I64(Box::new(RasterReprojectionProcessor::new(
×
458
                    qt,
×
459
                    self.source_srs,
×
460
                    self.target_srs,
×
461
                    self.tiling_spec,
×
462
                    self.state,
×
463
                )))
×
464
            }
465
            geoengine_datatypes::raster::RasterDataType::F32 => {
466
                let qt = q.get_f32().unwrap();
×
467
                TypedRasterQueryProcessor::F32(Box::new(RasterReprojectionProcessor::new(
×
468
                    qt,
×
469
                    self.source_srs,
×
470
                    self.target_srs,
×
471
                    self.tiling_spec,
×
472
                    self.state,
×
473
                )))
×
474
            }
475
            geoengine_datatypes::raster::RasterDataType::F64 => {
476
                let qt = q.get_f64().unwrap();
×
477
                TypedRasterQueryProcessor::F64(Box::new(RasterReprojectionProcessor::new(
×
478
                    qt,
×
479
                    self.source_srs,
×
480
                    self.target_srs,
×
481
                    self.tiling_spec,
×
482
                    self.state,
×
483
                )))
×
484
            }
485
        })
486
    }
4✔
487

488
    fn canonic_name(&self) -> CanonicOperatorName {
×
489
        self.name.clone()
×
490
    }
×
491
}
492

493
pub struct RasterReprojectionProcessor<Q, P>
494
where
495
    Q: RasterQueryProcessor<RasterType = P>,
496
{
497
    source: Q,
498
    from: SpatialReference,
499
    to: SpatialReference,
500
    tiling_spec: TilingSpecification,
501
    state: Option<ReprojectionBounds>,
502
    _phantom_data: PhantomData<P>,
503
}
504

505
impl<Q, P> RasterReprojectionProcessor<Q, P>
506
where
507
    Q: RasterQueryProcessor<RasterType = P>,
508
    P: Pixel,
509
{
510
    pub fn new(
4✔
511
        source: Q,
4✔
512
        from: SpatialReference,
4✔
513
        to: SpatialReference,
4✔
514
        tiling_spec: TilingSpecification,
4✔
515
        state: Option<ReprojectionBounds>,
4✔
516
    ) -> Self {
4✔
517
        Self {
4✔
518
            source,
4✔
519
            from,
4✔
520
            to,
4✔
521
            tiling_spec,
4✔
522
            state,
4✔
523
            _phantom_data: PhantomData,
4✔
524
        }
4✔
525
    }
4✔
526
}
527

528
#[async_trait]
529
impl<Q, P> QueryProcessor for RasterReprojectionProcessor<Q, P>
530
where
531
    Q: QueryProcessor<
532
        Output = RasterTile2D<P>,
533
        SpatialBounds = SpatialPartition2D,
534
        Selection = BandSelection,
535
    >,
536
    P: Pixel,
537
{
538
    type Output = RasterTile2D<P>;
539
    type SpatialBounds = SpatialPartition2D;
540
    type Selection = BandSelection;
541
    async fn _query<'a>(
4✔
542
        &'a self,
4✔
543
        query: RasterQueryRectangle,
4✔
544
        ctx: &'a dyn QueryContext,
4✔
545
    ) -> Result<BoxStream<'a, Result<Self::Output>>> {
4✔
546
        if let Some(state) = &self.state {
4✔
547
            let valid_bounds_in = state.valid_in_bounds;
4✔
548
            let valid_bounds_out = state.valid_out_bounds;
4✔
549

550
            // calculate the spatial resolution the input data should have using the intersection and the requested resolution
551
            let in_spatial_res = suggest_pixel_size_from_diag_cross_projected(
4✔
552
                valid_bounds_out,
4✔
553
                valid_bounds_in,
4✔
554
                query.spatial_resolution,
4✔
555
            )?;
4✔
556

557
            // setup the subquery
558
            let sub_query_spec = TileReprojectionSubQuery {
4✔
559
                in_srs: self.from,
4✔
560
                out_srs: self.to,
4✔
561
                fold_fn: fold_by_coordinate_lookup_future,
4✔
562
                in_spatial_res,
4✔
563
                valid_bounds_in,
4✔
564
                valid_bounds_out,
4✔
565
                _phantom_data: PhantomData,
4✔
566
            };
4✔
567

4✔
568
            // return the adapter which will reproject the tiles and uses the fill adapter to inject missing tiles
4✔
569
            Ok(RasterSubQueryAdapter::<'a, P, _, _>::new(
4✔
570
                &self.source,
4✔
571
                query,
4✔
572
                self.tiling_spec,
4✔
573
                ctx,
4✔
574
                sub_query_spec,
4✔
575
            )
4✔
576
            .filter_and_fill(FillerTileCacheExpirationStrategy::DerivedFromSurroundingTiles))
4✔
577
        } else {
578
            log::debug!("No intersection between source data / srs and target srs");
×
579

580
            let tiling_strat = self
×
581
                .tiling_spec
×
582
                .strategy(query.spatial_resolution.x, -query.spatial_resolution.y);
×
583

×
584
            let grid_bounds = tiling_strat.tile_grid_box(query.spatial_partition());
×
585
            Ok(Box::pin(SparseTilesFillAdapter::new(
×
586
                stream::empty(),
×
587
                grid_bounds,
×
NEW
588
                query.attributes.count(),
×
589
                tiling_strat.geo_transform,
×
590
                self.tiling_spec.tile_size_in_pixels,
×
591
                FillerTileCacheExpirationStrategy::DerivedFromSurroundingTiles,
×
592
            )))
×
593
        }
594
    }
8✔
595
}
596

597
#[cfg(test)]
598
mod tests {
599
    use super::*;
600
    use crate::engine::{MockExecutionContext, MockQueryContext, RasterBandDescriptors};
601
    use crate::mock::MockFeatureCollectionSource;
602
    use crate::mock::{MockRasterSource, MockRasterSourceParams};
603
    use crate::{
604
        engine::{ChunkByteSize, VectorOperator},
605
        source::{
606
            FileNotFoundHandling, GdalDatasetGeoTransform, GdalDatasetParameters,
607
            GdalMetaDataRegular, GdalMetaDataStatic, GdalSource, GdalSourceParameters,
608
            GdalSourceTimePlaceholder, TimeReference,
609
        },
610
        test_data,
611
        util::gdal::{add_ndvi_dataset, gdal_open_dataset},
612
    };
613
    use float_cmp::approx_eq;
614
    use futures::StreamExt;
615
    use geoengine_datatypes::collections::IntoGeometryIterator;
616
    use geoengine_datatypes::dataset::NamedData;
617
    use geoengine_datatypes::primitives::{
618
        AxisAlignedRectangle, Coordinate2D, DateTimeParseFormat,
619
    };
620
    use geoengine_datatypes::primitives::{CacheHint, CacheTtlSeconds};
621
    use geoengine_datatypes::raster::TilesEqualIgnoringCacheHint;
622
    use geoengine_datatypes::{
623
        collections::{
624
            GeometryCollection, MultiLineStringCollection, MultiPointCollection,
625
            MultiPolygonCollection,
626
        },
627
        dataset::{DataId, DatasetId},
628
        hashmap,
629
        primitives::{
630
            BoundingBox2D, MultiLineString, MultiPoint, MultiPolygon, QueryRectangle,
631
            SpatialResolution, TimeGranularity, TimeInstance, TimeInterval, TimeStep,
632
        },
633
        raster::{Grid, GridShape, GridShape2D, GridSize, RasterDataType, RasterTile2D},
634
        spatial_reference::SpatialReferenceAuthority,
635
        util::{
636
            test::TestDefault,
637
            well_known_data::{
638
                COLOGNE_EPSG_4326, COLOGNE_EPSG_900_913, HAMBURG_EPSG_4326, HAMBURG_EPSG_900_913,
639
                MARBURG_EPSG_4326, MARBURG_EPSG_900_913,
640
            },
641
            Identifier,
642
        },
643
    };
644
    use std::collections::HashMap;
645
    use std::path::PathBuf;
646
    use std::str::FromStr;
647

648
    #[tokio::test]
1✔
649
    async fn multi_point() -> Result<()> {
1✔
650
        let points = MultiPointCollection::from_data(
1✔
651
            MultiPoint::many(vec![
1✔
652
                MARBURG_EPSG_4326,
1✔
653
                COLOGNE_EPSG_4326,
1✔
654
                HAMBURG_EPSG_4326,
1✔
655
            ])
1✔
656
            .unwrap(),
1✔
657
            vec![TimeInterval::new_unchecked(0, 1); 3],
1✔
658
            Default::default(),
1✔
659
            CacheHint::default(),
1✔
660
        )?;
1✔
661

662
        let expected = MultiPoint::many(vec![
1✔
663
            MARBURG_EPSG_900_913,
1✔
664
            COLOGNE_EPSG_900_913,
1✔
665
            HAMBURG_EPSG_900_913,
1✔
666
        ])
1✔
667
        .unwrap();
1✔
668

1✔
669
        let point_source = MockFeatureCollectionSource::single(points.clone()).boxed();
1✔
670

1✔
671
        let target_spatial_reference =
1✔
672
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 900_913);
1✔
673

674
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
675
            params: ReprojectionParams {
1✔
676
                target_spatial_reference,
1✔
677
            },
1✔
678
            sources: SingleRasterOrVectorSource {
1✔
679
                source: point_source.into(),
1✔
680
            },
1✔
681
        })
1✔
682
        .initialize(
1✔
683
            WorkflowOperatorPath::initialize_root(),
1✔
684
            &MockExecutionContext::test_default(),
1✔
685
        )
1✔
686
        .await?;
×
687

688
        let query_processor = initialized_operator.query_processor()?;
1✔
689

690
        let query_processor = query_processor.multi_point().unwrap();
1✔
691

1✔
692
        let query_rectangle = VectorQueryRectangle {
1✔
693
            spatial_bounds: BoundingBox2D::new(
1✔
694
                (COLOGNE_EPSG_4326.x, MARBURG_EPSG_4326.y).into(),
1✔
695
                (MARBURG_EPSG_4326.x, HAMBURG_EPSG_4326.y).into(),
1✔
696
            )
1✔
697
            .unwrap(),
1✔
698
            time_interval: TimeInterval::default(),
1✔
699
            spatial_resolution: SpatialResolution::zero_point_one(),
1✔
700
            attributes: ColumnSelection::all(),
1✔
701
        };
1✔
702
        let ctx = MockQueryContext::new(ChunkByteSize::MAX);
1✔
703

704
        let query = query_processor.query(query_rectangle, &ctx).await.unwrap();
1✔
705

706
        let result = query
1✔
707
            .map(Result::unwrap)
1✔
708
            .collect::<Vec<MultiPointCollection>>()
1✔
709
            .await;
×
710

711
        assert_eq!(result.len(), 1);
1✔
712

713
        result[0]
1✔
714
            .geometries()
1✔
715
            .zip(expected.iter())
1✔
716
            .for_each(|(a, e)| {
3✔
717
                assert!(approx_eq!(&MultiPoint, &a.into(), e, epsilon = 0.00001));
3✔
718
            });
3✔
719

1✔
720
        Ok(())
1✔
721
    }
722

723
    #[tokio::test]
1✔
724
    async fn multi_lines() -> Result<()> {
1✔
725
        let lines = MultiLineStringCollection::from_data(
1✔
726
            vec![MultiLineString::new(vec![vec![
1✔
727
                MARBURG_EPSG_4326,
1✔
728
                COLOGNE_EPSG_4326,
1✔
729
                HAMBURG_EPSG_4326,
1✔
730
            ]])
1✔
731
            .unwrap()],
1✔
732
            vec![TimeInterval::new_unchecked(0, 1); 1],
1✔
733
            Default::default(),
1✔
734
            CacheHint::default(),
1✔
735
        )?;
1✔
736

737
        let expected = [MultiLineString::new(vec![vec![
1✔
738
            MARBURG_EPSG_900_913,
1✔
739
            COLOGNE_EPSG_900_913,
1✔
740
            HAMBURG_EPSG_900_913,
1✔
741
        ]])
1✔
742
        .unwrap()];
1✔
743

1✔
744
        let lines_source = MockFeatureCollectionSource::single(lines.clone()).boxed();
1✔
745

1✔
746
        let target_spatial_reference =
1✔
747
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 900_913);
1✔
748

749
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
750
            params: ReprojectionParams {
1✔
751
                target_spatial_reference,
1✔
752
            },
1✔
753
            sources: SingleRasterOrVectorSource {
1✔
754
                source: lines_source.into(),
1✔
755
            },
1✔
756
        })
1✔
757
        .initialize(
1✔
758
            WorkflowOperatorPath::initialize_root(),
1✔
759
            &MockExecutionContext::test_default(),
1✔
760
        )
1✔
761
        .await?;
×
762

763
        let query_processor = initialized_operator.query_processor()?;
1✔
764

765
        let query_processor = query_processor.multi_line_string().unwrap();
1✔
766

1✔
767
        let query_rectangle = VectorQueryRectangle {
1✔
768
            spatial_bounds: BoundingBox2D::new(
1✔
769
                (COLOGNE_EPSG_4326.x, MARBURG_EPSG_4326.y).into(),
1✔
770
                (MARBURG_EPSG_4326.x, HAMBURG_EPSG_4326.y).into(),
1✔
771
            )
1✔
772
            .unwrap(),
1✔
773
            time_interval: TimeInterval::default(),
1✔
774
            spatial_resolution: SpatialResolution::zero_point_one(),
1✔
775
            attributes: ColumnSelection::all(),
1✔
776
        };
1✔
777
        let ctx = MockQueryContext::new(ChunkByteSize::MAX);
1✔
778

779
        let query = query_processor.query(query_rectangle, &ctx).await.unwrap();
1✔
780

781
        let result = query
1✔
782
            .map(Result::unwrap)
1✔
783
            .collect::<Vec<MultiLineStringCollection>>()
1✔
784
            .await;
×
785

786
        assert_eq!(result.len(), 1);
1✔
787

788
        result[0]
1✔
789
            .geometries()
1✔
790
            .zip(expected.iter())
1✔
791
            .for_each(|(a, e)| {
1✔
792
                assert!(approx_eq!(
1✔
793
                    &MultiLineString,
1✔
794
                    &a.into(),
1✔
795
                    e,
1✔
796
                    epsilon = 0.00001
1✔
797
                ));
1✔
798
            });
1✔
799

1✔
800
        Ok(())
1✔
801
    }
802

803
    #[tokio::test]
1✔
804
    async fn multi_polygons() -> Result<()> {
1✔
805
        let polygons = MultiPolygonCollection::from_data(
1✔
806
            vec![MultiPolygon::new(vec![vec![vec![
1✔
807
                MARBURG_EPSG_4326,
1✔
808
                COLOGNE_EPSG_4326,
1✔
809
                HAMBURG_EPSG_4326,
1✔
810
                MARBURG_EPSG_4326,
1✔
811
            ]]])
1✔
812
            .unwrap()],
1✔
813
            vec![TimeInterval::new_unchecked(0, 1); 1],
1✔
814
            Default::default(),
1✔
815
            CacheHint::default(),
1✔
816
        )?;
1✔
817

818
        let expected = [MultiPolygon::new(vec![vec![vec![
1✔
819
            MARBURG_EPSG_900_913,
1✔
820
            COLOGNE_EPSG_900_913,
1✔
821
            HAMBURG_EPSG_900_913,
1✔
822
            MARBURG_EPSG_900_913,
1✔
823
        ]]])
1✔
824
        .unwrap()];
1✔
825

1✔
826
        let polygon_source = MockFeatureCollectionSource::single(polygons.clone()).boxed();
1✔
827

1✔
828
        let target_spatial_reference =
1✔
829
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 900_913);
1✔
830

831
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
832
            params: ReprojectionParams {
1✔
833
                target_spatial_reference,
1✔
834
            },
1✔
835
            sources: SingleRasterOrVectorSource {
1✔
836
                source: polygon_source.into(),
1✔
837
            },
1✔
838
        })
1✔
839
        .initialize(
1✔
840
            WorkflowOperatorPath::initialize_root(),
1✔
841
            &MockExecutionContext::test_default(),
1✔
842
        )
1✔
843
        .await?;
×
844

845
        let query_processor = initialized_operator.query_processor()?;
1✔
846

847
        let query_processor = query_processor.multi_polygon().unwrap();
1✔
848

1✔
849
        let query_rectangle = VectorQueryRectangle {
1✔
850
            spatial_bounds: BoundingBox2D::new(
1✔
851
                (COLOGNE_EPSG_4326.x, MARBURG_EPSG_4326.y).into(),
1✔
852
                (MARBURG_EPSG_4326.x, HAMBURG_EPSG_4326.y).into(),
1✔
853
            )
1✔
854
            .unwrap(),
1✔
855
            time_interval: TimeInterval::default(),
1✔
856
            spatial_resolution: SpatialResolution::zero_point_one(),
1✔
857
            attributes: ColumnSelection::all(),
1✔
858
        };
1✔
859
        let ctx = MockQueryContext::new(ChunkByteSize::MAX);
1✔
860

861
        let query = query_processor.query(query_rectangle, &ctx).await.unwrap();
1✔
862

863
        let result = query
1✔
864
            .map(Result::unwrap)
1✔
865
            .collect::<Vec<MultiPolygonCollection>>()
1✔
866
            .await;
×
867

868
        assert_eq!(result.len(), 1);
1✔
869

870
        result[0]
1✔
871
            .geometries()
1✔
872
            .zip(expected.iter())
1✔
873
            .for_each(|(a, e)| {
1✔
874
                assert!(approx_eq!(&MultiPolygon, &a.into(), e, epsilon = 0.00001));
1✔
875
            });
1✔
876

1✔
877
        Ok(())
1✔
878
    }
879

880
    #[tokio::test]
1✔
881
    async fn raster_identity() -> Result<()> {
1✔
882
        let projection = SpatialReference::new(
1✔
883
            geoengine_datatypes::spatial_reference::SpatialReferenceAuthority::Epsg,
1✔
884
            4326,
1✔
885
        );
1✔
886

1✔
887
        let data = vec![
1✔
888
            RasterTile2D {
1✔
889
                time: TimeInterval::new_unchecked(0, 5),
1✔
890
                tile_position: [-1, 0].into(),
1✔
891
                band: 0,
1✔
892
                global_geo_transform: TestDefault::test_default(),
1✔
893
                grid_array: Grid::new([2, 2].into(), vec![1, 2, 3, 4]).unwrap().into(),
1✔
894
                properties: Default::default(),
1✔
895
                cache_hint: CacheHint::default(),
1✔
896
            },
1✔
897
            RasterTile2D {
1✔
898
                time: TimeInterval::new_unchecked(0, 5),
1✔
899
                tile_position: [-1, 1].into(),
1✔
900
                band: 0,
1✔
901
                global_geo_transform: TestDefault::test_default(),
1✔
902
                grid_array: Grid::new([2, 2].into(), vec![7, 8, 9, 10]).unwrap().into(),
1✔
903
                properties: Default::default(),
1✔
904
                cache_hint: CacheHint::default(),
1✔
905
            },
1✔
906
            RasterTile2D {
1✔
907
                time: TimeInterval::new_unchecked(5, 10),
1✔
908
                tile_position: [-1, 0].into(),
1✔
909
                band: 0,
1✔
910
                global_geo_transform: TestDefault::test_default(),
1✔
911
                grid_array: Grid::new([2, 2].into(), vec![13, 14, 15, 16])
1✔
912
                    .unwrap()
1✔
913
                    .into(),
1✔
914
                properties: Default::default(),
1✔
915
                cache_hint: CacheHint::default(),
1✔
916
            },
1✔
917
            RasterTile2D {
1✔
918
                time: TimeInterval::new_unchecked(5, 10),
1✔
919
                tile_position: [-1, 1].into(),
1✔
920
                band: 0,
1✔
921
                global_geo_transform: TestDefault::test_default(),
1✔
922
                grid_array: Grid::new([2, 2].into(), vec![19, 20, 21, 22])
1✔
923
                    .unwrap()
1✔
924
                    .into(),
1✔
925
                properties: Default::default(),
1✔
926
                cache_hint: CacheHint::default(),
1✔
927
            },
1✔
928
        ];
1✔
929

1✔
930
        let mrs1 = MockRasterSource {
1✔
931
            params: MockRasterSourceParams {
1✔
932
                data: data.clone(),
1✔
933
                result_descriptor: RasterResultDescriptor {
1✔
934
                    data_type: RasterDataType::U8,
1✔
935
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
936
                    time: None,
1✔
937
                    bbox: None,
1✔
938
                    resolution: Some(SpatialResolution::one()),
1✔
939
                    bands: RasterBandDescriptors::new_single_band(),
1✔
940
                },
1✔
941
            },
1✔
942
        }
1✔
943
        .boxed();
1✔
944

1✔
945
        let mut exe_ctx = MockExecutionContext::test_default();
1✔
946
        exe_ctx.tiling_specification.tile_size_in_pixels = GridShape {
1✔
947
            // we need a smaller tile size
1✔
948
            shape_array: [2, 2],
1✔
949
        };
1✔
950

1✔
951
        let query_ctx = MockQueryContext::test_default();
1✔
952

953
        let initialized_operator = RasterOperator::boxed(Reprojection {
1✔
954
            params: ReprojectionParams {
1✔
955
                target_spatial_reference: projection, // This test will do a identity reprojection
1✔
956
            },
1✔
957
            sources: SingleRasterOrVectorSource {
1✔
958
                source: mrs1.into(),
1✔
959
            },
1✔
960
        })
1✔
961
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
962
        .await?;
×
963

964
        let qp = initialized_operator
1✔
965
            .query_processor()
1✔
966
            .unwrap()
1✔
967
            .get_u8()
1✔
968
            .unwrap();
1✔
969

1✔
970
        let query_rect = RasterQueryRectangle {
1✔
971
            spatial_bounds: SpatialPartition2D::new_unchecked((0., 1.).into(), (3., 0.).into()),
1✔
972
            time_interval: TimeInterval::new_unchecked(0, 10),
1✔
973
            spatial_resolution: SpatialResolution::one(),
1✔
974
            attributes: BandSelection::first(),
1✔
975
        };
1✔
976

977
        let a = qp.raster_query(query_rect, &query_ctx).await?;
1✔
978

979
        let res = a
1✔
980
            .map(Result::unwrap)
1✔
981
            .collect::<Vec<RasterTile2D<u8>>>()
1✔
982
            .await;
8✔
983
        assert!(data.tiles_equal_ignoring_cache_hint(&res));
1✔
984

985
        Ok(())
1✔
986
    }
987

988
    #[tokio::test]
1✔
989
    async fn raster_ndvi_3857() -> Result<()> {
1✔
990
        let mut exe_ctx = MockExecutionContext::test_default();
1✔
991
        let query_ctx = MockQueryContext::test_default();
1✔
992
        let id = add_ndvi_dataset(&mut exe_ctx);
1✔
993
        exe_ctx.tiling_specification =
1✔
994
            TilingSpecification::new((0.0, 0.0).into(), [450, 450].into());
1✔
995

1✔
996
        let output_shape: GridShape2D = [900, 1800].into();
1✔
997
        let output_bounds =
1✔
998
            SpatialPartition2D::new_unchecked((0., 20_000_000.).into(), (20_000_000., 0.).into());
1✔
999
        let time_interval = TimeInterval::new_unchecked(1_388_534_400_000, 1_388_534_400_001);
1✔
1000
        // 2014-01-01
1✔
1001

1✔
1002
        let gdal_op = GdalSource {
1✔
1003
            params: GdalSourceParameters { data: id.clone() },
1✔
1004
        }
1✔
1005
        .boxed();
1✔
1006

1✔
1007
        let projection = SpatialReference::new(
1✔
1008
            geoengine_datatypes::spatial_reference::SpatialReferenceAuthority::Epsg,
1✔
1009
            3857,
1✔
1010
        );
1✔
1011

1012
        let initialized_operator = RasterOperator::boxed(Reprojection {
1✔
1013
            params: ReprojectionParams {
1✔
1014
                target_spatial_reference: projection,
1✔
1015
            },
1✔
1016
            sources: SingleRasterOrVectorSource {
1✔
1017
                source: gdal_op.into(),
1✔
1018
            },
1✔
1019
        })
1✔
1020
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1021
        .await?;
×
1022

1023
        let x_query_resolution = output_bounds.size_x() / output_shape.axis_size_x() as f64;
1✔
1024
        let y_query_resolution = output_bounds.size_y() / (output_shape.axis_size_y() * 2) as f64; // *2 to account for the dataset aspect ratio 2:1
1✔
1025
        let spatial_resolution =
1✔
1026
            SpatialResolution::new_unchecked(x_query_resolution, y_query_resolution);
1✔
1027

1✔
1028
        let qp = initialized_operator
1✔
1029
            .query_processor()
1✔
1030
            .unwrap()
1✔
1031
            .get_u8()
1✔
1032
            .unwrap();
1✔
1033

1034
        let qs = qp
1✔
1035
            .raster_query(
1✔
1036
                RasterQueryRectangle {
1✔
1037
                    spatial_bounds: output_bounds,
1✔
1038
                    time_interval,
1✔
1039
                    spatial_resolution,
1✔
1040
                    attributes: BandSelection::first(),
1✔
1041
                },
1✔
1042
                &query_ctx,
1✔
1043
            )
1✔
1044
            .await
×
1045
            .unwrap();
1✔
1046

1047
        let res = qs
1✔
1048
            .map(Result::unwrap)
1✔
1049
            .collect::<Vec<RasterTile2D<u8>>>()
1✔
1050
            .await;
125✔
1051

1052
        // Write the tiles to a file
1053
        // let mut buffer = File::create("MOD13A2_M_NDVI_2014-04-01_tile-20.rst")?;
1054
        // buffer.write(res[8].clone().into_materialized_tile().grid_array.data.as_slice())?;
1055

1056
        // This check is against a tile produced by the operator itself. It was visually validated. TODO: rebuild when open issues are solved.
1057
        // A perfect validation would be against a GDAL output generated like this:
1058
        // gdalwarp -t_srs EPSG:3857 -tr 11111.11111111 11111.11111111 -r near -te 0.0 5011111.111111112 5000000.0 10011111.111111112 -te_srs EPSG:3857 -of GTiff ./MOD13A2_M_NDVI_2014-04-01.TIFF ./MOD13A2_M_NDVI_2014-04-01_tile-20.rst
1059

1060
        assert_eq!(
1✔
1061
            include_bytes!(
1✔
1062
                "../../../test_data/raster/modis_ndvi/projected_3857/MOD13A2_M_NDVI_2014-04-01_tile-20.rst"
1✔
1063
            ) as &[u8],
1✔
1064
            res[8].clone().into_materialized_tile().grid_array.inner_grid.data.as_slice()
1✔
1065
        );
1✔
1066

1067
        Ok(())
1✔
1068
    }
1069

1070
    #[test]
1✔
1071
    fn query_rewrite_4326_3857() {
1✔
1072
        let query = VectorQueryRectangle {
1✔
1073
            spatial_bounds: BoundingBox2D::new_unchecked((-180., -90.).into(), (180., 90.).into()),
1✔
1074
            time_interval: TimeInterval::default(),
1✔
1075
            spatial_resolution: SpatialResolution::zero_point_one(),
1✔
1076
            attributes: ColumnSelection::all(),
1✔
1077
        };
1✔
1078

1✔
1079
        let expected = BoundingBox2D::new_unchecked(
1✔
1080
            (-20_037_508.342_789_244, -20_048_966.104_014_594).into(),
1✔
1081
            (20_037_508.342_789_244, 20_048_966.104_014_594).into(),
1✔
1082
        );
1✔
1083

1✔
1084
        let reprojected = reproject_query(
1✔
1085
            query,
1✔
1086
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 3857),
1✔
1087
            SpatialReference::epsg_4326(),
1✔
1088
        )
1✔
1089
        .unwrap()
1✔
1090
        .unwrap();
1✔
1091

1✔
1092
        assert!(approx_eq!(
1✔
1093
            BoundingBox2D,
1✔
1094
            expected,
1✔
1095
            reprojected.spatial_bounds,
1✔
1096
            epsilon = 0.000_001
1✔
1097
        ));
1✔
1098
    }
1✔
1099

1100
    #[tokio::test]
1✔
1101
    async fn raster_ndvi_3857_to_4326() -> Result<()> {
1✔
1102
        let mut exe_ctx = MockExecutionContext::test_default();
1✔
1103
        let query_ctx = MockQueryContext::test_default();
1✔
1104

1✔
1105
        let m = GdalMetaDataRegular {
1✔
1106
            data_time: TimeInterval::new_unchecked(
1✔
1107
                TimeInstance::from_str("2014-01-01T00:00:00.000Z").unwrap(),
1✔
1108
                TimeInstance::from_str("2014-07-01T00:00:00.000Z").unwrap(),
1✔
1109
            ),
1✔
1110
            step: TimeStep {
1✔
1111
                granularity: TimeGranularity::Months,
1✔
1112
                step: 1,
1✔
1113
            },
1✔
1114
            time_placeholders: hashmap! {
1✔
1115
                "%_START_TIME_%".to_string() => GdalSourceTimePlaceholder {
1✔
1116
                    format: DateTimeParseFormat::custom("%Y-%m-%d".to_string()),
1✔
1117
                    reference: TimeReference::Start,
1✔
1118
                },
1✔
1119
            },
1✔
1120
            params: GdalDatasetParameters {
1✔
1121
                file_path: test_data!(
1✔
1122
                    "raster/modis_ndvi/projected_3857/MOD13A2_M_NDVI_%_START_TIME_%.TIFF"
1✔
1123
                )
1✔
1124
                .into(),
1✔
1125
                rasterband_channel: 1,
1✔
1126
                geo_transform: GdalDatasetGeoTransform {
1✔
1127
                    origin_coordinate: (-20_037_508.342_789_244, 19_971_868.880_408_563).into(),
1✔
1128
                    x_pixel_size: 14_052.950_258_048_739,
1✔
1129
                    y_pixel_size: -14_057.881_117_788_405,
1✔
1130
                },
1✔
1131
                width: 2851,
1✔
1132
                height: 2841,
1✔
1133
                file_not_found_handling: FileNotFoundHandling::Error,
1✔
1134
                no_data_value: Some(0.),
1✔
1135
                properties_mapping: None,
1✔
1136
                gdal_open_options: None,
1✔
1137
                gdal_config_options: None,
1✔
1138
                allow_alphaband_as_mask: true,
1✔
1139
                retry: None,
1✔
1140
            },
1✔
1141
            result_descriptor: RasterResultDescriptor {
1✔
1142
                data_type: RasterDataType::U8,
1✔
1143
                spatial_reference: SpatialReference::new(SpatialReferenceAuthority::Epsg, 3857)
1✔
1144
                    .into(),
1✔
1145
                time: None,
1✔
1146
                bbox: None,
1✔
1147
                resolution: None,
1✔
1148
                bands: RasterBandDescriptors::new_single_band(),
1✔
1149
            },
1✔
1150
            cache_ttl: CacheTtlSeconds::default(),
1✔
1151
        };
1✔
1152

1✔
1153
        let id: DataId = DatasetId::new().into();
1✔
1154
        let name = NamedData::with_system_name("ndvi");
1✔
1155
        exe_ctx.add_meta_data(id.clone(), name.clone(), Box::new(m));
1✔
1156

1✔
1157
        exe_ctx.tiling_specification = TilingSpecification::new((0.0, 0.0).into(), [60, 60].into());
1✔
1158

1✔
1159
        let output_bounds =
1✔
1160
            SpatialPartition2D::new_unchecked((-180., 90.).into(), (180., -90.).into());
1✔
1161
        let time_interval = TimeInterval::new_unchecked(1_396_310_400_000, 1_396_310_400_000);
1✔
1162
        // 2014-04-01
1✔
1163

1✔
1164
        let gdal_op = GdalSource {
1✔
1165
            params: GdalSourceParameters { data: name },
1✔
1166
        }
1✔
1167
        .boxed();
1✔
1168

1169
        let initialized_operator = RasterOperator::boxed(Reprojection {
1✔
1170
            params: ReprojectionParams {
1✔
1171
                target_spatial_reference: SpatialReference::epsg_4326(),
1✔
1172
            },
1✔
1173
            sources: SingleRasterOrVectorSource {
1✔
1174
                source: gdal_op.into(),
1✔
1175
            },
1✔
1176
        })
1✔
1177
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1178
        .await?;
×
1179

1180
        let x_query_resolution = output_bounds.size_x() / 480.; // since we request x -180 to 180 and y -90 to 90 with 60x60 tiles this will result in 8 x 4 tiles
1✔
1181
        let y_query_resolution = output_bounds.size_y() / 240.; // *2 to account for the dataset aspect ratio 2:1
1✔
1182
        let spatial_resolution =
1✔
1183
            SpatialResolution::new_unchecked(x_query_resolution, y_query_resolution);
1✔
1184

1✔
1185
        let qp = initialized_operator
1✔
1186
            .query_processor()
1✔
1187
            .unwrap()
1✔
1188
            .get_u8()
1✔
1189
            .unwrap();
1✔
1190

1191
        let qs = qp
1✔
1192
            .raster_query(
1✔
1193
                QueryRectangle {
1✔
1194
                    spatial_bounds: output_bounds,
1✔
1195
                    time_interval,
1✔
1196
                    spatial_resolution,
1✔
1197
                    attributes: BandSelection::first(),
1✔
1198
                },
1✔
1199
                &query_ctx,
1✔
1200
            )
1✔
1201
            .await
×
1202
            .unwrap();
1✔
1203

1204
        let tiles = qs
1✔
1205
            .map(Result::unwrap)
1✔
1206
            .collect::<Vec<RasterTile2D<u8>>>()
1✔
1207
            .await;
239✔
1208

1209
        // the test must generate 8x4 tiles
1210
        assert_eq!(tiles.len(), 32);
1✔
1211

1212
        // none of the tiles should be empty
1213
        assert!(tiles.iter().all(|t| !t.is_empty()));
32✔
1214

1215
        Ok(())
1✔
1216
    }
1217

1218
    #[test]
1✔
1219
    fn source_resolution() {
1✔
1220
        let epsg_4326 = SpatialReference::epsg_4326();
1✔
1221
        let epsg_3857 = SpatialReference::new(SpatialReferenceAuthority::Epsg, 3857);
1✔
1222

1✔
1223
        // use ndvi dataset that was reprojected using gdal as ground truth
1✔
1224
        let dataset_4326 = gdal_open_dataset(test_data!(
1✔
1225
            "raster/modis_ndvi/MOD13A2_M_NDVI_2014-04-01.TIFF"
1✔
1226
        ))
1✔
1227
        .unwrap();
1✔
1228
        let geotransform_4326 = dataset_4326.geo_transform().unwrap();
1✔
1229
        let res_4326 = SpatialResolution::new(geotransform_4326[1], -geotransform_4326[5]).unwrap();
1✔
1230

1✔
1231
        let dataset_3857 = gdal_open_dataset(test_data!(
1✔
1232
            "raster/modis_ndvi/projected_3857/MOD13A2_M_NDVI_2014-04-01.TIFF"
1✔
1233
        ))
1✔
1234
        .unwrap();
1✔
1235
        let geotransform_3857 = dataset_3857.geo_transform().unwrap();
1✔
1236
        let res_3857 = SpatialResolution::new(geotransform_3857[1], -geotransform_3857[5]).unwrap();
1✔
1237

1✔
1238
        // ndvi was projected from 4326 to 3857. The calculated source_resolution for getting the raster in 3857 with `res_3857`
1✔
1239
        // should thus roughly be like the original `res_4326`
1✔
1240
        let result_res = suggest_pixel_size_from_diag_cross_projected::<SpatialPartition2D>(
1✔
1241
            epsg_3857.area_of_use_projected().unwrap(),
1✔
1242
            epsg_4326.area_of_use_projected().unwrap(),
1✔
1243
            res_3857,
1✔
1244
        )
1✔
1245
        .unwrap();
1✔
1246
        assert!(1. - (result_res.x / res_4326.x).abs() < 0.02);
1✔
1247
        assert!(1. - (result_res.y / res_4326.y).abs() < 0.02);
1✔
1248
    }
1✔
1249

1250
    #[tokio::test]
1✔
1251
    async fn query_outside_projection_area_of_use_produces_empty_tiles() {
1✔
1252
        let mut exe_ctx = MockExecutionContext::test_default();
1✔
1253
        let query_ctx = MockQueryContext::test_default();
1✔
1254

1✔
1255
        let m = GdalMetaDataStatic {
1✔
1256
            time: Some(TimeInterval::default()),
1✔
1257
            params: GdalDatasetParameters {
1✔
1258
                file_path: PathBuf::new(),
1✔
1259
                rasterband_channel: 1,
1✔
1260
                geo_transform: GdalDatasetGeoTransform {
1✔
1261
                    origin_coordinate: (166_021.44, 9_329_005.188).into(),
1✔
1262
                    x_pixel_size: (534_994.66 - 166_021.444) / 100.,
1✔
1263
                    y_pixel_size: -9_329_005.18 / 100.,
1✔
1264
                },
1✔
1265
                width: 100,
1✔
1266
                height: 100,
1✔
1267
                file_not_found_handling: FileNotFoundHandling::NoData,
1✔
1268
                no_data_value: Some(0.),
1✔
1269
                properties_mapping: None,
1✔
1270
                gdal_open_options: None,
1✔
1271
                gdal_config_options: None,
1✔
1272
                allow_alphaband_as_mask: true,
1✔
1273
                retry: None,
1✔
1274
            },
1✔
1275
            result_descriptor: RasterResultDescriptor {
1✔
1276
                data_type: RasterDataType::U8,
1✔
1277
                spatial_reference: SpatialReference::new(SpatialReferenceAuthority::Epsg, 32636)
1✔
1278
                    .into(),
1✔
1279
                time: None,
1✔
1280
                bbox: None,
1✔
1281
                resolution: None,
1✔
1282
                bands: RasterBandDescriptors::new_single_band(),
1✔
1283
            },
1✔
1284
            cache_ttl: CacheTtlSeconds::default(),
1✔
1285
        };
1✔
1286

1✔
1287
        let id: DataId = DatasetId::new().into();
1✔
1288
        let name = NamedData::with_system_name("ndvi");
1✔
1289
        exe_ctx.add_meta_data(id.clone(), name.clone(), Box::new(m));
1✔
1290

1✔
1291
        exe_ctx.tiling_specification =
1✔
1292
            TilingSpecification::new((0.0, 0.0).into(), [600, 600].into());
1✔
1293

1✔
1294
        let output_shape: GridShape2D = [1000, 1000].into();
1✔
1295
        let output_bounds =
1✔
1296
            SpatialPartition2D::new_unchecked((-180., 0.).into(), (180., -90.).into());
1✔
1297
        let time_interval = TimeInterval::new_instant(1_388_534_400_000).unwrap(); // 2014-01-01
1✔
1298

1✔
1299
        let gdal_op = GdalSource {
1✔
1300
            params: GdalSourceParameters { data: name },
1✔
1301
        }
1✔
1302
        .boxed();
1✔
1303

1304
        let initialized_operator = RasterOperator::boxed(Reprojection {
1✔
1305
            params: ReprojectionParams {
1✔
1306
                target_spatial_reference: SpatialReference::epsg_4326(),
1✔
1307
            },
1✔
1308
            sources: SingleRasterOrVectorSource {
1✔
1309
                source: gdal_op.into(),
1✔
1310
            },
1✔
1311
        })
1✔
1312
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1313
        .await
×
1314
        .unwrap();
1✔
1315

1✔
1316
        let x_query_resolution = output_bounds.size_x() / output_shape.axis_size_x() as f64;
1✔
1317
        let y_query_resolution = output_bounds.size_y() / (output_shape.axis_size_y()) as f64;
1✔
1318
        let spatial_resolution =
1✔
1319
            SpatialResolution::new_unchecked(x_query_resolution, y_query_resolution);
1✔
1320

1✔
1321
        let qp = initialized_operator
1✔
1322
            .query_processor()
1✔
1323
            .unwrap()
1✔
1324
            .get_u8()
1✔
1325
            .unwrap();
1✔
1326

1327
        let result = qp
1✔
1328
            .raster_query(
1✔
1329
                QueryRectangle {
1✔
1330
                    spatial_bounds: output_bounds,
1✔
1331
                    time_interval,
1✔
1332
                    spatial_resolution,
1✔
1333
                    attributes: BandSelection::first(),
1✔
1334
                },
1✔
1335
                &query_ctx,
1✔
1336
            )
1✔
1337
            .await
×
1338
            .unwrap()
1✔
1339
            .map(Result::unwrap)
1✔
1340
            .collect::<Vec<_>>()
1✔
1341
            .await;
×
1342

1343
        assert_eq!(result.len(), 4);
1✔
1344

1345
        for r in result {
5✔
1346
            assert!(r.is_empty());
4✔
1347
        }
1348
    }
1349

1350
    #[tokio::test]
1✔
1351
    async fn points_from_wgs84_to_utm36n() {
1✔
1352
        let exe_ctx = MockExecutionContext::test_default();
1✔
1353
        let query_ctx = MockQueryContext::test_default();
1✔
1354

1✔
1355
        let point_source = MockFeatureCollectionSource::single(
1✔
1356
            MultiPointCollection::from_data(
1✔
1357
                MultiPoint::many(vec![
1✔
1358
                    vec![(30.0, 0.0)], // lower left of utm36n area of use
1✔
1359
                    vec![(36.0, 84.0)],
1✔
1360
                    vec![(33.0, 42.0)], // upper right of utm36n area of use
1✔
1361
                ])
1✔
1362
                .unwrap(),
1✔
1363
                vec![TimeInterval::default(); 3],
1✔
1364
                HashMap::default(),
1✔
1365
                CacheHint::default(),
1✔
1366
            )
1✔
1367
            .unwrap(),
1✔
1368
        )
1✔
1369
        .boxed();
1✔
1370

1371
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
1372
            params: ReprojectionParams {
1✔
1373
                target_spatial_reference: SpatialReference::new(
1✔
1374
                    SpatialReferenceAuthority::Epsg,
1✔
1375
                    32636, // utm36n
1✔
1376
                ),
1✔
1377
            },
1✔
1378
            sources: SingleRasterOrVectorSource {
1✔
1379
                source: point_source.into(),
1✔
1380
            },
1✔
1381
        })
1✔
1382
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1383
        .await
×
1384
        .unwrap();
1✔
1385

1✔
1386
        let qp = initialized_operator
1✔
1387
            .query_processor()
1✔
1388
            .unwrap()
1✔
1389
            .multi_point()
1✔
1390
            .unwrap();
1✔
1391

1✔
1392
        let spatial_bounds = BoundingBox2D::new(
1✔
1393
            (166_021.44, 0.00).into(), // lower left of projected utm36n area of use
1✔
1394
            (534_994.666_6, 9_329_005.18).into(), // upper right of projected utm36n area of use
1✔
1395
        )
1✔
1396
        .unwrap();
1✔
1397

1398
        let qs = qp
1✔
1399
            .vector_query(
1✔
1400
                QueryRectangle {
1✔
1401
                    spatial_bounds,
1✔
1402
                    time_interval: TimeInterval::default(),
1✔
1403
                    spatial_resolution: SpatialResolution::zero_point_one(),
1✔
1404
                    attributes: ColumnSelection::all(),
1✔
1405
                },
1✔
1406
                &query_ctx,
1✔
1407
            )
1✔
1408
            .await
×
1409
            .unwrap();
1✔
1410

1411
        let points = qs.map(Result::unwrap).collect::<Vec<_>>().await;
1✔
1412

1413
        assert_eq!(points.len(), 1);
1✔
1414

1415
        let points = &points[0];
1✔
1416

1✔
1417
        assert_eq!(
1✔
1418
            points.coordinates(),
1✔
1419
            &[
1✔
1420
                (166_021.443_080_538_42, 0.0).into(),
1✔
1421
                (534_994.655_061_136_1, 9_329_005.182_447_437).into(),
1✔
1422
                (499_999.999_999_999_5, 4_649_776.224_819_178).into()
1✔
1423
            ]
1✔
1424
        );
1✔
1425
    }
1426

1427
    #[tokio::test]
1✔
1428
    async fn points_from_utm36n_to_wgs84() {
1✔
1429
        let exe_ctx = MockExecutionContext::test_default();
1✔
1430
        let query_ctx = MockQueryContext::test_default();
1✔
1431

1✔
1432
        let point_source = MockFeatureCollectionSource::with_collections_and_sref(
1✔
1433
            vec![MultiPointCollection::from_data(
1✔
1434
                MultiPoint::many(vec![
1✔
1435
                    vec![(166_021.443_080_538_42, 0.0)],
1✔
1436
                    vec![(534_994.655_061_136_1, 9_329_005.182_447_437)],
1✔
1437
                    vec![(499_999.999_999_999_5, 4_649_776.224_819_178)],
1✔
1438
                ])
1✔
1439
                .unwrap(),
1✔
1440
                vec![TimeInterval::default(); 3],
1✔
1441
                HashMap::default(),
1✔
1442
                CacheHint::default(),
1✔
1443
            )
1✔
1444
            .unwrap()],
1✔
1445
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 32636), //utm36n
1✔
1446
        )
1✔
1447
        .boxed();
1✔
1448

1449
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
1450
            params: ReprojectionParams {
1✔
1451
                target_spatial_reference: SpatialReference::new(
1✔
1452
                    SpatialReferenceAuthority::Epsg,
1✔
1453
                    4326, // utm36n
1✔
1454
                ),
1✔
1455
            },
1✔
1456
            sources: SingleRasterOrVectorSource {
1✔
1457
                source: point_source.into(),
1✔
1458
            },
1✔
1459
        })
1✔
1460
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1461
        .await
×
1462
        .unwrap();
1✔
1463

1✔
1464
        let qp = initialized_operator
1✔
1465
            .query_processor()
1✔
1466
            .unwrap()
1✔
1467
            .multi_point()
1✔
1468
            .unwrap();
1✔
1469

1✔
1470
        let spatial_bounds = BoundingBox2D::new(
1✔
1471
            (30.0, 0.0).into(),  // lower left of utm36n area of use
1✔
1472
            (33.0, 42.0).into(), // upper right of utm36n area of use
1✔
1473
        )
1✔
1474
        .unwrap();
1✔
1475

1476
        let qs = qp
1✔
1477
            .vector_query(
1✔
1478
                QueryRectangle {
1✔
1479
                    spatial_bounds,
1✔
1480
                    time_interval: TimeInterval::default(),
1✔
1481
                    spatial_resolution: SpatialResolution::zero_point_one(),
1✔
1482
                    attributes: ColumnSelection::all(),
1✔
1483
                },
1✔
1484
                &query_ctx,
1✔
1485
            )
1✔
1486
            .await
×
1487
            .unwrap();
1✔
1488

1489
        let points = qs.map(Result::unwrap).collect::<Vec<_>>().await;
1✔
1490

1491
        assert_eq!(points.len(), 1);
1✔
1492

1493
        let points = &points[0];
1✔
1494

1✔
1495
        assert!(approx_eq!(
1✔
1496
            &[Coordinate2D],
1✔
1497
            points.coordinates(),
1✔
1498
            &[
1✔
1499
                (30.0, 0.0).into(), // lower left of utm36n area of use
1✔
1500
                (36.0, 84.0).into(),
1✔
1501
                (33.0, 42.0).into(), // upper right of utm36n area of use
1✔
1502
            ]
1✔
1503
        ));
1✔
1504
    }
1505

1506
    #[tokio::test]
1✔
1507
    async fn points_from_utm36n_to_wgs84_out_of_area() {
1✔
1508
        // This test checks that points that are outside the area of use of the target spatial reference are not projected and an empty collection is returned
1✔
1509

1✔
1510
        let exe_ctx = MockExecutionContext::test_default();
1✔
1511
        let query_ctx = MockQueryContext::test_default();
1✔
1512

1✔
1513
        let point_source = MockFeatureCollectionSource::with_collections_and_sref(
1✔
1514
            vec![MultiPointCollection::from_data(
1✔
1515
                MultiPoint::many(vec![
1✔
1516
                    vec![(758_565., 4_928_353.)], // (12.25, 44,46)
1✔
1517
                ])
1✔
1518
                .unwrap(),
1✔
1519
                vec![TimeInterval::default(); 1],
1✔
1520
                HashMap::default(),
1✔
1521
                CacheHint::default(),
1✔
1522
            )
1✔
1523
            .unwrap()],
1✔
1524
            SpatialReference::new(SpatialReferenceAuthority::Epsg, 32636), //utm36n
1✔
1525
        )
1✔
1526
        .boxed();
1✔
1527

1528
        let initialized_operator = VectorOperator::boxed(Reprojection {
1✔
1529
            params: ReprojectionParams {
1✔
1530
                target_spatial_reference: SpatialReference::new(
1✔
1531
                    SpatialReferenceAuthority::Epsg,
1✔
1532
                    4326, // utm36n
1✔
1533
                ),
1✔
1534
            },
1✔
1535
            sources: SingleRasterOrVectorSource {
1✔
1536
                source: point_source.into(),
1✔
1537
            },
1✔
1538
        })
1✔
1539
        .initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1✔
1540
        .await
×
1541
        .unwrap();
1✔
1542

1✔
1543
        let qp = initialized_operator
1✔
1544
            .query_processor()
1✔
1545
            .unwrap()
1✔
1546
            .multi_point()
1✔
1547
            .unwrap();
1✔
1548

1✔
1549
        let spatial_bounds = BoundingBox2D::new(
1✔
1550
            (10.0, 0.0).into(),  // -20 x values left of lower left of utm36n area of use
1✔
1551
            (13.0, 42.0).into(), // -20 x values left of upper right of utm36n area of use
1✔
1552
        )
1✔
1553
        .unwrap();
1✔
1554

1555
        let qs = qp
1✔
1556
            .vector_query(
1✔
1557
                QueryRectangle {
1✔
1558
                    spatial_bounds,
1✔
1559
                    time_interval: TimeInterval::default(),
1✔
1560
                    spatial_resolution: SpatialResolution::zero_point_one(),
1✔
1561
                    attributes: ColumnSelection::all(),
1✔
1562
                },
1✔
1563
                &query_ctx,
1✔
1564
            )
1✔
1565
            .await
×
1566
            .unwrap();
1✔
1567

1568
        let points = qs.map(Result::unwrap).collect::<Vec<_>>().await;
1✔
1569

1570
        assert_eq!(points.len(), 1);
1✔
1571

1572
        let points = &points[0];
1✔
1573

1✔
1574
        assert!(geoengine_datatypes::collections::FeatureCollectionInfos::is_empty(points));
1✔
1575
        assert!(points.coordinates().is_empty());
1✔
1576
    }
1577

1578
    #[test]
1✔
1579
    fn it_derives_raster_result_descriptor() {
1✔
1580
        let in_proj = SpatialReference::epsg_4326();
1✔
1581
        let out_proj = SpatialReference::from_str("EPSG:3857").unwrap();
1✔
1582
        let bbox = Some(SpatialPartition2D::new_unchecked(
1✔
1583
            (-180., 90.).into(),
1✔
1584
            (180., -90.).into(),
1✔
1585
        ));
1✔
1586

1✔
1587
        let resolution = Some(SpatialResolution::new_unchecked(0.1, 0.1));
1✔
1588

1✔
1589
        let (in_bounds, out_bounds, out_res) =
1✔
1590
            InitializedRasterReprojection::derive_raster_in_bounds_out_bounds_out_res(
1✔
1591
                in_proj, out_proj, resolution, bbox,
1✔
1592
            )
1✔
1593
            .unwrap();
1✔
1594

1✔
1595
        assert_eq!(
1✔
1596
            in_bounds.unwrap(),
1✔
1597
            SpatialPartition2D::new_unchecked((-180., 85.06).into(), (180., -85.06).into(),)
1✔
1598
        );
1✔
1599

1600
        assert_eq!(
1✔
1601
            out_bounds.unwrap(),
1✔
1602
            out_proj
1✔
1603
                .area_of_use_projected::<SpatialPartition2D>()
1✔
1604
                .unwrap()
1✔
1605
        );
1✔
1606

1607
        // TODO: y resolution should be double the x resolution, but currently we only compute a uniform resolution
1608
        assert_eq!(
1✔
1609
            out_res.unwrap(),
1✔
1610
            SpatialResolution::new_unchecked(14_237.781_884_528_267, 14_237.781_884_528_267),
1✔
1611
        );
1✔
1612
    }
1✔
1613
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc