Skip to content

Commit c33c038

Browse files
feat(services): connector to wildlife portal data (#1043)
* wildlife portal example * add layers for project * layers and datasets * query improvements * first version * database cache * clippy * captures dataset * sqlfluff lints * db fixes * remove examples * fix migration version
1 parent 7aadfa3 commit c33c038

File tree

29 files changed

+3990
-6
lines changed

29 files changed

+3990
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ lcov.info
1010
/.idea
1111
/.vscode
1212
Settings.toml
13+
.env
1314

1415
# Venvs
15-
env
16+
/.venv
1617

1718
# Data
1819
upload/

Cargo.lock

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datatypes/src/primitives/bounding_box.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use float_cmp::ApproxEq;
88
use postgres_types::{FromSql, ToSql};
99
use serde::{Deserialize, Serialize};
1010
use snafu::ensure;
11+
use wkt::{ToWkt, Wkt};
1112

1213
#[derive(Copy, Clone, Serialize, Deserialize, PartialEq, Debug, ToSql, FromSql)]
1314
#[repr(C)]
@@ -443,6 +444,20 @@ impl BoundingBox2D {
443444

444445
(lower_left, lower_right, upper_left, upper_right)
445446
}
447+
448+
/// Iterates over the four corners of the bounding box in counter-clockwise order
449+
///
450+
/// Note: It repeats the first coordinate at the end
451+
fn coords_counter_clockwise(&self) -> impl Iterator<Item = Coordinate2D> {
452+
[
453+
self.upper_left(),
454+
self.lower_left(),
455+
self.lower_right(),
456+
self.upper_right(),
457+
self.upper_left(),
458+
]
459+
.into_iter()
460+
}
446461
}
447462

448463
impl AxisAlignedRectangle for BoundingBox2D {
@@ -580,6 +595,22 @@ impl TryFrom<BoundingBox2D> for gdal::vector::Geometry {
580595
}
581596
}
582597

598+
impl From<BoundingBox2D> for geojson::Geometry {
599+
fn from(bounds: BoundingBox2D) -> Self {
600+
let value = geojson::Value::Polygon(vec![
601+
bounds
602+
.coords_counter_clockwise()
603+
.map(|c| vec![c.x, c.y])
604+
.collect(),
605+
]);
606+
geojson::Geometry {
607+
bbox: None,
608+
value,
609+
foreign_members: None,
610+
}
611+
}
612+
}
613+
583614
impl ApproxEq for BoundingBox2D {
584615
type Margin = float_cmp::F64Margin;
585616

@@ -615,6 +646,14 @@ pub fn bboxes_extent<I: Iterator<Item = Option<BoundingBox2D>>>(
615646
Some(extent)
616647
}
617648

649+
impl ToWkt<f64> for BoundingBox2D {
650+
fn to_wkt(&self) -> Wkt<f64> {
651+
Wkt::Polygon(wkt::types::Polygon(vec![wkt::types::LineString(
652+
self.coords_counter_clockwise().map(Into::into).collect(),
653+
)]))
654+
}
655+
}
656+
618657
#[cfg(test)]
619658
mod tests {
620659

datatypes/src/primitives/coordinate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::{
1313
ops::{Add, Div, Mul, Sub},
1414
slice,
1515
};
16+
use wkt::{ToWkt, Wkt};
1617

1718
#[derive(
1819
Clone, Copy, Debug, Deserialize, PartialEq, PartialOrd, Serialize, Default, ToSql, FromSql,
@@ -359,6 +360,17 @@ impl From<&Coordinate2D> for wkt::types::Coord<f64> {
359360
}
360361
}
361362

363+
impl ToWkt<f64> for Coordinate2D {
364+
fn to_wkt(&self) -> Wkt<f64> {
365+
Wkt::Point(wkt::types::Point(Some(wkt::types::Coord {
366+
x: self.x,
367+
y: self.y,
368+
z: None,
369+
m: None,
370+
})))
371+
}
372+
}
373+
362374
#[cfg(test)]
363375
mod test {
364376

operators/src/processing/circle_merging_quadtree/operator.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ impl VisualPointClusteringProcessor {
361361
FeatureDataValue::Text(value) | FeatureDataValue::NullableText(Some(value)),
362362
AttributeAggregateType::StringSample,
363363
) => AttributeAggregate::StringSample(StringSampler::from_value(value)),
364+
(
365+
FeatureDataValue::DateTime(value) | FeatureDataValue::NullableDateTime(Some(value)),
366+
AttributeAggregateType::StringSample,
367+
) => AttributeAggregate::StringSample(StringSampler::from_value(value.to_string())),
364368
_ => AttributeAggregate::Null,
365369
}
366370
}

services/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ clap_derive.workspace = true
3131
clap.workspace = true
3232
config = { workspace = true }
3333
convert_case = { workspace = true }
34+
csv = { workspace = true }
3435
erased-serde = { workspace = true }
3536
flexi_logger = { workspace = true }
3637
float-cmp = { workspace = true }
@@ -54,6 +55,7 @@ opentelemetry-otlp = { workspace = true }
5455
ordered-float = { workspace = true }
5556
paste = { workspace = true }
5657
pbkdf2 = { workspace = true }
58+
postgres-protocol = { workspace = true }
5759
postgres-types = { workspace = true }
5860
proj = { workspace = true }
5961
proj-sys = { workspace = true }
@@ -70,6 +72,7 @@ snafu = { workspace = true }
7072
stac = { workspace = true }
7173
strum = { workspace = true }
7274
strum_macros = { workspace = true }
75+
tempfile = { workspace = true }
7376
time = { workspace = true }
7477
tokio = { workspace = true }
7578
tokio-postgres = { workspace = true }
@@ -84,6 +87,7 @@ utoipa-swagger-ui = { workspace = true }
8487
uuid = { workspace = true }
8588
validator = { workspace = true }
8689
walkdir = { workspace = true }
90+
wkt = { workspace = true }
8791
zip = { workspace = true }
8892

8993
[target.'cfg(target_os = "linux")'.dependencies]
@@ -95,7 +99,6 @@ httptest = { workspace = true }
9599
pretty_assertions = { workspace = true }
96100
prost = { workspace = true } # must be compatbile with aruna-rust-api
97101
serial_test = { workspace = true }
98-
tempfile = { workspace = true }
99102
xml-rs = { workspace = true }
100103

101104
[build-dependencies]

0 commit comments

Comments
 (0)