Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ name: CI

on:
push:
branches:
- main
pull_request:
merge_group:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
Expand All @@ -15,7 +20,7 @@ jobs:
steps:
- name: Dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential pkg-config libclang-dev libgdal-dev

- name: Checkout
uses: actions/checkout@v4

Expand All @@ -27,9 +32,52 @@ jobs:

- name: Format
run: cargo fmt --all -- --check

- name: Clippy
run: cargo clippy --workspace --all-features --all-targets -- -D warnings

- name: Test
run: cargo test --workspace --all-features --all-targets

ogc-compliance:
name: Validate OGC API Compliance
runs-on: ubuntu-latest

steps:
- name: Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
pkg-config \
libclang-dev \
libgdal-dev \
python3-dotenv

- name: Checkout
uses: actions/checkout@v4

- name: Setup
run: docker compose up db -d

- name: Start service
run: |
cargo run -p demo-service &
npx wait-on http://localhost:8484/

- name: Validate service
uses: geo-engine/ogc-validator@v2
with:
service-url: http://localhost:8484/
ogc-api-processes: true
ogc-api-processes-container-tag: 1.3-teamengine-6.0.0-RC2
echoprocessid: echo
# cf. <https://github.com/opengeospatial/ets-ogcapi-processes10/issues/106>
ogc-api-processes-ignore: |-
testJobCreationInputValidation
testJobCreationInputRef
ogc-api-features: true
ogc-api-features-container-tag: 1.9-teamengine-6.0.0-RC2
ogc-api-features-ignore: |-
featureOperation
validateFeatureResponse
69 changes: 62 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ cargo clippy --workspace --all-features --all-targets
```bash
podman run --network host docker.io/ogccite/ets-ogcapi-features10
# podman run --network host docker.io/ogccite/ets-ogcapi-edr10
# podman run --network host docker.io/ogccite/ets-ogcapi-processes10
```

Navigate to <http://localhost:8080/teamengine/> to execute the test suite. For documentation and more info see <https://cite.opengeospatial.org/teamengine/about/ogcapi-features-1.0/1.0/site>.
Expand Down
12 changes: 8 additions & 4 deletions examples/demo-service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use clap::Parser;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

use ogcapi::{
processes::{gdal_loader::GdalLoader, geojson_loader::GeoJsonLoader, greeter::Greeter},
processes::{
echo::Echo,
// gdal_loader::GdalLoader, geojson_loader::GeoJsonLoader, greeter::Greeter
},
services::{AppState, Config, Service},
};

Expand All @@ -25,9 +28,10 @@ async fn main() {

// Register processes/processors
let state = state.processors(vec![
Box::new(Greeter),
Box::new(GeoJsonLoader),
Box::new(GdalLoader),
// Box::new(Greeter),
// Box::new(GeoJsonLoader),
// Box::new(GdalLoader),
Box::new(Echo),
]);

// Build & run with hyper
Expand Down
92 changes: 51 additions & 41 deletions ogcapi-client/src/processes.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{Client, Error};

use ogcapi_processes::ProcessResponseBody;
use ogcapi_types::processes::{Execute, Response, Results, StatusInfo, TransmissionMode};
use ogcapi_types::processes::{Execute, Output, Response, Results, StatusInfo, TransmissionMode};
use std::collections::HashMap;

impl Client {
#[cfg(feature = "processes")]
Expand Down Expand Up @@ -56,9 +55,20 @@ impl Client {
}
}

#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub enum ProcessResponseBody {
Requested {
outputs: HashMap<String, Output>,
parts: Vec<Vec<u8>>,
},
Results(Results),
Empty(String),
StatusInfo(StatusInfo),
}

#[cfg(test)]
mod tests {
use ogcapi_processes::gdal_loader::GdalLoaderOutputs;
// use ogcapi_processes::gdal_loader::GdalLoaderOutputs;
use ogcapi_types::processes::Execute;

use super::*;
Expand Down Expand Up @@ -100,41 +110,41 @@ mod tests {
)
}

#[test]
#[ignore = "needs running demo service"]
fn execute_gdal_loader() {
use ogcapi_processes::{
Processor,
gdal_loader::{GdalLoader, GdalLoaderInputs},
};

let endpoint = "http://0.0.0.0:8484/";
let client = Client::new(endpoint).unwrap();

let input = GdalLoaderInputs {
input: "/data/ne_10m_railroads_north_america.geojson".to_owned(),
collection: "streets".to_string(),
filter: None,
s_srs: None,
database_url: "postgresql://postgres:password@db:5432/ogcapi".to_string(),
};

let execute = Execute {
inputs: input.execute_input(),
outputs: GdalLoaderOutputs::execute_output(),
..Default::default()
};

let response = client.execute(GdalLoader {}.id(), &execute).unwrap();

let ProcessResponseBody::Requested {
outputs: _outputs,
parts,
} = response
else {
panic!()
};

assert_eq!(String::from_utf8(parts[0].clone()).unwrap(), "streets");
}
// #[test]
// #[ignore = "needs running demo service"]
// fn execute_gdal_loader() {
// use ogcapi_processes::{
// Processor,
// gdal_loader::{GdalLoader, GdalLoaderInputs},
// };

// let endpoint = "http://0.0.0.0:8484/";
// let client = Client::new(endpoint).unwrap();

// let input = GdalLoaderInputs {
// input: "/data/ne_10m_railroads_north_america.geojson".to_owned(),
// collection: "streets".to_string(),
// filter: None,
// s_srs: None,
// database_url: "postgresql://postgres:password@db:5432/ogcapi".to_string(),
// };

// let execute = Execute {
// inputs: input.execute_input(),
// outputs: GdalLoaderOutputs::execute_output(),
// ..Default::default()
// };

// let response = client.execute(GdalLoader {}.id(), &execute).unwrap();

// let ProcessResponseBody::Requested {
// outputs: _outputs,
// parts,
// } = response
// else {
// panic!()
// };

// assert_eq!(String::from_utf8(parts[0].clone()).unwrap(), "streets");
// }
}
3 changes: 3 additions & 0 deletions ogcapi-drivers/migrations/20251020900000_response_type.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE TYPE response_type AS ENUM ('raw', 'document');

ALTER TABLE meta.jobs ADD COLUMN response response_type NOT NULL;
Loading
Loading