Skip to content

Commit

Permalink
Merge #451
Browse files Browse the repository at this point in the history
451: None params in gdal_source  produce empty tile r=michaelmattig a=jdroenner



Co-authored-by: Johannes Drönner <droenner@mathematik.uni-marburg.de>
  • Loading branch information
bors[bot] and jdroenner authored Jan 28, 2022
2 parents 2c2770a + 9374abf commit 0bb9a04
Show file tree
Hide file tree
Showing 15 changed files with 653 additions and 163 deletions.
3 changes: 3 additions & 0 deletions datatypes/src/primitives/time_interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ impl TimeInterval {
}
}

/// Returns the duration of the interval
/// This is the difference between the start and end time.
/// If the start and end time are equal i.e. the interval is an instant, the duration is 0.
pub fn duration_ms(&self) -> u64 {
self.end.inner().wrapping_sub(self.start.inner()) as u64
}
Expand Down
37 changes: 34 additions & 3 deletions datatypes/src/raster/raster_tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,25 @@ where
time: TimeInterval,
tile_info: TileInformation,
data: GridOrEmpty<D, T>,
) -> Self {
// TODO: assert, tile information xy size equals the data xy size
) -> Self
where
D: GridSize,
{
debug_assert_eq!(
tile_info.tile_size_in_pixels.axis_size_x(),
data.shape_ref().axis_size_x()
);

debug_assert_eq!(
tile_info.tile_size_in_pixels.axis_size_y(),
data.shape_ref().axis_size_y()
);

debug_assert_eq!(
tile_info.tile_size_in_pixels.number_of_elements(),
data.shape_ref().number_of_elements()
);

Self {
time,
tile_position: tile_info.global_tile_position,
Expand All @@ -112,7 +129,21 @@ where
data: GridOrEmpty<D, T>,
properties: RasterProperties,
) -> Self {
// TODO: assert, tile information xy size equals the data xy size
debug_assert_eq!(
tile_info.tile_size_in_pixels.axis_size_x(),
data.shape_ref().axis_size_x()
);

debug_assert_eq!(
tile_info.tile_size_in_pixels.axis_size_y(),
data.shape_ref().axis_size_y()
);

debug_assert_eq!(
tile_info.tile_size_in_pixels.number_of_elements(),
data.shape_ref().number_of_elements()
);

Self {
time,
tile_position: tile_info.global_tile_position,
Expand Down
2 changes: 1 addition & 1 deletion operators/benches/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn setup_gdal_source(
GdalSourceProcessor::<u8> {
tiling_specification,
meta_data: Box::new(meta_data),
phantom_data: Default::default(),
no_data_value: Some(0),
}
}

Expand Down
2 changes: 1 addition & 1 deletion operators/src/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub use raster_subquery::{
SubQueryTileAggregator, TileReprojectionSubQuery,
};
pub use raster_time::RasterTimeAdapter;
pub use sparse_tiles_fill_adapter::SparseTilesFillAdapter;
pub use sparse_tiles_fill_adapter::{SparseTilesFillAdapter, SparseTilesFillAdapterError};

use self::raster_time_substream::RasterTimeMultiFold;
use crate::util::Result;
Expand Down
485 changes: 417 additions & 68 deletions operators/src/adapters/sparse_tiles_fill_adapter.rs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions operators/src/engine/result_descriptor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use geoengine_datatypes::primitives::{FeatureDataType, Measurement};
use geoengine_datatypes::raster::FromPrimitive;
use geoengine_datatypes::{
collections::VectorDataType, raster::RasterDataType, spatial_reference::SpatialReferenceOption,
};
Expand Down Expand Up @@ -82,6 +83,12 @@ impl ResultDescriptor for RasterResultDescriptor {
}
}

impl RasterResultDescriptor {
pub fn no_data_value_as_<T: FromPrimitive<f64>>(&self) -> Option<T> {
self.no_data_value.map(|v| T::from_(v))
}
}

/// A `ResultDescriptor` for vector queries
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down
10 changes: 10 additions & 0 deletions operators/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,22 @@ pub enum Error {
source: crate::util::statistics::StatisticsError,
},

#[snafu(display("SparseTilesFillAdapter error: {}", source))]
SparseTilesFillAdapter {
source: crate::adapters::SparseTilesFillAdapterError,
},
#[snafu(context(false))]
ExpressionOperator {
source: crate::processing::ExpressionError,
},
}

impl From<crate::adapters::SparseTilesFillAdapterError> for Error {
fn from(source: crate::adapters::SparseTilesFillAdapterError) -> Self {
Error::SparseTilesFillAdapter { source }
}
}

/// The error requires to be `Send`.
/// This inner modules tries to enforce this.
mod requirements {
Expand Down
Loading

0 comments on commit 0bb9a04

Please sign in to comment.