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

geo-engine / geoengine / 23057588730

13 Mar 2026 03:20PM UTC coverage: 88.251%. First build
23057588730

Pull #1130

github

web-flow
Merge 96f28eebb into ca0d5a3ca
Pull Request #1130: feat: add histogram and statistics plot operators to openapi.json

399 of 436 new or added lines in 9 files covered. (91.51%)

113255 of 128333 relevant lines covered (88.25%)

504640.77 hits per line

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

78.57
/services/src/api/model/processing_graphs/mod.rs
1
#![allow(clippy::needless_for_each)] // TODO: remove when clippy is fixed for utoipa <https://github.com/juhaku/utoipa/issues/1420>
2

3
// use crate::api::model::processing_graphs::{
4
//     processing::{Expression, ExpressionParameters, RasterVectorJoin, RasterVectorJoinParameters},
5
//     source::{GdalSource, GdalSourceParameters, MockPointSource, MockPointSourceParameters},
6
// };
7
use geoengine_operators::{
8
    engine::{
9
        PlotOperator as OperatorsPlotOperator, RasterOperator as OperatorsRasterOperator,
10
        TypedOperator as OperatorsTypedOperator, VectorOperator as OperatorsVectorOperator,
11
    },
12
    mock::MockPointSource as OperatorsMockPointSource,
13
    plot::{Histogram as OperatorsHistogram, Statistics as OperatorsStatistics},
14
    processing::{
15
        Expression as OperatorsExpression, RasterVectorJoin as OperatorsRasterVectorJoin,
16
    },
17
    source::GdalSource as OperatorsGdalSource,
18
};
19
use serde::{Deserialize, Serialize};
20
use utoipa::{OpenApi, ToSchema};
21

22
mod macros;
23
mod parameters;
24
mod plots;
25
mod processing;
26
mod source;
27
mod source_parameters;
28

29
// TODO: avoid exporting them to outside of API module
30
#[cfg(test)]
31
pub(crate) use crate::api::model::processing_graphs::parameters::SpatialBoundsDerive;
32
pub(crate) use crate::api::model::processing_graphs::{
33
    plots::{Histogram, HistogramParameters, Statistics, StatisticsParameters},
34
    processing::{Expression, ExpressionParameters, RasterVectorJoin, RasterVectorJoinParameters},
35
    source::{GdalSource, GdalSourceParameters, MockPointSource, MockPointSourceParameters},
36
    source_parameters::{
37
        MultipleRasterOrSingleVectorOperator, MultipleRasterOrSingleVectorSource,
38
        SingleRasterOrVectorOperator, SingleRasterOrVectorSource, SingleRasterSource,
39
        SingleVectorMultipleRasterSources,
40
    },
41
};
42

43
/// Operator outputs are distinguished by their data type.
44
/// There are `raster`, `vector` and `plot` operators.
45
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
46
#[serde(tag = "type", content = "operator")]
47
pub enum TypedOperator {
48
    Vector(VectorOperator),
49
    Raster(RasterOperator),
50
    Plot(PlotOperator),
51
}
52

53
/// An operator that produces raster data.
54
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
55
#[serde(rename_all = "camelCase", untagged)]
56
#[schema(discriminator = "type")]
57
pub enum RasterOperator {
58
    Expression(Expression),
59
    GdalSource(GdalSource),
60
}
61

62
/// An operator that produces vector data.
63
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
64
#[serde(rename_all = "camelCase", untagged)]
65
#[schema(discriminator = "type")]
66
pub enum VectorOperator {
67
    MockPointSource(MockPointSource),
68
    RasterVectorJoin(RasterVectorJoin),
69
}
70

71
/// An operator that produces plot data.
72
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, ToSchema)]
73
#[serde(rename_all = "camelCase", untagged)]
74
#[schema(discriminator = "type")]
75
pub enum PlotOperator {
76
    Histogram(Histogram),
77
    Statistics(Statistics),
78
}
79

