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

geo-engine / geoengine / 11910714914

19 Nov 2024 10:06AM UTC coverage: 90.445% (-0.2%) from 90.687%
11910714914

push

github

web-flow
Merge pull request #994 from geo-engine/workspace-dependencies

use workspace dependencies, update toolchain, use global lock in expression

9 of 11 new or added lines in 6 files covered. (81.82%)

375 existing lines in 75 files now uncovered.

132867 of 146904 relevant lines covered (90.44%)

54798.11 hits per line

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

97.74
/services/src/contexts/postgres.rs
1
use super::migrations::{all_migrations, CurrentSchemaMigration, MigrationResult};
2
use super::{initialize_database, ExecutionContextImpl, Session, SimpleApplicationContext};
3
use crate::api::cli::{add_datasets_from_directory, add_providers_from_directory};
4
use crate::api::model::services::Volume;
5
use crate::contexts::{ApplicationContext, QueryContextImpl, SessionId, SimpleSession};
6
use crate::contexts::{GeoEngineDb, SessionContext};
7
use crate::datasets::upload::Volumes;
8
use crate::datasets::DatasetName;
9
use crate::error::{self, Error, Result};
10
use crate::layers::add_from_directory::{
11
    add_layer_collections_from_directory, add_layers_from_directory,
12
};
13
use crate::projects::{ProjectId, STRectangle};
14
use crate::tasks::{SimpleTaskManager, SimpleTaskManagerBackend, SimpleTaskManagerContext};
15
use crate::util::config;
16
use crate::util::config::get_config_element;
17
use async_trait::async_trait;
18
use bb8_postgres::{
19
    bb8::Pool,
20
    bb8::PooledConnection,
21
    tokio_postgres::{error::SqlState, tls::MakeTlsConnect, tls::TlsConnect, Config, Socket},
22
    PostgresConnectionManager,
23
};
24
use geoengine_datatypes::raster::TilingSpecification;
25
use geoengine_operators::engine::ChunkByteSize;
26
use geoengine_operators::util::create_rayon_thread_pool;
27
use log::info;
28
use rayon::ThreadPool;
29
use snafu::ensure;
30
use std::path::PathBuf;
31
use std::sync::Arc;
32

33
// TODO: distinguish user-facing errors from system-facing error messages
34

35
/// A context with references to Postgres backends of the database.
36
#[derive(Clone)]
37
pub struct PostgresContext<Tls>
38
where
39
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
40
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
41
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
42
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
43
{
44
    default_session_id: SessionId,
45
    thread_pool: Arc<ThreadPool>,
46
    exe_ctx_tiling_spec: TilingSpecification,
47
    query_ctx_chunk_size: ChunkByteSize,
48
    task_manager: Arc<SimpleTaskManagerBackend>,
49
    pool: Pool<PostgresConnectionManager<Tls>>,
50
    volumes: Volumes,
51
}
52

53
enum DatabaseStatus {
54
    Unitialized,
55
    InitializedClearDatabase,
56
    InitializedKeepDatabase,
57
}
58

59
impl<Tls> PostgresContext<Tls>
60
where
61
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
62
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
63
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
64
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
65
{
66
    pub async fn new_with_context_spec(
227✔
67
        config: Config,
227✔
68
        tls: Tls,
227✔
69
        exe_ctx_tiling_spec: TilingSpecification,
227✔
70
        query_ctx_chunk_size: ChunkByteSize,
227✔
71
        volumes: Volumes,
227✔
72
    ) -> Result<Self> {
227✔
73
        let pg_mgr = PostgresConnectionManager::new(config, tls);
227✔
74

75
        let pool = Pool::builder().build(pg_mgr).await?;
227✔
76
        let created_schema = Self::create_database(pool.get().await?).await?;
2,951✔
77

78
        let session = if created_schema {
227✔
79
            let session = SimpleSession::default();
227✔
80
            Self::create_default_session(pool.get().await?, session.id()).await?;
454✔
81
            session
227✔
82
        } else {
83
            Self::load_default_session(pool.get().await?).await?
×
84
        };
85

86
        Ok(PostgresContext {
227✔
87
            default_session_id: session.id(),
227✔
88
            task_manager: Default::default(),
227✔
89
            thread_pool: create_rayon_thread_pool(0),
227✔
90
            exe_ctx_tiling_spec,
227✔
91
            query_ctx_chunk_size,
227✔
92
            pool,
227✔
93
            volumes,
227✔
94
        })
227✔
95
    }
227✔
96

97
    // TODO: check if the datasets exist already and don't output warnings when skipping them
98
    #[allow(clippy::too_many_arguments)]
99
    pub async fn new_with_data(
×
100
        config: Config,
×
101
        tls: Tls,
×
102
        dataset_defs_path: PathBuf,
×
103
        provider_defs_path: PathBuf,
×
104
        layer_defs_path: PathBuf,
×
105
        layer_collection_defs_path: PathBuf,
×
106
        exe_ctx_tiling_spec: TilingSpecification,
×
107
        query_ctx_chunk_size: ChunkByteSize,
×
108
    ) -> Result<Self> {
×
109
        let pg_mgr = PostgresConnectionManager::new(config, tls);
×
110

111
        let pool = Pool::builder().build(pg_mgr).await?;
×
112
        let created_schema = Self::create_database(pool.get().await?).await?;
×
113

114
        let session = if created_schema {
×
115
            let session = SimpleSession::default();
×
116
            Self::create_default_session(pool.get().await?, session.id()).await?;
×
117
            session
×
118
        } else {
119
            Self::load_default_session(pool.get().await?).await?
×
120
        };
121

122
        let app_ctx = PostgresContext {
×
123
            default_session_id: session.id(),
×
124
            task_manager: Default::default(),
×
125
            thread_pool: create_rayon_thread_pool(0),
×
126
            exe_ctx_tiling_spec,
×
127
            query_ctx_chunk_size,
×
128
            pool,
×
129
            volumes: Default::default(),
×
130
        };
×
131

×
132
        if created_schema {
×
133
            info!("Populating database with initial data...");
×
134

135
            let ctx = app_ctx.session_context(session);
×
136

×
137
            let mut db = ctx.db();
×
138
            add_layers_from_directory(&mut db, layer_defs_path).await;
×
139
            add_layer_collections_from_directory(&mut db, layer_collection_defs_path).await;
×
140

141
            add_datasets_from_directory(&mut db, dataset_defs_path).await;
×
142

143
            add_providers_from_directory(&mut db, provider_defs_path).await;
×
144
        }
×
145

146
        Ok(app_ctx)
×
147
    }
×
148

149
    async fn check_schema_status(
320✔
150
        conn: &PooledConnection<'_, PostgresConnectionManager<Tls>>,
320✔
151
    ) -> Result<DatabaseStatus> {
320✔
152
        let stmt = match conn
320✔
153
            .prepare("SELECT clear_database_on_start from geoengine;")
320✔
154
            .await
320✔
155
        {
156
            Ok(stmt) => stmt,
×
157
            Err(e) => {
320✔
158
                if let Some(code) = e.code() {
320✔
159
                    if *code == SqlState::UNDEFINED_TABLE {
320✔
160
                        info!("Initializing schema.");
320✔
161
                        return Ok(DatabaseStatus::Unitialized);
320✔
162
                    }
×
163
                }
×
164
                return Err(error::Error::TokioPostgres { source: e });
×
165
            }
166
        };
167

168
        let row = conn.query_one(&stmt, &[]).await?;
×
169

170
        if row.get(0) {
×
171
            Ok(DatabaseStatus::InitializedClearDatabase)
×
172
        } else {
173
            Ok(DatabaseStatus::InitializedKeepDatabase)
×
174
        }
175
    }
320✔
176

177
    /// Clears the database if the Settings demand and the database properties allows it.
178
    pub(crate) async fn maybe_clear_database(
320✔
179
        conn: &PooledConnection<'_, PostgresConnectionManager<Tls>>,
320✔
180
    ) -> Result<()> {
320✔
181
        let postgres_config = get_config_element::<crate::util::config::Postgres>()?;
320✔
182
        let database_status = Self::check_schema_status(conn).await?;
320✔
183
        let schema_name = postgres_config.schema;
320✔
184

185
        match database_status {
×
186
            DatabaseStatus::InitializedClearDatabase
×
187
                if postgres_config.clear_database_on_start && schema_name != "pg_temp" =>
×
188
            {
×
189
                info!("Clearing schema {}.", schema_name);
×
190
                conn.batch_execute(&format!("DROP SCHEMA {schema_name} CASCADE;"))
×
191
                    .await?;
×
192
            }
193
            DatabaseStatus::InitializedKeepDatabase if postgres_config.clear_database_on_start => {
×
194
                return Err(Error::ClearDatabaseOnStartupNotAllowed)
×
195
            }
196
            DatabaseStatus::InitializedClearDatabase
197
            | DatabaseStatus::InitializedKeepDatabase
198
            | DatabaseStatus::Unitialized => (),
320✔
199
        };
200

201
        Ok(())
320✔
202
    }
320✔
203

204
    /// Creates the database schema. Returns true if the schema was created, false if it already existed.
205
    pub(crate) async fn create_database(
227✔
206
        mut conn: PooledConnection<'_, PostgresConnectionManager<Tls>>,
227✔
207
    ) -> Result<bool> {
227✔
208
        Self::maybe_clear_database(&conn).await?;
227✔
209

210
        let migration = initialize_database(
227✔
211
            &mut conn,
227✔
212
            Box::new(CurrentSchemaMigration),
227✔
213
            &all_migrations(),
227✔
214
        )
227✔
215
        .await?;
2,724✔
216

217
        Ok(migration == MigrationResult::CreatedDatabase)
227✔
218
    }
227✔
219

220
    async fn create_default_session(
227✔
221
        conn: PooledConnection<'_, PostgresConnectionManager<Tls>>,
227✔
222
        session_id: SessionId,
227✔
223
    ) -> Result<()> {
227✔
224
        let stmt = conn
227✔
225
            .prepare("INSERT INTO sessions (id, project_id, view) VALUES ($1, NULL ,NULL);")
227✔
226
            .await?;
227✔
227

228
        conn.execute(&stmt, &[&session_id]).await?;
227✔
229

230
        Ok(())
227✔
231
    }
227✔
232
    async fn load_default_session(
71✔
233
        conn: PooledConnection<'_, PostgresConnectionManager<Tls>>,
71✔
234
    ) -> Result<SimpleSession> {
71✔
235
        let stmt = conn
71✔
236
            .prepare("SELECT id, project_id, view FROM sessions LIMIT 1;")
71✔
237
            .await?;
426✔
238

239
        let row = conn.query_one(&stmt, &[]).await?;
76✔
240

241
        Ok(SimpleSession::new(row.get(0), row.get(1), row.get(2)))
71✔
242
    }
71✔
243
}
244

245
#[async_trait]
246
impl<Tls> SimpleApplicationContext for PostgresContext<Tls>
247
where
248
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
249
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
250
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
251
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
252
{
253
    async fn default_session_id(&self) -> SessionId {
87✔
254
        self.default_session_id
87✔
255
    }
174✔
256

257
    async fn default_session(&self) -> Result<SimpleSession> {
71✔
258
        Self::load_default_session(self.pool.get().await?).await
502✔
259
    }
142✔
260

261
    async fn update_default_session_project(&self, project: ProjectId) -> Result<()> {
1✔
262
        let conn = self.pool.get().await?;
1✔
263

264
        let stmt = conn
1✔
265
            .prepare("UPDATE sessions SET project_id = $1 WHERE id = $2;")
1✔
266
            .await?;
1✔
267

268
        conn.execute(&stmt, &[&project, &self.default_session_id])
1✔
269
            .await?;
1✔
270

271
        Ok(())
1✔
272
    }
2✔
273

274
    async fn update_default_session_view(&self, view: STRectangle) -> Result<()> {
1✔
275
        let conn = self.pool.get().await?;
1✔
276

277
        let stmt = conn
1✔
278
            .prepare("UPDATE sessions SET view = $1 WHERE id = $2;")
1✔
279
            .await?;
1✔
280

281
        conn.execute(&stmt, &[&view, &self.default_session_id])
1✔
282
            .await?;
1✔
283

284
        Ok(())
1✔
285
    }
2✔
286

287
    async fn default_session_context(&self) -> Result<Self::SessionContext> {
363✔
288
        Ok(self.session_context(self.session_by_id(self.default_session_id).await?))
4,307✔
289
    }
726✔
290
}
291

292
#[async_trait]
293
impl<Tls> ApplicationContext for PostgresContext<Tls>
294
where
295
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
296
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
297
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
298
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
299
{
300
    type SessionContext = PostgresSessionContext<Tls>;
301
    type Session = SimpleSession;
302

303
    fn session_context(&self, session: Self::Session) -> Self::SessionContext {
549✔
304
        PostgresSessionContext {
549✔
305
            session,
549✔
306
            context: self.clone(),
549✔
307
        }
549✔
308
    }
549✔
309

310
    async fn session_by_id(&self, session_id: SessionId) -> Result<Self::Session> {
482✔
311
        let mut conn = self.pool.get().await?;
482✔
312

313
        let tx = conn.build_transaction().start().await?;
478✔
314

315
        let stmt = tx
477✔
316
            .prepare(
477✔
317
                "
477✔
318
            SELECT           
477✔
319
                project_id,
477✔
320
                view
477✔
321
            FROM sessions
477✔
322
            WHERE id = $1;",
477✔
323
            )
477✔
324
            .await?;
3,382✔
325

326
        let row = tx
477✔
327
            .query_one(&stmt, &[&session_id])
477✔
328
            .await
450✔
329
            .map_err(|_error| error::Error::InvalidSession)?;
477✔
330

331
        Ok(SimpleSession::new(session_id, row.get(0), row.get(1)))
477✔
332
    }
959✔
333
}
334

335
#[derive(Clone)]
336
pub struct PostgresSessionContext<Tls>
337
where
338
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
339
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
340
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
341
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
342
{
343
    session: SimpleSession,
344
    context: PostgresContext<Tls>,
345
}
346

347
#[async_trait]
348
impl<Tls> SessionContext for PostgresSessionContext<Tls>
349
where
350
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
351
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
352
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
353
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
354
{
355
    type Session = SimpleSession;
356
    type GeoEngineDB = PostgresDb<Tls>;
357

358
    type TaskContext = SimpleTaskManagerContext;
359
    type TaskManager = SimpleTaskManager; // this does not persist across restarts
360
    type QueryContext = QueryContextImpl;
361
    type ExecutionContext = ExecutionContextImpl<Self::GeoEngineDB>;
362

363
    fn db(&self) -> Self::GeoEngineDB {
563✔
364
        PostgresDb::new(self.context.pool.clone())
563✔
365
    }
563✔
366

367
    fn tasks(&self) -> Self::TaskManager {
40✔
368
        SimpleTaskManager::new(self.context.task_manager.clone())
40✔
369
    }
40✔
370

371
    fn query_context(&self) -> Result<Self::QueryContext> {
29✔
372
        Ok(QueryContextImpl::new(
29✔
373
            self.context.query_ctx_chunk_size,
29✔
374
            self.context.thread_pool.clone(),
29✔
375
        ))
29✔
376
    }
29✔
377

378
    fn execution_context(&self) -> Result<Self::ExecutionContext> {
48✔
379
        Ok(ExecutionContextImpl::<PostgresDb<Tls>>::new(
48✔
380
            self.db(),
48✔
381
            self.context.thread_pool.clone(),
48✔
382
            self.context.exe_ctx_tiling_spec,
48✔
383
        ))
48✔
384
    }
48✔
385

386
    fn volumes(&self) -> Result<Vec<Volume>> {
1✔
387
        Ok(self
1✔
388
            .context
1✔
389
            .volumes
1✔
390
            .volumes
1✔
391
            .iter()
1✔
392
            .map(|v| Volume {
1✔
393
                name: v.name.0.clone(),
1✔
394
                path: Some(v.path.to_string_lossy().to_string()),
1✔
395
            })
1✔
396
            .collect())
1✔
397
    }
1✔
398

399
    fn session(&self) -> &Self::Session {
116✔
400
        &self.session
116✔
401
    }
116✔
402
}
403

404
#[derive(Debug)]
405
pub struct PostgresDb<Tls>
406
where
407
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
408
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
409
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
410
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
411
{
412
    pub(crate) conn_pool: Pool<PostgresConnectionManager<Tls>>,
413
}
414

415
impl<Tls> PostgresDb<Tls>
416
where
417
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
418
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
419
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
420
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
421
{
422
    pub fn new(conn_pool: Pool<PostgresConnectionManager<Tls>>) -> Self {
564✔
423
        Self { conn_pool }
564✔
424
    }
564✔
425

426
    /// Check whether the namespace of the given dataset is allowed for insertion
427
    pub(crate) fn check_namespace(id: &DatasetName) -> Result<()> {
83✔
428
        // due to a lack of users, etc., we only allow one namespace for now
83✔
429
        if id.namespace.is_none() {
83✔
430
            Ok(())
83✔
431
        } else {
432
            Err(Error::InvalidDatasetIdNamespace)
×
433
        }
434
    }
83✔
435
}
436

437
impl<Tls> GeoEngineDb for PostgresDb<Tls>
438
where
439
    Tls: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static + std::fmt::Debug,
440
    <Tls as MakeTlsConnect<Socket>>::Stream: Send + Sync,
441
    <Tls as MakeTlsConnect<Socket>>::TlsConnect: Send,
442
    <<Tls as MakeTlsConnect<Socket>>::TlsConnect as TlsConnect<Socket>>::Future: Send,
443
{
444
}
445

446
impl TryFrom<config::Postgres> for Config {
447
    type Error = Error;
448

449
    fn try_from(db_config: config::Postgres) -> Result<Self> {
26✔
450
        ensure!(
26✔
451
            db_config.schema != "public",
26✔
452
            crate::error::InvalidDatabaseSchema
×
453
        );
454

455
        let mut pg_config = Config::new();
26✔
456
        pg_config
26✔
457
            .user(&db_config.user)
26✔
458
            .password(&db_config.password)
26✔
459
            .host(&db_config.host)
26✔
460
            .dbname(&db_config.database)
26✔
461
            .port(db_config.port)
26✔
462
            // fix schema by providing `search_path` option
26✔
463
            .options(format!("-c search_path={}", db_config.schema));
26✔
464
        Ok(pg_config)
26✔
465
    }
26✔
466
}
467

