Skip to content

Commit 1493c5f

Browse files
committed
try
1 parent b40e1a3 commit 1493c5f

File tree

10 files changed

+72
-35
lines changed

10 files changed

+72
-35
lines changed

.env

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ RUST_LOG=ogcapi=debug,ogcapi_services=debug,ogcapi_client=debug,tower_http=debug
33
APP_HOST=0.0.0.0
44
APP_PORT=8484
55

6+
# PUBLIC_URL=http://example.org
7+
68
DB_USER=postgres
79
DB_PASSWORD=password
810
DB_HOST=localhost
9-
DB_PORT=5433
11+
DB_PORT=5432
1012
DB_NAME=ogcapi
1113

12-
DATABASE_URL=postgresql://postgres:password@localhost:5433/ogcapi
14+
DATABASE_URL=postgresql://postgres:password@localhost:5432/ogcapi
1315

1416
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
1517
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

.github/workflows/cite.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,22 @@ jobs:
2626
--health-retries 5
2727
ports:
2828
- 5432:5432
29-
# cite:
30-
# image: docker.io/ogccite/ets-ogcapi-features10
31-
# ports:
32-
# - 8080:8080
29+
cite:
30+
image: docker.io/ogccite/ets-ogcapi-features10
31+
ports:
32+
- 8080:8080
3333

3434
steps:
3535
- name: Checkout
3636
uses: actions/checkout@v4
3737

3838
- name: Load
39-
run: cargo run -p data-loader -- --input data/ne_110m_admin_0_countries.geojson --collection countries
40-
env:
41-
DATABASE_URL: "postgresql://postgres:password@localhost:5432/ogcapi"
39+
run: cargo run -p data-loader -- --input data/ne_110m_populated_places.geojson --collection places
4240

4341
- name: Run
4442
run: RUNNER_TRACKING_ID="" && cargo run -p cite-service &
45-
env:
46-
APP_HOST: "0.0.0.0"
47-
APP_PORT: "8484"
48-
DATABASE_URL: "postgresql://postgres:password@localhost:5432/ogcapi"
43+
# env:
44+
# PUBLIC_URL: "http://host.docker.internal:8484"
4945

5046
- name: Check running service
5147
run: |
@@ -55,15 +51,29 @@ jobs:
5551
do
5652
sleep 5
5753
done
54+
curl -v http://localhost:8484/ | jq
55+
56+
# - name: Downgrade click
57+
# run: pip install ogc-cite-runner "click<8.2.0"
5858

59-
- name: Downgrade click
60-
run: pip install ogc-cite-runner "click<8.2.0"
59+
# - name: Cite container
60+
# run: docker run -d --network host docker.io/ogccite/ets-ogcapi-features10
6161

62+
# - name: Check running container
63+
# run: |
64+
# until [ \
65+
# "$(curl -s -w '%{http_code}' -o /dev/null "http://localhost:8080/teamengine")" \
66+
# -eq 200 ]
67+
# echo $http_code
68+
# do
69+
# sleep 5
70+
# done
71+
6272
- name: Validate
63-
run: docker run -d --network host docker.io/ogccite/ets-ogcapi-features10 && sleep 20 && ogc-cite-runner execute-test-suite http://localhost:8080/teamengine ogcapi-features-1.0 --suite-input iut http://host.docker.internal:8484
64-
# uses: OSGEO/[email protected]
65-
# with:
66-
# test_suite_identifier: ogcapi-features-1.0
67-
# test_session_arguments: >-
68-
# iut=http://host.docker.internal:8484
73+
# run: ogc-cite-runner execute-test-suite http://localhost:8080/teamengine ogcapi-features-1.0 --suite-input iut http://host.docker.internal:8484
74+
uses: OSGEO/[email protected]
75+
with:
76+
test_suite_identifier: ogcapi-features-1.0
77+
test_session_arguments: >-
78+
iut=http://host.docker.internal:8484
6979

examples/cite-service/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tokio = { version = "1.47", features = ["full"] }
1212
tracing = "0.1.41"
1313
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
1414