80
impl TryFrom<RasterOperator> for Box<dyn OperatorsRasterOperator> {
81
    type Error = anyhow::Error;
82
    fn try_from(operator: RasterOperator) -> Result<Self, Self::Error> {
29✔
83
        match operator {
29✔
84
            RasterOperator::Expression(expression) => {
×
85
                OperatorsExpression::try_from(expression).map(OperatorsRasterOperator::boxed)
×
86
            }
87
            RasterOperator::GdalSource(gdal_source) => {
29✔
88
                OperatorsGdalSource::try_from(gdal_source).map(OperatorsRasterOperator::boxed)
29✔
89
            }
90
        }
91
    }
29✔
92
}
93

94
impl TryFrom<VectorOperator> for Box<dyn OperatorsVectorOperator> {
95
    type Error = anyhow::Error;
96
    fn try_from(operator: VectorOperator) -> Result<Self, Self::Error> {
7✔
97
        match operator {
7✔
98
            VectorOperator::MockPointSource(mock_point_source) => {
7✔
99
                OperatorsMockPointSource::try_from(mock_point_source)
7✔
100
                    .map(OperatorsVectorOperator::boxed)
7✔
101
            }
102
            VectorOperator::RasterVectorJoin(rvj) => {
×
103
                OperatorsRasterVectorJoin::try_from(rvj).map(OperatorsVectorOperator::boxed)
×
104
            }
105
        }
106
    }
7✔
107
}
108

109
impl TryFrom<PlotOperator> for Box<dyn OperatorsPlotOperator> {
110
    type Error = anyhow::Error;
111
    fn try_from(operator: PlotOperator) -> Result<Self, Self::Error> {
1✔
112
        match operator {
1✔
NEW
113
            PlotOperator::Histogram(histogram) => {
×
NEW
114
                OperatorsHistogram::try_from(histogram).map(OperatorsPlotOperator::boxed)
×
115
            }
116
            PlotOperator::Statistics(statistics) => {
1✔
117
                OperatorsStatistics::try_from(statistics).map(OperatorsPlotOperator::boxed)
1✔
118
            }
119
        }
120
    }
1✔
121
}
122

123
impl TryFrom<TypedOperator> for OperatorsTypedOperator {
124
    type Error = anyhow::Error;
125
    fn try_from(operator: TypedOperator) -> Result<Self, Self::Error> {
27✔
126
        match operator {
27✔
127
            TypedOperator::Raster(raster_operator) => Ok(Self::Raster(raster_operator.try_into()?)),
23✔
128
            TypedOperator::Vector(vector_operator) => Ok(Self::Vector(vector_operator.try_into()?)),
3✔
129
            TypedOperator::Plot(plot_operator) => Ok(Self::Plot(plot_operator.try_into()?)),
1✔
130
        }
131
    }
27✔
132
}
133

134
#[derive(OpenApi)]
135
#[openapi(components(schemas(
136
    // General
137
    PlotOperator,
138
    TypedOperator,
139
    VectorOperator,
140
    // Source
141
    GdalSource,
142
    GdalSourceParameters,
143
    MockPointSource,
144
    MockPointSourceParameters,
145
    // Processing
146
    Expression,
147
    ExpressionParameters,
148
    RasterOperator,
149
    RasterVectorJoin,
150
    RasterVectorJoinParameters,
151
    // Plots
152
    Histogram,
153
    HistogramParameters,
154
    Statistics,
155
    StatisticsParameters,
156
    // Source Parameters
157
    MultipleRasterOrSingleVectorOperator,
158
    MultipleRasterOrSingleVectorSource,
159
    SingleRasterOrVectorOperator,
160
    SingleRasterOrVectorSource,
161
    SingleRasterSource,
162
    SingleVectorMultipleRasterSources,
163

164
)))]
165
pub struct OperatorsApi;
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