468
#[cfg(test)]
469
mod tests {
470
    use super::*;
471
    use crate::datasets::external::aruna::ArunaDataProviderDefinition;
472
    use crate::datasets::external::gbif::{GbifDataProvider, GbifDataProviderDefinition};
473
    use crate::datasets::external::gfbio_abcd::GfbioAbcdDataProviderDefinition;
474
    use crate::datasets::external::gfbio_collections::GfbioCollectionsDataProviderDefinition;
475
    use crate::datasets::external::netcdfcf::{
476
        EbvPortalDataProviderDefinition, NetCdfCfDataProviderDefinition,
477
    };
478
    use crate::datasets::external::pangaea::PangaeaDataProviderDefinition;
479
    use crate::datasets::listing::{DatasetListOptions, DatasetListing, ProvenanceOutput};
480
    use crate::datasets::listing::{DatasetProvider, Provenance};
481
    use crate::datasets::storage::{DatasetStore, MetaDataDefinition};
482
    use crate::datasets::upload::{FileId, UploadId};
483
    use crate::datasets::upload::{FileUpload, Upload, UploadDb};
484
    use crate::datasets::{AddDataset, DatasetIdAndName};
485
    use crate::ge_context;
486
    use crate::layers::add_from_directory::UNSORTED_COLLECTION_ID;
487
    use crate::layers::external::TypedDataProviderDefinition;
488
    use crate::layers::layer::{
489
        AddLayer, AddLayerCollection, CollectionItem, LayerCollection, LayerCollectionListOptions,
490
        LayerCollectionListing, LayerListing, Property, ProviderLayerCollectionId, ProviderLayerId,
491
    };
492
    use crate::layers::listing::{
493
        LayerCollectionId, LayerCollectionProvider, SearchParameters, SearchType,
494
    };
495
    use crate::layers::storage::{
496
        LayerDb, LayerProviderDb, LayerProviderListing, LayerProviderListingOptions,
497
        INTERNAL_PROVIDER_ID,
498
    };
499
    use crate::projects::{
500
        ColorParam, CreateProject, DerivedColor, DerivedNumber, LayerUpdate, LineSymbology,
501
        LoadVersion, NumberParam, OrderBy, Plot, PlotUpdate, PointSymbology, PolygonSymbology,
502
        ProjectDb, ProjectId, ProjectLayer, ProjectListOptions, ProjectListing, RasterSymbology,
503
        STRectangle, StrokeParam, Symbology, TextSymbology, UpdateProject,
504
    };
505
    use crate::util::encryption::U96;
506
    use crate::util::postgres::{assert_sql_type, DatabaseConnectionConfig};
507
    use crate::util::tests::register_ndvi_workflow_helper;
508
    use crate::workflows::registry::WorkflowRegistry;
509
    use crate::workflows::workflow::Workflow;
510
    use aes_gcm::aead::generic_array::arr;
511
    use bb8_postgres::tokio_postgres::NoTls;
512
    use futures::join;
513
    use geoengine_datatypes::collections::VectorDataType;
514
    use geoengine_datatypes::dataset::{DataProviderId, LayerId};
515
    use geoengine_datatypes::operations::image::{
516
        Breakpoint, Colorizer, RasterColorizer, RgbParams, RgbaColor,
517
    };
518
    use geoengine_datatypes::primitives::{
519
        BoundingBox2D, ClassificationMeasurement, ColumnSelection, ContinuousMeasurement,
520
        Coordinate2D, DateTimeParseFormat, FeatureDataType, MultiLineString, MultiPoint,
521
        MultiPolygon, NoGeometry, RasterQueryRectangle, SpatialPartition2D, SpatialResolution,
522
        TimeGranularity, TimeInstance, TimeInterval, TimeStep, TypedGeometry, VectorQueryRectangle,
523
    };
524
    use geoengine_datatypes::primitives::{CacheTtlSeconds, Measurement};
525
    use geoengine_datatypes::raster::{
526
        RasterDataType, RasterPropertiesEntryType, RasterPropertiesKey,
527
    };
528
    use geoengine_datatypes::spatial_reference::{SpatialReference, SpatialReferenceOption};
529
    use geoengine_datatypes::test_data;
530
    use geoengine_datatypes::util::test::TestDefault;
531
    use geoengine_datatypes::util::{NotNanF64, StringPair};
532
    use geoengine_operators::engine::{
533
        MetaData, MetaDataProvider, MultipleRasterOrSingleVectorSource, PlotOperator,
534
        PlotResultDescriptor, RasterBandDescriptor, RasterBandDescriptors, RasterResultDescriptor,
535
        StaticMetaData, TypedOperator, TypedResultDescriptor, VectorColumnInfo, VectorOperator,
536
        VectorResultDescriptor,
537
    };
538
    use geoengine_operators::mock::{
539
        MockDatasetDataSourceLoadingInfo, MockPointSource, MockPointSourceParams,
540
    };
541
    use geoengine_operators::plot::{Statistics, StatisticsParams};
542
    use geoengine_operators::source::{
543
        CsvHeader, FileNotFoundHandling, FormatSpecifics, GdalDatasetGeoTransform,
544
        GdalDatasetParameters, GdalLoadingInfo, GdalLoadingInfoTemporalSlice, GdalMetaDataList,
545
        GdalMetaDataRegular, GdalMetaDataStatic, GdalMetadataMapping, GdalMetadataNetCdfCf,
546
        GdalRetryOptions, GdalSourceTimePlaceholder, OgrSourceColumnSpec, OgrSourceDataset,
547
        OgrSourceDatasetTimeType, OgrSourceDurationSpec, OgrSourceErrorSpec, OgrSourceTimeFormat,
548
        TimeReference, UnixTimeStampType,
549
    };
550
    use geoengine_operators::util::input::MultiRasterOrVectorOperator::Raster;
551
    use ordered_float::NotNan;
552
    use serde_json::json;
553
    use std::marker::PhantomData;
554
    use std::str::FromStr;
555
    use tokio_postgres::config::Host;
556

557
    #[ge_context::test]
2✔
558
    async fn test(app_ctx: PostgresContext<NoTls>) {
1✔
559
        let session = app_ctx.default_session().await.unwrap();
18✔
560

1✔
561
        create_projects(&app_ctx, &session).await;
74✔
562

563
        let projects = list_projects(&app_ctx, &session).await;
13✔
564

565
        let project_id = projects[0].id;
1✔
566

1✔
567
        update_projects(&app_ctx, &session, project_id).await;
168✔
568

569
        delete_project(&app_ctx, &session, project_id).await;
7✔
570
    }
1✔
571

572
    async fn delete_project(
1✔
573
        app_ctx: &PostgresContext<NoTls>,
1✔
574
        session: &SimpleSession,
1✔
575
        project_id: ProjectId,
1✔
576
    ) {
1✔
577
        let db = app_ctx.session_context(session.clone()).db();
1✔
578

1✔
579
        db.delete_project(project_id).await.unwrap();
3✔
580

1✔
581
        assert!(db.load_project(project_id).await.is_err());
4✔
582
    }
1✔
583

584
    #[allow(clippy::too_many_lines)]
585
    async fn update_projects(
1✔
586
        app_ctx: &PostgresContext<NoTls>,
1✔
587
        session: &SimpleSession,
1✔
588
        project_id: ProjectId,
1✔
589
    ) {
1✔
590
        let db = app_ctx.session_context(session.clone()).db();
1✔
591

592
        let project = db
1✔
593
            .load_project_version(project_id, LoadVersion::Latest)
1✔
594
            .await
41✔
595
            .unwrap();
1✔
596

597
        let layer_workflow_id = db
1✔
598
            .register_workflow(Workflow {
1✔
599
                operator: TypedOperator::Vector(
1✔
600
                    MockPointSource {
1✔
601
                        params: MockPointSourceParams {
1✔
602
                            points: vec![Coordinate2D::new(1., 2.); 3],
1✔
603
                        },
1✔
604
                    }
1✔
605
                    .boxed(),
1✔
606
                ),
1✔
607
            })
1✔
608
            .await
3✔
609
            .unwrap();
1✔
610

1✔
611
        assert!(db.load_workflow(&layer_workflow_id).await.is_ok());
3✔
612

613
        let plot_workflow_id = db
1✔
614
            .register_workflow(Workflow {
1✔
615
                operator: Statistics {
1✔
616
                    params: StatisticsParams {
1✔
617
                        column_names: vec![],
1✔
618
                        percentiles: vec![],
1✔
619
                    },
1✔
620
                    sources: MultipleRasterOrSingleVectorSource {
1✔
621
                        source: Raster(vec![]),
1✔
622
                    },
1✔
623
                }
1✔
624
                .boxed()
1✔
625
                .into(),
1✔
626
            })
1✔
627
            .await
3✔
628
            .unwrap();
1✔
629

1✔
630
        assert!(db.load_workflow(&plot_workflow_id).await.is_ok());
3✔
631

632
        // add a plot
633
        let update = UpdateProject {
1✔
634
            id: project.id,
1✔
635
            name: Some("Test9 Updated".into()),
1✔
636
            description: None,
1✔
637
            layers: Some(vec![LayerUpdate::UpdateOrInsert(ProjectLayer {
1✔
638
                workflow: layer_workflow_id,
1✔
639
                name: "TestLayer".into(),
1✔
640
                symbology: PointSymbology::default().into(),
1✔
641
                visibility: Default::default(),
1✔
642
            })]),
1✔
643
            plots: Some(vec![PlotUpdate::UpdateOrInsert(Plot {
1✔
644
                workflow: plot_workflow_id,
1✔
645
                name: "Test Plot".into(),
1✔
646
            })]),
1✔
647
            bounds: None,
1✔
648
            time_step: None,
1✔
649
        };
1✔
650
        db.update_project(update).await.unwrap();
70✔
651

652
        let versions = db.list_project_versions(project_id).await.unwrap();
3✔
653
        assert_eq!(versions.len(), 2);
1✔
654

655
        // add second plot
656
        let update = UpdateProject {
1✔
657
            id: project.id,
1✔
658
            name: Some("Test9 Updated".into()),
1✔
659
            description: None,
1✔
660
            layers: Some(vec![LayerUpdate::UpdateOrInsert(ProjectLayer {
1✔
661
                workflow: layer_workflow_id,
1✔
662
                name: "TestLayer".into(),
1✔
663
                symbology: PointSymbology::default().into(),
1✔
664
                visibility: Default::default(),
1✔
665
            })]),
1✔
666
            plots: Some(vec![
1✔
667
                PlotUpdate::UpdateOrInsert(Plot {
1✔
668
                    workflow: plot_workflow_id,
1✔
669
                    name: "Test Plot".into(),
1✔
670
                }),
1✔
671
                PlotUpdate::UpdateOrInsert(Plot {
1✔
672
                    workflow: plot_workflow_id,
1✔
673
                    name: "Test Plot".into(),
1✔
674
                }),
1✔
675
            ]),
1✔
676
            bounds: None,
1✔
677
            time_step: None,
1✔
678
        };
1✔
679
        db.update_project(update).await.unwrap();
20✔
680

681
        let versions = db.list_project_versions(project_id).await.unwrap();
3✔
682
        assert_eq!(versions.len(), 3);
1✔
683

684
        // delete plots
685
        let update = UpdateProject {
1✔
686
            id: project.id,
1✔
687
            name: None,
1✔
688
            description: None,
1✔
689
            layers: None,
1✔
690
            plots: Some(vec![]),
1✔
691
            bounds: None,
1✔
692
            time_step: None,
1✔
693
        };
1✔
694
        db.update_project(update).await.unwrap();
16✔
695

696
        let versions = db.list_project_versions(project_id).await.unwrap();
3✔
697
        assert_eq!(versions.len(), 4);
1✔
698
    }
1✔
699

700
    async fn list_projects(
1✔
701
        app_ctx: &PostgresContext<NoTls>,
1✔
702
        session: &SimpleSession,
1✔
703
    ) -> Vec<ProjectListing> {
1✔
704
        let options = ProjectListOptions {
1✔
705
            order: OrderBy::NameDesc,
1✔
706
            offset: 0,
1✔
707
            limit: 2,
1✔
708
        };
1✔
709

1✔
710
        let db = app_ctx.session_context(session.clone()).db();
1✔
711

712
        let projects = db.list_projects(options).await.unwrap();
13✔
713

1✔
714
        assert_eq!(projects.len(), 2);
1✔
715
        assert_eq!(projects[0].name, "Test9");
1✔
716
        assert_eq!(projects[1].name, "Test8");
1✔
717
        projects
1✔
718
    }
1✔
719

720
    async fn create_projects(app_ctx: &PostgresContext<NoTls>, session: &SimpleSession) {
1✔
721
        let db = app_ctx.session_context(session.clone()).db();
1✔
722

723
        for i in 0..10 {
11✔
724
            let create = CreateProject {
10✔
725
                name: format!("Test{i}"),
10✔
726
                description: format!("Test{}", 10 - i),
10✔
727
                bounds: STRectangle::new(
10✔
728
                    SpatialReferenceOption::Unreferenced,
10✔
729
                    0.,
10✔
730
                    0.,
10✔
731
                    1.,
10✔
732
                    1.,
10✔
733
                    0,
10✔
734
                    1,
10✔
735
                )
10✔
736
                .unwrap(),
10✔
737
                time_step: None,
10✔
738
            };
10✔
739
            db.create_project(create).await.unwrap();
74✔
740
        }
741
    }
1✔
742

743
    #[ge_context::test]
2✔
744
    async fn it_persists_workflows(app_ctx: PostgresContext<NoTls>) {
1✔
745
        let workflow = Workflow {
1✔
746
            operator: TypedOperator::Vector(
1✔
747
                MockPointSource {
1✔
748
                    params: MockPointSourceParams {
1✔
749
                        points: vec![Coordinate2D::new(1., 2.); 3],
1✔
750
                    },
1✔
751
                }
1✔
752
                .boxed(),
1✔
753
            ),
1✔
754
        };
1✔
755

756
        let session = app_ctx.default_session().await.unwrap();
18✔
757
        let ctx = app_ctx.session_context(session);
1✔
758

1✔
759
        let db = ctx.db();
1✔
760
        let id = db.register_workflow(workflow).await.unwrap();
3✔
761

1✔
762
        drop(ctx);
1✔
763

764
        let workflow = db.load_workflow(&id).await.unwrap();
3✔
765

1✔
766
        let json = serde_json::to_string(&workflow).unwrap();
1✔
767
        assert_eq!(
1✔
768
            json,
1✔
769
            r#"{"type":"Vector","operator":{"type":"MockPointSource","params":{"points":[{"x":1.0,"y":2.0},{"x":1.0,"y":2.0},{"x":1.0,"y":2.0}]}}}"#
1✔
770
        );
1✔
771
    }
1✔
772

773
    #[allow(clippy::too_many_lines)]
774
    #[ge_context::test]
2✔
775
    async fn it_persists_datasets(app_ctx: PostgresContext<NoTls>) {
1✔
776
        let loading_info = OgrSourceDataset {
1✔
777
            file_name: PathBuf::from("test.csv"),
1✔
778
            layer_name: "test.csv".to_owned(),
1✔
779
            data_type: Some(VectorDataType::MultiPoint),
1✔
780
            time: OgrSourceDatasetTimeType::Start {
1✔
781
                start_field: "start".to_owned(),
1✔
782
                start_format: OgrSourceTimeFormat::Auto,
1✔
783
                duration: OgrSourceDurationSpec::Zero,
1✔
784
            },
1✔
785
            default_geometry: None,
1✔
786
            columns: Some(OgrSourceColumnSpec {
1✔
787
                format_specifics: Some(FormatSpecifics::Csv {
1✔
788
                    header: CsvHeader::Auto,
1✔
789
                }),
1✔
790
                x: "x".to_owned(),
1✔
791
                y: None,
1✔
792
                int: vec![],
1✔
793
                float: vec![],
1✔
794
                text: vec![],
1✔
795
                bool: vec![],
1✔
796
                datetime: vec![],
1✔
797
                rename: None,
1✔
798
            }),
1✔
799
            force_ogr_time_filter: false,
1✔
800
            force_ogr_spatial_filter: false,
1✔
801
            on_error: OgrSourceErrorSpec::Ignore,
1✔
802
            sql_query: None,
1✔
803
            attribute_query: None,
1✔
804
            cache_ttl: CacheTtlSeconds::default(),
1✔
805
        };
1✔
806

1✔
807
        let meta_data = MetaDataDefinition::OgrMetaData(StaticMetaData::<
1✔
808
            OgrSourceDataset,
1✔
809
            VectorResultDescriptor,
1✔
810
            VectorQueryRectangle,
1✔
811
        > {
1✔
812
            loading_info: loading_info.clone(),
1✔
813
            result_descriptor: VectorResultDescriptor {
1✔
814
                data_type: VectorDataType::MultiPoint,
1✔
815
                spatial_reference: SpatialReference::epsg_4326().into(),
1✔
816
                columns: [(
1✔
817
                    "foo".to_owned(),
1✔
818
                    VectorColumnInfo {
1✔
819
                        data_type: FeatureDataType::Float,
1✔
820
                        measurement: Measurement::Unitless,
1✔
821
                    },
1✔
822
                )]
1✔
823
                .into_iter()
1✔
824
                .collect(),
1✔
825
                time: None,
1✔
826
                bbox: None,
1✔
827
            },
1✔
828
            phantom: Default::default(),
1✔
829
        });
1✔
830

831
        let session = app_ctx.default_session().await.unwrap();
18✔
832

1✔
833
        let dataset_name = DatasetName::new(None, "my_dataset");
1✔
834

1✔
835
        let db = app_ctx.session_context(session.clone()).db();
1✔
836
        let DatasetIdAndName {
837
            id: dataset_id,
1✔
838
            name: dataset_name,
1✔
839
        } = db
1✔
840
            .add_dataset(
1✔
841
                AddDataset {
1✔
842
                    name: Some(dataset_name.clone()),
1✔
843
                    display_name: "Ogr Test".to_owned(),
1✔
844
                    description: "desc".to_owned(),
1✔
845
                    source_operator: "OgrSource".to_owned(),
1✔
846
                    symbology: None,
1✔
847
                    provenance: Some(vec![Provenance {
1✔
848
                        citation: "citation".to_owned(),
1✔
849
                        license: "license".to_owned(),
1✔
850
                        uri: "uri".to_owned(),
1✔
851
                    }]),
1✔
852
                    tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
853
                },
1✔
854
                meta_data,
1✔
855
            )
1✔
856
            .await
161✔
857
            .unwrap();
1✔
858

859
        let datasets = db
1✔
860
            .list_datasets(DatasetListOptions {
1✔
861
                filter: None,
1✔
862
                order: crate::datasets::listing::OrderBy::NameAsc,
1✔
863
                offset: 0,
1✔
864
                limit: 10,
1✔
865
                tags: None,
1✔
866
            })
1✔
867
            .await
3✔
868
            .unwrap();
1✔
869

1✔
870
        assert_eq!(datasets.len(), 1);
1✔
871

872
        assert_eq!(
1✔
873
            datasets[0],
1✔
874
            DatasetListing {
1✔
875
                id: dataset_id,
1✔
876
                name: dataset_name,
1✔
877
                display_name: "Ogr Test".to_owned(),
1✔
878
                description: "desc".to_owned(),
1✔
879
                source_operator: "OgrSource".to_owned(),
1✔
880
                symbology: None,
1✔
881
                tags: vec!["upload".to_owned(), "test".to_owned()],
1✔
882
                result_descriptor: TypedResultDescriptor::Vector(VectorResultDescriptor {
1✔
883
                    data_type: VectorDataType::MultiPoint,
1✔
884
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
885
                    columns: [(
1✔
886
                        "foo".to_owned(),
1✔
887
                        VectorColumnInfo {
1✔
888
                            data_type: FeatureDataType::Float,
1✔
889
                            measurement: Measurement::Unitless
1✔
890
                        }
1✔
891
                    )]
1✔
892
                    .into_iter()
1✔
893
                    .collect(),
1✔
894
                    time: None,
1✔
895
                    bbox: None,
1✔
896
                })
1✔
897
            },
1✔
898
        );
1✔
899

900
        let provenance = db.load_provenance(&dataset_id).await.unwrap();
3✔
901

1✔
902
        assert_eq!(
1✔
903
            provenance,
1✔
904
            ProvenanceOutput {
1✔
905
                data: dataset_id.into(),
1✔
906
                provenance: Some(vec![Provenance {
1✔
907
                    citation: "citation".to_owned(),
1✔
908
                    license: "license".to_owned(),
1✔
909
                    uri: "uri".to_owned(),
1✔
910
                }])
1✔
911
            }
1✔
912
        );
1✔
913

914
        let meta_data: Box<dyn MetaData<OgrSourceDataset, _, _>> =
1✔
915
            db.meta_data(&dataset_id.into()).await.unwrap();
3✔
916

917
        assert_eq!(
1✔
918
            meta_data
1✔
919
                .loading_info(VectorQueryRectangle {
1✔
920
                    spatial_bounds: BoundingBox2D::new_unchecked(
1✔
921
                        (-180., -90.).into(),
1✔
922
                        (180., 90.).into()
1✔
923
                    ),
1✔
924
                    time_interval: TimeInterval::default(),
1✔
925
                    spatial_resolution: SpatialResolution::zero_point_one(),
1✔
926
                    attributes: ColumnSelection::all()
1✔
927
                })
1✔
928
                .await
×
929
                .unwrap(),
1✔
930
            loading_info
931
        );
932
    }
1✔
933

934
    #[ge_context::test]
2✔
935
    async fn it_persists_uploads(app_ctx: PostgresContext<NoTls>) {
1✔
936
        let id = UploadId::from_str("2de18cd8-4a38-4111-a445-e3734bc18a80").unwrap();
1✔
937
        let input = Upload {
1✔
938
            id,
1✔
939
            files: vec![FileUpload {
1✔
940
                id: FileId::from_str("e80afab0-831d-4d40-95d6-1e4dfd277e72").unwrap(),
1✔
941
                name: "test.csv".to_owned(),
1✔
942
                byte_size: 1337,
1✔
943
            }],
1✔
944
        };
1✔
945

946
        let session = app_ctx.default_session().await.unwrap();
18✔
947

1✔
948
        let db = app_ctx.session_context(session.clone()).db();
1✔
949

1✔
950
        db.create_upload(input.clone()).await.unwrap();
6✔
951

952
        let upload = db.load_upload(id).await.unwrap();
3✔
953

1✔
954
        assert_eq!(upload, input);
1✔
955
    }
1✔
956

957
    #[allow(clippy::too_many_lines)]
958
    #[ge_context::test]
2✔
959
    async fn it_persists_layer_providers(app_ctx: PostgresContext<NoTls>) {
1✔
960
        let db = app_ctx.default_session_context().await.unwrap().db();
19✔
961

1✔
962
        let provider = NetCdfCfDataProviderDefinition {
1✔
963
            name: "netcdfcf".to_string(),
1✔
964
            description: "NetCdfCfProviderDefinition".to_string(),
1✔
965
            priority: Some(21),
1✔
966
            data: test_data!("netcdf4d/").into(),
1✔
967
            overviews: test_data!("netcdf4d/overviews/").into(),
1✔
968
            cache_ttl: CacheTtlSeconds::new(0),
1✔
969
        };
1✔
970

971
        let provider_id = db.add_layer_provider(provider.into()).await.unwrap();
33✔
972

973
        let providers = db
1✔
974
            .list_layer_providers(LayerProviderListingOptions {
1✔
975
                offset: 0,
1✔
976
                limit: 10,
1✔
977
            })
1✔
978
            .await
3✔
979
            .unwrap();
1✔
980

1✔
981
        assert_eq!(providers.len(), 1);
1✔
982

983
        assert_eq!(
1✔
984
            providers[0],
1✔
985
            LayerProviderListing {
1✔
986
                id: provider_id,
1✔
987
                name: "netcdfcf".to_owned(),
1✔
988
                priority: 21,
1✔
989
            }
1✔
990
        );
1✔
991

992
        let provider = db.load_layer_provider(provider_id).await.unwrap();
3✔
993

994
        let datasets = provider
1✔
995
            .load_layer_collection(
1✔
996
                &provider.get_root_layer_collection_id().await.unwrap(),
1✔
997
                LayerCollectionListOptions {
1✔
998
                    offset: 0,
1✔
999
                    limit: 10,
1✔
1000
                },
1✔
1001
            )
1002
            .await
5✔
1003
            .unwrap();
1✔
1004

1✔
1005
        assert_eq!(datasets.items.len(), 5, "{:?}", datasets.items);
1✔
1006
    }
1✔
1007

1008
    #[allow(clippy::too_many_lines)]
1009
    #[ge_context::test]
2✔
1010
    async fn it_loads_all_meta_data_types(app_ctx: PostgresContext<NoTls>) {
1✔
1011
        let session = app_ctx.default_session().await.unwrap();
18✔
1012

1✔
1013
        let db = app_ctx.session_context(session.clone()).db();
1✔
1014

1✔
1015
        let vector_descriptor = VectorResultDescriptor {
1✔
1016
            data_type: VectorDataType::Data,
1✔
1017
            spatial_reference: SpatialReferenceOption::Unreferenced,
1✔
1018
            columns: Default::default(),
1✔
1019
            time: None,
1✔
1020
            bbox: None,
1✔
1021
        };
1✔
1022

1✔
1023
        let raster_descriptor = RasterResultDescriptor {
1✔
1024
            data_type: RasterDataType::U8,
1✔
1025
            spatial_reference: SpatialReferenceOption::Unreferenced,
1✔
1026
            time: None,
1✔
1027
            bbox: None,
1✔
1028
            resolution: None,
1✔
1029
            bands: RasterBandDescriptors::new_single_band(),
1✔
1030
        };
1✔
1031

1✔
1032
        let vector_ds = AddDataset {
1✔
1033
            name: None,
1✔
1034
            display_name: "OgrDataset".to_string(),
1✔
1035
            description: "My Ogr dataset".to_string(),
1✔
1036
            source_operator: "OgrSource".to_string(),
1✔
1037
            symbology: None,
1✔
1038
            provenance: None,
1✔
1039
            tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
1040
        };
1✔
1041

1✔
1042
        let raster_ds = AddDataset {
1✔
1043
            name: None,
1✔
1044
            display_name: "GdalDataset".to_string(),
1✔
1045
            description: "My Gdal dataset".to_string(),
1✔
1046
            source_operator: "GdalSource".to_string(),
1✔
1047
            symbology: None,
1✔
1048
            provenance: None,
1✔
1049
            tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
1050
        };
1✔
1051

1✔
1052
        let gdal_params = GdalDatasetParameters {
1✔
1053
            file_path: Default::default(),
1✔
1054
            rasterband_channel: 0,
1✔
1055
            geo_transform: GdalDatasetGeoTransform {
1✔
1056
                origin_coordinate: Default::default(),
1✔
1057
                x_pixel_size: 0.0,
1✔
1058
                y_pixel_size: 0.0,
1✔
1059
            },
1✔
1060
            width: 0,
1✔
1061
            height: 0,
1✔
1062
            file_not_found_handling: FileNotFoundHandling::NoData,
1✔
1063
            no_data_value: None,
1✔
1064
            properties_mapping: None,
1✔
1065
            gdal_open_options: None,
1✔
1066
            gdal_config_options: None,
1✔
1067
            allow_alphaband_as_mask: false,
1✔
1068
            retry: None,
1✔
1069
        };
1✔
1070

1✔
1071
        let meta = StaticMetaData {
1✔
1072
            loading_info: OgrSourceDataset {
1✔
1073
                file_name: Default::default(),
1✔
1074
                layer_name: String::new(),
1✔
1075
                data_type: None,
1✔
1076
                time: Default::default(),
1✔
1077
                default_geometry: None,
1✔
1078
                columns: None,
1✔
1079
                force_ogr_time_filter: false,
1✔
1080
                force_ogr_spatial_filter: false,
1✔
1081
                on_error: OgrSourceErrorSpec::Ignore,
1✔
1082
                sql_query: None,
1✔
1083
                attribute_query: None,
1✔
1084
                cache_ttl: CacheTtlSeconds::default(),
1✔
1085
            },
1✔
1086
            result_descriptor: vector_descriptor.clone(),
1✔
1087
            phantom: Default::default(),
1✔
1088
        };
1✔
1089

1090
        let id = db.add_dataset(vector_ds, meta.into()).await.unwrap().id;
160✔
1091

1092
        let meta: geoengine_operators::util::Result<
1✔
1093
            Box<dyn MetaData<OgrSourceDataset, VectorResultDescriptor, VectorQueryRectangle>>,
1✔
1094
        > = db.meta_data(&id.into()).await;
3✔
1095

1096
        assert!(meta.is_ok());
1✔
1097

1098
        let meta = GdalMetaDataRegular {
1✔
1099
            result_descriptor: raster_descriptor.clone(),
1✔
1100
            params: gdal_params.clone(),
1✔
1101
            time_placeholders: Default::default(),
1✔
1102
            data_time: Default::default(),
1✔
1103
            step: TimeStep {
1✔
1104
                granularity: TimeGranularity::Millis,
1✔
1105
                step: 0,
1✔
1106
            },
1✔
1107
            cache_ttl: CacheTtlSeconds::default(),
1✔
1108
        };
1✔
1109

1110
        let id = db
1✔
1111
            .add_dataset(raster_ds.clone(), meta.into())
1✔
1112
            .await
5✔
1113
            .unwrap()
1✔
1114
            .id;
1115

1116
        let meta: geoengine_operators::util::Result<
1✔
1117
            Box<dyn MetaData<GdalLoadingInfo, RasterResultDescriptor, RasterQueryRectangle>>,
1✔
1118
        > = db.meta_data(&id.into()).await;
3✔
1119

1120
        assert!(meta.is_ok());
1✔
1121

1122
        let meta = GdalMetaDataStatic {
1✔
1123
            time: None,
1✔
1124
            params: gdal_params.clone(),
1✔
1125
            result_descriptor: raster_descriptor.clone(),
1✔
1126
            cache_ttl: CacheTtlSeconds::default(),
1✔
1127
        };
1✔
1128

1129
        let id = db
1✔
1130
            .add_dataset(raster_ds.clone(), meta.into())
1✔
1131
            .await
5✔
1132
            .unwrap()
1✔
1133
            .id;
1134

1135
        let meta: geoengine_operators::util::Result<
1✔
1136
            Box<dyn MetaData<GdalLoadingInfo, RasterResultDescriptor, RasterQueryRectangle>>,
1✔
1137
        > = db.meta_data(&id.into()).await;
3✔
1138

1139
        assert!(meta.is_ok());
1✔
1140

1141
        let meta = GdalMetaDataList {
1✔
1142
            result_descriptor: raster_descriptor.clone(),
1✔
1143
            params: vec![],
1✔
1144
        };
1✔
1145

1146
        let id = db
1✔
1147
            .add_dataset(raster_ds.clone(), meta.into())
1✔
1148
            .await
5✔
1149
            .unwrap()
1✔
1150
            .id;
1151

1152
        let meta: geoengine_operators::util::Result<
1✔
1153
            Box<dyn MetaData<GdalLoadingInfo, RasterResultDescriptor, RasterQueryRectangle>>,
1✔
1154
        > = db.meta_data(&id.into()).await;
3✔
1155

1156
        assert!(meta.is_ok());
1✔
1157

1158
        let meta = GdalMetadataNetCdfCf {
1✔
1159
            result_descriptor: raster_descriptor.clone(),
1✔
1160
            params: gdal_params.clone(),
1✔
1161
            start: TimeInstance::MIN,
1✔
1162
            end: TimeInstance::MAX,
1✔
1163
            step: TimeStep {
1✔
1164
                granularity: TimeGranularity::Millis,
1✔
1165
                step: 0,
1✔
1166
            },
1✔
1167
            band_offset: 0,
1✔
1168
            cache_ttl: CacheTtlSeconds::default(),
1✔
1169
        };
1✔
1170

1171
        let id = db
1✔
1172
            .add_dataset(raster_ds.clone(), meta.into())
1✔
1173
            .await
5✔
1174
            .unwrap()
1✔
1175
            .id;
1176

1177
        let meta: geoengine_operators::util::Result<
1✔
1178
            Box<dyn MetaData<GdalLoadingInfo, RasterResultDescriptor, RasterQueryRectangle>>,
1✔
1179
        > = db.meta_data(&id.into()).await;
3✔
1180

1181
        assert!(meta.is_ok());
1✔
1182
    }
1✔
1183

1184
    #[allow(clippy::too_many_lines)]
1185
    #[ge_context::test]
2✔
1186
    async fn it_collects_layers(app_ctx: PostgresContext<NoTls>) {
1✔
1187
        let session = app_ctx.default_session().await.unwrap();
18✔
1188

1✔
1189
        let layer_db = app_ctx.session_context(session).db();
1✔
1190

1✔
1191
        let workflow = Workflow {
1✔
1192
            operator: TypedOperator::Vector(
1✔
1193
                MockPointSource {
1✔
1194
                    params: MockPointSourceParams {
1✔
1195
                        points: vec![Coordinate2D::new(1., 2.); 3],
1✔
1196
                    },
1✔
1197
                }
1✔
1198
                .boxed(),
1✔
1199
            ),
1✔
1200
        };
1✔
1201

1202
        let root_collection_id = layer_db.get_root_layer_collection_id().await.unwrap();
1✔
1203

1204
        let layer1 = layer_db
1✔
1205
            .add_layer(
1✔
1206
                AddLayer {
1✔
1207
                    name: "Layer1".to_string(),
1✔
1208
                    description: "Layer 1".to_string(),
1✔
1209
                    symbology: None,
1✔
1210
                    workflow: workflow.clone(),
1✔
1211
                    metadata: [("meta".to_string(), "datum".to_string())].into(),
1✔
1212
                    properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1213
                },
1✔
1214
                &root_collection_id,
1✔
1215
            )
1✔
1216
            .await
45✔
1217
            .unwrap();
1✔
1218

1219
        assert_eq!(
1✔
1220
            layer_db.load_layer(&layer1).await.unwrap(),
3✔
1221
            crate::layers::layer::Layer {
1✔
1222
                id: ProviderLayerId {
1✔
1223
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1224
                    layer_id: layer1.clone(),
1✔
1225
                },
1✔
1226
                name: "Layer1".to_string(),
1✔
1227
                description: "Layer 1".to_string(),
1✔
1228
                symbology: None,
1✔
1229
                workflow: workflow.clone(),
1✔
1230
                metadata: [("meta".to_string(), "datum".to_string())].into(),
1✔
1231
                properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1232
            }
1✔
1233
        );
1234

1235
        let collection1_id = layer_db
1✔
1236
            .add_layer_collection(
1✔
1237
                AddLayerCollection {
1✔
1238
                    name: "Collection1".to_string(),
1✔
1239
                    description: "Collection 1".to_string(),
1✔
1240
                    properties: Default::default(),
1✔
1241
                },
1✔
1242
                &root_collection_id,
1✔
1243
            )
1✔
1244
            .await
7✔
1245
            .unwrap();
1✔
1246

1247
        let layer2 = layer_db
1✔
1248
            .add_layer(
1✔
1249
                AddLayer {
1✔
1250
                    name: "Layer2".to_string(),
1✔
1251
                    description: "Layer 2".to_string(),
1✔
1252
                    symbology: None,
1✔
1253
                    workflow: workflow.clone(),
1✔
1254
                    metadata: Default::default(),
1✔
1255
                    properties: Default::default(),
1✔
1256
                },
1✔
1257
                &collection1_id,
1✔
1258
            )
1✔
1259
            .await
9✔
1260
            .unwrap();
1✔
1261

1262
        let collection2_id = layer_db
1✔
1263
            .add_layer_collection(
1✔
1264
                AddLayerCollection {
1✔
1265
                    name: "Collection2".to_string(),
1✔
1266
                    description: "Collection 2".to_string(),
1✔
1267
                    properties: Default::default(),
1✔
1268
                },
1✔
1269
                &collection1_id,
1✔
1270
            )
1✔
1271
            .await
7✔
1272
            .unwrap();
1✔
1273

1✔
1274
        layer_db
1✔
1275
            .add_collection_to_parent(&collection2_id, &collection1_id)
1✔
1276
            .await
3✔
1277
            .unwrap();
1✔
1278

1279
        let root_collection = layer_db
1✔
1280
            .load_layer_collection(
1✔
1281
                &root_collection_id,
1✔
1282
                LayerCollectionListOptions {
1✔
1283
                    offset: 0,
1✔
1284
                    limit: 20,
1✔
1285
                },
1✔
1286
            )
1✔
1287
            .await
5✔
1288
            .unwrap();
1✔
1289

1✔
1290
        assert_eq!(
1✔
1291
            root_collection,
1✔
1292
            LayerCollection {
1✔
1293
                id: ProviderLayerCollectionId {
1✔
1294
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1295
                    collection_id: root_collection_id,
1✔
1296
                },
1✔
1297
                name: "Layers".to_string(),
1✔
1298
                description: "All available Geo Engine layers".to_string(),
1✔
1299
                items: vec![
1✔
1300
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1301
                        id: ProviderLayerCollectionId {
1✔
1302
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1303
                            collection_id: collection1_id.clone(),
1✔
1304
                        },
1✔
1305
                        name: "Collection1".to_string(),
1✔
1306
                        description: "Collection 1".to_string(),
1✔
1307
                        properties: Default::default(),
1✔
1308
                    }),
1✔
1309
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1310
                        id: ProviderLayerCollectionId {
1✔
1311
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1312
                            collection_id: LayerCollectionId(UNSORTED_COLLECTION_ID.to_string()),
1✔
1313
                        },
1✔
1314
                        name: "Unsorted".to_string(),
1✔
1315
                        description: "Unsorted Layers".to_string(),
1✔
1316
                        properties: Default::default(),
1✔
1317
                    }),
1✔
1318
                    CollectionItem::Layer(LayerListing {
1✔
1319
                        id: ProviderLayerId {
1✔
1320
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1321
                            layer_id: layer1,
1✔
1322
                        },
1✔
1323
                        name: "Layer1".to_string(),
1✔
1324
                        description: "Layer 1".to_string(),
1✔
1325
                        properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1326
                    })
1✔
1327
                ],
