mirror of
https://github.com/maplibre/martin.git
synced 2024-12-20 05:11:57 +03:00
Views handling (#571)
* Adds a view to `points1.sql` fixture * Replaces `table` with `view` in log statements relating to views --------- Co-authored-by: Chris Thiange <cthiange@gmail.com>
This commit is contained in:
parent
612a8d38c4
commit
22bf2008e5
@ -88,7 +88,7 @@ impl PgBuilder {
|
|||||||
let dup = if dup { "duplicate " } else { "" };
|
let dup = if dup { "duplicate " } else { "" };
|
||||||
|
|
||||||
let id2 = self.resolve_id(id, cfg_inf);
|
let id2 = self.resolve_id(id, cfg_inf);
|
||||||
let Some(cfg_inf) = merge_table_info(self.default_srid,&id2, cfg_inf, src_inf) else { continue };
|
let Some(cfg_inf) = merge_table_info(self.default_srid, &id2, cfg_inf, src_inf) else { continue };
|
||||||
warn_on_rename(id, &id2, "Table");
|
warn_on_rename(id, &id2, "Table");
|
||||||
info!("Configured {dup}source {id2} from {}", summary(&cfg_inf));
|
info!("Configured {dup}source {id2} from {}", summary(&cfg_inf));
|
||||||
pending.push(table_to_query(
|
pending.push(table_to_query(
|
||||||
@ -263,8 +263,12 @@ fn warn_on_rename(old_id: &String, new_id: &String, typ: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn summary(info: &TableInfo) -> String {
|
fn summary(info: &TableInfo) -> String {
|
||||||
|
let relkind = match info.is_view {
|
||||||
|
Some(true) => "view",
|
||||||
|
_ => "table",
|
||||||
|
};
|
||||||
format!(
|
format!(
|
||||||
"table {}.{} with {} column ({}, SRID={})",
|
"{relkind} {}.{} with {} column ({}, SRID={})",
|
||||||
info.schema,
|
info.schema,
|
||||||
info.table,
|
info.table,
|
||||||
info.geometry_column,
|
info.geometry_column,
|
||||||
|
@ -189,6 +189,8 @@ pub fn merge_table_info(
|
|||||||
schema: src_inf.schema.clone(),
|
schema: src_inf.schema.clone(),
|
||||||
table: src_inf.table.clone(),
|
table: src_inf.table.clone(),
|
||||||
geometry_column: src_inf.geometry_column.clone(),
|
geometry_column: src_inf.geometry_column.clone(),
|
||||||
|
geometry_index: src_inf.geometry_index,
|
||||||
|
is_view: src_inf.is_view,
|
||||||
srid: calc_srid(&table_id, new_id, src_inf.srid, cfg_inf.srid, default_srid)?,
|
srid: calc_srid(&table_id, new_id, src_inf.srid, cfg_inf.srid, default_srid)?,
|
||||||
prop_mapping: HashMap::new(),
|
prop_mapping: HashMap::new(),
|
||||||
..cfg_inf.clone()
|
..cfg_inf.clone()
|
||||||
|
@ -87,6 +87,11 @@
|
|||||||
"id": "points1",
|
"id": "points1",
|
||||||
"name": "public.points1.geom"
|
"name": "public.points1.geom"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"content_type": "application/x-protobuf",
|
||||||
|
"id": "points1_vw",
|
||||||
|
"name": "public.points1_vw.geom"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"content_type": "application/x-protobuf",
|
"content_type": "application/x-protobuf",
|
||||||
"id": "points2",
|
"id": "points2",
|
||||||
|
@ -27,6 +27,17 @@ postgres:
|
|||||||
geometry_type: POINT
|
geometry_type: POINT
|
||||||
properties:
|
properties:
|
||||||
gid: int4
|
gid: int4
|
||||||
|
points1_vw:
|
||||||
|
schema: public
|
||||||
|
table: points1_vw
|
||||||
|
srid: 4326
|
||||||
|
geometry_column: geom
|
||||||
|
extent: 4096
|
||||||
|
buffer: 64
|
||||||
|
clip_geom: true
|
||||||
|
geometry_type: POINT
|
||||||
|
properties:
|
||||||
|
gid: int4
|
||||||
points2:
|
points2:
|
||||||
schema: public
|
schema: public
|
||||||
table: points2
|
table: points2
|
||||||
|
4
tests/fixtures/tables/points1.sql
vendored
4
tests/fixtures/tables/points1.sql
vendored
@ -4,6 +4,10 @@ CREATE TABLE points1
|
|||||||
geom GEOMETRY(POINT, 4326)
|
geom GEOMETRY(POINT, 4326)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
CREATE VIEW points1_vw AS
|
||||||
|
SELECT gid, geom
|
||||||
|
FROM points1;
|
||||||
|
|
||||||
-- INSERT INTO points1
|
-- INSERT INTO points1
|
||||||
-- SELECT generate_series(1, 3) as id,
|
-- SELECT generate_series(1, 3) as id,
|
||||||
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(18, 235085, 122323), 4326), 3))).geom;
|
-- (ST_DUMP(ST_GENERATEPOINTS(st_transform(st_tileenvelope(18, 235085, 122323), 4326), 3))).geom;
|
||||||
|
Loading…
Reference in New Issue
Block a user