15-
ogcapi = { path = "../../ogcapi", version = "0.3", features = [
15+
ogcapi = { path = "../../ogcapi", version = "0.3", default-features = false, features = [
1616
"services",
1717
"common",
1818
"features",

ogcapi-drivers/src/postgres/collection.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ impl CollectionTransactions for Db {
107107
}
108108

109109
async fn list_collections(&self, _query: &Query) -> anyhow::Result<Collections> {
110-
println!("Query collections");
111110
let collections: Option<sqlx::types::Json<Vec<Collection>>> = if cfg!(feature = "stac") {
112111
sqlx::query_scalar(
113112
r#"

ogcapi-drivers/src/postgres/feature.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ impl FeatureTransactions for Db {
153153
.unwrap_or_default()
154154
.as_srid();
155155

156+
// TODO: handle antimeridian (lower > upper on axis 1)
156157
let intersection = match bbox {
157158
Bbox::Bbox2D(bbox) => format!(
158159
"ST_Intersects(geom, ST_Transform(ST_MakeEnvelope({}, {}, {}, {}, {}), {storage_srid}))",

ogcapi-processes/src/gdal_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ mod tests {
372372
collection: "streets-gdal".to_string(),
373373
filter: None,
374374
s_srs: None,
375-
database_url: "postgresql://postgres:password@localhost:5433/ogcapi".to_string(),
375+
database_url: "postgresql://postgres:password@localhost:5432/ogcapi".to_string(),
376376
};
377377

378378
let execute = Execute {

ogcapi-processes/src/geojson_loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ mod tests {
249249
input: "../data/ne_10m_railroads_north_america.geojson".to_owned(),
250250
collection: "streets-geojson".to_string(),
251251
s_srs: None,
252-
database_url: "postgresql://postgres:password@localhost:5433/ogcapi".to_string(),
252+
database_url: "postgresql://postgres:password@localhost:5432/ogcapi".to_string(),
253253
};
254254

255255
let execute = Execute {

ogcapi-services/src/extractors.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ where
2020
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
2121
let uri = OriginalUri::from_request_parts(parts, state).await.unwrap();
2222

23-
let url = if uri.0.scheme().is_some() {
23+
let url = if let Ok(url) = std::env::var("PUBLIC_URL") {
24+
format!(
25+
"{}{}",
26+
url.trim_end_matches('/'),
27+
uri.path_and_query().unwrap()
28+
)
29+
} else if uri.0.scheme().is_some() {
2430
uri.0.to_string()
2531
} else {
2632
let host = Host::from_request_parts(parts, state)

ogcapi-services/src/routes/features.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ use crate::{
2323
extractors::{Qs, RemoteUrl},
2424
};
2525

26-
const CONFORMANCE: [&str; 3] = [
26+
const CONFORMANCE: [&str; 4] = [
2727
"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/core",
28-
// "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30",
28+
"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30",
2929
"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson",
3030
"http://www.opengis.net/spec/ogcapi-features-2/1.0/conf/crs",
3131
];
@@ -259,11 +259,15 @@ async fn items(
259259

260260
// Limit
261261
if let Some(limit) = query.limit {
262+
// TODO: sync with opanapi specification
262263
if limit > 10000 {
263264
query.limit = Some(10000);
264265
}
266+
if limit == 0 {
267+
query.limit = Some(1)
268+
}
265269
} else {
266-
query.limit = Some(100);
270+
query.limit = Some(10);
267271
}
268272

269273
let collection = state

ogcapi-types/src/common/bbox.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ use std::{fmt, str};
33
use serde::{Deserialize, Serialize};
44
use utoipa::ToSchema;
55

6-
type Bbox2D = [f64; 4];
7-
type Bbox3D = [f64; 6];
8-
96
/// Each bounding box is provided as four or six numbers, depending on
107
/// whether the coordinate reference system includes a vertical axis
118
/// (height or depth):
@@ -41,9 +38,9 @@ type Bbox3D = [f64; 6];
4138
#[serde(untagged)]
4239
pub enum Bbox {
4340
#[schema(value_type = Vec<f64>)]
44-
Bbox2D(Bbox2D),
41+
Bbox2D([f64; 4]),
4542
#[schema(value_type = Vec<f64>)]
46-
Bbox3D(Bbox3D),
43+
Bbox3D([f64; 6]),
4744
}
4845

4946
impl fmt::Display for Bbox {
@@ -79,10 +76,28 @@ impl str::FromStr for Bbox {
7976
fn from_str(s: &str) -> Result<Self, Self::Err> {
8077
let numbers: Vec<f64> = s
8178
.split(',')
82-
.map(|d| d.trim().parse::<f64>())
79+
.map(|d| d.trim().trim_matches(&['[', ']']).parse::<f64>())
8380
.collect::<Result<Vec<f64>, std::num::ParseFloatError>>()
8481
.map_err(|_| "Unable to convert bbox coordinates to float")?;
8582

83+
let n = numbers.len();
84+
85+
// check number of coordinates
86+
if !(n == 4 || n == 6) {
87+
return Err("Expected 4 or 6 numbers");
88+
}
89+
90+
// check lower <= upper on axis 2
91+
if (n == 4 && numbers[1] > numbers[3]) || (n == 6 && numbers[1] > numbers[4]) {
92+
// TODO: ensure this assumption is correct
93+
return Err("Lower value of coordinate axis 2 must be larger than upper value!");
94+
}
95+
96+
// check lower <= upper on axis 3
97+
if n == 6 && numbers[2] > numbers[5] {
98+
return Err("Lower value of coordinate axis 3 must be larger than upper value!");
99+
}
100+
86101
match numbers.len() {
87102
4 => Ok(Bbox::Bbox2D([
88103
numbers[0], numbers[1], numbers[2], numbers[3],

0 commit comments

Comments
 (0)