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

geo-engine / geoengine / 7006568925

27 Nov 2023 02:07PM UTC coverage: 89.651% (+0.2%) from 89.498%
7006568925

push

github

web-flow
Merge pull request #888 from geo-engine/raster_stacks

raster stacking

4032 of 4274 new or added lines in 107 files covered. (94.34%)

12 existing lines in 8 files now uncovered.

113020 of 126066 relevant lines covered (89.65%)

59901.79 hits per line

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

0.0
/operators/src/processing/map_query.rs
1
use crate::adapters::{FillerTileCacheExpirationStrategy, SparseTilesFillAdapter};
2
use crate::engine::{QueryContext, RasterQueryProcessor, VectorQueryProcessor};
3
use crate::util::Result;
4
use async_trait::async_trait;
5
use futures::stream::BoxStream;
6
use futures::StreamExt;
7
use geoengine_datatypes::primitives::{RasterQueryRectangle, VectorQueryRectangle};
8
use geoengine_datatypes::raster::{RasterTile2D, TilingSpecification};
9

10
/// This `QueryProcessor` allows to rewrite a query. It does not change the data. Results of the children are forwarded.
11
pub(crate) struct MapQueryProcessor<S, Q, A> {
12
    source: S,
13
    query_fn: Q,
14
    additional_data: A,
15
}
16

17
impl<S, Q, A> MapQueryProcessor<S, Q, A> {
18
    pub fn new(source: S, query_fn: Q, additional_data: A) -> Self {
×
19
        Self {
×
20
            source,
×
21
            query_fn,
×
22
            additional_data,
×
23
        }
×
24
    }
×
25
}
26

27
#[async_trait]
28
impl<S, Q> RasterQueryProcessor for MapQueryProcessor<S, Q, TilingSpecification>
29
where
30
    S: RasterQueryProcessor,
31
    Q: Fn(RasterQueryRectangle) -> Result<Option<RasterQueryRectangle>> + Sync + Send,
32
{
33
    type RasterType = S::RasterType;
34
    async fn raster_query<'a>(
×
35
        &'a self,
×
36
        query: RasterQueryRectangle,
×
37
        ctx: &'a dyn QueryContext,
×
38
    ) -> Result<BoxStream<'a, Result<RasterTile2D<S::RasterType>>>> {
×
NEW
39
        let rewritten_query = (self.query_fn)(query.clone())?;
×
40

41
        if let Some(rewritten_query) = rewritten_query {
×
42
            self.source.raster_query(rewritten_query, ctx).await
×
43
        } else {
44
            log::debug!("Query was rewritten to empty query. Returning empty / filled stream.");
×
45
            let s = futures::stream::empty();
×
46

×
47
            // TODO: The input of the `SparseTilesFillAdapter` is empty here, so we can't derive the expiration, as there are no tiles to derive them from.
×
48
            //       As this is the result of the query not being rewritten, we should check if the expiration could also be `max`, because this error
×
49
            //       will be persistent and we might as well cache the empty stream.
×
50
            Ok(SparseTilesFillAdapter::new_like_subquery(
×
51
                s,
×
NEW
52
                &query,
×
53
                self.additional_data,
×
54
                FillerTileCacheExpirationStrategy::NoCache,
×
55
            )
×
56
            .boxed())
×
57
        }
58
    }
×
59
}
60

61
#[async_trait]
62
impl<S, Q> VectorQueryProcessor for MapQueryProcessor<S, Q, ()>
63
where
64
    S: VectorQueryProcessor,
65
    Q: Fn(VectorQueryRectangle) -> Result<Option<VectorQueryRectangle>> + Sync + Send,
66
    S::VectorType: Send,
67
{
68
    type VectorType = S::VectorType;
69
    async fn vector_query<'a>(
×
70
        &'a self,
×
71
        query: VectorQueryRectangle,
×
72
        ctx: &'a dyn QueryContext,
×
73
    ) -> Result<BoxStream<'a, Result<Self::VectorType>>> {
×
74
        let rewritten_query = (self.query_fn)(query)?;
×
75
        if let Some(rewritten_query) = rewritten_query {
×
76
            self.source.vector_query(rewritten_query, ctx).await
×
77
        } else {
78
            log::debug!("Query was rewritten to empty query. Returning empty stream.");
×
79
            Ok(Box::pin(futures::stream::empty())) // TODO: should be empty collection?
×
80
        }
81
    }
×
82
}
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

© 2025 Coveralls, Inc