1✔
1328
                entry_label: None,
1✔
1329
                properties: vec![],
1✔
1330
            }
1✔
1331
        );
1✔
1332

1333
        let collection1 = layer_db
1✔
1334
            .load_layer_collection(
1✔
1335
                &collection1_id,
1✔
1336
                LayerCollectionListOptions {
1✔
1337
                    offset: 0,
1✔
1338
                    limit: 20,
1✔
1339
                },
1✔
1340
            )
1✔
1341
            .await
5✔
1342
            .unwrap();
1✔
1343

1✔
1344
        assert_eq!(
1✔
1345
            collection1,
1✔
1346
            LayerCollection {
1✔
1347
                id: ProviderLayerCollectionId {
1✔
1348
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1349
                    collection_id: collection1_id,
1✔
1350
                },
1✔
1351
                name: "Collection1".to_string(),
1✔
1352
                description: "Collection 1".to_string(),
1✔
1353
                items: vec![
1✔
1354
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1355
                        id: ProviderLayerCollectionId {
1✔
1356
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1357
                            collection_id: collection2_id,
1✔
1358
                        },
1✔
1359
                        name: "Collection2".to_string(),
1✔
1360
                        description: "Collection 2".to_string(),
1✔
1361
                        properties: Default::default(),
1✔
1362
                    }),
1✔
1363
                    CollectionItem::Layer(LayerListing {
1✔
1364
                        id: ProviderLayerId {
1✔
1365
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1366
                            layer_id: layer2,
1✔
1367
                        },
1✔
1368
                        name: "Layer2".to_string(),
1✔
1369
                        description: "Layer 2".to_string(),
1✔
1370
                        properties: vec![],
1✔
1371
                    })
1✔
1372
                ],
1✔
1373
                entry_label: None,
1✔
1374
                properties: vec![],
1✔
1375
            }
1✔
1376
        );
1✔
1377
    }
1✔
1378

1379
    #[allow(clippy::too_many_lines)]
1380
    #[ge_context::test]
2✔
1381
    async fn it_searches_layers(app_ctx: PostgresContext<NoTls>) {
1✔
1382
        let session = app_ctx.default_session().await.unwrap();
18✔
1383

1✔
1384
        let layer_db = app_ctx.session_context(session).db();
1✔
1385

1✔
1386
        let workflow = Workflow {
1✔
1387
            operator: TypedOperator::Vector(
1✔
1388
                MockPointSource {
1✔
1389
                    params: MockPointSourceParams {
1✔
1390
                        points: vec![Coordinate2D::new(1., 2.); 3],
1✔
1391
                    },
1✔
1392
                }
1✔
1393
                .boxed(),
1✔
1394
            ),
1✔
1395
        };
1✔
1396

1397
        let root_collection_id = layer_db.get_root_layer_collection_id().await.unwrap();
1✔
1398

1399
        let layer1 = layer_db
1✔
1400
            .add_layer(
1✔
1401
                AddLayer {
1✔
1402
                    name: "Layer1".to_string(),
1✔
1403
                    description: "Layer 1".to_string(),
1✔
1404
                    symbology: None,
1✔
1405
                    workflow: workflow.clone(),
1✔
1406
                    metadata: [("meta".to_string(), "datum".to_string())].into(),
1✔
1407
                    properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1408
                },
1✔
1409
                &root_collection_id,
1✔
1410
            )
1✔
1411
            .await
45✔
1412
            .unwrap();
1✔
1413

1414
        let collection1_id = layer_db
1✔
1415
            .add_layer_collection(
1✔
1416
                AddLayerCollection {
1✔
1417
                    name: "Collection1".to_string(),
1✔
1418
                    description: "Collection 1".to_string(),
1✔
1419
                    properties: Default::default(),
1✔
1420
                },
1✔
1421
                &root_collection_id,
1✔
1422
            )
1✔
1423
            .await
7✔
1424
            .unwrap();
1✔
1425

1426
        let layer2 = layer_db
1✔
1427
            .add_layer(
1✔
1428
                AddLayer {
1✔
1429
                    name: "Layer2".to_string(),
1✔
1430
                    description: "Layer 2".to_string(),
1✔
1431
                    symbology: None,
1✔
1432
                    workflow: workflow.clone(),
1✔
1433
                    metadata: Default::default(),
1✔
1434
                    properties: Default::default(),
1✔
1435
                },
1✔
1436
                &collection1_id,
1✔
1437
            )
1✔
1438
            .await
9✔
1439
            .unwrap();
1✔
1440

1441
        let collection2_id = layer_db
1✔
1442
            .add_layer_collection(
1✔
1443
                AddLayerCollection {
1✔
1444
                    name: "Collection2".to_string(),
1✔
1445
                    description: "Collection 2".to_string(),
1✔
1446
                    properties: Default::default(),
1✔
1447
                },
1✔
1448
                &collection1_id,
1✔
1449
            )
1✔
1450
            .await
7✔
1451
            .unwrap();
1✔
1452

1453
        let root_collection_all = layer_db
1✔
1454
            .search(
1✔
1455
                &root_collection_id,
1✔
1456
                SearchParameters {
1✔
1457
                    search_type: SearchType::Fulltext,
1✔
1458
                    search_string: String::new(),
1✔
1459
                    limit: 10,
1✔
1460
                    offset: 0,
1✔
1461
                },
1✔
1462
            )
1✔
1463
            .await
5✔
1464
            .unwrap();
1✔
1465

1✔
1466
        assert_eq!(
1✔
1467
            root_collection_all,
1✔
1468
            LayerCollection {
1✔
1469
                id: ProviderLayerCollectionId {
1✔
1470
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1471
                    collection_id: root_collection_id.clone(),
1✔
1472
                },
1✔
1473
                name: "Layers".to_string(),
1✔
1474
                description: "All available Geo Engine layers".to_string(),
1✔
1475
                items: vec![
1✔
1476
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1477
                        id: ProviderLayerCollectionId {
1✔
1478
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1479
                            collection_id: collection1_id.clone(),
1✔
1480
                        },
1✔
1481
                        name: "Collection1".to_string(),
1✔
1482
                        description: "Collection 1".to_string(),
1✔
1483
                        properties: Default::default(),
1✔
1484
                    }),
1✔
1485
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1486
                        id: ProviderLayerCollectionId {
1✔
1487
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1488
                            collection_id: collection2_id.clone(),
1✔
1489
                        },
1✔
1490
                        name: "Collection2".to_string(),
1✔
1491
                        description: "Collection 2".to_string(),
1✔
1492
                        properties: Default::default(),
1✔
1493
                    }),
1✔
1494
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1495
                        id: ProviderLayerCollectionId {
1✔
1496
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1497
                            collection_id: LayerCollectionId(
1✔
1498
                                "ffb2dd9e-f5ad-427c-b7f1-c9a0c7a0ae3f".to_string()
1✔
1499
                            ),
1✔
1500
                        },
1✔
1501
                        name: "Unsorted".to_string(),
1✔
1502
                        description: "Unsorted Layers".to_string(),
1✔
1503
                        properties: Default::default(),
1✔
1504
                    }),
1✔
1505
                    CollectionItem::Layer(LayerListing {
1✔
1506
                        id: ProviderLayerId {
1✔
1507
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1508
                            layer_id: layer1.clone(),
1✔
1509
                        },
1✔
1510
                        name: "Layer1".to_string(),
1✔
1511
                        description: "Layer 1".to_string(),
1✔
1512
                        properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1513
                    }),
1✔
1514
                    CollectionItem::Layer(LayerListing {
1✔
1515
                        id: ProviderLayerId {
1✔
1516
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1517
                            layer_id: layer2.clone(),
1✔
1518
                        },
1✔
1519
                        name: "Layer2".to_string(),
1✔
1520
                        description: "Layer 2".to_string(),
1✔
1521
                        properties: vec![],
1✔
1522
                    }),
1✔
1523
                ],
1✔
1524
                entry_label: None,
1✔
1525
                properties: vec![],
1✔
1526
            }
1✔
1527
        );
1✔
1528

1529
        let root_collection_filtered = layer_db
1✔
1530
            .search(
1✔
1531
                &root_collection_id,
1✔
1532
                SearchParameters {
1✔
1533
                    search_type: SearchType::Fulltext,
1✔
1534
                    search_string: "lection".to_string(),
1✔
1535
                    limit: 10,
1✔
1536
                    offset: 0,
1✔
1537
                },
1✔
1538
            )
1✔
1539
            .await
5✔
1540
            .unwrap();
1✔
1541

1✔
1542
        assert_eq!(
1✔
1543
            root_collection_filtered,
1✔
1544
            LayerCollection {
1✔
1545
                id: ProviderLayerCollectionId {
1✔
1546
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1547
                    collection_id: root_collection_id.clone(),
1✔
1548
                },
1✔
1549
                name: "Layers".to_string(),
1✔
1550
                description: "All available Geo Engine layers".to_string(),
1✔
1551
                items: vec![
1✔
1552
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1553
                        id: ProviderLayerCollectionId {
1✔
1554
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1555
                            collection_id: collection1_id.clone(),
1✔
1556
                        },
1✔
1557
                        name: "Collection1".to_string(),
1✔
1558
                        description: "Collection 1".to_string(),
1✔
1559
                        properties: Default::default(),
1✔
1560
                    }),
1✔
1561
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1562
                        id: ProviderLayerCollectionId {
1✔
1563
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1564
                            collection_id: collection2_id.clone(),
1✔
1565
                        },
1✔
1566
                        name: "Collection2".to_string(),
1✔
1567
                        description: "Collection 2".to_string(),
1✔
1568
                        properties: Default::default(),
1✔
1569
                    }),
1✔
1570
                ],
1✔
1571
                entry_label: None,
1✔
1572
                properties: vec![],
1✔
1573
            }
1✔
1574
        );
1✔
1575

1576
        let collection1_all = layer_db
1✔
1577
            .search(
1✔
1578
                &collection1_id,
1✔
1579
                SearchParameters {
1✔
1580
                    search_type: SearchType::Fulltext,
1✔
1581
                    search_string: String::new(),
1✔
1582
                    limit: 10,
1✔
1583
                    offset: 0,
1✔
1584
                },
1✔
1585
            )
1✔
1586
            .await
5✔
1587
            .unwrap();
1✔
1588

1✔
1589
        assert_eq!(
1✔
1590
            collection1_all,
1✔
1591
            LayerCollection {
1✔
1592
                id: ProviderLayerCollectionId {
1✔
1593
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1594
                    collection_id: collection1_id.clone(),
1✔
1595
                },
1✔
1596
                name: "Collection1".to_string(),
1✔
1597
                description: "Collection 1".to_string(),
1✔
1598
                items: vec![
1✔
1599
                    CollectionItem::Collection(LayerCollectionListing {
1✔
1600
                        id: ProviderLayerCollectionId {
1✔
1601
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1602
                            collection_id: collection2_id.clone(),
1✔
1603
                        },
1✔
1604
                        name: "Collection2".to_string(),
1✔
1605
                        description: "Collection 2".to_string(),
1✔
1606
                        properties: Default::default(),
1✔
1607
                    }),
1✔
1608
                    CollectionItem::Layer(LayerListing {
1✔
1609
                        id: ProviderLayerId {
1✔
1610
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
1611
                            layer_id: layer2.clone(),
1✔
1612
                        },
1✔
1613
                        name: "Layer2".to_string(),
1✔
1614
                        description: "Layer 2".to_string(),
1✔
1615
                        properties: vec![],
1✔
1616
                    }),
1✔
1617
                ],
1✔
1618
                entry_label: None,
1✔
1619
                properties: vec![],
1✔
1620
            }
1✔
1621
        );
1✔
1622

1623
        let collection1_filtered_fulltext = layer_db
1✔
1624
            .search(
1✔
1625
                &collection1_id,
1✔
1626
                SearchParameters {
1✔
1627
                    search_type: SearchType::Fulltext,
1✔
1628
                    search_string: "ay".to_string(),
1✔
1629
                    limit: 10,
1✔
1630
                    offset: 0,
1✔
1631
                },
1✔
1632
            )
1✔
1633
            .await
5✔
1634
            .unwrap();
1✔
1635

1✔
1636
        assert_eq!(
1✔
1637
            collection1_filtered_fulltext,
1✔
1638
            LayerCollection {
1✔
1639
                id: ProviderLayerCollectionId {
1✔
1640
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1641
                    collection_id: collection1_id.clone(),
1✔
1642
                },
1✔
1643
                name: "Collection1".to_string(),
1✔
1644
                description: "Collection 1".to_string(),
1✔
1645
                items: vec![CollectionItem::Layer(LayerListing {
1✔
1646
                    id: ProviderLayerId {
1✔
1647
                        provider_id: INTERNAL_PROVIDER_ID,
1✔
1648
                        layer_id: layer2.clone(),
1✔
1649
                    },
1✔
1650
                    name: "Layer2".to_string(),
1✔
1651
                    description: "Layer 2".to_string(),
1✔
1652
                    properties: vec![],
1✔
1653
                }),],
1✔
1654
                entry_label: None,
1✔
1655
                properties: vec![],
1✔
1656
            }
1✔
1657
        );
1✔
1658

1659
        let collection1_filtered_prefix = layer_db
1✔
1660
            .search(
1✔
1661
                &collection1_id,
1✔
1662
                SearchParameters {
1✔
1663
                    search_type: SearchType::Prefix,
1✔
1664
                    search_string: "ay".to_string(),
1✔
1665
                    limit: 10,
1✔
1666
                    offset: 0,
1✔
1667
                },
1✔
1668
            )
1✔
1669
            .await
5✔
1670
            .unwrap();
1✔
1671

1✔
1672
        assert_eq!(
1✔
1673
            collection1_filtered_prefix,
1✔
1674
            LayerCollection {
1✔
1675
                id: ProviderLayerCollectionId {
1✔
1676
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1677
                    collection_id: collection1_id.clone(),
1✔
1678
                },
1✔
1679
                name: "Collection1".to_string(),
1✔
1680
                description: "Collection 1".to_string(),
1✔
1681
                items: vec![],
1✔
1682
                entry_label: None,
1✔
1683
                properties: vec![],
1✔
1684
            }
1✔
1685
        );
1✔
1686

1687
        let collection1_filtered_prefix2 = layer_db
1✔
1688
            .search(
1✔
1689
                &collection1_id,
1✔
1690
                SearchParameters {
1✔
1691
                    search_type: SearchType::Prefix,
1✔
1692
                    search_string: "Lay".to_string(),
1✔
1693
                    limit: 10,
1✔
1694
                    offset: 0,
1✔
1695
                },
1✔
1696
            )
1✔
1697
            .await
5✔
1698
            .unwrap();
1✔
1699

1✔
1700
        assert_eq!(
1✔
1701
            collection1_filtered_prefix2,
1✔
1702
            LayerCollection {
1✔
1703
                id: ProviderLayerCollectionId {
1✔
1704
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
1705
                    collection_id: collection1_id.clone(),
1✔
1706
                },
1✔
1707
                name: "Collection1".to_string(),
1✔
1708
                description: "Collection 1".to_string(),
1✔
1709
                items: vec![CollectionItem::Layer(LayerListing {
1✔
1710
                    id: ProviderLayerId {
1✔
1711
                        provider_id: INTERNAL_PROVIDER_ID,
1✔
1712
                        layer_id: layer2.clone(),
1✔
1713
                    },
1✔
1714
                    name: "Layer2".to_string(),
1✔
1715
                    description: "Layer 2".to_string(),
1✔
1716
                    properties: vec![],
1✔
1717
                }),],
1✔
1718
                entry_label: None,
1✔
1719
                properties: vec![],
1✔
1720
            }
1✔
1721
        );
1✔
1722
    }
1✔
1723

1724
    #[allow(clippy::too_many_lines)]
1725
    #[ge_context::test]
2✔
1726
    async fn it_autocompletes_layers(app_ctx: PostgresContext<NoTls>) {
1✔
1727
        let session = app_ctx.default_session().await.unwrap();
18✔
1728

1✔
1729
        let layer_db = app_ctx.session_context(session).db();
1✔
1730

1✔
1731
        let workflow = Workflow {
1✔
1732
            operator: TypedOperator::Vector(
1✔
1733
                MockPointSource {
1✔
1734
                    params: MockPointSourceParams {
1✔
1735
                        points: vec![Coordinate2D::new(1., 2.); 3],
1✔
1736
                    },
1✔
1737
                }
1✔
1738
                .boxed(),
1✔
1739
            ),
1✔
1740
        };
1✔
1741

1742
        let root_collection_id = layer_db.get_root_layer_collection_id().await.unwrap();
1✔
1743

1744
        let _layer1 = layer_db
1✔
1745
            .add_layer(
1✔
1746
                AddLayer {
1✔
1747
                    name: "Layer1".to_string(),
1✔
1748
                    description: "Layer 1".to_string(),
1✔
1749
                    symbology: None,
1✔
1750
                    workflow: workflow.clone(),
1✔
1751
                    metadata: [("meta".to_string(), "datum".to_string())].into(),
1✔
1752
                    properties: vec![("proper".to_string(), "tee".to_string()).into()],
1✔
1753
                },
1✔
1754
                &root_collection_id,
1✔
1755
            )
1✔
1756
            .await
46✔
1757
            .unwrap();
1✔
1758

1759
        let collection1_id = layer_db
1✔
1760
            .add_layer_collection(
1✔
1761
                AddLayerCollection {
1✔
1762
                    name: "Collection1".to_string(),
1✔
1763
                    description: "Collection 1".to_string(),
1✔
1764
                    properties: Default::default(),
1✔
1765
                },
1✔
1766
                &root_collection_id,
1✔
1767
            )
1✔
1768
            .await
7✔
1769
            .unwrap();
1✔
1770

1771
        let _layer2 = layer_db
1✔
1772
            .add_layer(
1✔
1773
                AddLayer {
1✔
1774
                    name: "Layer2".to_string(),
1✔
1775
                    description: "Layer 2".to_string(),
1✔
1776
                    symbology: None,
1✔
1777
                    workflow: workflow.clone(),
1✔
1778
                    metadata: Default::default(),
1✔
1779
                    properties: Default::default(),
1✔
1780
                },
1✔
1781
                &collection1_id,
1✔
1782
            )
1✔
1783
            .await
9✔
1784
            .unwrap();
1✔
1785

1786
        let _collection2_id = layer_db
1✔
1787
            .add_layer_collection(
1✔
1788
                AddLayerCollection {
1✔
1789
                    name: "Collection2".to_string(),
1✔
1790
                    description: "Collection 2".to_string(),
1✔
1791
                    properties: Default::default(),
1✔
1792
                },
1✔
1793
                &collection1_id,
1✔
1794
            )
1✔
1795
            .await
7✔
1796
            .unwrap();
1✔
1797

1798
        let root_collection_all = layer_db
1✔
1799
            .autocomplete_search(
1✔
1800
                &root_collection_id,
1✔
1801
                SearchParameters {
1✔
1802
                    search_type: SearchType::Fulltext,
1✔
1803
                    search_string: String::new(),
1✔
1804
                    limit: 10,
1✔
1805
                    offset: 0,
1✔
1806
                },
1✔
1807
            )
1✔
1808
            .await
3✔
1809
            .unwrap();
1✔
1810

1✔
1811
        assert_eq!(
1✔
1812
            root_collection_all,
1✔
1813
            vec![
1✔
1814
                "Collection1".to_string(),
1✔
1815
                "Collection2".to_string(),
1✔
1816
                "Layer1".to_string(),
1✔
1817
                "Layer2".to_string(),
1✔
1818
                "Unsorted".to_string(),
1✔
1819
            ]
1✔
1820
        );
1✔
1821

1822
        let root_collection_filtered = layer_db
1✔
1823
            .autocomplete_search(
1✔
1824
                &root_collection_id,
1✔
1825
                SearchParameters {
1✔
1826
                    search_type: SearchType::Fulltext,
1✔
1827
                    search_string: "lection".to_string(),
1✔
1828
                    limit: 10,
1✔
1829
                    offset: 0,
1✔
1830
                },
1✔
1831
            )
1✔
1832
            .await
3✔
1833
            .unwrap();
1✔
1834

1✔
1835
        assert_eq!(
1✔
1836
            root_collection_filtered,
1✔
1837
            vec!["Collection1".to_string(), "Collection2".to_string(),]
1✔
1838
        );
1✔
1839

1840
        let collection1_all = layer_db
1✔
1841
            .autocomplete_search(
1✔
1842
                &collection1_id,
1✔
1843
                SearchParameters {
1✔
1844
                    search_type: SearchType::Fulltext,
1✔
1845
                    search_string: String::new(),
1✔
1846
                    limit: 10,
1✔
1847
                    offset: 0,
1✔
1848
                },
1✔
1849
            )
1✔
1850
            .await
3✔
1851
            .unwrap();
1✔
1852

1✔
1853
        assert_eq!(
1✔
1854
            collection1_all,
1✔
1855
            vec!["Collection2".to_string(), "Layer2".to_string(),]
1✔
1856
        );
1✔
1857

1858
        let collection1_filtered_fulltext = layer_db
1✔
1859
            .autocomplete_search(
1✔
1860
                &collection1_id,
1✔
1861
                SearchParameters {
1✔
1862
                    search_type: SearchType::Fulltext,
1✔
1863
                    search_string: "ay".to_string(),
1✔
1864
                    limit: 10,
1✔
1865
                    offset: 0,
1✔
1866
                },
1✔
1867
            )
1✔
1868
            .await
3✔
1869
            .unwrap();
1✔
1870

1✔
1871
        assert_eq!(collection1_filtered_fulltext, vec!["Layer2".to_string(),]);
1✔
1872

1873
        let collection1_filtered_prefix = layer_db
1✔
1874
            .autocomplete_search(
1✔
1875
                &collection1_id,
1✔
1876
                SearchParameters {
1✔
1877
                    search_type: SearchType::Prefix,
1✔
1878
                    search_string: "ay".to_string(),
1✔
1879
                    limit: 10,
1✔
1880
                    offset: 0,
1✔
1881
                },
1✔
1882
            )
1✔
1883
            .await
3✔
1884
            .unwrap();
1✔
1885

1✔
1886
        assert_eq!(collection1_filtered_prefix, Vec::<String>::new());
1✔
1887

1888
        let collection1_filtered_prefix2 = layer_db
1✔
1889
            .autocomplete_search(
1✔
1890
                &collection1_id,
1✔
1891
                SearchParameters {
1✔
1892
                    search_type: SearchType::Prefix,
1✔
1893
                    search_string: "Lay".to_string(),
1✔
1894
                    limit: 10,
1✔
1895
                    offset: 0,
1✔
1896
                },
1✔
1897
            )
1✔
1898
            .await
3✔
1899
            .unwrap();
1✔
1900

1✔
1901
        assert_eq!(collection1_filtered_prefix2, vec!["Layer2".to_string(),]);
1✔
1902
    }
