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

geo-engine / geoengine / 21625090376

03 Feb 2026 09:42AM UTC coverage: 88.837%. First build
21625090376

Pull #1116

github

web-flow
Merge 47454b91b into 0a5e73d64
Pull Request #1116: feat: Operators in OpenAPI

32 of 33 new or added lines in 2 files covered. (96.97%)

106461 of 119839 relevant lines covered (88.84%)

84147.45 hits per line

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

95.83
/api/src/processes/source.rs
1
use geoengine_datatypes::dataset::NamedData;
2
use geoengine_macros::type_tag;
3
use geoengine_operators::source::{
4
    GdalSource as OperatorsGdalSource, GdalSourceParameters as OperatorsGdalSourceParameters,
5
};
6
use serde::{Deserialize, Serialize};
7
use utoipa::ToSchema;
8

9
/// # GdalSource
10
///
11
/// The [`GdalSource`] is a source operator that reads raster data using GDAL.
12
/// The counterpart for vector data is the [`OgrSource`].
13
///
14
/// ## Errors
15
///
16
/// If the given dataset does not exist or is not readable, an error is thrown.
17
///
18
/// ## Example JSON
19
///
20
/// ```json
21
/// {
22
///   "type": "GdalSource",
23
///   "params": {
24
///     "data": "ndvi"
25
///   }
26
/// }
27
/// ```
28
#[type_tag(value = "GdalSource")]
29
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
30
#[serde(rename_all = "camelCase")]
31
pub struct GdalSource {
32
    pub params: GdalSourceParameters,
33
}
34

35
/// Parameters for the [`GdalSource`] operator.
36
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
37
#[serde(rename_all = "camelCase")]
38
pub struct GdalSourceParameters {
39
    /// Dataset name or identifier to be loaded.
40
    ///
41
    /// ### Example
42
    /// `"ndvi"`
43
    pub data: String,
44
}
45

46
impl TryFrom<GdalSource> for OperatorsGdalSource {
47
    type Error = anyhow::Error;
48
    fn try_from(value: GdalSource) -> Result<Self, Self::Error> {
2✔
49
        Ok(OperatorsGdalSource {
50
            params: OperatorsGdalSourceParameters {
51
                data: serde_json::from_str::<NamedData>(&serde_json::to_string(
2✔
52
                    &value.params.data,
2✔
NEW
53
                )?)?,
×
54
            },
55
        })
56
    }
2✔
57
}
58

59
// TODO: OpenAPI and conversions for other operators:
60
//  - MockPointSource
61
//  - Expression
62
//  - RasterVectorJoin
63

64
#[cfg(test)]
65
mod tests {
66
    use super::*;
67
    use crate::processes::{RasterOperator, TypedOperator};
68
    use geoengine_operators::engine::TypedOperator as OperatorsTypedOperator;
69

70
    #[test]
71
    fn it_converts_into_gdal_source() {
1✔
72
        let api_operator = GdalSource {
1✔
73
            r#type: Default::default(),
1✔
74
            params: GdalSourceParameters {
1✔
75
                data: "example_dataset".to_string(),
1✔
76
            },
1✔
77
        };
1✔
78

79
        let operators_operator: OperatorsGdalSource =
1✔
80
            api_operator.try_into().expect("it should convert");
1✔
81

82
        assert_eq!(
1✔
83
            operators_operator.params.data,
84
            NamedData::with_system_name("example_dataset")
1✔
85
        );
86

87
        let typed_operator = TypedOperator::Raster(RasterOperator::GdalSource(GdalSource {
1✔
88
            r#type: Default::default(),
1✔
89
            params: GdalSourceParameters {
1✔
90
                data: "example_dataset".to_string(),
1✔
91
            },
1✔
92
        }));
1✔
93

94
        OperatorsTypedOperator::try_from(typed_operator).expect("it should convert");
1✔
95
    }
1✔
96
}
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

© 2026 Coveralls, Inc