Skip to content

Commit 27fb409

Browse files
feat: WildLIVE connector outputs more layers with more detailed information
1 parent afa5346 commit 27fb409

File tree

5 files changed

+229
-53
lines changed

5 files changed

+229
-53
lines changed

operators/src/processing/expression/vector_operator.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ pub enum OutputColumn {
9898
Column(String),
9999
}
100100

101+
impl From<GeoVectorDataType> for OutputColumn {
102+
fn from(value: GeoVectorDataType) -> Self {
103+
OutputColumn::Geometry(value)
104+
}
105+
}
106+
101107
struct InitializedVectorExpression {
102108
name: CanonicOperatorName,
103109
path: WorkflowOperatorPath,

services/src/datasets/external/wildlive/cache.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub trait DatasetInDb {
2121
impl DatasetInDb for WildliveLayerId {
2222
fn table_name(&self) -> &str {
2323
match self {
24-
WildliveLayerId::Projects => "wildlive_projects",
24+
WildliveLayerId::Projects | WildliveLayerId::ProjectBounds => "wildlive_projects",
2525
WildliveLayerId::Stations { project_id: _ } => "wildlive_stations",
2626
WildliveLayerId::Captures { project_id: _ } => "wildlive_captures",
2727
}
@@ -57,6 +57,12 @@ pub trait WildliveDbCache: Send + Sync {
5757
project_id: &str,
5858
captures: &[CaptureFeature],
5959
) -> Result<()>;
60+
61+
async fn project_name_by_id(
62+
&self,
63+
provider_id: DataProviderId,
64+
project_id: &str,
65+
) -> Result<Option<String>>;
6066
}
6167

6268
#[async_trait]
@@ -172,6 +178,32 @@ where
172178
.await
173179
.boxed_context(error::UnexpectedExecution)
174180
}
181+
182+
async fn project_name_by_id(
183+
&self,
184+
provider_id: DataProviderId,
185+
project_id: &str,
186+
) -> Result<Option<String>> {
187+
let connection = get_connection!(self.conn_pool);
188+
189+
let row = connection
190+
.query_opt(
191+
"
192+
SELECT name
193+
FROM wildlive_projects
194+
WHERE
195+
provider_id = $1 AND
196+
project_id = $2
197+
ORDER BY cache_date DESC
198+
LIMIT 1
199+
",
200+
&[&provider_id, &project_id],
201+
)
202+
.await
203+
.boxed_context(error::UnexpectedExecution)?;
204+
205+
Ok(row.map(|r| r.get::<_, String>(0)))
206+
}
175207
}
176208

177209
/// Gets a connection from the pool
@@ -290,7 +322,7 @@ where
290322
"
291323
SELECT EXISTS (
292324
SELECT 1
293-
FROM wildlive_stations
325+
FROM wildlive_projects
294326
WHERE
295327
provider_id = $1 AND
296328
cache_date = $2

services/src/datasets/external/wildlive/datasets.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@ pub(super) async fn projects_dataset(
191191
.filter_map(|layout| station_coordinates.get(layout))
192192
.flat_map(|coordinates| coordinates.iter().map(Coordinate2D::from)),
193193
) else {
194-
return Err(WildliveError::EmptyProjectBounds {
195-
project: project.id,
196-
});
194+
error!(
195+
"{:?}",
196+
WildliveError::EmptyProjectBounds {
197+
project: project.id,
198+
}
199+
);
200+
continue;
197201
};
198202

199203
features.push(ProjectFeature {
@@ -204,10 +208,10 @@ pub(super) async fn projects_dataset(
204208
});
205209
}
206210

207-
Ok(features)
211+
features
208212
})
209213
.await
210-
.boxed_context(error::UnexpectedExecution)??;
214+
.boxed_context(error::UnexpectedExecution)?;
211215

212216
Ok(features)
213217
}
@@ -238,7 +242,7 @@ pub(super) async fn projects(
238242
.collect())
239243
}
240244

241-
async fn project(
245+
pub(super) async fn project(
242246
api_endpoint: &Url,
243247
api_token: Option<&AccessToken>,
244248
project_id: &str,

services/src/datasets/external/wildlive/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub enum WildliveError {
2424
InvalidProjectBounds {
2525
source: geoengine_datatypes::error::Error,
2626
},
27-
#[snafu(display("Unable to get bounds for project: {project}"))]
27+
#[snafu(display("Empty project bounds for project: {project}"))]
2828
EmptyProjectBounds {
2929
project: String,
3030
},

0 commit comments

Comments
 (0)