1✔
1903

1904
    #[allow(clippy::too_many_lines)]
1905
    #[ge_context::test]
2✔
1906
    async fn it_reports_search_capabilities(app_ctx: PostgresContext<NoTls>) {
1✔
1907
        let session = app_ctx.default_session().await.unwrap();
18✔
1908

1✔
1909
        let layer_db = app_ctx.session_context(session).db();
1✔
1910

1✔
1911
        let capabilities = layer_db.capabilities().search;
1✔
1912

1913
        let root_collection_id = layer_db.get_root_layer_collection_id().await.unwrap();
1✔
1914

1✔
1915
        if capabilities.search_types.fulltext {
1✔
1916
            assert!(layer_db
1✔
1917
                .search(
1✔
1918
                    &root_collection_id,
1✔
1919
                    SearchParameters {
1✔
1920
                        search_type: SearchType::Fulltext,
1✔
1921
                        search_string: String::new(),
1✔
1922
                        limit: 10,
1✔
1923
                        offset: 0,
1✔
1924
                    },
1✔
1925
                )
1✔
1926
                .await
8✔
1927
                .is_ok());
1✔
1928

1929
            if capabilities.autocomplete {
1✔
1930
                assert!(layer_db
1✔
1931
                    .autocomplete_search(
1✔
1932
                        &root_collection_id,
1✔
1933
                        SearchParameters {
1✔
1934
                            search_type: SearchType::Fulltext,
1✔
1935
                            search_string: String::new(),
1✔
1936
                            limit: 10,
1✔
1937
                            offset: 0,
1✔
1938
                        },
1✔
1939
                    )
1✔
1940
                    .await
3✔
1941
                    .is_ok());
1✔
1942
            } else {
1943
                assert!(layer_db
×
1944
                    .autocomplete_search(
×
1945
                        &root_collection_id,
×
1946
                        SearchParameters {
×
1947
                            search_type: SearchType::Fulltext,
×
1948
                            search_string: String::new(),
×
1949
                            limit: 10,
×
1950
                            offset: 0,
×
1951
                        },
×
1952
                    )
×
1953
                    .await
×
1954
                    .is_err());
×
1955
            }
1956
        }
×
1957
        if capabilities.search_types.prefix {
1✔
1958
            assert!(layer_db
1✔
1959
                .search(
1✔
1960
                    &root_collection_id,
1✔
1961
                    SearchParameters {
1✔
1962
                        search_type: SearchType::Prefix,
1✔
1963
                        search_string: String::new(),
1✔
1964
                        limit: 10,
1✔
1965
                        offset: 0,
1✔
1966
                    },
1✔
1967
                )
1✔
1968
                .await
5✔
1969
                .is_ok());
1✔
1970

1971
            if capabilities.autocomplete {
1✔
1972
                assert!(layer_db
1✔
1973
                    .autocomplete_search(
1✔
1974
                        &root_collection_id,
1✔
1975
                        SearchParameters {
1✔
1976
                            search_type: SearchType::Prefix,
1✔
1977
                            search_string: String::new(),
1✔
1978
                            limit: 10,
1✔
1979
                            offset: 0,
1✔
1980
                        },
1✔
1981
                    )
1✔
1982
                    .await
3✔
1983
                    .is_ok());
1✔
1984
            } else {
1985
                assert!(layer_db
×
1986
                    .autocomplete_search(
×
1987
                        &root_collection_id,
×
1988
                        SearchParameters {
×
1989
                            search_type: SearchType::Prefix,
×
1990
                            search_string: String::new(),
×
1991
                            limit: 10,
×
1992
                            offset: 0,
×
1993
                        },
×
1994
                    )
×
1995
                    .await
×
1996
                    .is_err());
×
1997
            }
1998
        }
×
1999
    }
1✔
2000

2001
    #[allow(clippy::too_many_lines)]
2002
    #[ge_context::test]
2✔
2003
    async fn it_removes_layer_collections(app_ctx: PostgresContext<NoTls>) {
1✔
2004
        let session = app_ctx.default_session().await.unwrap();
18✔
2005

1✔
2006
        let layer_db = app_ctx.session_context(session).db();
1✔
2007

1✔
2008
        let layer = AddLayer {
1✔
2009
            name: "layer".to_string(),
1✔
2010
            description: "description".to_string(),
1✔
2011
            workflow: Workflow {
1✔
2012
                operator: TypedOperator::Vector(
1✔
2013
                    MockPointSource {
1✔
2014
                        params: MockPointSourceParams {
1✔
2015
                            points: vec![Coordinate2D::new(1., 2.); 3],
1✔
2016
                        },
1✔
2017
                    }
1✔
2018
                    .boxed(),
1✔
2019
                ),
1✔
2020
            },
1✔
2021
            symbology: None,
1✔
2022
            metadata: Default::default(),
1✔
2023
            properties: Default::default(),
1✔
2024
        };
1✔
2025

2026
        let root_collection = &layer_db.get_root_layer_collection_id().await.unwrap();
1✔
2027

1✔
2028
        let collection = AddLayerCollection {
1✔
2029
            name: "top collection".to_string(),
1✔
2030
            description: "description".to_string(),
1✔
2031
            properties: Default::default(),
1✔
2032
        };
1✔
2033

2034
        let top_c_id = layer_db
1✔
2035
            .add_layer_collection(collection, root_collection)
1✔
2036
            .await
10✔
2037
            .unwrap();
1✔
2038

2039
        let l_id = layer_db.add_layer(layer, &top_c_id).await.unwrap();
42✔
2040

1✔
2041
        let collection = AddLayerCollection {
1✔
2042
            name: "empty collection".to_string(),
1✔
2043
            description: "description".to_string(),
1✔
2044
            properties: Default::default(),
1✔
2045
        };
1✔
2046

2047
        let empty_c_id = layer_db
1✔
2048
            .add_layer_collection(collection, &top_c_id)
1✔
2049
            .await
7✔
2050
            .unwrap();
1✔
2051

2052
        let items = layer_db
1✔
2053
            .load_layer_collection(
1✔
2054
                &top_c_id,
1✔
2055
                LayerCollectionListOptions {
1✔
2056
                    offset: 0,
1✔
2057
                    limit: 20,
1✔
2058
                },
1✔
2059
            )
1✔
2060
            .await
5✔
2061
            .unwrap();
1✔
2062

1✔
2063
        assert_eq!(
1✔
2064
            items,
1✔
2065
            LayerCollection {
1✔
2066
                id: ProviderLayerCollectionId {
1✔
2067
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
2068
                    collection_id: top_c_id.clone(),
1✔
2069
                },
1✔
2070
                name: "top collection".to_string(),
1✔
2071
                description: "description".to_string(),
1✔
2072
                items: vec![
1✔
2073
                    CollectionItem::Collection(LayerCollectionListing {
1✔
2074
                        id: ProviderLayerCollectionId {
1✔
2075
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
2076
                            collection_id: empty_c_id.clone(),
1✔
2077
                        },
1✔
2078
                        name: "empty collection".to_string(),
1✔
2079
                        description: "description".to_string(),
1✔
2080
                        properties: Default::default(),
1✔
2081
                    }),
1✔
2082
                    CollectionItem::Layer(LayerListing {
1✔
2083
                        id: ProviderLayerId {
1✔
2084
                            provider_id: INTERNAL_PROVIDER_ID,
1✔
2085
                            layer_id: l_id.clone(),
1✔
2086
                        },
1✔
2087
                        name: "layer".to_string(),
1✔
2088
                        description: "description".to_string(),
1✔
2089
                        properties: vec![],
1✔
2090
                    })
1✔
2091
                ],
1✔
2092
                entry_label: None,
1✔
2093
                properties: vec![],
1✔
2094
            }
1✔
2095
        );
1✔
2096

2097
        // remove empty collection
2098
        layer_db.remove_layer_collection(&empty_c_id).await.unwrap();
9✔
2099

2100
        let items = layer_db
1✔
2101
            .load_layer_collection(
1✔
2102
                &top_c_id,
1✔
2103
                LayerCollectionListOptions {
1✔
2104
                    offset: 0,
1✔
2105
                    limit: 20,
1✔
2106
                },
1✔
2107
            )
1✔
2108
            .await
5✔
2109
            .unwrap();
1✔
2110

1✔
2111
        assert_eq!(
1✔
2112
            items,
1✔
2113
            LayerCollection {
1✔
2114
                id: ProviderLayerCollectionId {
1✔
2115
                    provider_id: INTERNAL_PROVIDER_ID,
1✔
2116
                    collection_id: top_c_id.clone(),
1✔
2117
                },
1✔
2118
                name: "top collection".to_string(),
1✔
2119
                description: "description".to_string(),
1✔
2120
                items: vec![CollectionItem::Layer(LayerListing {
1✔
2121
                    id: ProviderLayerId {
1✔
2122
                        provider_id: INTERNAL_PROVIDER_ID,
1✔
2123
                        layer_id: l_id.clone(),
1✔
2124
                    },
1✔
2125
                    name: "layer".to_string(),
1✔
2126
                    description: "description".to_string(),
1✔
2127
                    properties: vec![],
1✔
2128
                })],
1✔
2129
                entry_label: None,
1✔
2130
                properties: vec![],
1✔
2131
            }
1✔
2132
        );
1✔
2133

2134
        // remove top (not root) collection
2135
        layer_db.remove_layer_collection(&top_c_id).await.unwrap();
9✔
2136

1✔
2137
        layer_db
1✔
2138
            .load_layer_collection(
1✔
2139
                &top_c_id,
1✔
2140
                LayerCollectionListOptions {
1✔
2141
                    offset: 0,
1✔
2142
                    limit: 20,
1✔
2143
                },
1✔
2144
            )
1✔
2145
            .await
3✔
2146
            .unwrap_err();
1✔
2147

1✔
2148
        // should be deleted automatically
1✔
2149
        layer_db.load_layer(&l_id).await.unwrap_err();
3✔
2150

1✔
2151
        // it is not allowed to remove the root collection
1✔
2152
        layer_db
1✔
2153
            .remove_layer_collection(root_collection)
1✔
2154
            .await
2✔
2155
            .unwrap_err();
1✔
2156
        layer_db
1✔
2157
            .load_layer_collection(
1✔
2158
                root_collection,
1✔
2159
                LayerCollectionListOptions {
1✔
2160
                    offset: 0,
1✔
2161
                    limit: 20,
1✔
2162
                },
1✔
2163
            )
1✔
2164
            .await
5✔
2165
            .unwrap();
1✔
2166
    }
1✔
2167

2168
    #[ge_context::test]
2✔
2169
    #[allow(clippy::too_many_lines)]
2170
    async fn it_removes_collections_from_collections(app_ctx: PostgresContext<NoTls>) {
1✔
2171
        let session = app_ctx.default_session().await.unwrap();
18✔
2172

1✔
2173
        let db = app_ctx.session_context(session).db();
1✔
2174

2175
        let root_collection_id = &db.get_root_layer_collection_id().await.unwrap();
1✔
2176

2177
        let mid_collection_id = db
1✔
2178
            .add_layer_collection(
1✔
2179
                AddLayerCollection {
1✔
2180
                    name: "mid collection".to_string(),
1✔
2181
                    description: "description".to_string(),
1✔
2182
                    properties: Default::default(),
1✔
2183
                },
1✔
2184
                root_collection_id,
1✔
2185
            )
1✔
2186
            .await
10✔
2187
            .unwrap();
1✔
2188

2189
        let bottom_collection_id = db
1✔
2190
            .add_layer_collection(
1✔
2191
                AddLayerCollection {
1✔
2192
                    name: "bottom collection".to_string(),
1✔
2193
                    description: "description".to_string(),
1✔
2194
                    properties: Default::default(),
1✔
2195
                },
1✔
2196
                &mid_collection_id,
1✔
2197
            )
1✔
2198
            .await
7✔
2199
            .unwrap();
1✔
2200

2201
        let layer_id = db
1✔
2202
            .add_layer(
1✔
2203
                AddLayer {
1✔
2204
                    name: "layer".to_string(),
1✔
2205
                    description: "description".to_string(),
1✔
2206
                    workflow: Workflow {
1✔
2207
                        operator: TypedOperator::Vector(
1✔
2208
                            MockPointSource {
1✔
2209
                                params: MockPointSourceParams {
1✔
2210
                                    points: vec![Coordinate2D::new(1., 2.); 3],
1✔
2211
                                },
1✔
2212
                            }
1✔
2213
                            .boxed(),
1✔
2214
                        ),
1✔
2215
                    },
1✔
2216
                    symbology: None,
1✔
2217
                    metadata: Default::default(),
1✔
2218
                    properties: Default::default(),
1✔
2219
                },
1✔
2220
                &mid_collection_id,
1✔
2221
            )
1✔
2222
            .await
42✔
2223
            .unwrap();
1✔
2224

1✔
2225
        // removing the mid collection…
1✔
2226
        db.remove_layer_collection_from_parent(&mid_collection_id, root_collection_id)
1✔
2227
            .await
11✔
2228
            .unwrap();
1✔
2229

1✔
2230
        // …should remove itself
1✔
2231
        db.load_layer_collection(&mid_collection_id, LayerCollectionListOptions::default())
1✔
2232
            .await
3✔
2233
            .unwrap_err();
1✔
2234

1✔
2235
        // …should remove the bottom collection
1✔
2236
        db.load_layer_collection(&bottom_collection_id, LayerCollectionListOptions::default())
1✔
2237
            .await
3✔
2238
            .unwrap_err();
1✔
2239

1✔
2240
        // … and should remove the layer of the bottom collection
1✔
2241
        db.load_layer(&layer_id).await.unwrap_err();
3✔
2242

1✔
2243
        // the root collection is still there
1✔
2244
        db.load_layer_collection(root_collection_id, LayerCollectionListOptions::default())
1✔
2245
            .await
5✔
2246
            .unwrap();
1✔
2247
    }
1✔
2248

2249
    #[ge_context::test]
2✔
2250
    #[allow(clippy::too_many_lines)]
2251
    async fn it_removes_layers_from_collections(app_ctx: PostgresContext<NoTls>) {
1✔
2252
        let session = app_ctx.default_session().await.unwrap();
18✔
2253

1✔
2254
        let db = app_ctx.session_context(session).db();
1✔
2255

2256
        let root_collection = &db.get_root_layer_collection_id().await.unwrap();
1✔
2257

2258
        let another_collection = db
1✔
2259
            .add_layer_collection(
1✔
2260
                AddLayerCollection {
1✔
2261
                    name: "top collection".to_string(),
1✔
2262
                    description: "description".to_string(),
1✔
2263
                    properties: Default::default(),
1✔
2264
                },
1✔
2265
                root_collection,
1✔
2266
            )
1✔
2267
            .await
10✔
2268
            .unwrap();
1✔
2269

2270
        let layer_in_one_collection = db
1✔
2271
            .add_layer(
1✔
2272
                AddLayer {
1✔
2273
                    name: "layer 1".to_string(),
1✔
2274
                    description: "description".to_string(),
1✔
2275
                    workflow: Workflow {
1✔
2276
                        operator: TypedOperator::Vector(
1✔
2277
                            MockPointSource {
1✔
2278
                                params: MockPointSourceParams {
1✔
2279
                                    points: vec![Coordinate2D::new(1., 2.); 3],
1✔
2280
                                },
1✔
2281
                            }
1✔
2282
                            .boxed(),
1✔
2283
                        ),
1✔
2284
                    },
1✔
2285
                    symbology: None,
1✔
2286
                    metadata: Default::default(),
1✔
2287
                    properties: Default::default(),
1✔
2288
                },
1✔
2289
                &another_collection,
1✔
2290
            )
1✔
2291
            .await
42✔
2292
            .unwrap();
1✔
2293

2294
        let layer_in_two_collections = db
1✔
2295
            .add_layer(
1✔
2296
                AddLayer {
1✔
2297
                    name: "layer 2".to_string(),
1✔
2298
                    description: "description".to_string(),
1✔
2299
                    workflow: Workflow {
1✔
2300
                        operator: TypedOperator::Vector(
1✔
2301
                            MockPointSource {
1✔
2302
                                params: MockPointSourceParams {
1✔
2303
                                    points: vec![Coordinate2D::new(1., 2.); 3],
1✔
2304
                                },
1✔
2305
                            }
1✔
2306
                            .boxed(),
1✔
2307
                        ),
1✔
2308
                    },
1✔
2309
                    symbology: None,
1✔
2310
                    metadata: Default::default(),
1✔
2311
                    properties: Default::default(),
1✔
2312
                },
1✔
2313
                &another_collection,
1✔
2314
            )
1✔
2315
            .await
9✔
2316
            .unwrap();
1✔
2317

1✔
2318
        db.add_layer_to_collection(&layer_in_two_collections, root_collection)
1✔
2319
            .await
3✔
2320
            .unwrap();
1✔
2321

1✔
2322
        // remove first layer --> should be deleted entirely
1✔
2323

1✔
2324
        db.remove_layer_from_collection(&layer_in_one_collection, &another_collection)
1✔
2325
            .await
7✔
2326
            .unwrap();
1✔
2327

2328
        let number_of_layer_in_collection = db
1✔
2329
            .load_layer_collection(
1✔
2330
                &another_collection,
1✔
2331
                LayerCollectionListOptions {
1✔
2332
                    offset: 0,
1✔
2333
                    limit: 20,
1✔
2334
                },
1✔
2335
            )
1✔
2336
            .await
5✔
2337
            .unwrap()
1✔
2338
            .items
1✔
2339
            .len();
1✔
2340
        assert_eq!(
1✔
2341
            number_of_layer_in_collection,
1✔
2342
            1 /* only the other collection should be here */
1✔
2343
        );
1✔
2344

2345
        db.load_layer(&layer_in_one_collection).await.unwrap_err();
3✔
2346

1✔
2347
        // remove second layer --> should only be gone in collection
1✔
2348

1✔
2349
        db.remove_layer_from_collection(&layer_in_two_collections, &another_collection)
1✔
2350
            .await
7✔
2351
            .unwrap();
1✔
2352

2353
        let number_of_layer_in_collection = db
1✔
2354
            .load_layer_collection(
1✔
2355
                &another_collection,
1✔
2356
                LayerCollectionListOptions {
1✔
2357
                    offset: 0,
1✔
2358
                    limit: 20,
1✔
2359
                },
1✔
2360
            )
1✔
2361
            .await
5✔
2362
            .unwrap()
1✔
2363
            .items
1✔
2364
            .len();
1✔
2365
        assert_eq!(
1✔
2366
            number_of_layer_in_collection,
1✔
2367
            0 /* both layers were deleted */
1✔
2368
        );
1✔
2369

2370
        db.load_layer(&layer_in_two_collections).await.unwrap();
3✔
2371
    }
1✔
2372

2373
    #[ge_context::test]
2✔
2374
    #[allow(clippy::too_many_lines)]
2375
    async fn it_deletes_dataset(app_ctx: PostgresContext<NoTls>) {
1✔
2376
        let loading_info = OgrSourceDataset {
1✔
2377
            file_name: PathBuf::from("test.csv"),
1✔
2378
            layer_name: "test.csv".to_owned(),
1✔
2379
            data_type: Some(VectorDataType::MultiPoint),
1✔
2380
            time: OgrSourceDatasetTimeType::Start {
1✔
2381
                start_field: "start".to_owned(),
1✔
2382
                start_format: OgrSourceTimeFormat::Auto,
1✔
2383
                duration: OgrSourceDurationSpec::Zero,
1✔
2384
            },
1✔
2385
            default_geometry: None,
1✔
2386
            columns: Some(OgrSourceColumnSpec {
1✔
2387
                format_specifics: Some(FormatSpecifics::Csv {
1✔
2388
                    header: CsvHeader::Auto,
1✔
2389
                }),
1✔
2390
                x: "x".to_owned(),
1✔
2391
                y: None,
1✔
2392
                int: vec![],
1✔
2393
                float: vec![],
1✔
2394
                text: vec![],
1✔
2395
                bool: vec![],
1✔
2396
                datetime: vec![],
1✔
2397
                rename: None,
1✔
2398
            }),
1✔
2399
            force_ogr_time_filter: false,
1✔
2400
            force_ogr_spatial_filter: false,
1✔
2401
            on_error: OgrSourceErrorSpec::Ignore,
1✔
2402
            sql_query: None,
1✔
2403
            attribute_query: None,
1✔
2404
            cache_ttl: CacheTtlSeconds::default(),
1✔
2405
        };
1✔
2406

1✔
2407
        let meta_data = MetaDataDefinition::OgrMetaData(StaticMetaData::<
1✔
2408
            OgrSourceDataset,
1✔
2409
            VectorResultDescriptor,
1✔
2410
            VectorQueryRectangle,
1✔
2411
        > {
1✔
2412
            loading_info: loading_info.clone(),
1✔
2413
            result_descriptor: VectorResultDescriptor {
1✔
2414
                data_type: VectorDataType::MultiPoint,
1✔
2415
                spatial_reference: SpatialReference::epsg_4326().into(),
1✔
2416
                columns: [(
1✔
2417
                    "foo".to_owned(),
1✔
2418
                    VectorColumnInfo {
1✔
2419
                        data_type: FeatureDataType::Float,
1✔
2420
                        measurement: Measurement::Unitless,
1✔
2421
                    },
1✔
2422
                )]
1✔
2423
                .into_iter()
1✔
2424
                .collect(),
1✔
2425
                time: None,
1✔
2426
                bbox: None,
1✔
2427
            },
1✔
2428
            phantom: Default::default(),
1✔
2429
        });
1✔
2430

2431
        let session = app_ctx.default_session().await.unwrap();
18✔
2432

1✔
2433
        let dataset_name = DatasetName::new(None, "my_dataset");
1✔
2434

1✔
2435
        let db = app_ctx.session_context(session.clone()).db();
1✔
2436
        let dataset_id = db
1✔
2437
            .add_dataset(
1✔
2438
                AddDataset {
1✔
2439
                    name: Some(dataset_name),
1✔
2440
                    display_name: "Ogr Test".to_owned(),
1✔
2441
                    description: "desc".to_owned(),
1✔
2442
                    source_operator: "OgrSource".to_owned(),
1✔
2443
                    symbology: None,
1✔
2444
                    provenance: Some(vec![Provenance {
1✔
2445
                        citation: "citation".to_owned(),
1✔
2446
                        license: "license".to_owned(),
1✔
2447
                        uri: "uri".to_owned(),
1✔
2448
                    }]),
1✔
2449
                    tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
2450
                },
1✔
2451
                meta_data,
1✔
2452
            )
1✔
2453
            .await
161✔
2454
            .unwrap()
1✔
2455
            .id;
1✔
2456

1✔
2457
        assert!(db.load_dataset(&dataset_id).await.is_ok());
3✔
2458

2459
        db.delete_dataset(dataset_id).await.unwrap();
3✔
2460

1✔
2461
        assert!(db.load_dataset(&dataset_id).await.is_err());
3✔
2462
    }
1✔
2463

2464
    #[ge_context::test]
2✔
2465
    #[allow(clippy::too_many_lines)]
2466
    async fn it_deletes_admin_dataset(app_ctx: PostgresContext<NoTls>) {
1✔
2467
        let dataset_name = DatasetName::new(None, "my_dataset");
1✔
2468

1✔
2469
        let loading_info = OgrSourceDataset {
1✔
2470
            file_name: PathBuf::from("test.csv"),
1✔
2471
            layer_name: "test.csv".to_owned(),
1✔
2472
            data_type: Some(VectorDataType::MultiPoint),
1✔
2473
            time: OgrSourceDatasetTimeType::Start {
1✔
2474
                start_field: "start".to_owned(),
1✔
2475
                start_format: OgrSourceTimeFormat::Auto,
1✔
2476
                duration: OgrSourceDurationSpec::Zero,
1✔
2477
            },
1✔
2478
            default_geometry: None,
1✔
2479
            columns: Some(OgrSourceColumnSpec {
1✔
2480
                format_specifics: Some(FormatSpecifics::Csv {
1✔
2481
                    header: CsvHeader::Auto,
1✔
2482
                }),
1✔
2483
                x: "x".to_owned(),
1✔
2484
                y: None,
1✔
2485
                int: vec![],
1✔
2486
                float: vec![],
1✔
2487
                text: vec![],
1✔
2488
                bool: vec![],
1✔
2489
                datetime: vec![],
1✔
2490
                rename: None,
1✔
2491
            }),
1✔
2492
            force_ogr_time_filter: false,
1✔
2493
            force_ogr_spatial_filter: false,
1✔
2494
            on_error: OgrSourceErrorSpec::Ignore,
1✔
2495
            sql_query: None,
1✔
2496
            attribute_query: None,
1✔
2497
            cache_ttl: CacheTtlSeconds::default(),
1✔
2498
        };
1✔
2499

1✔
2500
        let meta_data = MetaDataDefinition::OgrMetaData(StaticMetaData::<
1✔
2501
            OgrSourceDataset,
1✔
2502
            VectorResultDescriptor,
1✔
2503
            VectorQueryRectangle,
1✔
2504
        > {
1✔
2505
            loading_info: loading_info.clone(),
1✔
2506
            result_descriptor: VectorResultDescriptor {
1✔
2507
                data_type: VectorDataType::MultiPoint,
1✔
2508
                spatial_reference: SpatialReference::epsg_4326().into(),
1✔
2509
                columns: [(
1✔
2510
                    "foo".to_owned(),
1✔
2511
                    VectorColumnInfo {
1✔
2512
                        data_type: FeatureDataType::Float,
1✔
2513
                        measurement: Measurement::Unitless,
1✔
2514
                    },
1✔
2515
                )]
1✔
2516
                .into_iter()
1✔
2517
                .collect(),
1✔
2518
                time: None,
1✔
2519
                bbox: None,
1✔
2520
            },
1✔
2521
            phantom: Default::default(),
1✔
2522
        });
1✔
2523

2524
        let session = app_ctx.default_session().await.unwrap();
18✔
2525

1✔
2526
        let db = app_ctx.session_context(session).db();
1✔
2527
        let dataset_id = db
1✔
2528
            .add_dataset(
1✔
2529
                AddDataset {
1✔
2530
                    name: Some(dataset_name),
1✔
2531
                    display_name: "Ogr Test".to_owned(),
1✔
2532
                    description: "desc".to_owned(),
1✔
2533
                    source_operator: "OgrSource".to_owned(),
1✔
2534
                    symbology: None,
1✔
2535
                    provenance: Some(vec![Provenance {
1✔
2536
                        citation: "citation".to_owned(),
1✔
2537
                        license: "license".to_owned(),
1✔
2538
                        uri: "uri".to_owned(),
1✔
2539
                    }]),
1✔
2540
                    tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
2541
                },
1✔
2542
                meta_data,
1✔
2543
            )
1✔
2544
            .await
161✔
2545
            .unwrap()
1✔
2546
            .id;
1✔
2547

1✔
2548
        assert!(db.load_dataset(&dataset_id).await.is_ok());
4✔
2549

2550
        db.delete_dataset(dataset_id).await.unwrap();
3✔
2551

1✔
2552
        assert!(db.load_dataset(&dataset_id).await.is_err());
3✔
2553
    }
