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;
|
|
|
|
use martin::pg::config::{FunctionInfo, TableInfo};
|
|
|
|
use martin::srv::server::IndexEntry;
|
2022-08-06 19:48:10 +03:00
|
|
|
use tilejson::{Bounds, TileJSON};
|
2019-10-26 20:37:49 +03:00
|
|
|
|
2022-11-26 12:46:40 +03:00
|
|
|
#[path = "utils.rs"]
|
|
|
|
mod utils;
|
|
|
|
use utils::*;
|
|
|
|
|
|
|
|
#[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 {
|
2022-11-26 12:46:40 +03:00
|
|
|
($sources:expr) => {{
|
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 sources = $sources.await.0;
|
|
|
|
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-10-12 11:52:26 +03:00
|
|
|
.configure(::martin::srv::server::router),
|
|
|
|
)
|
|
|
|
.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]
|
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
|
|
|
async fn get_catalog_ok() {
|
|
|
|
let app = create_app!(mock_unconfigured());
|
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);
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_table_source_ok() {
|
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 mut tables = mock_table_config_map();
|
|
|
|
let table = tables.remove("table_source").unwrap();
|
2022-11-26 12:46:40 +03:00
|
|
|
let table_source = TableInfo {
|
2021-10-13 14:51:29 +03:00
|
|
|
minzoom: Some(0),
|
|
|
|
maxzoom: Some(30),
|
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
|
|
|
..table.clone()
|
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
|
|
|
let bad_srid = TableInfo {
|
|
|
|
srid: 3857,
|
|
|
|
..table
|
|
|
|
};
|
|
|
|
let app = create_app!(mock_sources(
|
|
|
|
None,
|
|
|
|
Some(vec![("table_source", table_source), ("bad_srid", bad_srid)]),
|
|
|
|
None
|
|
|
|
));
|
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);
|
|
|
|
|
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;
|
2022-11-26 12:46:40 +03:00
|
|
|
assert_eq!(result.name, Some(String::from("public.table_source.geom")));
|
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_uri = "http://localhost:8080/tiles/table_source/{z}/{x}/{y}?token=martin";
|
|
|
|
assert_eq!(result.tiles, &[expected_uri]);
|
2021-10-13 14:51:29 +03:00
|
|
|
assert_eq!(result.minzoom, Some(0));
|
|
|
|
assert_eq!(result.maxzoom, Some(30));
|
2022-05-30 14:06:44 +03:00
|
|
|
assert_eq!(result.bounds, Some(Bounds::MAX));
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_table_source_tile_ok() {
|
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 app = create_app!(mock_configured_tables(None));
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_table_source_multiple_geom_tile_ok() {
|
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 app = create_app!(mock_configured_tables(None));
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_table_source_tile_minmax_zoom_ok() {
|
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 mut tables = mock_table_config_map();
|
|
|
|
|
|
|
|
let app = create_app!(mock_sources(
|
|
|
|
None,
|
|
|
|
Some(vec![
|
|
|
|
(
|
|
|
|
"points1",
|
|
|
|
TableInfo {
|
|
|
|
minzoom: Some(6),
|
|
|
|
maxzoom: Some(12),
|
|
|
|
..tables.remove("points1").unwrap()
|
|
|
|
},
|
|
|
|
),
|
|
|
|
("points2", tables.remove("points2").unwrap()),
|
|
|
|
(
|
|
|
|
"points3857",
|
|
|
|
TableInfo {
|
|
|
|
minzoom: Some(6),
|
|
|
|
..tables.remove("points3857").unwrap()
|
|
|
|
},
|
|
|
|
),
|
|
|
|
(
|
|
|
|
"table_source",
|
|
|
|
TableInfo {
|
|
|
|
maxzoom: Some(6),
|
|
|
|
..tables.remove("table_source").unwrap()
|
|
|
|
},
|
|
|
|
),
|
|
|
|
]),
|
|
|
|
None
|
|
|
|
));
|
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]
|
|
|
|
async fn get_function_tiles() {
|
|
|
|
let app = create_app!(mock_unconfigured());
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_composite_source_ok() {
|
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 app = create_app!(mock_configured_tables(None));
|
2021-04-24 20:19:37 +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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_composite_source_tile_ok() {
|
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 app = create_app!(mock_configured_tables(None));
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_composite_source_tile_minmax_zoom_ok() {
|
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 mut tables = mock_table_config_map();
|
|
|
|
|
|
|
|
let points1 = TableInfo {
|
2021-10-13 14:51:29 +03:00
|
|
|
minzoom: Some(6),
|
|
|
|
maxzoom: Some(13),
|
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
|
|
|
..tables.remove("points1").unwrap()
|
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
|
|
|
let points2 = TableInfo {
|
2021-10-13 14:51:29 +03:00
|
|
|
minzoom: Some(13),
|
|
|
|
maxzoom: Some(20),
|
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
|
|
|
..tables.remove("points2").unwrap()
|
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
|
|
|
let tables = vec![("points1", points1), ("points2", points2)];
|
|
|
|
let app = create_app!(mock_sources(None, Some(tables), None));
|
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
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_function_source_ok() {
|
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 app = create_app!(mock_unconfigured());
|
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
|
|
|
|
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());
|
|
|
|
|
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
|
|
|
);
|
2019-10-26 20:37:49 +03:00
|
|
|
}
|
|
|
|
|
2020-04-26 17:57:13 +03:00
|
|
|
#[actix_rt::test]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_function_source_tile_ok() {
|
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 app = create_app!(mock_unconfigured());
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_function_source_tile_minmax_zoom_ok() {
|
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 function_source1 = FunctionInfo::new("public".to_owned(), "function_zxy_query".to_owned());
|
|
|
|
let function_source2 = FunctionInfo::new_extended(
|
|
|
|
"public".to_owned(),
|
|
|
|
"function_zxy_query".to_owned(),
|
|
|
|
6,
|
|
|
|
12,
|
|
|
|
Bounds::MAX,
|
|
|
|
);
|
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
|
|
|
let funcs = vec![
|
2022-11-26 12:46:40 +03:00
|
|
|
("function_source1", function_source1),
|
|
|
|
("function_source2", function_source2),
|
|
|
|
];
|
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 app = create_app!(mock_sources(Some(funcs), None, None));
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_function_source_query_params_ok() {
|
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 app = create_app!(mock_unconfigured());
|
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]
|
2022-10-12 11:52:26 +03:00
|
|
|
async fn get_health_returns_ok() {
|
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 app = create_app!(mock_unconfigured());
|
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]
|
|
|
|
async fn tables_feature_id() {
|
|
|
|
let mut tables = mock_table_config_map();
|
|
|
|
|
|
|
|
let default = tables.remove("MIXPOINTS").unwrap();
|
|
|
|
|
|
|
|
let no_id = TableInfo {
|
|
|
|
id_column: None,
|
|
|
|
properties: props(&[("TABLE", "text")]),
|
|
|
|
..default.clone()
|
|
|
|
};
|
|
|
|
let id_only = TableInfo {
|
|
|
|
id_column: Some("giD".to_string()),
|
|
|
|
properties: props(&[("TABLE", "text")]),
|
|
|
|
..default.clone()
|
|
|
|
};
|
|
|
|
let id_and_prop = TableInfo {
|
|
|
|
id_column: Some("giD".to_string()),
|
|
|
|
properties: props(&[("giD", "int4"), ("TABLE", "text")]),
|
|
|
|
..default.clone()
|
|
|
|
};
|
|
|
|
let prop_only = TableInfo {
|
|
|
|
id_column: None,
|
|
|
|
properties: props(&[("giD", "int4"), ("TABLE", "text")]),
|
|
|
|
..default.clone()
|
|
|
|
};
|
|
|
|
|
|
|
|
let tables = vec![
|
|
|
|
("no_id", no_id),
|
|
|
|
("id_only", id_only),
|
|
|
|
("id_and_prop", id_and_prop),
|
|
|
|
("prop_only", prop_only),
|
|
|
|
];
|
|
|
|
let mock = mock_sources(None, Some(tables.clone()), None).await;
|
|
|
|
|
|
|
|
let src = table(&mock, "no_id");
|
|
|
|
assert_eq!(src.id_column, None);
|
|
|
|
assert_eq!(src.properties.len(), 1);
|
|
|
|
// let tj = source(&mock, "no_id").get_tilejson();
|
|
|
|
// tj.vector_layers.unwrap().iter().for_each(|vl| {
|
|
|
|
// assert_eq!(vl.id, "no_id");
|
|
|
|
// assert_eq!(vl.fields.len(), 2);
|
|
|
|
// });
|
|
|
|
|
|
|
|
let src = table(&mock, "id_only");
|
|
|
|
assert_eq!(src.id_column, Some("giD".to_string()));
|
|
|
|
assert_eq!(src.properties.len(), 1);
|
|
|
|
|
|
|
|
let src = table(&mock, "id_and_prop");
|
|
|
|
assert_eq!(src.id_column, Some("giD".to_string()));
|
|
|
|
assert_eq!(src.properties.len(), 2);
|
|
|
|
|
|
|
|
let src = table(&mock, "prop_only");
|
|
|
|
assert_eq!(src.id_column, None);
|
|
|
|
assert_eq!(src.properties.len(), 2);
|
|
|
|
|
|
|
|
// --------------------------------------------
|
|
|
|
|
|
|
|
let app = create_app!(mock_sources(None, Some(tables.clone()), None));
|
|
|
|
for (name, _) in tables.iter() {
|
|
|
|
let req = test_get(format!("/{name}/0/0/0").as_str());
|
|
|
|
let response = call_service(&app, req).await;
|
|
|
|
assert!(response.status().is_success());
|
|
|
|
}
|
|
|
|
}
|