Skip to content

Commit 437d1a1

Browse files
committed
clean up
1 parent 7059375 commit 437d1a1

File tree

7 files changed

+15
-170
lines changed

7 files changed

+15
-170
lines changed

operators/src/adapters/raster_subquery/raster_subquery_reprojection.rs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ where
9595
self.state.out_spatial_grid.geo_transform()
9696
);
9797

98-
// why is this none?
98+
// TODO: instead of producing an empty stream if the query does not intersect the data or projection,
99+
// we need to actually perform the query in order to give the nodata tiles the correct time interval
100+
// because all tiles in a time step need the same temporal validity, even across diferent quereis
101+
102+
// so we need a way to reliably query the source in such cases that ensures no data tiles are produced.
103+
// what to do in cases where the bbox coordinates cannot be reprojected?
104+
// - query the data bbox but discard the data?
105+
// - implement a special empty bbox query that makes sure to produce empty tiles but correct time intervals?
106+
// - ideally: implement a way to query the time intervals of the source data and produce empty tiles accordingly
107+
99108
let valid_pixel_bounds = dbg!(
100109
dbg!(
101110
self.state
@@ -106,35 +115,17 @@ where
106115
.and_then(|b| b.intersection(&query_rect.spatial_query.grid_bounds()))
107116
);
108117

109-
log::debug!(
110-
"ÖÖÖÖÖ valid_pixel_bounds {:?} -> {:?}",
111-
tile_info.global_pixel_bounds(),
112-
valid_pixel_bounds
113-
);
114-
115118
let valid_spatial_bounds = valid_pixel_bounds.map(|pb| {
116119
self.state
117120
.out_spatial_grid
118121
.geo_transform()
119122
.grid_to_spatial_bounds(&pb)
120123
});
121124

122-
log::debug!(
123-
"ÖÖÖÖÖ valid_spatial_bounds {:?} -> {:?}",
124-
query_rect.spatial_query.grid_bounds(),
125-
valid_spatial_bounds
126-
);
127-
128125
if let Some(bounds) = valid_spatial_bounds {
129126
let proj = CoordinateProjector::from_known_srs(self.out_srs, self.in_srs)?;
130127
let projected_bounds = bounds.reproject(&proj);
131128

132-
log::debug!(
133-
"ÖÖÖÖÖ projected_bounds {:?} -> {:?}",
134-
bounds,
135-
projected_bounds
136-
);
137-
138129
match projected_bounds {
139130
Ok(pb) => {
140131
dbg!("produce something");
@@ -154,13 +145,6 @@ where
154145
}
155146
} else {
156147
dbg!("output query rectangle is not valid in source projection => produce empty tile");
157-
log::debug!(
158-
"ÖÖÖÖÖ output query rectangle is not valid in source projection => produce empty tile {:?}",
159-
self.state
160-
.out_spatial_grid
161-
.geo_transform()
162-
.grid_to_spatial_bounds(&query_rect.spatial_query.grid_bounds())
163-
);
164148

165149
// output query rectangle is not valid in source projection => produce empty tile
166150
Ok(None)

operators/src/adapters/sparse_tiles_fill_adapter.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ impl<T: Pixel> StateContainer<T> {
284284

285285
fn set_current_time_from_initial_tile(&mut self, first_tile_time: TimeInterval) {
286286
debug_assert!(first_tile_time.end() > first_tile_time.start());
287-
debug_assert!(first_tile_time.end() != first_tile_time.start() + 1);
288287
// if we know a bound we must use it to set the current time
289288
let start_data_bound = self.data_time_bounds.start();
290289
let requested_start = self.requested_time_bounds.start();
@@ -322,15 +321,13 @@ impl<T: Pixel> StateContainer<T> {
322321
TimeInterval::new(self.data_time_bounds.start(), self.data_time_bounds.end()).unwrap(),
323322
);
324323
debug_assert!(!self.current_time.unwrap().is_instant());
325-
// debug_assert!(self.current_time.unwrap().end() != self.current_time.unwrap().start() + 1);
326324
}
327325

328326
fn update_current_time(&mut self, new_time: TimeInterval) {
329327
debug_assert!(
330328
!new_time.is_instant(),
331329
"Tile time is the data validity and must not be an instant!"
332330
);
333-
debug_assert!(new_time.end() != new_time.start() + 1);
334331

335332
if let Some(old_time) = self.current_time {
336333
if old_time == new_time {

operators/src/processing/downsample/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,6 @@ where
256256
query: RasterQueryRectangle,
257257
ctx: &'a dyn QueryContext,
258258
) -> Result<BoxStream<'a, Result<Self::Output>>> {
259-
log::debug!("ÖÖÖÖÖÖ Downsampling query: {:?}", query);
260-
261259
// do not interpolate if the source resolution is already fine enough
262260

263261
let in_spatial_grid = self.source.result_descriptor().spatial_grid_descriptor();
@@ -405,7 +403,6 @@ impl<T: Pixel> FoldTileAccu for DownsampleAccu<T> {
405403

406404
async fn into_tile(self) -> Result<RasterTile2D<Self::RasterType>> {
407405
debug_assert!(self.time.unwrap().end() > self.time.unwrap().start());
408-
debug_assert!(self.time.unwrap().end() != self.time.unwrap().start() + 1);
409406
// TODO: later do conversation of accu into tile here
410407

411408
let output_tile = RasterTile2D::new_with_tile_info(

operators/src/processing/reprojection.rs

Lines changed: 3 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,6 @@ where
638638
query: RasterQueryRectangle,
639639
ctx: &'a dyn QueryContext,
640640
) -> Result<BoxStream<'a, Result<Self::Output>>> {
641-
log::debug!("ÖÖÖÖÖÖ Reprojection query: {:?}", query);
642-
643641
let state = self.state;
644642

645643
// setup the subquery
@@ -682,9 +680,8 @@ mod tests {
682680
use crate::mock::MockFeatureCollectionSource;
683681
use crate::mock::{MockRasterSource, MockRasterSourceParams};
684682
use crate::source::{
685-
FileNotFoundHandling, GdalDatasetGeoTransform, GdalDatasetParameters,
686-
GdalLoadingInfoTemporalSlice, GdalMetaDataList, GdalMetaDataRegular, GdalMetaDataStatic,
687-
GdalSourceTimePlaceholder, TimeReference,
683+
FileNotFoundHandling, GdalDatasetGeoTransform, GdalDatasetParameters, GdalMetaDataRegular,
684+
GdalMetaDataStatic, GdalSourceTimePlaceholder, TimeReference,
688685
};
689686
use crate::util::gdal::add_ndvi_dataset;
690687
use crate::{
@@ -1483,6 +1480,7 @@ mod tests {
14831480

14841481
for r in result {
14851482
assert!(r.is_empty());
1483+
assert_eq!(r.time, time_interval);
14861484
}
14871485
}
14881486

@@ -1754,125 +1752,4 @@ mod tests {
17541752
GridBoundingBox2D::new_min_max(-1405, 1405, -1410, 1409).unwrap()
17551753
);
17561754
}
1757-
1758-
#[tokio::test]
1759-
async fn it_sets_correct_temporal_validity_for_partially_undefined_source_regions() -> Result<()>
1760-
{
1761-
let tile_size_in_pixels = [600, 600].into(); //TODO ??
1762-
let data_geo_transform =
1763-
GeoTransform::new(Coordinate2D::new(399_960.000, 5700_000.000), 1098., -1098.);
1764-
let data_bounds = GridBoundingBox2D::new([0, 0], [99, 99]).unwrap();
1765-
let result_descriptor = RasterResultDescriptor {
1766-
data_type: RasterDataType::U8,
1767-
spatial_reference: SpatialReference::new(SpatialReferenceAuthority::Epsg, 32632).into(),
1768-
time: None,
1769-
spatial_grid: SpatialGridDescriptor::source_from_parts(data_geo_transform, data_bounds),
1770-
bands: RasterBandDescriptors::new_single_band(),
1771-
};
1772-
1773-
dbg!(result_descriptor.spatial_grid);
1774-
1775-
let m = GdalMetaDataList {
1776-
result_descriptor: result_descriptor.clone(),
1777-
params: vec![GdalLoadingInfoTemporalSlice {
1778-
time: TimeInterval::new_unchecked(
1779-
TimeInstance::from_str("2022-02-01T00:00:00.000Z").unwrap(),
1780-
TimeInstance::from_str("2022-03-01T00:00:00.000Z").unwrap(),
1781-
),
1782-
params: Some(GdalDatasetParameters {
1783-
file_path: test_data!(
1784-
"raster/sentinel2/S2B_32UMB_20220129_0_L2A__B02.tif_downsampled.tif"
1785-
)
1786-
.into(),
1787-
rasterband_channel: 1,
1788-
geo_transform: GdalDatasetGeoTransform {
1789-
origin_coordinate: data_geo_transform.origin_coordinate,
1790-
x_pixel_size: data_geo_transform.x_pixel_size(),
1791-
y_pixel_size: data_geo_transform.y_pixel_size(),
1792-
},
1793-
width: data_bounds.axis_size_x(),
1794-
height: data_bounds.axis_size_y(),
1795-
file_not_found_handling: FileNotFoundHandling::Error,
1796-
no_data_value: Some(0.),
1797-
properties_mapping: None,
1798-
gdal_open_options: None,
1799-
gdal_config_options: None,
1800-
allow_alphaband_as_mask: true,
1801-
retry: None,
1802-
}),
1803-
cache_ttl: CacheTtlSeconds::default(),
1804-
}],
1805-
};
1806-
1807-
let tiling_spec = TilingSpecification::new(tile_size_in_pixels);
1808-
let mut exe_ctx = MockExecutionContext::new_with_tiling_spec(tiling_spec);
1809-
1810-
let id: DataId = DatasetId::new().into();
1811-
let name = NamedData::with_system_name("s2");
1812-
exe_ctx.add_meta_data(id.clone(), name.clone(), Box::new(m));
1813-
1814-
let gdal_op = GdalSource {
1815-
params: GdalSourceParameters::new(name),
1816-
}
1817-
.boxed();
1818-
1819-
let initialized_operator = RasterOperator::boxed(Reprojection {
1820-
params: ReprojectionParams {
1821-
target_spatial_reference: SpatialReference::epsg_4326(),
1822-
derive_out_spec: DeriveOutRasterSpecsSource::DataBounds,
1823-
},
1824-
sources: SingleRasterOrVectorSource {
1825-
source: gdal_op.into(),
1826-
},
1827-
})
1828-
.initialize(WorkflowOperatorPath::initialize_root(), &exe_ctx)
1829-
.await?;
1830-
1831-
let qp = initialized_operator
1832-
.query_processor()
1833-
.unwrap()
1834-
.get_u8()
1835-
.unwrap();
1836-
1837-
let qr = qp.result_descriptor();
1838-
1839-
dbg!(qr.spatial_grid);
1840-
let query_ctx = exe_ctx.mock_query_context(TestDefault::test_default());
1841-
1842-
// query with Germany bbox which is partially outside of 32632 projection
1843-
let request_bounds = SpatialPartition2D::new(
1844-
Coordinate2D::new(5.98865807458, 54.983104153),
1845-
Coordinate2D::new(15.0169958839, 47.3024876979),
1846-
)?;
1847-
1848-
let query_tiling_pixel_grid = qr
1849-
.spatial_grid_descriptor()
1850-
.tiling_grid_definition(tiling_spec)
1851-
.tiling_spatial_grid_definition()
1852-
.spatial_bounds_to_compatible_spatial_grid(request_bounds);
1853-
1854-
let query_rect = RasterQueryRectangle::new_with_grid_bounds(
1855-
query_tiling_pixel_grid.grid_bounds(),
1856-
TimeInterval::new_instant(TimeInstance::from_str("2022-02-01T00:00:00.000Z").unwrap())
1857-
.unwrap(),
1858-
BandSelection::first(),
1859-
);
1860-
1861-
dbg!(&query_rect);
1862-
1863-
let qs = qp.raster_query(query_rect, &query_ctx).await.unwrap();
1864-
1865-
let tiles = qs
1866-
.map(Result::unwrap)
1867-
.collect::<Vec<RasterTile2D<u8>>>()
1868-
.await;
1869-
1870-
for r in tiles {
1871-
dbg!(r.time, r.is_empty());
1872-
}
1873-
1874-
assert!(false);
1875-
1876-
Ok(())
1877-
}
18781755
}

operators/src/source/gdal_source/loading_info.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,6 @@ impl MetaData<GdalLoadingInfo, RasterResultDescriptor, RasterQueryRectangle> for
303303
let known_time_before = known_time_start.unwrap_or(TimeInstance::MIN);
304304
let known_time_after = known_time_end.unwrap_or(TimeInstance::MAX);
305305

306-
log::debug!(
307-
"ÄÄÄÄÄÄ known_time_before: {known_time_before}, known_time_after: {known_time_after}",
308-
);
309-
310306
Ok(GdalLoadingInfo::new(
311307
GdalLoadingInfoTemporalSliceIterator::Static {
312308
parts: data.into_iter(),

services/examples/force-import.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use chrono::{NaiveDate, TimeZone, naive};
1+
use chrono::{NaiveDate, TimeZone};
22
use gdal::vector::{Defn, Feature, FieldDefn, LayerOptions, OGRFieldType};
33
use gdal::{Dataset as GdalDataset, DriverManager, Metadata};
44
use geoengine_datatypes::primitives::{CacheTtlSeconds, DateTime, TimeInstance, TimeInterval};

services/src/api/handlers/wms.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use snafu::ensure;
2828
use std::str::FromStr;
2929
use std::time::Duration;
3030
use tracing::debug;
31-
use tracing_subscriber::field::debug;
3231
use uuid::Uuid;
3332

3433
pub(crate) fn init_wms_routes<C>(cfg: &mut web::ServiceConfig)
@@ -277,15 +276,10 @@ async fn wms_map_handler<C: ApplicationContext>(
277276
request.crs.ok_or(error::Error::MissingSpatialReference)?;
278277

279278
let request_bounds: SpatialPartition2D = request.bbox.bounds(request_spatial_ref)?;
280-
281-
debug!("WMS request bounds: {:?}", request_bounds);
282-
283279
let x_request_res = request_bounds.size_x() / f64::from(request.width);
284280
let y_request_res = request_bounds.size_y() / f64::from(request.height);
285281
let request_resolution = SpatialResolution::new(x_request_res.abs(), y_request_res.abs())?;
286282

287-
debug!("WMS request resolution: {:?}", request_resolution);
288-
289283
let raster_colorizer = raster_colorizer_from_style(&request.styles)?;
290284

291285
let ctx = app_ctx.session_context(session);
@@ -357,7 +351,7 @@ async fn wms_map_handler<C: ApplicationContext>(
357351
query_tiling_pixel_grid.grid_bounds(),
358352
request.time.unwrap_or_else(default_time_from_config).into(),
359353
attributes,
360-
); // <-- this one
354+
);
361355

362356
debug!("WMS query rect: {:?}", query_rect);
363357

0 commit comments

Comments
 (0)