1✔
2554

2555
    #[ge_context::test]
2✔
2556
    async fn test_missing_layer_dataset_in_collection_listing(app_ctx: PostgresContext<NoTls>) {
1✔
2557
        let session = app_ctx.default_session().await.unwrap();
18✔
2558
        let db = app_ctx.session_context(session).db();
1✔
2559

2560
        let root_collection_id = &db.get_root_layer_collection_id().await.unwrap();
1✔
2561

2562
        let top_collection_id = db
1✔
2563
            .add_layer_collection(
1✔
2564
                AddLayerCollection {
1✔
2565
                    name: "top collection".to_string(),
1✔
2566
                    description: "description".to_string(),
1✔
2567
                    properties: Default::default(),
1✔
2568
                },
1✔
2569
                root_collection_id,
1✔
2570
            )
1✔
2571
            .await
10✔
2572
            .unwrap();
1✔
2573

1✔
2574
        let faux_layer = LayerId("faux".to_string());
1✔
2575

1✔
2576
        // this should fail
1✔
2577
        db.add_layer_to_collection(&faux_layer, &top_collection_id)
1✔
2578
            .await
×
2579
            .unwrap_err();
1✔
2580

2581
        let root_collection_layers = db
1✔
2582
            .load_layer_collection(
1✔
2583
                &top_collection_id,
1✔
2584
                LayerCollectionListOptions {
1✔
2585
                    offset: 0,
1✔
2586
                    limit: 20,
1✔
2587
                },
1✔
2588
            )
1✔
2589
            .await
5✔
2590
            .unwrap();
1✔
2591

1✔
2592
        assert_eq!(
1✔
2593
            root_collection_layers,
1✔
2594
            LayerCollection {
1✔
2595
                id: ProviderLayerCollectionId {
1✔
2596
                    provider_id: DataProviderId(
1✔
2597
                        "ce5e84db-cbf9-48a2-9a32-d4b7cc56ea74".try_into().unwrap()
1✔
2598
                    ),
1✔
2599
                    collection_id: top_collection_id.clone(),
1✔
2600
                },
1✔
2601
                name: "top collection".to_string(),
1✔
2602
                description: "description".to_string(),
1✔
2603
                items: vec![],
1✔
2604
                entry_label: None,
1✔
2605
                properties: vec![],
1✔
2606
            }
1✔
2607
        );
1✔
2608
    }
1✔
2609

2610
    #[allow(clippy::too_many_lines)]
2611
    #[ge_context::test]
2✔
2612
    async fn it_updates_project_layer_symbology(app_ctx: PostgresContext<NoTls>) {
1✔
2613
        let session = app_ctx.default_session().await.unwrap();
18✔
2614

2615
        let (_, workflow_id) = register_ndvi_workflow_helper(&app_ctx).await;
172✔
2616

2617
        let db = app_ctx.session_context(session.clone()).db();
1✔
2618

1✔
2619
        let create_project: CreateProject = serde_json::from_value(json!({
1✔
2620
            "name": "Default",
1✔
2621
            "description": "Default project",
1✔
2622
            "bounds": {
1✔
2623
                "boundingBox": {
1✔
2624
                    "lowerLeftCoordinate": {
1✔
2625
                        "x": -180,
1✔
2626
                        "y": -90
1✔
2627
                    },
1✔
2628
                    "upperRightCoordinate": {
1✔
2629
                        "x": 180,
1✔
2630
                        "y": 90
1✔
2631
                    }
1✔
2632
                },
1✔
2633
                "spatialReference": "EPSG:4326",
1✔
2634
                "timeInterval": {
1✔
2635
                    "start": 1_396_353_600_000i64,
1✔
2636
                    "end": 1_396_353_600_000i64
1✔
2637
                }
1✔
2638
            },
1✔
2639
            "timeStep": {
1✔
2640
                "step": 1,
1✔
2641
                "granularity": "months"
1✔
2642
            }
1✔
2643
        }))
1✔
2644
        .unwrap();
1✔
2645

2646
        let project_id = db.create_project(create_project).await.unwrap();
7✔
2647

1✔
2648
        let update: UpdateProject = serde_json::from_value(json!({
1✔
2649
            "id": project_id.to_string(),
1✔
2650
            "layers": [{
1✔
2651
                "name": "NDVI",
1✔
2652
                "workflow": workflow_id.to_string(),
1✔
2653
                "visibility": {
1✔
2654
                    "data": true,
1✔
2655
                    "legend": false
1✔
2656
                },
1✔
2657
                "symbology": {
1✔
2658
                    "type": "raster",
1✔
2659
                    "opacity": 1,
1✔
2660
                    "rasterColorizer": {
1✔
2661
                        "type": "singleBand",
1✔
2662
                        "band": 0,
1✔
2663
                        "bandColorizer": {
1✔
2664
                            "type": "linearGradient",
1✔
2665
                            "breakpoints": [{
1✔
2666
                                "value": 1,
1✔
2667
                                "color": [0, 0, 0, 255]
1✔
2668
                            }, {
1✔
2669
                                "value": 255,
1✔
2670
                                "color": [255, 255, 255, 255]
1✔
2671
                            }],
1✔
2672
                            "noDataColor": [0, 0, 0, 0],
1✔
2673
                            "overColor": [255, 255, 255, 127],
1✔
2674
                            "underColor": [255, 255, 255, 127]
1✔
2675
                        }
1✔
2676
                    }
1✔
2677
                }
1✔
2678
            }]
1✔
2679
        }))
1✔
2680
        .unwrap();
1✔
2681

1✔
2682
        db.update_project(update).await.unwrap();
70✔
2683

1✔
2684
        let update: UpdateProject = serde_json::from_value(json!({
1✔
2685
            "id": project_id.to_string(),
1✔
2686
            "layers": [{
1✔
2687
                "name": "NDVI",
1✔
2688
                "workflow": workflow_id.to_string(),
1✔
2689
                "visibility": {
1✔
2690
                    "data": true,
1✔
2691
                    "legend": false
1✔
2692
                },
1✔
2693
                "symbology": {
1✔
2694
                    "type": "raster",
1✔
2695
                    "opacity": 1,
1✔
2696
                    "rasterColorizer": {
1✔
2697
                        "type": "singleBand",
1✔
2698
                        "band": 0,
1✔
2699
                        "bandColorizer": {
1✔
2700
                            "type": "linearGradient",
1✔
2701
                            "breakpoints": [{
1✔
2702
                                "value": 1,
1✔
2703
                                "color": [0, 0, 4, 255]
1✔
2704
                            }, {
1✔
2705
                                "value": 17.866_666_666_666_667,
1✔
2706
                                "color": [11, 9, 36, 255]
1✔
2707
                            }, {
1✔
2708
                                "value": 34.733_333_333_333_334,
1✔
2709
                                "color": [32, 17, 75, 255]
1✔
2710
                            }, {
1✔
2711
                                "value": 51.6,
1✔
2712
                                "color": [59, 15, 112, 255]
1✔
2713
                            }, {
1✔
2714
                                "value": 68.466_666_666_666_67,
1✔
2715
                                "color": [87, 21, 126, 255]
1✔
2716
                            }, {
1✔
2717
                                "value": 85.333_333_333_333_33,
1✔
2718
                                "color": [114, 31, 129, 255]
1✔
2719
                            }, {
1✔
2720
                                "value": 102.199_999_999_999_99,
1✔
2721
                                "color": [140, 41, 129, 255]
1✔
2722
                            }, {
1✔
2723
                                "value": 119.066_666_666_666_65,
1✔
2724
                                "color": [168, 50, 125, 255]
1✔
2725
                            }, {
1✔
2726
                                "value": 135.933_333_333_333_34,
1✔
2727
                                "color": [196, 60, 117, 255]
1✔
2728
                            }, {
1✔
2729
                                "value": 152.799_999_999_999_98,
1✔
2730
                                "color": [222, 73, 104, 255]
1✔
2731
                            }, {
1✔
2732
                                "value": 169.666_666_666_666_66,
1✔
2733
                                "color": [241, 96, 93, 255]
1✔
2734
                            }, {
1✔
2735
                                "value": 186.533_333_333_333_33,
1✔
2736
                                "color": [250, 127, 94, 255]
1✔
2737
                            }, {
1✔
2738
                                "value": 203.399_999_999_999_98,
1✔
2739
                                "color": [254, 159, 109, 255]
1✔
2740
                            }, {
1✔
2741
                                "value": 220.266_666_666_666_65,
1✔
2742
                                "color": [254, 191, 132, 255]
1✔
2743
                            }, {
1✔
2744
                                "value": 237.133_333_333_333_3,
1✔
2745
                                "color": [253, 222, 160, 255]
1✔
2746
                            }, {
1✔
2747
                                "value": 254,
1✔
2748
                                "color": [252, 253, 191, 255]
1✔
2749
                            }],
1✔
2750
                            "noDataColor": [0, 0, 0, 0],
1✔
2751
                            "overColor": [255, 255, 255, 127],
1✔
2752
                            "underColor": [255, 255, 255, 127]
1✔
2753
                        }
1✔
2754
                    }
1✔
2755
                }
1✔
2756
            }]
1✔
2757
        }))
1✔
2758
        .unwrap();
1✔
2759

1✔
2760
        db.update_project(update).await.unwrap();
16✔
2761

1✔
2762
        let update: UpdateProject = serde_json::from_value(json!({
1✔
2763
            "id": project_id.to_string(),
1✔
2764
            "layers": [{
1✔
2765
                "name": "NDVI",
1✔
2766
                "workflow": workflow_id.to_string(),
1✔
2767
                "visibility": {
1✔
2768
                    "data": true,
1✔
2769
                    "legend": false
1✔
2770
                },
1✔
2771
                "symbology": {
1✔
2772
                    "type": "raster",
1✔
2773
                    "opacity": 1,
1✔
2774
                    "rasterColorizer": {
1✔
2775
                        "type": "singleBand",
1✔
2776
                        "band": 0,
1✔
2777
                        "bandColorizer": {
1✔
2778
                            "type": "linearGradient",
1✔
2779
                            "breakpoints": [{
1✔
2780
                                "value": 1,
1✔
2781
                                "color": [0, 0, 4, 255]
1✔
2782
                            }, {
1✔
2783
                                "value": 17.866_666_666_666_667,
1✔
2784
                                "color": [11, 9, 36, 255]
1✔
2785
                            }, {
1✔
2786
                                "value": 34.733_333_333_333_334,
1✔
2787
                                "color": [32, 17, 75, 255]
1✔
2788
                            }, {
1✔
2789
                                "value": 51.6,
1✔
2790
                                "color": [59, 15, 112, 255]
1✔
2791
                            }, {
1✔
2792
                                "value": 68.466_666_666_666_67,
1✔
2793
                                "color": [87, 21, 126, 255]
1✔
2794
                            }, {
1✔
2795
                                "value": 85.333_333_333_333_33,
1✔
2796
                                "color": [114, 31, 129, 255]
1✔
2797
                            }, {
1✔
2798
                                "value": 102.199_999_999_999_99,
1✔
2799
                                "color": [140, 41, 129, 255]
1✔
2800
                            }, {
1✔
2801
                                "value": 119.066_666_666_666_65,
1✔
2802
                                "color": [168, 50, 125, 255]
1✔
2803
                            }, {
1✔
2804
                                "value": 135.933_333_333_333_34,
1✔
2805
                                "color": [196, 60, 117, 255]
1✔
2806
                            }, {
1✔
2807
                                "value": 152.799_999_999_999_98,
1✔
2808
                                "color": [222, 73, 104, 255]
1✔
2809
                            }, {
1✔
2810
                                "value": 169.666_666_666_666_66,
1✔
2811
                                "color": [241, 96, 93, 255]
1✔
2812
                            }, {
1✔
2813
                                "value": 186.533_333_333_333_33,
1✔
2814
                                "color": [250, 127, 94, 255]
1✔
2815
                            }, {
1✔
2816
                                "value": 203.399_999_999_999_98,
1✔
2817
                                "color": [254, 159, 109, 255]
1✔
2818
                            }, {
1✔
2819
                                "value": 220.266_666_666_666_65,
1✔
2820
                                "color": [254, 191, 132, 255]
1✔
2821
                            }, {
1✔
2822
                                "value": 237.133_333_333_333_3,
1✔
2823
                                "color": [253, 222, 160, 255]
1✔
2824
                            }, {
1✔
2825
                                "value": 254,
1✔
2826
                                "color": [252, 253, 191, 255]
1✔
2827
                            }],
1✔
2828
                            "noDataColor": [0, 0, 0, 0],
1✔
2829
                            "overColor": [255, 255, 255, 127],
1✔
2830
                            "underColor": [255, 255, 255, 127]
1✔
2831
                        }
1✔
2832
                    }
1✔
2833
                }
1✔
2834
            }]
1✔
2835
        }))
1✔
2836
        .unwrap();
1✔
2837

1✔
2838
        db.update_project(update).await.unwrap();
16✔
2839

1✔
2840
        let update: UpdateProject = serde_json::from_value(json!({
1✔
2841
            "id": project_id.to_string(),
1✔
2842
            "layers": [{
1✔
2843
                "name": "NDVI",
1✔
2844
                "workflow": workflow_id.to_string(),
1✔
2845
                "visibility": {
1✔
2846
                    "data": true,
1✔
2847
                    "legend": false
1✔
2848
                },
1✔
2849
                "symbology": {
1✔
2850
                    "type": "raster",
1✔
2851
                    "opacity": 1,
1✔
2852
                    "rasterColorizer": {
1✔
2853
                        "type": "singleBand",
1✔
2854
                        "band": 0,
1✔
2855
                        "bandColorizer": {
1✔
2856
                            "type": "linearGradient",
1✔
2857
                            "breakpoints": [{
1✔
2858
                                "value": 1,
1✔
2859
                                "color": [0, 0, 4, 255]
1✔
2860
                            }, {
1✔
2861
                                "value": 17.933_333_333_333_334,
1✔
2862
                                "color": [11, 9, 36, 255]
1✔
2863
                            }, {
1✔
2864
                                "value": 34.866_666_666_666_67,
1✔
2865
                                "color": [32, 17, 75, 255]
1✔
2866
                            }, {
1✔
2867
                                "value": 51.800_000_000_000_004,
1✔
2868
                                "color": [59, 15, 112, 255]
1✔
2869
                            }, {
1✔
2870
                                "value": 68.733_333_333_333_33,
1✔
2871
                                "color": [87, 21, 126, 255]
1✔
2872
                            }, {
1✔
2873
                                "value": 85.666_666_666_666_66,
1✔
2874
                                "color": [114, 31, 129, 255]
1✔
2875
                            }, {
1✔
2876
                                "value": 102.6,
1✔
2877
                                "color": [140, 41, 129, 255]
1✔
2878
                            }, {
1✔
2879
                                "value": 119.533_333_333_333_32,
1✔
2880
                                "color": [168, 50, 125, 255]
1✔
2881
                            }, {
1✔
2882
                                "value": 136.466_666_666_666_67,
1✔
2883
                                "color": [196, 60, 117, 255]
1✔
2884
                            }, {
1✔
2885
                                "value": 153.4,
1✔
2886
                                "color": [222, 73, 104, 255]
1✔
2887
                            }, {
1✔
2888
                                "value": 170.333_333_333_333_31,
1✔
2889
                                "color": [241, 96, 93, 255]
1✔
2890
                            }, {
1✔
2891
                                "value": 187.266_666_666_666_65,
1✔
2892
                                "color": [250, 127, 94, 255]
1✔
2893
                            }, {
1✔
2894
                                "value": 204.2,
1✔
2895
                                "color": [254, 159, 109, 255]
1✔
2896
                            }, {
1✔
2897
                                "value": 221.133_333_333_333_33,
1✔
2898
                                "color": [254, 191, 132, 255]
1✔
2899
                            }, {
1✔
2900
                                "value": 238.066_666_666_666_63,
1✔
2901
                                "color": [253, 222, 160, 255]
1✔
2902
                            }, {
1✔
2903
                                "value": 255,
1✔
2904
                                "color": [252, 253, 191, 255]
1✔
2905
                            }],
1✔
2906
                            "noDataColor": [0, 0, 0, 0],
1✔
2907
                            "overColor": [255, 255, 255, 127],
1✔
2908
                            "underColor": [255, 255, 255, 127]
1✔
2909
                        }
1✔
2910
                    }
1✔
2911
                }
1✔
2912
            }]
1✔
2913
        }))
1✔
2914
        .unwrap();
1✔
2915

2916
        // run two updates concurrently
2917
        let (r0, r1) = join!(db.update_project(update.clone()), db.update_project(update));
1✔
2918

2919
        assert!(r0.is_ok());
1✔
2920
        assert!(r1.is_ok());
1✔
2921
    }
1✔
2922

2923
    #[ge_context::test]
2✔
2924
    #[allow(clippy::too_many_lines)]
2925
    async fn it_resolves_dataset_names_to_ids(app_ctx: PostgresContext<NoTls>) {
1✔
2926
        let session = app_ctx.default_session().await.unwrap();
18✔
2927
        let db = app_ctx.session_context(session.clone()).db();
1✔
2928

1✔
2929
        let loading_info = OgrSourceDataset {
1✔
2930
            file_name: PathBuf::from("test.csv"),
1✔
2931
            layer_name: "test.csv".to_owned(),
1✔
2932
            data_type: Some(VectorDataType::MultiPoint),
1✔
2933
            time: OgrSourceDatasetTimeType::Start {
1✔
2934
                start_field: "start".to_owned(),
1✔
2935
                start_format: OgrSourceTimeFormat::Auto,
1✔
2936
                duration: OgrSourceDurationSpec::Zero,
1✔
2937
            },
1✔
2938
            default_geometry: None,
1✔
2939
            columns: Some(OgrSourceColumnSpec {
1✔
2940
                format_specifics: Some(FormatSpecifics::Csv {
1✔
2941
                    header: CsvHeader::Auto,
1✔
2942
                }),
1✔
2943
                x: "x".to_owned(),
1✔
2944
                y: None,
1✔
2945
                int: vec![],
1✔
2946
                float: vec![],
1✔
2947
                text: vec![],
1✔
2948
                bool: vec![],
1✔
2949
                datetime: vec![],
1✔
2950
                rename: None,
1✔
2951
            }),
1✔
2952
            force_ogr_time_filter: false,
1✔
2953
            force_ogr_spatial_filter: false,
1✔
2954
            on_error: OgrSourceErrorSpec::Ignore,
1✔
2955
            sql_query: None,
1✔
2956
            attribute_query: None,
1✔
2957
            cache_ttl: CacheTtlSeconds::default(),
1✔
2958
        };
1✔
2959

1✔
2960
        let meta_data = MetaDataDefinition::OgrMetaData(StaticMetaData::<
1✔
2961
            OgrSourceDataset,
1✔
2962
            VectorResultDescriptor,
1✔
2963
            VectorQueryRectangle,
1✔
2964
        > {
1✔
2965
            loading_info: loading_info.clone(),
1✔
2966
            result_descriptor: VectorResultDescriptor {
1✔
2967
                data_type: VectorDataType::MultiPoint,
1✔
2968
                spatial_reference: SpatialReference::epsg_4326().into(),
1✔
2969
                columns: [(
1✔
2970
                    "foo".to_owned(),
1✔
2971
                    VectorColumnInfo {
1✔
2972
                        data_type: FeatureDataType::Float,
1✔
2973
                        measurement: Measurement::Unitless,
1✔
2974
                    },
1✔
2975
                )]
1✔
2976
                .into_iter()
1✔
2977
                .collect(),
1✔
2978
                time: None,
1✔
2979
                bbox: None,
1✔
2980
            },
1✔
2981
            phantom: Default::default(),
1✔
2982
        });
1✔
2983

2984
        let DatasetIdAndName {
2985
            id: dataset_id1,
1✔
2986
            name: dataset_name1,
1✔
2987
        } = db
1✔
2988
            .add_dataset(
1✔
2989
                AddDataset {
1✔
2990
                    name: Some(DatasetName::new(None, "my_dataset".to_owned())),
1✔
2991
                    display_name: "Ogr Test".to_owned(),
1✔
2992
                    description: "desc".to_owned(),
1✔
2993
                    source_operator: "OgrSource".to_owned(),
1✔
2994
                    symbology: None,
1✔
2995
                    provenance: Some(vec![Provenance {
1✔
2996
                        citation: "citation".to_owned(),
1✔
2997
                        license: "license".to_owned(),
1✔
2998
                        uri: "uri".to_owned(),
1✔
2999
                    }]),
1✔
3000
                    tags: Some(vec!["upload".to_owned(), "test".to_owned()]),
1✔
3001
                },
1✔
3002
                meta_data.clone(),
1✔
3003
            )
1✔
3004
            .await
160✔
3005
            .unwrap();
1✔
3006

3007
        assert_eq!(
1✔
3008
            db.resolve_dataset_name_to_id(&dataset_name1)
1✔
3009
                .await
3✔
3010
                .unwrap()
1✔
3011
                .unwrap(),
1✔
3012
            dataset_id1
3013
        );
3014
    }
1✔
3015

3016
    #[ge_context::test]
2✔
3017
    #[allow(clippy::too_many_lines)]
