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

geo-engine / geoengine / 16354926043

17 Jul 2025 08:09PM UTC coverage: 88.872%. First build
16354926043

Pull #1061

github

web-flow
Merge 6307e082f into b8910c811
Pull Request #1061: feat(operators): skip empty tiles and merge masks in onnx; remove trace/debug in release mode

414 of 569 new or added lines in 44 files covered. (72.76%)

111581 of 125552 relevant lines covered (88.87%)

80316.26 hits per line

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

68.97
/operators/src/machine_learning/metadata.rs
1
use std::path::PathBuf;
2

3
use geoengine_datatypes::{machine_learning::MlTensorShape3D, raster::RasterDataType};
4
use postgres_types::{FromSql, ToSql};
5
use serde::{Deserialize, Serialize};
6

7
/// Strategies to handle no-data in model inputs.
8
/// - `EncodedNoData`: If inputs have empty (no-data) pixels, pixels are mapped to a `no_data_value`. This is usefull if the model can handle missing data.
9
/// - `SkipIfNoData`: If any input pixel is empty (no-data), the output is also empty (no-data). This is usefull if the model can't handle missing data.
10
#[derive(PartialEq, Debug, Serialize, Deserialize, Copy, Clone, Default)]
11
pub enum MlModelInputNoDataHandling {
12
    EncodedNoData {
13
        no_data_value: f32,
14
    },
15
    #[default]
16
    SkipIfNoData,
17
}
18

19
impl MlModelInputNoDataHandling {
20
    pub fn no_data_value_encoding(self) -> Option<f32> {
3✔
21
        match self {
3✔
NEW
22
            MlModelInputNoDataHandling::EncodedNoData { no_data_value } => Some(no_data_value),
×
23
            MlModelInputNoDataHandling::SkipIfNoData => None,
3✔
24
        }
25
    }
3✔
26
}
27

28
/// Strategies to handle no-data in model outputs.
29
/// - `EncodedNoData`: If the model outputs a `no_data_value` pixel with the `no_data_value` are masked and are ignored by other operators.
30
/// - `NanIsNoData`: If the model produces NaN values, they are masked as as no data.
31
#[derive(PartialEq, Debug, Serialize, Deserialize, Copy, Clone, Default)]
32
pub enum MlModelOutputNoDataHandling {
33
    EncodedNoData {
34
        no_data_value: f32,
35
    },
36
    #[default]
37
    NanIsNoData,
38
}
39

40
impl MlModelOutputNoDataHandling {
41
    pub fn no_data_value_encoding(self) -> Option<f32> {
3✔
42
        match self {
3✔
NEW
43
            MlModelOutputNoDataHandling::EncodedNoData { no_data_value } => Some(no_data_value),
×
44
            MlModelOutputNoDataHandling::NanIsNoData => None,
3✔
45
        }
46
    }
3✔
47
}
48

49
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
50
pub struct MlModelLoadingInfo {
51
    pub storage_path: PathBuf,
52
    pub metadata: MlModelMetadata,
53
}
54

55
impl MlModelLoadingInfo {
NEW
56
    pub fn model_path_owned(&self) -> PathBuf {
×
NEW
57
        self.storage_path.clone()
×
NEW
58
    }
×
59
}
60

61
// For now we assume all models are pixel-wise, i.e., they take a single pixel with multiple bands as input and produce a single output value.
62
// To support different inputs, we would need a more sophisticated logic to produce the inputs for the model.
NEW
63
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize, ToSql, FromSql)]
×
64
pub struct MlModelMetadata {
65
    pub input_type: RasterDataType,
66
    pub output_type: RasterDataType,
67
    pub input_shape: MlTensorShape3D,
68
    pub output_shape: MlTensorShape3D, // TODO: output measurement, e.g. classification or regression, label names for classification. This would have to be provided by the model creator along the model file as it cannot be extracted from the model file(?)
69
    pub input_no_data_handling: MlModelInputNoDataHandling,
70
    pub output_no_data_handling: MlModelOutputNoDataHandling,
71
}
72

73
impl MlModelMetadata {
NEW
74
    pub fn num_input_bands(&self) -> u32 {
×
NEW
75
        self.input_shape.bands
×
NEW
76
    }
×
77

78
    pub fn num_output_bands(&self) -> u32 {
4✔
79
        self.output_shape.bands
4✔
80
    }
4✔
81

82
    pub fn input_is_single_pixel(&self) -> bool {
13✔
83
        self.input_shape.x == 1 && self.input_shape.y == 1
13✔
84
    }
13✔
85

86
    pub fn output_is_single_pixel(&self) -> bool {
4✔
87
        self.output_shape.x == 1 && self.output_shape.y == 1
4✔
88
    }
4✔
89

90
    pub fn output_is_single_attribute(&self) -> bool {
4✔
91
        self.num_output_bands() == 1
4✔
92
    }
4✔
93
}
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