2022-10-12 11:52:26 +03:00
|
|
|
use actix_http::Request;
|
|
|
|
use actix_web::http::StatusCode;
|
|
|
|
use actix_web::test::{call_and_read_body_json, call_service, read_body, TestRequest};
|
2022-11-26 12:46:40 +03:00
|
|
|
use ctor::ctor;
|
2023-01-01 08:03:21 +03:00
|
|
|
use indoc::indoc;
|
2022-12-27 09:56:27 +03:00
|
|
|
use martin::srv::IndexEntry;
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
use martin::OneOrMany;
|
2023-02-22 19:25:48 +03:00
|
|
|
use tilejson::TileJSON;
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2023-01-03 19:09:41 +03:00
|
|
|
pub mod utils;
|
|
|
|
pub use utils::*;
|
2022-11-26 12:46:40 +03:00
|
|
|
|
|
|
|
#[ctor]
|
2020-06-02 09:49:21 +03:00
|
|
|
fn init() {
|
|
|
|
let _ = env_logger::builder().is_test(true).try_init();
|
|
|
|
}
|
|
|
|
|
2022-10-12 11:52:26 +03:00
|
|
|
macro_rules! create_app {
|
2023-01-12 19:48:15 +03:00
|
|
|
($sources:expr) => {{
|
|
|
|
let cfg = mock_cfg(indoc::indoc!($sources));
|
|
|
|
let sources = mock_sources(cfg).await.0;
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let state = crate::utils::mock_app_data(sources).await;
|
2022-10-12 11:52:26 +03:00
|
|
|
::actix_web::test::init_service(
|
|
|
|
::actix_web::App::new()
|
2022-11-26 12:46:40 +03:00
|
|
|
.app_data(state)
|
2022-12-27 09:56:27 +03:00
|
|
|
.configure(::martin::srv::router),
|
2022-10-12 11:52:26 +03:00
|
|
|
)
|
|
|
|
.await
|
|
|
|
}};
|
|
|
|
}
|
2020-06-02 09:49:21 +03:00
|
|
|
|
2022-10-12 11:52:26 +03:00
|
|
|
fn test_get(path: &str) -> Request {
|
|
|
|
TestRequest::get().uri(path).to_request()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_rt::test]
|
2023-02-22 19:25:48 +03:00
|
|
|
async fn pg_get_catalog() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2020-06-02 09:49:21 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/catalog");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2020-06-02 09:49:21 +03:00
|
|
|
assert!(response.status().is_success());
|
2022-10-12 11:52:26 +03:00
|
|
|
let body = read_body(response).await;
|
2022-11-26 12:46:40 +03:00
|
|
|
let sources: Vec<IndexEntry> = serde_json::from_slice(&body).unwrap();
|
2020-06-02 09:49:21 +03:00
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let expected = "table_source";
|
|
|
|
assert_eq!(sources.iter().filter(|v| v.id == expected).count(), 1);
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
let expected = "function_zxy_query";
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
assert_eq!(sources.iter().filter(|v| v.id == expected).count(), 1);
|
2022-12-27 09:56:27 +03:00
|
|
|
|
|
|
|
let expected = "function_zxy_query_jsonb";
|
|
|
|
assert_eq!(sources.iter().filter(|v| v.id == expected).count(), 1);
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_table_source_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
bad_srid:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
" };
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/non_existent");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2019-10-26 20:37:49 +03:00
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let req = test_get("/bad_srid");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2023-01-12 19:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_rt::test]
|
2023-02-22 19:25:48 +03:00
|
|
|
async fn pg_get_table_source_rewrite() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
" };
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
2022-10-12 11:52:26 +03:00
|
|
|
let req = TestRequest::get()
|
2022-11-26 12:46:40 +03:00
|
|
|
.uri("/table_source?token=martin")
|
|
|
|
.insert_header(("x-rewrite-url", "/tiles/table_source?token=martin"))
|
2020-05-05 14:13:48 +03:00
|
|
|
.to_request();
|
2022-10-12 11:52:26 +03:00
|
|
|
let result: TileJSON = call_and_read_body_json(&app, req).await;
|
2023-02-22 19:25:48 +03:00
|
|
|
assert_eq!(
|
|
|
|
result,
|
|
|
|
serde_json::from_str(indoc! {r#"
|
|
|
|
{
|
|
|
|
"name": "table_source",
|
|
|
|
"description": "public.table_source.geom",
|
|
|
|
"tilejson": "3.0.0",
|
|
|
|
"tiles": [
|
|
|
|
"http://localhost:8080/tiles/table_source/{z}/{x}/{y}?token=martin"
|
|
|
|
],
|
|
|
|
"vector_layers": [
|
|
|
|
{
|
|
|
|
"id": "table_source",
|
|
|
|
"fields": {
|
|
|
|
"gid": "int4"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"bounds": [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
}
|
|
|
|
"#})
|
|
|
|
.unwrap()
|
|
|
|
);
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_table_source_tile_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points_empty_srid:
|
|
|
|
schema: public
|
|
|
|
table: points_empty_srid
|
|
|
|
srid: 900973
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points3857:
|
|
|
|
schema: public
|
|
|
|
table: points3857
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom1:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom1
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom2:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom2
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
MIXPOINTS:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
tAble: text
|
2023-01-01 08:03:21 +03:00
|
|
|
" };
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/non_existent/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-04-24 20:19:37 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/table_source/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2020-05-05 14:13:48 +03:00
|
|
|
assert!(response.status().is_success());
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2021-10-21 12:20:33 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_table_source_multiple_geom_tile_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom2:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom2
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
MIXPOINTS:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
tAble: text
|
|
|
|
points_empty_srid:
|
|
|
|
schema: public
|
|
|
|
table: points_empty_srid
|
|
|
|
srid: 900973
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points3857:
|
|
|
|
schema: public
|
|
|
|
table: points3857
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom1:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom1
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2021-10-21 12:20:33 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/table_source_multiple_geom.geom1/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-21 12:20:33 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/table_source_multiple_geom.geom2/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-21 12:20:33 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
|
2021-10-13 14:51:29 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_table_source_tile_minmax_zoom_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
points3857:
|
|
|
|
schema: public
|
|
|
|
table: points3857
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
minzoom: 6
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
minzoom: 6
|
|
|
|
maxzoom: 12
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
maxzoom: 6
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2021-10-13 14:51:29 +03:00
|
|
|
// zoom = 0 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 6 (points1)
|
|
|
|
let req = test_get("/points1/6/38/20");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (points1)
|
|
|
|
let req = test_get("/points1/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 13 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1/13/4952/2560");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 0 (points2)
|
|
|
|
let req = test_get("/points2/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 6 (points2)
|
|
|
|
let req = test_get("/points2/6/38/20");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (points2)
|
|
|
|
let req = test_get("/points2/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 13 (points2)
|
|
|
|
let req = test_get("/points2/13/4952/2560");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 0 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points3857/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (points3857)
|
|
|
|
let req = test_get("/points3857/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 0 (table_source)
|
|
|
|
let req = test_get("/table_source/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 12 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/table_source/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
}
|
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_function_tiles() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
let req = test_get("/function_zoom_xy/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy2/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy_query/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
2022-12-27 09:56:27 +03:00
|
|
|
let req = test_get("/function_zxy_query_jsonb/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let req = test_get("/function_zxy_row/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_Mixed_Name/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy_row_key/6/38/20");
|
|
|
|
assert!(call_service(&app, req).await.status().is_success());
|
|
|
|
}
|
|
|
|
|
2021-04-24 20:19:37 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_composite_source_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
table_source_multiple_geom.geom2:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom2
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points_empty_srid:
|
|
|
|
schema: public
|
|
|
|
table: points_empty_srid
|
|
|
|
srid: 900973
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
MIXPOINTS:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
tAble: text
|
|
|
|
table_source_multiple_geom.geom1:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom1
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points3857:
|
|
|
|
schema: public
|
|
|
|
table: points3857
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/non_existent1,non_existent2");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-04-24 20:19:37 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1,points2,points3857");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-04-24 20:19:37 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_composite_source_tile_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
points_empty_srid:
|
|
|
|
schema: public
|
|
|
|
table: points_empty_srid
|
|
|
|
srid: 900973
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom1:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom1
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source_multiple_geom.geom2:
|
|
|
|
schema: public
|
|
|
|
table: table_source_multiple_geom
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom2
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
table_source:
|
|
|
|
schema: public
|
|
|
|
table: table_source
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: GEOMETRY
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
MIXPOINTS:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
tAble: text
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points3857:
|
|
|
|
schema: public
|
|
|
|
table: points3857
|
|
|
|
srid: 3857
|
|
|
|
geometry_column: geom
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2021-04-24 20:19:37 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/non_existent1,non_existent2/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-04-24 20:19:37 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1,points2,points3857/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-04-24 20:19:37 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
|
2021-10-13 14:51:29 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_composite_source_tile_minmax_zoom_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! { "
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
points1:
|
|
|
|
schema: public
|
|
|
|
table: points1
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
minzoom: 6
|
|
|
|
maxzoom: 13
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
|
|
|
points2:
|
|
|
|
schema: public
|
|
|
|
table: points2
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geom
|
|
|
|
minzoom: 13
|
|
|
|
maxzoom: 20
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
gid: int4
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2021-10-13 14:51:29 +03:00
|
|
|
|
|
|
|
// zoom = 0 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1,points2/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 6 (points1)
|
|
|
|
let req = test_get("/points1,points2/6/38/20");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (points1)
|
|
|
|
let req = test_get("/points1,points2/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 13 (points1, points2)
|
|
|
|
let req = test_get("/points1,points2/13/4952/2560");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 14 (points2)
|
|
|
|
let req = test_get("/points1,points2/14/9904/5121");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 20 (points2)
|
|
|
|
let req = test_get("/points1,points2/20/633856/327787");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 21 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/points1,points2/21/1267712/655574");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
}
|
|
|
|
|
2022-12-15 15:12:55 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_null_functions() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2022-12-15 15:12:55 +03:00
|
|
|
|
|
|
|
let req = test_get("/function_null/0/0/0");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NO_CONTENT);
|
|
|
|
|
|
|
|
let req = test_get("/function_null_row/0/0/0");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NO_CONTENT);
|
|
|
|
|
|
|
|
let req = test_get("/function_null_row2/0/0/0");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NO_CONTENT);
|
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_function_source_ok() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2020-06-02 09:49:21 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/non_existent");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2019-10-26 20:37:49 +03:00
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let req = test_get("/function_zoom_xy");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
let req = test_get("/function_zxy_query");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2020-05-05 14:13:48 +03:00
|
|
|
assert!(response.status().is_success());
|
2021-10-15 18:19:36 +03:00
|
|
|
|
2022-12-27 09:56:27 +03:00
|
|
|
let req = test_get("/function_zxy_query_jsonb");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let req = test_get("/function_zxy_query_test");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy_row");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_Mixed_Name");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
let req = test_get("/function_zxy_row_key");
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
2023-01-12 19:48:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_rt::test]
|
|
|
|
async fn pg_get_function_source_ok_rewrite() {
|
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
2022-10-12 11:52:26 +03:00
|
|
|
let req = TestRequest::get()
|
2022-11-30 19:57:27 +03:00
|
|
|
.uri("/function_zxy_query?token=martin")
|
|
|
|
.insert_header(("x-rewrite-url", "/tiles/function_zxy_query?token=martin"))
|
2021-10-15 18:19:36 +03:00
|
|
|
.to_request();
|
2022-10-12 11:52:26 +03:00
|
|
|
let result: TileJSON = call_and_read_body_json(&app, req).await;
|
2021-10-15 18:19:36 +03:00
|
|
|
assert_eq!(
|
|
|
|
result.tiles,
|
2022-11-30 19:57:27 +03:00
|
|
|
&["http://localhost:8080/tiles/function_zxy_query/{z}/{x}/{y}?token=martin"]
|
2021-10-15 18:19:36 +03:00
|
|
|
);
|
2022-12-27 09:56:27 +03:00
|
|
|
|
|
|
|
let req = TestRequest::get()
|
|
|
|
.uri("/function_zxy_query_jsonb?token=martin")
|
|
|
|
.insert_header((
|
|
|
|
"x-rewrite-url",
|
|
|
|
"/tiles/function_zxy_query_jsonb?token=martin",
|
|
|
|
))
|
|
|
|
.to_request();
|
|
|
|
let result: TileJSON = call_and_read_body_json(&app, req).await;
|
|
|
|
assert_eq!(
|
|
|
|
result.tiles,
|
|
|
|
&["http://localhost:8080/tiles/function_zxy_query_jsonb/{z}/{x}/{y}?token=martin"]
|
|
|
|
);
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_function_source_tile_ok() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
let req = test_get("/function_zxy_query/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2020-05-05 14:13:48 +03:00
|
|
|
assert!(response.status().is_success());
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
2021-01-16 16:11:19 +03:00
|
|
|
|
2021-10-13 14:51:29 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_function_source_tile_minmax_zoom_ok() {
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = create_app! {"
|
2023-01-12 19:48:15 +03:00
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
functions:
|
|
|
|
function_source1:
|
|
|
|
schema: public
|
|
|
|
function: function_zxy_query
|
|
|
|
function_source2:
|
|
|
|
schema: public
|
|
|
|
function: function_zxy_query
|
|
|
|
minzoom: 6
|
|
|
|
maxzoom: 12
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
2023-01-01 08:03:21 +03:00
|
|
|
"};
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 0 (function_source1)
|
|
|
|
let req = test_get("/function_source1/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 6 (function_source1)
|
|
|
|
let req = test_get("/function_source1/6/38/20");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (function_source1)
|
|
|
|
let req = test_get("/function_source1/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 13 (function_source1)
|
|
|
|
let req = test_get("/function_source1/13/4952/2560");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 0 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/function_source2/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 6 (function_source2)
|
|
|
|
let req = test_get("/function_source2/6/38/20");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
// zoom = 12 (function_source2)
|
|
|
|
let req = test_get("/function_source2/12/2476/1280");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-10-13 14:51:29 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
|
|
|
|
// zoom = 13 (nothing)
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/function_source2/13/4952/2560");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
2021-10-13 14:51:29 +03:00
|
|
|
}
|
|
|
|
|
2021-07-16 12:09:18 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_function_source_query_params_ok() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2021-07-16 12:09:18 +03:00
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
let req = test_get("/function_zxy_query_test/0/0/0");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-07-16 12:09:18 +03:00
|
|
|
println!("response.status = {:?}", response.status());
|
|
|
|
assert!(response.status().is_server_error());
|
|
|
|
|
2022-11-30 19:57:27 +03:00
|
|
|
let req = test_get("/function_zxy_query_test/0/0/0?token=martin");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-07-16 12:09:18 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
|
2021-01-16 16:11:19 +03:00
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_get_health_returns_ok() {
|
2023-01-12 19:48:15 +03:00
|
|
|
let app = create_app! { "
|
|
|
|
postgres:
|
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
"};
|
2021-01-16 16:11:19 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
let req = test_get("/health");
|
2022-10-12 11:52:26 +03:00
|
|
|
let response = call_service(&app, req).await;
|
2021-01-16 16:11:19 +03:00
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
#[actix_rt::test]
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
async fn pg_tables_feature_id() {
|
2023-01-03 19:09:41 +03:00
|
|
|
let cfg = mock_pgcfg(indoc! {"
|
2023-01-01 08:03:21 +03:00
|
|
|
connection_string: $DATABASE_URL
|
|
|
|
tables:
|
|
|
|
id_and_prop:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
TABLE: text
|
|
|
|
giD: int4
|
|
|
|
no_id:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
TABLE: text
|
|
|
|
id_only:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
id_column: giD
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
TABLE: text
|
|
|
|
prop_only:
|
|
|
|
schema: MIXEDCASE
|
|
|
|
table: mixPoints
|
|
|
|
srid: 4326
|
|
|
|
geometry_column: geoM
|
|
|
|
bounds: [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
geometry_type: POINT
|
|
|
|
properties:
|
|
|
|
giD: int4
|
|
|
|
TABLE: text
|
|
|
|
"});
|
|
|
|
let mock = mock_sources(cfg.clone()).await;
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
let src = table(&mock, "no_id");
|
|
|
|
assert_eq!(src.id_column, None);
|
2023-01-01 08:03:21 +03:00
|
|
|
assert!(matches!(&src.properties, Some(v) if v.len() == 1));
|
2023-02-22 19:25:48 +03:00
|
|
|
assert_eq!(
|
|
|
|
source(&mock, "no_id").get_tilejson(),
|
|
|
|
serde_json::from_str(indoc! {r#"
|
|
|
|
{
|
|
|
|
"name": "no_id",
|
|
|
|
"description": "MixedCase.MixPoints.Geom",
|
|
|
|
"tilejson": "3.0.0",
|
|
|
|
"tiles": [],
|
|
|
|
"vector_layers": [
|
|
|
|
{
|
|
|
|
"id": "no_id",
|
|
|
|
"fields": {"TABLE": "text"}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"bounds": [-180.0, -90.0, 180.0, 90.0]
|
|
|
|
}
|
|
|
|
"#})
|
|
|
|
.unwrap()
|
|
|
|
);
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
let src = table(&mock, "id_only");
|
2022-12-27 09:56:27 +03:00
|
|
|
assert_eq!(src.id_column, some("giD"));
|
2023-01-01 08:03:21 +03:00
|
|
|
assert!(matches!(&src.properties, Some(v) if v.len() == 1));
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
let src = table(&mock, "id_and_prop");
|
2022-12-27 09:56:27 +03:00
|
|
|
assert_eq!(src.id_column, some("giD"));
|
2023-01-01 08:03:21 +03:00
|
|
|
assert!(matches!(&src.properties, Some(v) if v.len() == 2));
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
let src = table(&mock, "prop_only");
|
|
|
|
assert_eq!(src.id_column, None);
|
2023-01-01 08:03:21 +03:00
|
|
|
assert!(matches!(&src.properties, Some(v) if v.len() == 2));
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
2023-01-12 19:48:15 +03:00
|
|
|
let state = mock_app_data(mock.0).await;
|
2023-01-01 08:03:21 +03:00
|
|
|
let app = ::actix_web::test::init_service(
|
|
|
|
::actix_web::App::new()
|
|
|
|
.app_data(state)
|
|
|
|
.configure(::martin::srv::router),
|
|
|
|
)
|
|
|
|
.await;
|
|
|
|
|
Refactorings, content-type/enc, cli parsing, tests, minor fixes (#548)
* introduce a new Connections object to track all positional strings
passed as the CLI arguments
* each tile provider can now indicate if it can take a positional CLI
arg, and if the value can be shared between multiple providers, i.e. if
its a directory that could contain files for multiple providers
* make xyz use better types - u8 for zoom, u32 for x&y. Postgres casts
those to INT2 and INT8
* minor bug in pre-push git hook to abort in case of a testingerror
* added GIF detection/type
* combine MVT and compression concepts into one enum more explicitly. It
is not ideal (technically they are separate concerns), but it keeps it a
bit simpler for now for multiple providers.
* set content encoding and content type on HTTP responses if known, and
also include them in the `/catalog` response (json)
* raise an error if the user attempts to merge non-concatenatable tiles
from multiple sources. We may want to implement it in the future, e.g.
combine multiple semi-transparent PNGs. Or even combine GIF & PNG & JPEG
* do not set content-type on empty responses (http 204)
* add tilejson outputs to testing
2023-01-08 17:31:58 +03:00
|
|
|
let OneOrMany::One(cfg) = cfg.postgres.unwrap() else { panic!() };
|
2023-01-01 08:03:21 +03:00
|
|
|
for (name, _) in cfg.tables.unwrap_or_default() {
|
Support z,x,y and record-returning funcs, table rework (#380)
Can now handle several additional Postgres functions to get a tile, plus
tons of small fixes
### Multiple result variants
* `getmvt(z,x,y) -> [bytea,md5]` (single row with two columns)
* `getmvt(z,x,y) -> [bytea]` (single row with a single column)
* `getmvt(z,x,y) -> bytea` (value)
### Multiple input parameter variants
* `getmvt(z, x, y)` or `getmvt(zoom, x, y)` (all 3 vars must be
integers)
* `getmvt(z, x, y, url_query)`, where instead of `url_query` it could be
any other name, but must be of type JSON
### Breaking
* srid is now the same type as PG -- `i32`
* renamed config vals `table_sources` and `function_sources` into
`tables` and `functions`
### Features and fixes
* if postgis is v3.1+, uses margin parameter to extend the search box by
the size of the buffer. I think we should make 3.1 minimal required.
* fixes feature ID issue from #466
* fixes mixed case names for schemas, tables and columns, functions and
parameter names per #389
### Notes
* More dynamic SQL generation in code instead of using external SQL
files. Those should only be used when they are not parametrized.
* The new function/table discovery mechanism: query for all functions in
the database, and match up those functions with the ones configured (if
any), plus adds all the rest of the un-declared ones if discovery mode
is on.
* During table and function discovery, the code generates a map of
`(PgSqlInfo, FunctionInfo)` (or table) tupples containing SQL needed to
get the tile.
* Auto-discovery mode is currently hidden - the discovery is on only
when no tables or functions are configured. TBD - how to configure it in
the future
* The new system allows for an easy way to auto-discover for the
specific schemas only, solving #47
* predictable order of table/function instantiation
* bounding boxes computed in parallel for all tables (when not
configured)
* proper identifier escaping
* test cleanup
fixes #378
fixes #466
fixes #65
fixes #389
2022-12-10 17:20:42 +03:00
|
|
|
let req = test_get(format!("/{name}/0/0/0").as_str());
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
}
|