3018
    async fn test_postgres_type_serialization(app_ctx: PostgresContext<NoTls>) {
1✔
3019
        let pool = app_ctx.pool.get().await.unwrap();
1✔
3020

1✔
3021
        assert_sql_type(&pool, "RgbaColor", [RgbaColor::new(0, 1, 2, 3)]).await;
4✔
3022

3023
        assert_sql_type(
1✔
3024
            &pool,
1✔
3025
            "double precision",
1✔
3026
            [NotNanF64::from(NotNan::<f64>::new(1.0).unwrap())],
1✔
3027
        )
1✔
3028
        .await;
2✔
3029

3030
        assert_sql_type(
1✔
3031
            &pool,
1✔
3032
            "Breakpoint",
1✔
3033
            [Breakpoint {
1✔
3034
                value: NotNan::<f64>::new(1.0).unwrap(),
1✔
3035
                color: RgbaColor::new(0, 0, 0, 0),
1✔
3036
            }],
1✔
3037
        )
1✔
3038
        .await;
5✔
3039

3040
        assert_sql_type(
1✔
3041
            &pool,
1✔
3042
            "Colorizer",
1✔
3043
            [
1✔
3044
                Colorizer::LinearGradient {
1✔
3045
                    breakpoints: vec![
1✔
3046
                        Breakpoint {
1✔
3047
                            value: NotNan::<f64>::new(-10.0).unwrap(),
1✔
3048
                            color: RgbaColor::new(0, 0, 0, 0),
1✔
3049
                        },
1✔
3050
                        Breakpoint {
1✔
3051
                            value: NotNan::<f64>::new(2.0).unwrap(),
1✔
3052
                            color: RgbaColor::new(255, 0, 0, 255),
1✔
3053
                        },
1✔
3054
                    ],
1✔
3055
                    no_data_color: RgbaColor::new(0, 10, 20, 30),
1✔
3056
                    over_color: RgbaColor::new(1, 2, 3, 4),
1✔
3057
                    under_color: RgbaColor::new(5, 6, 7, 8),
1✔
3058
                },
1✔
3059
                Colorizer::LogarithmicGradient {
1✔
3060
                    breakpoints: vec![
1✔
3061
                        Breakpoint {
1✔
3062
                            value: NotNan::<f64>::new(1.0).unwrap(),
1✔
3063
                            color: RgbaColor::new(0, 0, 0, 0),
1✔
3064
                        },
1✔
3065
                        Breakpoint {
1✔
3066
                            value: NotNan::<f64>::new(2.0).unwrap(),
1✔
3067
                            color: RgbaColor::new(255, 0, 0, 255),
1✔
3068
                        },
1✔
3069
                    ],
1✔
3070
                    no_data_color: RgbaColor::new(0, 10, 20, 30),
1✔
3071
                    over_color: RgbaColor::new(1, 2, 3, 4),
1✔
3072
                    under_color: RgbaColor::new(5, 6, 7, 8),
1✔
3073
                },
1✔
3074
                Colorizer::palette(
1✔
3075
                    [
1✔
3076
                        (NotNan::<f64>::new(1.0).unwrap(), RgbaColor::new(0, 0, 0, 0)),
1✔
3077
                        (
1✔
3078
                            NotNan::<f64>::new(2.0).unwrap(),
1✔
3079
                            RgbaColor::new(255, 0, 0, 255),
1✔
3080
                        ),
1✔
3081
                        (
1✔
3082
                            NotNan::<f64>::new(3.0).unwrap(),
1✔
3083
                            RgbaColor::new(0, 10, 20, 30),
1✔
3084
                        ),
1✔
3085
                    ]
1✔
3086
                    .into(),
1✔
3087
                    RgbaColor::new(1, 2, 3, 4),
1✔
3088
                    RgbaColor::new(5, 6, 7, 8),
1✔
3089
                )
1✔
3090
                .unwrap(),
1✔
3091
            ],
1✔
3092
        )
1✔
3093
        .await;
12✔
3094

3095
        assert_sql_type(
1✔
3096
            &pool,
1✔
3097
            "ColorParam",
1✔
3098
            [
1✔
3099
                ColorParam::Static {
1✔
3100
                    color: RgbaColor::new(0, 10, 20, 30),
1✔
3101
                },
1✔
3102
                ColorParam::Derived(DerivedColor {
1✔
3103
                    attribute: "foobar".to_string(),
1✔
3104
                    colorizer: Colorizer::test_default(),
1✔
3105
                }),
1✔
3106
            ],
1✔
3107
        )
1✔
3108
        .await;
6✔
3109

3110
        assert_sql_type(
1✔
3111
            &pool,
1✔
3112
            "NumberParam",
1✔
3113
            [
1✔
3114
                NumberParam::Static { value: 42 },
1✔
3115
                NumberParam::Derived(DerivedNumber {
1✔
3116
                    attribute: "foobar".to_string(),
1✔
3117
                    factor: 1.0,
1✔
3118
                    default_value: 42.,
1✔
3119
                }),
1✔
3120
            ],
1✔
3121
        )
1✔
3122
        .await;
6✔
3123

3124
        assert_sql_type(
1✔
3125
            &pool,
1✔
3126
            "StrokeParam",
1✔
3127
            [StrokeParam {
1✔
3128
                width: NumberParam::Static { value: 42 },
1✔
3129
                color: ColorParam::Static {
1✔
3130
                    color: RgbaColor::new(0, 10, 20, 30),
1✔
3131
                },
1✔
3132
            }],
1✔
3133
        )
1✔
3134
        .await;
4✔
3135

3136
        assert_sql_type(
1✔
3137
            &pool,
1✔
3138
            "TextSymbology",
1✔
3139
            [TextSymbology {
1✔
3140
                attribute: "attribute".to_string(),
1✔
3141
                fill_color: ColorParam::Static {
1✔
3142
                    color: RgbaColor::new(0, 10, 20, 30),
1✔
3143
                },
1✔
3144
                stroke: StrokeParam {
1✔
3145
                    width: NumberParam::Static { value: 42 },
1✔
3146
                    color: ColorParam::Static {
1✔
3147
                        color: RgbaColor::new(0, 10, 20, 30),
1✔
3148
                    },
1✔
3149
                },
1✔
3150
            }],
1✔
3151
        )
1✔
3152
        .await;
4✔
3153

3154
        assert_sql_type(
1✔
3155
            &pool,
1✔
3156
            "RasterColorizer",
1✔
3157
            [RasterColorizer::SingleBand {
1✔
3158
                band: 0,
1✔
3159
                band_colorizer: Colorizer::LinearGradient {
1✔
3160
                    breakpoints: vec![
1✔
3161
                        Breakpoint {
1✔
3162
                            value: NotNan::<f64>::new(-10.0).unwrap(),
1✔
3163
                            color: RgbaColor::new(0, 0, 0, 0),
1✔
3164
                        },
1✔
3165
                        Breakpoint {
1✔
3166
                            value: NotNan::<f64>::new(2.0).unwrap(),
1✔
3167
                            color: RgbaColor::new(255, 0, 0, 255),
1✔
3168
                        },
1✔
3169
                    ],
1✔
3170
                    no_data_color: RgbaColor::new(0, 10, 20, 30),
1✔
3171
                    over_color: RgbaColor::new(1, 2, 3, 4),
1✔
3172
                    under_color: RgbaColor::new(5, 6, 7, 8),
1✔
3173
                },
1✔
3174
            }],
1✔
3175
        )
1✔
3176
        .await;
6✔
3177

3178
        assert_sql_type(
1✔
3179
            &pool,
1✔
3180
            "RasterColorizer",
1✔
3181
            [RasterColorizer::MultiBand {
1✔
3182
                red_band: 0,
1✔
3183
                green_band: 1,
1✔
3184
                blue_band: 2,
1✔
3185
                rgb_params: RgbParams {
1✔
3186
                    red_min: 0.,
1✔
3187
                    red_max: 255.,
1✔
3188
                    red_scale: 1.,
1✔
3189
                    green_min: 0.,
1✔
3190
                    green_max: 255.,
1✔
3191
                    green_scale: 1.,
1✔
3192
                    blue_min: 0.,
1✔
3193
                    blue_max: 255.,
1✔
3194
                    blue_scale: 1.,
1✔
3195
                    no_data_color: RgbaColor::new(0, 10, 20, 30),
1✔
3196
                },
1✔
3197
            }],
1✔
3198
        )
1✔
3199
        .await;
2✔
3200

3201
        assert_sql_type(
1✔
3202
            &pool,
1✔
3203
            "Symbology",
1✔
3204
            [
1✔
3205
                Symbology::Point(PointSymbology {
1✔
3206
                    fill_color: ColorParam::Static {
1✔
3207
                        color: RgbaColor::new(0, 10, 20, 30),
1✔
3208
                    },
1✔
3209
                    stroke: StrokeParam {
1✔
3210
                        width: NumberParam::Static { value: 42 },
1✔
3211
                        color: ColorParam::Static {
1✔
3212
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3213
                        },
1✔
3214
                    },
1✔
3215
                    radius: NumberParam::Static { value: 42 },
1✔
3216
                    text: Some(TextSymbology {
1✔
3217
                        attribute: "attribute".to_string(),
1✔
3218
                        fill_color: ColorParam::Static {
1✔
3219
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3220
                        },
1✔
3221
                        stroke: StrokeParam {
1✔
3222
                            width: NumberParam::Static { value: 42 },
1✔
3223
                            color: ColorParam::Static {
1✔
3224
                                color: RgbaColor::new(0, 10, 20, 30),
1✔
3225
                            },
1✔
3226
                        },
1✔
3227
                    }),
1✔
3228
                }),
1✔
3229
                Symbology::Line(LineSymbology {
1✔
3230
                    stroke: StrokeParam {
1✔
3231
                        width: NumberParam::Static { value: 42 },
1✔
3232
                        color: ColorParam::Static {
1✔
3233
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3234
                        },
1✔
3235
                    },
1✔
3236
                    text: Some(TextSymbology {
1✔
3237
                        attribute: "attribute".to_string(),
1✔
3238
                        fill_color: ColorParam::Static {
1✔
3239
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3240
                        },
1✔
3241
                        stroke: StrokeParam {
1✔
3242
                            width: NumberParam::Static { value: 42 },
1✔
3243
                            color: ColorParam::Static {
1✔
3244
                                color: RgbaColor::new(0, 10, 20, 30),
1✔
3245
                            },
1✔
3246
                        },
1✔
3247
                    }),
1✔
3248
                    auto_simplified: true,
1✔
3249
                }),
1✔
3250
                Symbology::Polygon(PolygonSymbology {
1✔
3251
                    fill_color: ColorParam::Static {
1✔
3252
                        color: RgbaColor::new(0, 10, 20, 30),
1✔
3253
                    },
1✔
3254
                    stroke: StrokeParam {
1✔
3255
                        width: NumberParam::Static { value: 42 },
1✔
3256
                        color: ColorParam::Static {
1✔
3257
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3258
                        },
1✔
3259
                    },
1✔
3260
                    text: Some(TextSymbology {
1✔
3261
                        attribute: "attribute".to_string(),
1✔
3262
                        fill_color: ColorParam::Static {
1✔
3263
                            color: RgbaColor::new(0, 10, 20, 30),
1✔
3264
                        },
1✔
3265
                        stroke: StrokeParam {
1✔
3266
                            width: NumberParam::Static { value: 42 },
1✔
3267
                            color: ColorParam::Static {
1✔
3268
                                color: RgbaColor::new(0, 10, 20, 30),
1✔
3269
                            },
1✔
3270
                        },
1✔
3271
                    }),
1✔
3272
                    auto_simplified: true,
1✔
3273
                }),
1✔
3274
                Symbology::Raster(RasterSymbology {
1✔
3275
                    opacity: 1.0,
1✔
3276
                    raster_colorizer: RasterColorizer::SingleBand {
1✔
3277
                        band: 0,
1✔
3278
                        band_colorizer: Colorizer::LinearGradient {
1✔
3279
                            breakpoints: vec![
1✔
3280
                                Breakpoint {
1✔
3281
                                    value: NotNan::<f64>::new(-10.0).unwrap(),
1✔
3282
                                    color: RgbaColor::new(0, 0, 0, 0),
1✔
3283
                                },
1✔
3284
                                Breakpoint {
1✔
3285
                                    value: NotNan::<f64>::new(2.0).unwrap(),
1✔
3286
                                    color: RgbaColor::new(255, 0, 0, 255),
1✔
3287
                                },
1✔
3288
                            ],
1✔
3289
                            no_data_color: RgbaColor::new(0, 10, 20, 30),
1✔
3290
                            over_color: RgbaColor::new(1, 2, 3, 4),
1✔
3291
                            under_color: RgbaColor::new(5, 6, 7, 8),
1✔
3292
                        },
1✔
3293
                    },
1✔
3294
                }),
1✔
3295
            ],
1✔
3296
        )
1✔
3297
        .await;
18✔
3298

3299
        assert_sql_type(
1✔
3300
            &pool,
1✔
3301
            "RasterDataType",
1✔
3302
            [
1✔
3303
                RasterDataType::U8,
1✔
3304
                RasterDataType::U16,
1✔
3305
                RasterDataType::U32,
1✔
3306
                RasterDataType::U64,
1✔
3307
                RasterDataType::I8,
1✔
3308
                RasterDataType::I16,
1✔
3309
                RasterDataType::I32,
1✔
3310
                RasterDataType::I64,
1✔
3311
                RasterDataType::F32,
1✔
3312
                RasterDataType::F64,
1✔
3313
            ],
1✔
3314
        )
1✔
3315
        .await;
22✔
3316

3317
        assert_sql_type(
1✔
3318
            &pool,
1✔
3319
            "Measurement",
1✔
3320
            [
1✔
3321
                Measurement::Unitless,
1✔
3322
                Measurement::Continuous(ContinuousMeasurement {
1✔
3323
                    measurement: "Temperature".to_string(),
1✔
3324
                    unit: Some("°C".to_string()),
1✔
3325
                }),
1✔
3326
                Measurement::Classification(ClassificationMeasurement {
1✔
3327
                    measurement: "Color".to_string(),
1✔
3328
                    classes: [(1, "Grayscale".to_string()), (2, "Colorful".to_string())].into(),
1✔
3329
                }),
1✔
3330
            ],
1✔
3331
        )
1✔
3332
        .await;
16✔
3333

3334
        assert_sql_type(&pool, "Coordinate2D", [Coordinate2D::new(0.0f64, 1.)]).await;
4✔
3335

3336
        assert_sql_type(
1✔
3337
            &pool,
1✔
3338
            "SpatialPartition2D",
1✔
3339
            [
1✔
3340
                SpatialPartition2D::new(Coordinate2D::new(0.0f64, 1.), Coordinate2D::new(2., 0.5))
1✔
3341
                    .unwrap(),
1✔
3342
            ],
1✔
3343
        )
1✔
3344
        .await;
4✔
3345

3346
        assert_sql_type(
1✔
3347
            &pool,
1✔
3348
            "BoundingBox2D",
1✔
3349
            [
1✔
3350
                BoundingBox2D::new(Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0))
1✔
3351
                    .unwrap(),
1✔
3352
            ],
1✔
3353
        )
1✔
3354
        .await;
4✔
3355

3356
        assert_sql_type(
1✔
3357
            &pool,
1✔
3358
            "SpatialResolution",
1✔
3359
            [SpatialResolution { x: 1.2, y: 2.3 }],
1✔
3360
        )
1✔
3361
        .await;
4✔
3362

3363
        assert_sql_type(
1✔
3364
            &pool,
1✔
3365
            "VectorDataType",
1✔
3366
            [
1✔
3367
                VectorDataType::Data,
1✔
3368
                VectorDataType::MultiPoint,
1✔
3369
                VectorDataType::MultiLineString,
1✔
3370
                VectorDataType::MultiPolygon,
1✔
3371
            ],
1✔
3372
        )
1✔
3373
        .await;
10✔
3374

3375
        assert_sql_type(
1✔
3376
            &pool,
1✔
3377
            "FeatureDataType",
1✔
3378
            [
1✔
3379
                FeatureDataType::Category,
1✔
3380
                FeatureDataType::Int,
1✔
3381
                FeatureDataType::Float,
1✔
3382
                FeatureDataType::Text,
1✔
3383
                FeatureDataType::Bool,
1✔
3384
                FeatureDataType::DateTime,
1✔
3385
            ],
1✔
3386
        )
1✔
3387
        .await;
14✔
3388

3389
        assert_sql_type(&pool, "TimeInterval", [TimeInterval::default()]).await;
4✔
3390

3391
        assert_sql_type(
1✔
3392
            &pool,
1✔
3393
            "SpatialReference",
1✔
3394
            [
1✔
3395
                SpatialReferenceOption::Unreferenced,
1✔
3396
                SpatialReferenceOption::SpatialReference(SpatialReference::epsg_4326()),
1✔
3397
            ],
1✔
3398
        )
1✔
3399
        .await;
8✔
3400

3401
        assert_sql_type(
1✔
3402
            &pool,
1✔
3403
            "PlotResultDescriptor",
1✔
3404
            [PlotResultDescriptor {
1✔
3405
                spatial_reference: SpatialReferenceOption::Unreferenced,
1✔
3406
                time: None,
1✔
3407
                bbox: None,
1✔
3408
            }],
1✔
3409
        )
1✔
3410
        .await;
4✔
3411

3412
        assert_sql_type(
1✔
3413
            &pool,
1✔
3414
            "VectorResultDescriptor",
1✔
3415
            [VectorResultDescriptor {
1✔
3416
                data_type: VectorDataType::MultiPoint,
1✔
3417
                spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3418
                    SpatialReference::epsg_4326(),
1✔
3419
                ),
1✔
3420
                columns: [(
1✔
3421
                    "foo".to_string(),
1✔
3422
                    VectorColumnInfo {
1✔
3423
                        data_type: FeatureDataType::Int,
1✔
3424
                        measurement: Measurement::Unitless,
1✔
3425
                    },
1✔
3426
                )]
1✔
3427
                .into(),
1✔
3428
                time: Some(TimeInterval::default()),
1✔
3429
                bbox: Some(
1✔
3430
                    BoundingBox2D::new(Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0))
1✔
3431
                        .unwrap(),
1✔
3432
                ),
1✔
3433
            }],
1✔
3434
        )
1✔
3435
        .await;
7✔
3436

3437
        assert_sql_type(
1✔
3438
            &pool,
1✔
3439
            "RasterResultDescriptor",
1✔
3440
            [RasterResultDescriptor {
1✔
3441
                data_type: RasterDataType::U8,
1✔
3442
                spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3443
                    SpatialReference::epsg_4326(),
1✔
3444
                ),
1✔
3445
                time: Some(TimeInterval::default()),
1✔
3446
                bbox: Some(
1✔
3447
                    SpatialPartition2D::new(
1✔
3448
                        Coordinate2D::new(0.0f64, 1.),
1✔
3449
                        Coordinate2D::new(2., 0.5),
1✔
3450
                    )
1✔
3451
                    .unwrap(),
1✔
3452
                ),
1✔
3453
                resolution: Some(SpatialResolution { x: 1.2, y: 2.3 }),
1✔
3454
                bands: RasterBandDescriptors::new_single_band(),
1✔
3455
            }],
1✔
3456
        )
1✔
3457
        .await;
7✔
3458

3459
        assert_sql_type(
1✔
3460
            &pool,
1✔
3461
            "ResultDescriptor",
1✔
3462
            [
1✔
3463
                TypedResultDescriptor::Vector(VectorResultDescriptor {
1✔
3464
                    data_type: VectorDataType::MultiPoint,
1✔
3465
                    spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3466
                        SpatialReference::epsg_4326(),
1✔
3467
                    ),
1✔
3468
                    columns: [(
1✔
3469
                        "foo".to_string(),
1✔
3470
                        VectorColumnInfo {
1✔
3471
                            data_type: FeatureDataType::Int,
1✔
3472
                            measurement: Measurement::Unitless,
1✔
3473
                        },
1✔
3474
                    )]
1✔
3475
                    .into(),
1✔
3476
                    time: Some(TimeInterval::default()),
1✔
3477
                    bbox: Some(
1✔
3478
                        BoundingBox2D::new(
1✔
3479
                            Coordinate2D::new(0.0f64, 0.5),
1✔
3480
                            Coordinate2D::new(2., 1.0),
1✔
3481
                        )
1✔
3482
                        .unwrap(),
1✔
3483
                    ),
1✔
3484
                }),
1✔
3485
                TypedResultDescriptor::Raster(RasterResultDescriptor {
1✔
3486
                    data_type: RasterDataType::U8,
1✔
3487
                    spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3488
                        SpatialReference::epsg_4326(),
1✔
3489
                    ),
1✔
3490
                    time: Some(TimeInterval::default()),
1✔
3491
                    bbox: Some(
1✔
3492
                        SpatialPartition2D::new(
1✔
3493
                            Coordinate2D::new(0.0f64, 1.),
1✔
3494
                            Coordinate2D::new(2., 0.5),
1✔
3495
                        )
1✔
3496
                        .unwrap(),
1✔
3497
                    ),
1✔
3498
                    resolution: Some(SpatialResolution { x: 1.2, y: 2.3 }),
1✔
3499
                    bands: RasterBandDescriptors::new_single_band(),
1✔
3500
                }),
1✔
3501
                TypedResultDescriptor::Plot(PlotResultDescriptor {
1✔
3502
                    spatial_reference: SpatialReferenceOption::Unreferenced,
1✔
3503
                    time: None,
1✔
3504
                    bbox: None,
1✔
3505
                }),
1✔
3506
            ],
1✔
3507
        )
1✔
3508
        .await;
9✔
3509

3510
        assert_sql_type(
1✔
3511
            &pool,
1✔
3512
            "MockDatasetDataSourceLoadingInfo",
1✔
3513
            [MockDatasetDataSourceLoadingInfo {
1✔
3514
                points: vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3515
            }],
1✔
3516
        )
1✔
3517
        .await;
5✔
3518

3519
        assert_sql_type(
1✔
3520
            &pool,
1✔
3521
            "OgrSourceTimeFormat",
1✔
3522
            [
1✔
3523
                OgrSourceTimeFormat::Auto,
1✔
3524
                OgrSourceTimeFormat::Custom {
1✔
3525
                    custom_format: geoengine_datatypes::primitives::DateTimeParseFormat::custom(
1✔
3526
                        "%Y-%m-%dT%H:%M:%S%.3fZ".to_string(),
1✔
3527
                    ),
1✔
3528
                },
1✔
3529
                OgrSourceTimeFormat::UnixTimeStamp {
1✔
3530
                    timestamp_type: UnixTimeStampType::EpochSeconds,
1✔
3531
                    fmt: geoengine_datatypes::primitives::DateTimeParseFormat::unix(),
1✔
3532
                },
1✔
3533
            ],
1✔
3534
        )
1✔
3535
        .await;
16✔
3536

3537
        assert_sql_type(
1✔
3538
            &pool,
1✔
3539
            "OgrSourceDurationSpec",
1✔
3540
            [
1✔
3541
                OgrSourceDurationSpec::Infinite,
1✔
3542
                OgrSourceDurationSpec::Zero,
1✔
3543
                OgrSourceDurationSpec::Value(TimeStep {
1✔
3544
                    granularity: TimeGranularity::Millis,
1✔
3545
                    step: 1000,
1✔
3546
                }),
1✔
3547
            ],
1✔
3548
        )
1✔
3549
        .await;
12✔
3550

3551
        assert_sql_type(
1✔
3552
            &pool,
1✔
3553
            "OgrSourceDatasetTimeType",
1✔
3554
            [
1✔
3555
                OgrSourceDatasetTimeType::None,
1✔
3556
                OgrSourceDatasetTimeType::Start {
1✔
3557
                    start_field: "start".to_string(),
1✔
3558
                    start_format: OgrSourceTimeFormat::Auto,
1✔
3559
                    duration: OgrSourceDurationSpec::Zero,
1✔
3560
                },
1✔
3561
                OgrSourceDatasetTimeType::StartEnd {
1✔
3562
                    start_field: "start".to_string(),
1✔
3563
                    start_format: OgrSourceTimeFormat::Auto,
1✔
3564
                    end_field: "end".to_string(),
1✔
3565
                    end_format: OgrSourceTimeFormat::Auto,
1✔
3566
                },
1✔
3567
                OgrSourceDatasetTimeType::StartDuration {
1✔
3568
                    start_field: "start".to_string(),
1✔
3569
                    start_format: OgrSourceTimeFormat::Auto,
1✔
3570
                    duration_field: "duration".to_string(),
1✔
3571
                },
1✔
3572
            ],
1✔
3573
        )
1✔
3574
        .await;
16✔
3575

3576
        assert_sql_type(
1✔
3577
            &pool,
1✔
3578
            "FormatSpecifics",
1✔
3579
            [FormatSpecifics::Csv {
1✔
3580
                header: CsvHeader::Yes,
1✔
3581
            }],
1✔
3582
        )
1✔
3583
        .await;
8✔
3584

3585
        assert_sql_type(
1✔
3586
            &pool,
1✔
3587
            "OgrSourceColumnSpec",
1✔
3588
            [OgrSourceColumnSpec {
1✔
3589
                format_specifics: Some(FormatSpecifics::Csv {
1✔
3590
                    header: CsvHeader::Auto,
1✔
3591
                }),
1✔
3592
                x: "x".to_string(),
1✔
3593
                y: Some("y".to_string()),
1✔
3594
                int: vec!["int".to_string()],
1✔
3595
                float: vec!["float".to_string()],
1✔
3596
                text: vec!["text".to_string()],
1✔
3597
                bool: vec!["bool".to_string()],
1✔
3598
                datetime: vec!["datetime".to_string()],
1✔
3599
                rename: Some(
1✔
3600
                    [
1✔
3601
                        ("xx".to_string(), "xx_renamed".to_string()),
1✔
3602
                        ("yx".to_string(), "yy_renamed".to_string()),
1✔
3603
                    ]
1✔
3604
                    .into(),
1✔
3605
                ),
1✔
3606
            }],
1✔
3607
        )
1✔
3608
        .await;
7✔
3609

3610
        assert_sql_type(
1✔
3611
            &pool,
1✔
3612
            "point[]",
1✔
3613
            [MultiPoint::new(vec![
1✔
3614
                Coordinate2D::new(0.0f64, 0.5),
1✔
3615
                Coordinate2D::new(2., 1.0),
1✔
3616
            ])
1✔
3617
            .unwrap()],
1✔
3618
        )
1✔
3619
        .await;
2✔
3620

3621
        assert_sql_type(
1✔
3622
            &pool,
1✔
3623
            "path[]",
1✔
3624
            [MultiLineString::new(vec![
1✔
3625
                vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3626
                vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3627
            ])
1✔
3628
            .unwrap()],
1✔
3629
        )
1✔
3630
        .await;
3✔
3631

3632
        assert_sql_type(
1✔
3633
            &pool,
1✔
3634
            "\"Polygon\"[]",
1✔
3635
            [MultiPolygon::new(vec![
1✔
3636
                vec![
1✔
3637
                    vec![
1✔
3638
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3639
                        Coordinate2D::new(2., 1.0),
1✔
3640
                        Coordinate2D::new(2., 1.0),
1✔
3641
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3642
                    ],
1✔
3643
                    vec![
1✔
3644
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3645
                        Coordinate2D::new(2., 1.0),
1✔
3646
                        Coordinate2D::new(2., 1.0),
1✔
3647
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3648
                    ],
1✔
3649
                ],
1✔
3650
                vec![
1✔
3651
                    vec![
1✔
3652
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3653
                        Coordinate2D::new(2., 1.0),
1✔
3654
                        Coordinate2D::new(2., 1.0),
1✔
3655
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3656
                    ],
1✔
3657
                    vec![
1✔
3658
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3659
                        Coordinate2D::new(2., 1.0),
1✔
3660
                        Coordinate2D::new(2., 1.0),
1✔
3661
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3662
                    ],
1✔
3663
                ],
1✔
3664
            ])
1✔
3665
            .unwrap()],
1✔
3666
        )
1✔
3667
        .await;
4✔
3668

3669
        assert_sql_type(
1✔
3670
            &pool,
1✔
3671
            "TypedGeometry",
1✔
3672
            [
1✔
3673
                TypedGeometry::Data(NoGeometry),
1✔
3674
                TypedGeometry::MultiPoint(
1✔
3675
                    MultiPoint::new(vec![
1✔
3676
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3677
                        Coordinate2D::new(2., 1.0),
1✔
3678
                    ])
1✔
3679
                    .unwrap(),
1✔
3680
                ),
1✔
3681
                TypedGeometry::MultiLineString(
1✔
3682
                    MultiLineString::new(vec![
1✔
3683
                        vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3684
                        vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3685
                    ])
1✔
3686
                    .unwrap(),
1✔
3687
                ),
1✔
3688
                TypedGeometry::MultiPolygon(
1✔
3689
                    MultiPolygon::new(vec![
1✔
3690
                        vec![
1✔
3691
                            vec![
1✔
3692
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3693
                                Coordinate2D::new(2., 1.0),
1✔
3694
                                Coordinate2D::new(2., 1.0),
1✔
3695
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3696
                            ],
1✔
3697
                            vec![
1✔
3698
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3699
                                Coordinate2D::new(2., 1.0),
1✔
3700
                                Coordinate2D::new(2., 1.0),
1✔
3701
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3702
                            ],
1✔
3703
                        ],
1✔
3704
                        vec![
1✔
3705
                            vec![
1✔
3706
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3707
                                Coordinate2D::new(2., 1.0),
1✔
3708
                                Coordinate2D::new(2., 1.0),
1✔
3709
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3710
                            ],
1✔
3711
                            vec![
1✔
3712
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3713
                                Coordinate2D::new(2., 1.0),
1✔
3714
                                Coordinate2D::new(2., 1.0),
1✔
3715
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3716
                            ],
1✔
3717
                        ],
1✔
3718
                    ])
1✔
3719
                    .unwrap(),
1✔
3720
                ),
1✔
3721
            ],
1✔
3722
        )
1✔
3723
        .await;
10✔
3724

3725
        assert_sql_type(&pool, "int", [CacheTtlSeconds::new(100)]).await;
2✔
3726

3727
        assert_sql_type(
1✔
3728
            &pool,
1✔
3729
            "OgrSourceDataset",
1✔
3730
            [OgrSourceDataset {
1✔
3731
                file_name: "test".into(),
1✔
3732
                layer_name: "test".to_string(),
1✔
3733
                data_type: Some(VectorDataType::MultiPoint),
1✔
3734
                time: OgrSourceDatasetTimeType::Start {
1✔
3735
                    start_field: "start".to_string(),
1✔
3736
                    start_format: OgrSourceTimeFormat::Auto,
1✔
3737
                    duration: OgrSourceDurationSpec::Zero,
1✔
3738
                },
1✔
3739
                default_geometry: Some(TypedGeometry::MultiPoint(
1✔
3740
                    MultiPoint::new(vec![
1✔
3741
                        Coordinate2D::new(0.0f64, 0.5),
1✔
3742
                        Coordinate2D::new(2., 1.0),
1✔
3743
                    ])
1✔
3744
                    .unwrap(),
1✔
3745
                )),
1✔
3746
                columns: Some(OgrSourceColumnSpec {
1✔
3747
                    format_specifics: Some(FormatSpecifics::Csv {
1✔
3748
                        header: CsvHeader::Auto,
1✔
3749
                    }),
1✔
3750
                    x: "x".to_string(),
1✔
3751
                    y: Some("y".to_string()),
1✔
3752
                    int: vec!["int".to_string()],
1✔
3753
                    float: vec!["float".to_string()],
1✔
3754
                    text: vec!["text".to_string()],
1✔
3755
                    bool: vec!["bool".to_string()],
1✔
3756
                    datetime: vec!["datetime".to_string()],
1✔
3757
                    rename: Some(
1✔
3758
                        [
1✔
3759
                            ("xx".to_string(), "xx_renamed".to_string()),
1✔
3760
                            ("yx".to_string(), "yy_renamed".to_string()),
1✔
3761
                        ]
1✔
3762
                        .into(),
1✔
3763
                    ),
1✔
3764
                }),
1✔
3765
                force_ogr_time_filter: false,
1✔
3766
                force_ogr_spatial_filter: true,
1✔
3767
                on_error: OgrSourceErrorSpec::Abort,
1✔
3768
                sql_query: None,
1✔
3769
                attribute_query: Some("foo = 'bar'".to_string()),
1✔
3770
                cache_ttl: CacheTtlSeconds::new(5),
1✔
3771
            }],
1✔
3772
        )
1✔
3773
        .await;
6✔
3774

3775
        assert_sql_type(
1✔
3776
            &pool,
1✔
3777
            "MockMetaData",
1✔
3778
            [StaticMetaData::<
1✔
3779
                MockDatasetDataSourceLoadingInfo,
1✔
3780
                VectorResultDescriptor,
1✔
3781
                VectorQueryRectangle,
1✔
3782
            > {
1✔
3783
                loading_info: MockDatasetDataSourceLoadingInfo {
1✔
3784
                    points: vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
3785
                },
1✔
3786
                result_descriptor: VectorResultDescriptor {
1✔
3787
                    data_type: VectorDataType::MultiPoint,
1✔
3788
                    spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3789
                        SpatialReference::epsg_4326(),
1✔
3790
                    ),
1✔
3791
                    columns: [(
1✔
3792
                        "foo".to_string(),
1✔
3793
                        VectorColumnInfo {
1✔
3794
                            data_type: FeatureDataType::Int,
1✔
3795
                            measurement: Measurement::Unitless,
1✔
3796
                        },
1✔
3797
                    )]
1✔
3798
                    .into(),
1✔
3799
                    time: Some(TimeInterval::default()),
1✔
3800
                    bbox: Some(
1✔
3801
                        BoundingBox2D::new(
1✔
3802
                            Coordinate2D::new(0.0f64, 0.5),
1✔
3803
                            Coordinate2D::new(2., 1.0),
1✔
3804
                        )
1✔
3805
                        .unwrap(),
1✔
3806
                    ),
1✔
3807
                },
1✔
3808
                phantom: PhantomData,
1✔
3809
            }],
1✔
3810
        )
1✔
3811
        .await;
4✔
3812

3813
        assert_sql_type(
1✔
3814
            &pool,
1✔
3815
            "OgrMetaData",
1✔
3816
            [
1✔
3817
                StaticMetaData::<OgrSourceDataset, VectorResultDescriptor, VectorQueryRectangle> {
1✔
3818
                    loading_info: OgrSourceDataset {
1✔
3819
                        file_name: "test".into(),
1✔
3820
                        layer_name: "test".to_string(),
1✔
3821
                        data_type: Some(VectorDataType::MultiPoint),
1✔
3822
                        time: OgrSourceDatasetTimeType::Start {
1✔
3823
                            start_field: "start".to_string(),
1✔
3824
                            start_format: OgrSourceTimeFormat::Auto,
1✔
3825
                            duration: OgrSourceDurationSpec::Zero,
1✔
3826
                        },
1✔
3827
                        default_geometry: Some(TypedGeometry::MultiPoint(
1✔
3828
                            MultiPoint::new(vec![
1✔
3829
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3830
                                Coordinate2D::new(2., 1.0),
1✔
3831
                            ])
1✔
3832
                            .unwrap(),
1✔
3833
                        )),
1✔
3834
                        columns: Some(OgrSourceColumnSpec {
1✔
3835
                            format_specifics: Some(FormatSpecifics::Csv {
1✔
3836
                                header: CsvHeader::Auto,
1✔
3837
                            }),
1✔
3838
                            x: "x".to_string(),
1✔
3839
                            y: Some("y".to_string()),
1✔
3840
                            int: vec!["int".to_string()],
1✔
3841
                            float: vec!["float".to_string()],
1✔
3842
                            text: vec!["text".to_string()],
1✔
3843
                            bool: vec!["bool".to_string()],
1✔
3844
                            datetime: vec!["datetime".to_string()],
1✔
3845
                            rename: Some(
1✔
3846
                                [
1✔
3847
                                    ("xx".to_string(), "xx_renamed".to_string()),
1✔
3848
                                    ("yx".to_string(), "yy_renamed".to_string()),
1✔
3849
                                ]
1✔
3850
                                .into(),
1✔
3851
                            ),
1✔
3852
                        }),
1✔
3853
                        force_ogr_time_filter: false,
1✔
3854
                        force_ogr_spatial_filter: true,
1✔
3855
                        on_error: OgrSourceErrorSpec::Abort,
1✔
3856
                        sql_query: None,
1✔
3857
                        attribute_query: Some("foo = 'bar'".to_string()),
1✔
3858
                        cache_ttl: CacheTtlSeconds::new(5),
1✔
3859
                    },
1✔
3860
                    result_descriptor: VectorResultDescriptor {
1✔
3861
                        data_type: VectorDataType::MultiPoint,
1✔
3862
                        spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
3863
                            SpatialReference::epsg_4326(),
1✔
3864
                        ),
1✔
3865
                        columns: [(
1✔
3866
                            "foo".to_string(),
1✔
3867
                            VectorColumnInfo {
1✔
3868
                                data_type: FeatureDataType::Int,
1✔
3869
                                measurement: Measurement::Unitless,
1✔
3870
                            },
1✔
3871
                        )]
1✔
3872
                        .into(),
1✔
3873
                        time: Some(TimeInterval::default()),
1✔
3874
                        bbox: Some(
1✔
3875
                            BoundingBox2D::new(
1✔
3876
                                Coordinate2D::new(0.0f64, 0.5),
1✔
3877
                                Coordinate2D::new(2., 1.0),
1✔
3878
                            )
1✔
3879
                            .unwrap(),
1✔
3880
                        ),
1✔
3881
                    },
1✔
3882
                    phantom: PhantomData,
1✔
3883
                },
1✔
3884
            ],
1✔
3885
        )
1✔
3886
        .await;
4✔
3887

3888
        assert_sql_type(
1✔
3889
            &pool,
1✔
3890
            "GdalDatasetGeoTransform",
1✔
3891
            [GdalDatasetGeoTransform {
1✔
3892
                origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
3893
                x_pixel_size: 1.0,
1✔
3894
                y_pixel_size: 2.0,
1✔
3895
            }],
1✔
3896
        )
1✔
3897
        .await;
4✔
3898

3899
        assert_sql_type(
1✔
3900
            &pool,
1✔
3901
            "FileNotFoundHandling",
1✔
3902
            [FileNotFoundHandling::NoData, FileNotFoundHandling::Error],
1✔
3903
        )
1✔
3904
        .await;
6✔
3905

3906
        assert_sql_type(
1✔
3907
            &pool,
1✔
3908
            "GdalMetadataMapping",
1✔
3909
            [GdalMetadataMapping {
1✔
3910
                source_key: RasterPropertiesKey {
1✔
3911
                    domain: None,
1✔
3912
                    key: "foo".to_string(),
1✔
3913
                },
1✔
3914
                target_key: RasterPropertiesKey {
1✔
3915
                    domain: Some("bar".to_string()),
1✔
3916
                    key: "foo".to_string(),
1✔
3917
                },
1✔
3918
                target_type: RasterPropertiesEntryType::String,
1✔
3919
            }],
1✔
3920
        )
1✔
3921
        .await;
8✔
3922

3923
        assert_sql_type(
1✔
3924
            &pool,
1✔
3925
            "StringPair",
1✔
3926
            [StringPair::from(("foo".to_string(), "bar".to_string()))],
1✔
3927
        )
1✔
3928
        .await;
3✔
3929

3930
        assert_sql_type(
1✔
3931
            &pool,
1✔
3932
            "GdalDatasetParameters",
1✔
3933
            [GdalDatasetParameters {
1✔
3934
                file_path: "text".into(),
1✔
3935
                rasterband_channel: 1,
1✔
3936
                geo_transform: GdalDatasetGeoTransform {
1✔
3937
                    origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
3938
                    x_pixel_size: 1.0,
1✔
3939
                    y_pixel_size: 2.0,
1✔
3940
                },
1✔
3941
                width: 42,
1✔
3942
                height: 23,
1✔
3943
                file_not_found_handling: FileNotFoundHandling::NoData,
1✔
3944
                no_data_value: Some(42.0),
1✔
3945
                properties_mapping: Some(vec![GdalMetadataMapping {
1✔
3946
                    source_key: RasterPropertiesKey {
1✔
3947
                        domain: None,
1✔
3948
                        key: "foo".to_string(),
1✔
3949
                    },
1✔
3950
                    target_key: RasterPropertiesKey {
1✔
3951
                        domain: Some("bar".to_string()),
1✔
3952
                        key: "foo".to_string(),
1✔
3953
                    },
1✔
3954
                    target_type: RasterPropertiesEntryType::String,
1✔
3955
                }]),
1✔
3956
                gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
3957
                gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
3958
                allow_alphaband_as_mask: false,
1✔
3959
                retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
3960
            }],
1✔
3961
        )
1✔
3962
        .await;
8✔
3963

3964
        assert_sql_type(
1✔
3965
            &pool,
1✔
3966
            "GdalMetaDataRegular",
1✔
3967
            [GdalMetaDataRegular {
1✔
3968
                result_descriptor: RasterResultDescriptor {
1✔
3969
                    data_type: RasterDataType::U8,
1✔
3970
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
3971
                    time: TimeInterval::new_unchecked(0, 1).into(),
1✔
3972
                    bbox: Some(
1✔
3973
                        SpatialPartition2D::new(
1✔
3974
                            Coordinate2D::new(0.0f64, 1.),
1✔
3975
                            Coordinate2D::new(2., 0.5),
1✔
3976
                        )
1✔
3977
                        .unwrap(),
1✔
3978
                    ),
1✔
3979
                    resolution: Some(SpatialResolution::zero_point_one()),
1✔
3980
                    bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
3981
                        "band".into(),
1✔
3982
                        Measurement::Continuous(ContinuousMeasurement {
1✔
3983
                            measurement: "Temperature".to_string(),
1✔
3984
                            unit: Some("°C".to_string()),
1✔
3985
                        }),
1✔
3986
                    )])
1✔
3987
                    .unwrap(),
1✔
3988
                },
1✔
3989
                params: GdalDatasetParameters {
1✔
3990
                    file_path: "text".into(),
1✔
3991
                    rasterband_channel: 1,
1✔
3992
                    geo_transform: GdalDatasetGeoTransform {
1✔
3993
                        origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
3994
                        x_pixel_size: 1.0,
1✔
3995
                        y_pixel_size: 2.0,
1✔
3996
                    },
1✔
3997
                    width: 42,
1✔
3998
                    height: 23,
1✔
3999
                    file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4000
                    no_data_value: Some(42.0),
1✔
4001
                    properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4002
                        source_key: RasterPropertiesKey {
1✔
4003
                            domain: None,
1✔
4004
                            key: "foo".to_string(),
1✔
4005
                        },
1✔
4006
                        target_key: RasterPropertiesKey {
1✔
4007
                            domain: Some("bar".to_string()),
1✔
4008
                            key: "foo".to_string(),
1✔
4009
                        },
1✔
4010
                        target_type: RasterPropertiesEntryType::String,
1✔
4011
                    }]),
1✔
4012
                    gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4013
                    gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4014
                    allow_alphaband_as_mask: false,
1✔
4015
                    retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4016
                },
1✔
4017
                time_placeholders: [(
1✔
4018
                    "foo".to_string(),
1✔
4019
                    GdalSourceTimePlaceholder {
1✔
4020
                        format: geoengine_datatypes::primitives::DateTimeParseFormat::unix(),
1✔
4021
                        reference: TimeReference::Start,
1✔
4022
                    },
1✔
4023
                )]
1✔
4024
                .into(),
1✔
4025
                data_time: TimeInterval::new_unchecked(0, 1),
1✔
4026
                step: TimeStep {
1✔
4027
                    granularity: TimeGranularity::Millis,
1✔
4028
                    step: 1,
1✔
4029
                },
1✔
4030
                cache_ttl: CacheTtlSeconds::max(),
1✔
4031
            }],
1✔
4032
        )
1✔
4033
        .await;
11✔
4034

4035
        assert_sql_type(
1✔
4036
            &pool,
1✔
4037
            "GdalMetaDataStatic",
1✔
4038
            [GdalMetaDataStatic {
1✔
4039
                time: Some(TimeInterval::new_unchecked(0, 1)),
1✔
4040
                result_descriptor: RasterResultDescriptor {
1✔
4041
                    data_type: RasterDataType::U8,
1✔
4042
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4043
                    time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4044
                    bbox: Some(
1✔
4045
                        SpatialPartition2D::new(
1✔
4046
                            Coordinate2D::new(0.0f64, 1.),
1✔
4047
                            Coordinate2D::new(2., 0.5),
1✔
4048
                        )
1✔
4049
                        .unwrap(),
1✔
4050
                    ),
1✔
4051
                    resolution: Some(SpatialResolution::zero_point_one()),
1✔
4052
                    bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4053
                        "band".into(),
1✔
4054
                        Measurement::Continuous(ContinuousMeasurement {
1✔
4055
                            measurement: "Temperature".to_string(),
1✔
4056
                            unit: Some("°C".to_string()),
1✔
4057
                        }),
1✔
4058
                    )])
1✔
4059
                    .unwrap(),
1✔
4060
                },
1✔
4061
                params: GdalDatasetParameters {
1✔
4062
                    file_path: "text".into(),
1✔
4063
                    rasterband_channel: 1,
1✔
4064
                    geo_transform: GdalDatasetGeoTransform {
1✔
4065
                        origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4066
                        x_pixel_size: 1.0,
1✔
4067
                        y_pixel_size: 2.0,
1✔
4068
                    },
1✔
4069
                    width: 42,
1✔
4070
                    height: 23,
1✔
4071
                    file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4072
                    no_data_value: Some(42.0),
1✔
4073
                    properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4074
                        source_key: RasterPropertiesKey {
1✔
4075
                            domain: None,
1✔
4076
                            key: "foo".to_string(),
1✔
4077
                        },
1✔
4078
                        target_key: RasterPropertiesKey {
1✔
4079
                            domain: Some("bar".to_string()),
1✔
4080
                            key: "foo".to_string(),
1✔
4081
                        },
1✔
4082
                        target_type: RasterPropertiesEntryType::String,
1✔
4083
                    }]),
1✔
4084
                    gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4085
                    gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4086
                    allow_alphaband_as_mask: false,
1✔
4087
                    retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4088
                },
1✔
4089
                cache_ttl: CacheTtlSeconds::max(),
1✔
4090
            }],
1✔
4091
        )
1✔
4092
        .await;
4✔
4093

4094
        assert_sql_type(
1✔
4095
            &pool,
1✔
4096
            "GdalMetadataNetCdfCf",
1✔
4097
            [GdalMetadataNetCdfCf {
1✔
4098
                result_descriptor: RasterResultDescriptor {
1✔
4099
                    data_type: RasterDataType::U8,
1✔
4100
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4101
                    time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4102
                    bbox: Some(
1✔
4103
                        SpatialPartition2D::new(
1✔
4104
                            Coordinate2D::new(0.0f64, 1.),
1✔
4105
                            Coordinate2D::new(2., 0.5),
1✔
4106
                        )
1✔
4107
                        .unwrap(),
1✔
4108
                    ),
1✔
4109
                    resolution: Some(SpatialResolution::zero_point_one()),
1✔
4110
                    bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4111
                        "band".into(),
1✔
4112
                        Measurement::Continuous(ContinuousMeasurement {
1✔
4113
                            measurement: "Temperature".to_string(),
1✔
4114
                            unit: Some("°C".to_string()),
1✔
4115
                        }),
1✔
4116
                    )])
1✔
4117
                    .unwrap(),
1✔
4118
                },
1✔
4119
                params: GdalDatasetParameters {
1✔
4120
                    file_path: "text".into(),
1✔
4121
                    rasterband_channel: 1,
1✔
4122
                    geo_transform: GdalDatasetGeoTransform {
1✔
4123
                        origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4124
                        x_pixel_size: 1.0,
1✔
4125
                        y_pixel_size: 2.0,
1✔
4126
                    },
1✔
4127
                    width: 42,
1✔
4128
                    height: 23,
1✔
4129
                    file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4130
                    no_data_value: Some(42.0),
1✔
4131
                    properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4132
                        source_key: RasterPropertiesKey {
1✔
4133
                            domain: None,
1✔
4134
                            key: "foo".to_string(),
1✔
4135
                        },
1✔
4136
                        target_key: RasterPropertiesKey {
1✔
4137
                            domain: Some("bar".to_string()),
1✔
4138
                            key: "foo".to_string(),
1✔
4139
                        },
1✔
4140
                        target_type: RasterPropertiesEntryType::String,
1✔
4141
                    }]),
1✔
4142
                    gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4143
                    gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4144
                    allow_alphaband_as_mask: false,
1✔
4145
                    retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4146
                },
1✔
4147
                start: TimeInstance::from_millis(0).unwrap(),
1✔
4148
                end: TimeInstance::from_millis(1000).unwrap(),
1✔
4149
                cache_ttl: CacheTtlSeconds::max(),
1✔
4150
                step: TimeStep {
1✔
4151
                    granularity: TimeGranularity::Millis,
1✔
4152
                    step: 1,
1✔
4153
                },
1✔
4154
                band_offset: 3,
1✔
4155
            }],
1✔
4156
        )
1✔
4157
        .await;
4✔
4158

4159
        assert_sql_type(
1✔
4160
            &pool,
1✔
4161
            "GdalMetaDataList",
1✔
4162
            [GdalMetaDataList {
1✔
4163
                result_descriptor: RasterResultDescriptor {
1✔
4164
                    data_type: RasterDataType::U8,
1✔
4165
                    spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4166
                    time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4167
                    bbox: Some(
1✔
4168
                        SpatialPartition2D::new(
1✔
4169
                            Coordinate2D::new(0.0f64, 1.),
1✔
4170
                            Coordinate2D::new(2., 0.5),
1✔
4171
                        )
1✔
4172
                        .unwrap(),
1✔
4173
                    ),
1✔
4174
                    resolution: Some(SpatialResolution::zero_point_one()),
1✔
4175
                    bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4176
                        "band".into(),
1✔
4177
                        Measurement::Continuous(ContinuousMeasurement {
1✔
4178
                            measurement: "Temperature".to_string(),
1✔
4179
                            unit: Some("°C".to_string()),
1✔
4180
                        }),
1✔
4181
                    )])
1✔
4182
                    .unwrap(),
1✔
4183
                },
1✔
4184
                params: vec![GdalLoadingInfoTemporalSlice {
1✔
4185
                    time: TimeInterval::new_unchecked(0, 1),
1✔
4186
                    params: Some(GdalDatasetParameters {
1✔
4187
                        file_path: "text".into(),
1✔
4188
                        rasterband_channel: 1,
1✔
4189
                        geo_transform: GdalDatasetGeoTransform {
1✔
4190
                            origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4191
                            x_pixel_size: 1.0,
1✔
4192
                            y_pixel_size: 2.0,
1✔
4193
                        },
1✔
4194
                        width: 42,
1✔
4195
                        height: 23,
1✔
4196
                        file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4197
                        no_data_value: Some(42.0),
1✔
4198
                        properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4199
                            source_key: RasterPropertiesKey {
1✔
4200
                                domain: None,
1✔
4201
                                key: "foo".to_string(),
1✔
4202
                            },
1✔
4203
                            target_key: RasterPropertiesKey {
1✔
4204
                                domain: Some("bar".to_string()),
1✔
4205
                                key: "foo".to_string(),
1✔
4206
                            },
1✔
4207
                            target_type: RasterPropertiesEntryType::String,
1✔
4208
                        }]),
1✔
4209
                        gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4210
                        gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4211
                        allow_alphaband_as_mask: false,
1✔
4212
                        retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4213
                    }),
1✔
4214
                    cache_ttl: CacheTtlSeconds::max(),
1✔
4215
                }],
1✔
4216
            }],
1✔
4217
        )
1✔
4218
        .await;
7✔
4219

4220
        assert_sql_type(
1✔
4221
            &pool,
1✔
4222
            "MetaDataDefinition",
1✔
4223
            [
1✔
4224
                MetaDataDefinition::MockMetaData(StaticMetaData::<
1✔
4225
                    MockDatasetDataSourceLoadingInfo,
1✔
4226
                    VectorResultDescriptor,
1✔
4227
                    VectorQueryRectangle,
1✔
4228
                > {
1✔
4229
                    loading_info: MockDatasetDataSourceLoadingInfo {
1✔
4230
                        points: vec![Coordinate2D::new(0.0f64, 0.5), Coordinate2D::new(2., 1.0)],
1✔
4231
                    },
1✔
4232
                    result_descriptor: VectorResultDescriptor {
1✔
4233
                        data_type: VectorDataType::MultiPoint,
1✔
4234
                        spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
4235
                            SpatialReference::epsg_4326(),
1✔
4236
                        ),
1✔
4237
                        columns: [(
1✔
4238
                            "foo".to_string(),
1✔
4239
                            VectorColumnInfo {
1✔
4240
                                data_type: FeatureDataType::Int,
1✔
4241
                                measurement: Measurement::Unitless,
1✔
4242
                            },
1✔
4243
                        )]
1✔
4244
                        .into(),
1✔
4245
                        time: Some(TimeInterval::default()),
1✔
4246
                        bbox: Some(
1✔
4247
                            BoundingBox2D::new(
1✔
4248
                                Coordinate2D::new(0.0f64, 0.5),
1✔
4249
                                Coordinate2D::new(2., 1.0),
1✔
4250
                            )
1✔
4251
                            .unwrap(),
1✔
4252
                        ),
1✔
4253
                    },
1✔
4254
                    phantom: PhantomData,
1✔
4255
                }),
1✔
4256
                MetaDataDefinition::OgrMetaData(StaticMetaData::<
1✔
4257
                    OgrSourceDataset,
1✔
4258
                    VectorResultDescriptor,
1✔
4259
                    VectorQueryRectangle,
1✔
4260
                > {
1✔
4261
                    loading_info: OgrSourceDataset {
1✔
4262
                        file_name: "test".into(),
1✔
4263
                        layer_name: "test".to_string(),
1✔
4264
                        data_type: Some(VectorDataType::MultiPoint),
1✔
4265
                        time: OgrSourceDatasetTimeType::Start {
1✔
4266
                            start_field: "start".to_string(),
1✔
4267
                            start_format: OgrSourceTimeFormat::Auto,
1✔
4268
                            duration: OgrSourceDurationSpec::Zero,
1✔
4269
                        },
1✔
4270
                        default_geometry: Some(TypedGeometry::MultiPoint(
1✔
4271
                            MultiPoint::new(vec![
1✔
4272
                                Coordinate2D::new(0.0f64, 0.5),
1✔
4273
                                Coordinate2D::new(2., 1.0),
1✔
4274
                            ])
1✔
4275
                            .unwrap(),
1✔
4276
                        )),
1✔
4277
                        columns: Some(OgrSourceColumnSpec {
1✔
4278
                            format_specifics: Some(FormatSpecifics::Csv {
1✔
4279
                                header: CsvHeader::Auto,
1✔
4280
                            }),
1✔
4281
                            x: "x".to_string(),
1✔
4282
                            y: Some("y".to_string()),
1✔
4283
                            int: vec!["int".to_string()],
1✔
4284
                            float: vec!["float".to_string()],
1✔
4285
                            text: vec!["text".to_string()],
1✔
4286
                            bool: vec!["bool".to_string()],
1✔
4287
                            datetime: vec!["datetime".to_string()],
1✔
4288
                            rename: Some(
1✔
4289
                                [
1✔
4290
                                    ("xx".to_string(), "xx_renamed".to_string()),
1✔
4291
                                    ("yx".to_string(), "yy_renamed".to_string()),
1✔
4292
                                ]
1✔
4293
                                .into(),
1✔
4294
                            ),
1✔
4295
                        }),
1✔
4296
                        force_ogr_time_filter: false,
1✔
4297
                        force_ogr_spatial_filter: true,
1✔
4298
                        on_error: OgrSourceErrorSpec::Abort,
1✔
4299
                        sql_query: None,
1✔
4300
                        attribute_query: Some("foo = 'bar'".to_string()),
1✔
4301
                        cache_ttl: CacheTtlSeconds::new(5),
1✔
4302
                    },
1✔
4303
                    result_descriptor: VectorResultDescriptor {
1✔
4304
                        data_type: VectorDataType::MultiPoint,
1✔
4305
                        spatial_reference: SpatialReferenceOption::SpatialReference(
1✔
4306
                            SpatialReference::epsg_4326(),
1✔
4307
                        ),
1✔
4308
                        columns: [(
1✔
4309
                            "foo".to_string(),
1✔
4310
                            VectorColumnInfo {
1✔
4311
                                data_type: FeatureDataType::Int,
1✔
4312
                                measurement: Measurement::Unitless,
1✔
4313
                            },
1✔
4314
                        )]
1✔
4315
                        .into(),
1✔
4316
                        time: Some(TimeInterval::default()),
1✔
4317
                        bbox: Some(
1✔
4318
                            BoundingBox2D::new(
1✔
4319
                                Coordinate2D::new(0.0f64, 0.5),
1✔
4320
                                Coordinate2D::new(2., 1.0),
1✔
4321
                            )
1✔
4322
                            .unwrap(),
1✔
4323
                        ),
1✔
4324
                    },
1✔
4325
                    phantom: PhantomData,
1✔
4326
                }),
1✔
4327
                MetaDataDefinition::GdalMetaDataRegular(GdalMetaDataRegular {
1✔
4328
                    result_descriptor: RasterResultDescriptor {
1✔
4329
                        data_type: RasterDataType::U8,
1✔
4330
                        spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4331
                        time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4332
                        bbox: Some(
1✔
4333
                            SpatialPartition2D::new(
1✔
4334
                                Coordinate2D::new(0.0f64, 1.),
1✔
4335
                                Coordinate2D::new(2., 0.5),
1✔
4336
                            )
1✔
4337
                            .unwrap(),
1✔
4338
                        ),
1✔
4339
                        resolution: Some(SpatialResolution::zero_point_one()),
1✔
4340
                        bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4341
                            "band".into(),
1✔
4342
                            Measurement::Continuous(ContinuousMeasurement {
1✔
4343
                                measurement: "Temperature".to_string(),
1✔
4344
                                unit: Some("°C".to_string()),
1✔
4345
                            }),
1✔
4346
                        )])
1✔
4347
                        .unwrap(),
1✔
4348
                    },
1✔
4349
                    params: GdalDatasetParameters {
1✔
4350
                        file_path: "text".into(),
1✔
4351
                        rasterband_channel: 1,
1✔
4352
                        geo_transform: GdalDatasetGeoTransform {
1✔
4353
                            origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4354
                            x_pixel_size: 1.0,
1✔
4355
                            y_pixel_size: 2.0,
1✔
4356
                        },
1✔
4357
                        width: 42,
1✔
4358
                        height: 23,
1✔
4359
                        file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4360
                        no_data_value: Some(42.0),
1✔
4361
                        properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4362
                            source_key: RasterPropertiesKey {
1✔
4363
                                domain: None,
1✔
4364
                                key: "foo".to_string(),
1✔
4365
                            },
1✔
4366
                            target_key: RasterPropertiesKey {
1✔
4367
                                domain: Some("bar".to_string()),
1✔
4368
                                key: "foo".to_string(),
1✔
4369
                            },
1✔
4370
                            target_type: RasterPropertiesEntryType::String,
1✔
4371
                        }]),
1✔
4372
                        gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4373
                        gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4374
                        allow_alphaband_as_mask: false,
1✔
4375
                        retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4376
                    },
1✔
4377
                    time_placeholders: [(
1✔
4378
                        "foo".to_string(),
1✔
4379
                        GdalSourceTimePlaceholder {
1✔
4380
                            format: DateTimeParseFormat::unix(),
1✔
4381
                            reference: TimeReference::Start,
1✔
4382
                        },
1✔
4383
                    )]
1✔
4384
                    .into(),
1✔
4385
                    data_time: TimeInterval::new_unchecked(0, 1),
1✔
4386
                    step: TimeStep {
1✔
4387
                        granularity: TimeGranularity::Millis,
1✔
4388
                        step: 1,
1✔
4389
                    },
1✔
4390
                    cache_ttl: CacheTtlSeconds::max(),
1✔
4391
                }),
1✔
4392
                MetaDataDefinition::GdalStatic(GdalMetaDataStatic {
1✔
4393
                    time: Some(TimeInterval::new_unchecked(0, 1)),
1✔
4394
                    result_descriptor: RasterResultDescriptor {
1✔
4395
                        data_type: RasterDataType::U8,
1✔
4396
                        spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4397
                        time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4398
                        bbox: Some(
1✔
4399
                            SpatialPartition2D::new(
1✔
4400
                                Coordinate2D::new(0.0f64, 1.),
1✔
4401
                                Coordinate2D::new(2., 0.5),
1✔
4402
                            )
1✔
4403
                            .unwrap(),
1✔
4404
                        ),
1✔
4405
                        resolution: Some(SpatialResolution::zero_point_one()),
1✔
4406
                        bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4407
                            "band".into(),
1✔
4408
                            Measurement::Continuous(ContinuousMeasurement {
1✔
4409
                                measurement: "Temperature".to_string(),
1✔
4410
                                unit: Some("°C".to_string()),
1✔
4411
                            }),
1✔
4412
                        )])
1✔
4413
                        .unwrap(),
1✔
4414
                    },
1✔
4415
                    params: GdalDatasetParameters {
1✔
4416
                        file_path: "text".into(),
1✔
4417
                        rasterband_channel: 1,
1✔
4418
                        geo_transform: GdalDatasetGeoTransform {
1✔
4419
                            origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4420
                            x_pixel_size: 1.0,
1✔
4421
                            y_pixel_size: 2.0,
1✔
4422
                        },
1✔
4423
                        width: 42,
1✔
4424
                        height: 23,
1✔
4425
                        file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4426
                        no_data_value: Some(42.0),
1✔
4427
                        properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4428
                            source_key: RasterPropertiesKey {
1✔
4429
                                domain: None,
1✔
4430
                                key: "foo".to_string(),
1✔
4431
                            },
1✔
4432
                            target_key: RasterPropertiesKey {
1✔
4433
                                domain: Some("bar".to_string()),
1✔
4434
                                key: "foo".to_string(),
1✔
4435
                            },
1✔
4436
                            target_type: RasterPropertiesEntryType::String,
1✔
4437
                        }]),
1✔
4438
                        gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4439
                        gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4440
                        allow_alphaband_as_mask: false,
1✔
4441
                        retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4442
                    },
1✔
4443
                    cache_ttl: CacheTtlSeconds::max(),
1✔
4444
                }),
1✔
4445
                MetaDataDefinition::GdalMetadataNetCdfCf(GdalMetadataNetCdfCf {
1✔
4446
                    result_descriptor: RasterResultDescriptor {
1✔
4447
                        data_type: RasterDataType::U8,
1✔
4448
                        spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4449
                        time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4450
                        bbox: Some(
1✔
4451
                            SpatialPartition2D::new(
1✔
4452
                                Coordinate2D::new(0.0f64, 1.),
1✔
4453
                                Coordinate2D::new(2., 0.5),
1✔
4454
                            )
1✔
4455
                            .unwrap(),
1✔
4456
                        ),
1✔
4457
                        resolution: Some(SpatialResolution::zero_point_one()),
1✔
4458
                        bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4459
                            "band".into(),
1✔
4460
                            Measurement::Continuous(ContinuousMeasurement {
1✔
4461
                                measurement: "Temperature".to_string(),
1✔
4462
                                unit: Some("°C".to_string()),
1✔
4463
                            }),
1✔
4464
                        )])
1✔
4465
                        .unwrap(),
1✔
4466
                    },
1✔
4467
                    params: GdalDatasetParameters {
1✔
4468
                        file_path: "text".into(),
1✔
4469
                        rasterband_channel: 1,
1✔
4470
                        geo_transform: GdalDatasetGeoTransform {
1✔
4471
                            origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4472
                            x_pixel_size: 1.0,
1✔
4473
                            y_pixel_size: 2.0,
1✔
4474
                        },
1✔
4475
                        width: 42,
1✔
4476
                        height: 23,
1✔
4477
                        file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4478
                        no_data_value: Some(42.0),
1✔
4479
                        properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4480
                            source_key: RasterPropertiesKey {
1✔
4481
                                domain: None,
1✔
4482
                                key: "foo".to_string(),
1✔
4483
                            },
1✔
4484
                            target_key: RasterPropertiesKey {
1✔
4485
                                domain: Some("bar".to_string()),
1✔
4486
                                key: "foo".to_string(),
1✔
4487
                            },
1✔
4488
                            target_type: RasterPropertiesEntryType::String,
1✔
4489
                        }]),
1✔
4490
                        gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4491
                        gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4492
                        allow_alphaband_as_mask: false,
1✔
4493
                        retry: Some(GdalRetryOptions { max_retries: 3 }),
1✔
4494
                    },
1✔
4495
                    start: TimeInstance::from_millis(0).unwrap(),
1✔
4496
                    end: TimeInstance::from_millis(1000).unwrap(),
1✔
4497
                    cache_ttl: CacheTtlSeconds::max(),
1✔
4498
                    step: TimeStep {
1✔
4499
                        granularity: TimeGranularity::Millis,
1✔
4500
                        step: 1,
1✔
4501
                    },
1✔
4502
                    band_offset: 3,
1✔
4503
                }),
1✔
4504
                MetaDataDefinition::GdalMetaDataList(GdalMetaDataList {
1✔
4505
                    result_descriptor: RasterResultDescriptor {
1✔
4506
                        data_type: RasterDataType::U8,
1✔
4507
                        spatial_reference: SpatialReference::epsg_4326().into(),
1✔
4508
                        time: TimeInterval::new_unchecked(0, 1).into(),
1✔
4509
                        bbox: Some(
1✔
4510
                            SpatialPartition2D::new(
1✔
4511
                                Coordinate2D::new(0.0f64, 1.),
1✔
4512
                                Coordinate2D::new(2., 0.5),
1✔
4513
                            )
1✔
4514
                            .unwrap(),
1✔
4515
                        ),
1✔
4516
                        resolution: Some(SpatialResolution::zero_point_one()),
1✔
4517
                        bands: RasterBandDescriptors::new(vec![RasterBandDescriptor::new(
1✔
4518
                            "band".into(),
1✔
4519
                            Measurement::Continuous(ContinuousMeasurement {
1✔
4520
                                measurement: "Temperature".to_string(),
1✔
4521
                                unit: Some("°C".to_string()),
1✔
4522
                            }),
1✔
4523
                        )])
1✔
4524
                        .unwrap(),
1✔
4525
                    },
1✔
4526
                    params: vec![GdalLoadingInfoTemporalSlice {
1✔
4527
                        time: TimeInterval::new_unchecked(0, 1),
1✔
4528
                        params: Some(GdalDatasetParameters {
1✔
4529
                            file_path: "text".into(),
1✔
4530
                            rasterband_channel: 1,
1✔
4531
                            geo_transform: GdalDatasetGeoTransform {
1✔
4532
                                origin_coordinate: Coordinate2D::new(0.0f64, 0.5),
1✔
4533
                                x_pixel_size: 1.0,
1✔
4534
                                y_pixel_size: 2.0,
1✔
4535
                            },
1✔
4536
                            width: 42,
1✔
4537
                            height: 23,
1✔
4538
                            file_not_found_handling: FileNotFoundHandling::NoData,
1✔
4539
                            no_data_value: Some(42.0),
1✔
4540
                            properties_mapping: Some(vec![GdalMetadataMapping {
1✔
4541
                                source_key: RasterPropertiesKey {
1✔
4542
                                    domain: None,
1✔
4543
                                    key: "foo".to_string(),
1✔
4544
                                },
1✔
4545
                                target_key: RasterPropertiesKey {
1✔
4546
                                    domain: Some("bar".to_string()),
1✔
4547
                                    key: "foo".to_string(),
1✔
4548
                                },
1✔
4549
                                target_type: RasterPropertiesEntryType::String,
1✔
4550
                            }]),
1✔
4551
                            gdal_open_options: Some(vec!["foo".to_string(), "bar".to_string()]),
1✔
4552
                            gdal_config_options: Some(vec![("foo".to_string(), "bar".to_string())]),
1✔
4553
                            allow_alphaband_as_mask: false,
1✔
4554
                            retry: None,
1✔
4555
                        }),
1✔
4556
                        cache_ttl: CacheTtlSeconds::max(),
1✔
4557
                    }],
1✔
4558
                }),
1✔
4559
            ],
1✔
4560
        )
1✔
4561
        .await;
14✔
4562

4563
        assert_sql_type(
1✔
4564
            &pool,
1✔
4565
            "bytea",
1✔
4566
            [U96::from(
1✔
4567
                arr![u8; 13, 227, 191, 247, 123, 193, 214, 165, 185, 37, 101, 24],
1✔
4568
            )],
1✔
4569
        )
1✔
UNCOV
4570
        .await;
×
4571

4572
        test_data_provider_definition_types(&pool).await;
1✔
4573
    }
1✔
4574

4575
    #[test]
4576
    fn test_postgres_config_translation() {
1✔
4577
        let host = "localhost";
1✔
4578
        let port = 8095;
1✔
4579
        let ge_default = "geoengine";
1✔
4580
        let schema = "geoengine";
1✔
4581

1✔
4582
        let db_config = config::Postgres {
1✔
4583
            host: host.to_string(),
1✔
4584
            port,
1✔
4585
            database: ge_default.to_string(),
1✔
4586
            schema: schema.to_string(),
1✔
4587
            user: ge_default.to_string(),
1✔
4588
            password: ge_default.to_string(),
1✔
4589
            clear_database_on_start: false,
1✔
4590
        };
1✔
4591

1✔
4592
        let pg_config = Config::try_from(db_config).unwrap();
1✔
4593

1✔
4594
        assert_eq!(ge_default, pg_config.get_user().unwrap());
1✔
4595
        assert_eq!(
1✔
4596
            <str as AsRef<[u8]>>::as_ref(ge_default).to_vec(),
1✔
4597
            pg_config.get_password().unwrap()
1✔
4598
        );
1✔
4599
        assert_eq!(ge_default, pg_config.get_dbname().unwrap());
1✔
4600
        assert_eq!(
1✔
4601
            &format!("-c search_path={schema}"),
1✔
4602
            pg_config.get_options().unwrap()
1✔
4603
        );
1✔
4604
        assert_eq!(vec![Host::Tcp(host.to_string())], pg_config.get_hosts());
1✔
4605
        assert_eq!(vec![port], pg_config.get_ports());
1✔
4606
    }
1✔
4607

4608
    #[allow(clippy::too_many_lines)]
4609
    async fn test_data_provider_definition_types(
1✔
4610
        pool: &PooledConnection<'_, PostgresConnectionManager<tokio_postgres::NoTls>>,
1✔
4611
    ) {
1✔
4612
        assert_sql_type(
1✔
4613
            pool,
1✔
4614
            "ArunaDataProviderDefinition",
1✔
4615
            [ArunaDataProviderDefinition {
1✔
4616
                id: DataProviderId::from_str("86a7f7ce-1bab-4ce9-a32b-172c0f958ee0").unwrap(),
1✔
4617
                name: "NFDI".to_string(),
1✔
4618
                description: "NFDI".to_string(),
1✔
4619
                priority: Some(33),
1✔
4620
                api_url: "http://test".to_string(),
1✔
4621
                project_id: "project".to_string(),
1✔
4622
                api_token: "api_token".to_string(),
1✔
4623
                filter_label: "filter".to_string(),
1✔
4624
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4625
            }],
1✔
4626
        )
1✔
UNCOV
4627
        .await;
×
4628

4629
        assert_sql_type(
1✔
4630
            pool,
1✔
4631
            "GbifDataProviderDefinition",
1✔
4632
            [GbifDataProviderDefinition {
1✔
4633
                name: "GBIF".to_string(),
1✔
4634
                description: "GFBio".to_string(),
1✔
4635
                priority: None,
1✔
4636
                db_config: DatabaseConnectionConfig {
1✔
4637
                    host: "testhost".to_string(),
1✔
4638
                    port: 1234,
1✔
4639
                    database: "testdb".to_string(),
1✔
4640
                    schema: "testschema".to_string(),
1✔
4641
                    user: "testuser".to_string(),
1✔
4642
                    password: "testpass".to_string(),
1✔
4643
                },
1✔
4644
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4645
                autocomplete_timeout: 3,
1✔
4646
                columns: GbifDataProvider::all_columns(),
1✔
4647
            }],
1✔
4648
        )
1✔
UNCOV
4649
        .await;
×
4650

4651
        assert_sql_type(
1✔
4652
            pool,
1✔
4653
            "GfbioAbcdDataProviderDefinition",
1✔
4654
            [GfbioAbcdDataProviderDefinition {
1✔
4655
                name: "GFbio".to_string(),
1✔
4656
                description: "GFBio".to_string(),
1✔
4657
                priority: None,
1✔
4658
                db_config: DatabaseConnectionConfig {
1✔
4659
                    host: "testhost".to_string(),
1✔
4660
                    port: 1234,
1✔
4661
                    database: "testdb".to_string(),
1✔
4662
                    schema: "testschema".to_string(),
1✔
4663
                    user: "testuser".to_string(),
1✔
4664
                    password: "testpass".to_string(),
1✔
4665
                },
1✔
4666
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4667
            }],
1✔
4668
        )
1✔
UNCOV
4669
        .await;
×
4670

4671
        assert_sql_type(
1✔
4672
            pool,
1✔
4673
            "GfbioCollectionsDataProviderDefinition",
1✔
4674
            [GfbioCollectionsDataProviderDefinition {
1✔
4675
                name: "GFbio".to_string(),
1✔
4676
                description: "GFBio".to_string(),
1✔
4677
                priority: None,
1✔
4678
                collection_api_url: "http://testhost".try_into().unwrap(),
1✔
4679
                collection_api_auth_token: "token".to_string(),
1✔
4680
                abcd_db_config: DatabaseConnectionConfig {
1✔
4681
                    host: "testhost".to_string(),
1✔
4682
                    port: 1234,
1✔
4683
                    database: "testdb".to_string(),
1✔
4684
                    schema: "testschema".to_string(),
1✔
4685
                    user: "testuser".to_string(),
1✔
4686
                    password: "testpass".to_string(),
1✔
4687
                },
1✔
4688
                pangaea_url: "http://panaea".try_into().unwrap(),
1✔
4689
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4690
            }],
1✔
4691
        )
1✔
UNCOV
4692
        .await;
×
4693

4694
        assert_sql_type(pool, "\"PropertyType\"[]", [Vec::<Property>::new()]).await;
1✔
4695

4696
        assert_sql_type(
1✔
4697
            pool,
1✔
4698
            "EbvPortalDataProviderDefinition",
1✔
4699
            [EbvPortalDataProviderDefinition {
1✔
4700
                name: "ebv".to_string(),
1✔
4701
                description: "EBV".to_string(),
1✔
4702
                priority: None,
1✔
4703
                data: "a_path".into(),
1✔
4704
                base_url: "http://base".try_into().unwrap(),
1✔
4705
                overviews: "another_path".into(),
1✔
4706
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4707
            }],
1✔
4708
        )
1✔
UNCOV
4709
        .await;
×
4710

4711
        assert_sql_type(
1✔
4712
            pool,
1✔
4713
            "NetCdfCfDataProviderDefinition",
1✔
4714
            [NetCdfCfDataProviderDefinition {
1✔
4715
                name: "netcdfcf".to_string(),
1✔
4716
                description: "netcdfcf".to_string(),
1✔
4717
                priority: Some(33),
1✔
4718
                data: "a_path".into(),
1✔
4719
                overviews: "another_path".into(),
1✔
4720
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4721
            }],
1✔
4722
        )
1✔
UNCOV
4723
        .await;
×
4724

4725
        assert_sql_type(
1✔
4726
            pool,
1✔
4727
            "PangaeaDataProviderDefinition",
1✔
4728
            [PangaeaDataProviderDefinition {
1✔
4729
                name: "pangaea".to_string(),
1✔
4730
                description: "pangaea".to_string(),
1✔
4731
                priority: None,
1✔
4732
                base_url: "http://base".try_into().unwrap(),
1✔
4733
                cache_ttl: CacheTtlSeconds::new(0),
1✔
4734
            }],
1✔
4735
        )
1✔
UNCOV
4736
        .await;
×
4737

4738
        assert_sql_type(
1✔
4739
            pool,
1✔
4740
            "DataProviderDefinition",
1✔
4741
            [
1✔
4742
                TypedDataProviderDefinition::ArunaDataProviderDefinition(
1✔
4743
                    ArunaDataProviderDefinition {
1✔
4744
                        id: DataProviderId::from_str("86a7f7ce-1bab-4ce9-a32b-172c0f958ee0")
1✔
4745
                            .unwrap(),
1✔
4746
                        name: "NFDI".to_string(),
1✔
4747
                        description: "NFDI".to_string(),
1✔
4748
                        priority: Some(33),
1✔
4749
                        api_url: "http://test".to_string(),
1✔
4750
                        project_id: "project".to_string(),
1✔
4751
                        api_token: "api_token".to_string(),
1✔
4752
                        filter_label: "filter".to_string(),
1✔
4753
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4754
                    },
1✔
4755
                ),
1✔
4756
                TypedDataProviderDefinition::GbifDataProviderDefinition(
1✔
4757
                    GbifDataProviderDefinition {
1✔
4758
                        name: "GBIF".to_string(),
1✔
4759
                        description: "GFBio".to_string(),
1✔
4760
                        priority: None,
1✔
4761
                        db_config: DatabaseConnectionConfig {
1✔
4762
                            host: "testhost".to_string(),
1✔
4763
                            port: 1234,
1✔
4764
                            database: "testdb".to_string(),
1✔
4765
                            schema: "testschema".to_string(),
1✔
4766
                            user: "testuser".to_string(),
1✔
4767
                            password: "testpass".to_string(),
1✔
4768
                        },
1✔
4769
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4770
                        autocomplete_timeout: 3,
1✔
4771
                        columns: GbifDataProvider::all_columns(),
1✔
4772
                    },
1✔
4773
                ),
1✔
4774
                TypedDataProviderDefinition::GfbioAbcdDataProviderDefinition(
1✔
4775
                    GfbioAbcdDataProviderDefinition {
1✔
4776
                        name: "GFbio".to_string(),
1✔
4777
                        description: "GFBio".to_string(),
1✔
4778
                        priority: None,
1✔
4779
                        db_config: DatabaseConnectionConfig {
1✔
4780
                            host: "testhost".to_string(),
1✔
4781
                            port: 1234,
1✔
4782
                            database: "testdb".to_string(),
1✔
4783
                            schema: "testschema".to_string(),
1✔
4784
                            user: "testuser".to_string(),
1✔
4785
                            password: "testpass".to_string(),
1✔
4786
                        },
1✔
4787
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4788
                    },
1✔
4789
                ),
1✔
4790
                TypedDataProviderDefinition::GfbioCollectionsDataProviderDefinition(
1✔
4791
                    GfbioCollectionsDataProviderDefinition {
1✔
4792
                        name: "GFbio".to_string(),
1✔
4793
                        description: "GFBio".to_string(),
1✔
4794
                        priority: None,
1✔
4795
                        collection_api_url: "http://testhost".try_into().unwrap(),
1✔
4796
                        collection_api_auth_token: "token".to_string(),
1✔
4797
                        abcd_db_config: DatabaseConnectionConfig {
1✔
4798
                            host: "testhost".to_string(),
1✔
4799
                            port: 1234,
1✔
4800
                            database: "testdb".to_string(),
1✔
4801
                            schema: "testschema".to_string(),
1✔
4802
                            user: "testuser".to_string(),
1✔
4803
                            password: "testpass".to_string(),
1✔
4804
                        },
1✔
4805
                        pangaea_url: "http://panaea".try_into().unwrap(),
1✔
4806
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4807
                    },
1✔
4808
                ),
1✔
4809
                TypedDataProviderDefinition::EbvPortalDataProviderDefinition(
1✔
4810
                    EbvPortalDataProviderDefinition {
1✔
4811
                        name: "ebv".to_string(),
1✔
4812
                        description: "ebv".to_string(),
1✔
4813
                        priority: Some(33),
1✔
4814
                        data: "a_path".into(),
1✔
4815
                        base_url: "http://base".try_into().unwrap(),
1✔
4816
                        overviews: "another_path".into(),
1✔
4817
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4818
                    },
1✔
4819
                ),
1✔
4820
                TypedDataProviderDefinition::NetCdfCfDataProviderDefinition(
1✔
4821
                    NetCdfCfDataProviderDefinition {
1✔
4822
                        name: "netcdfcf".to_string(),
1✔
4823
                        description: "netcdfcf".to_string(),
1✔
4824
                        priority: Some(33),
1✔
4825
                        data: "a_path".into(),
1✔
4826
                        overviews: "another_path".into(),
1✔
4827
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4828
                    },
1✔
4829
                ),
1✔
4830
                TypedDataProviderDefinition::PangaeaDataProviderDefinition(
1✔
4831
                    PangaeaDataProviderDefinition {
1✔
4832
                        name: "pangaea".to_string(),
1✔
4833
                        description: "pangaea".to_string(),
1✔
4834
                        priority: None,
1✔
4835
                        base_url: "http://base".try_into().unwrap(),
1✔
4836
                        cache_ttl: CacheTtlSeconds::new(0),
1✔
4837
                    },
1✔
4838
                ),
1✔
4839
            ],
1✔
4840
        )
1✔
UNCOV
4841
        .await;
×
4842
    }
1✔
4843
}
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