Skip to content

Commit

Permalink
Add clip_geom,buffer under auto_publish conf
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkAndshark committed Sep 19, 2023
1 parent 2bef7c0 commit d984329
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
6 changes: 6 additions & 0 deletions martin/src/pg/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ pub struct PgCfgPublishType {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(alias = "id_column")]
pub id_columns: Option<OneOrMany<String>>,

#[serde(skip_serializing_if = "Option::is_none")]
pub clip_geom: Option<bool>,

#[serde(skip_serializing_if = "Option::is_none")]
pub buffer: Option<u32>,
}

impl PgConfig {
Expand Down
25 changes: 25 additions & 0 deletions martin/src/pg/configurator.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::BorrowMut;
use std::cmp::Ordering;
use std::collections::HashSet;

Expand Down Expand Up @@ -28,6 +29,8 @@ pub struct PgBuilderAuto {
source_id_format: String,
schemas: Option<HashSet<String>>,
id_columns: Option<Vec<String>>,
clip_geom: Option<bool>,
buffer: Option<u32>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -146,6 +149,8 @@ impl PgBuilder {
};
db_inf.srid = srid;
update_id_column(&id2, &mut db_inf, auto_tables);
db_inf.borrow_mut().buffer = auto_tables.buffer;
db_inf.borrow_mut().clip_geom = auto_tables.clip_geom;
info!("Discovered source {id2} from {}", summary(&db_inf));
pending.push(table_to_query(
id2,
Expand Down Expand Up @@ -317,6 +322,8 @@ fn new_auto_publish(config: &PgConfig, is_function: bool) -> Option<PgBuilderAut
source_id_format: default_id_fmt(is_function),
schemas,
id_columns: None,
clip_geom: None,
buffer: None,
})
};

Expand All @@ -339,6 +346,22 @@ fn new_auto_publish(config: &PgConfig, is_function: bool) -> Option<PgBuilderAut
Some(ids.iter().cloned().collect())
}
}),
clip_geom: {
if is_function {
error!("Configuration parameter auto_publish.functions.clip_geom is not supported");
None
} else {
item.clip_geom
}
},
buffer: {
if is_function {
error!("Configuration parameter auto_publish.functions.buffer is not supported");
None
} else {
item.buffer
}
},
}),
BoolOrObject::Bool(true) => default(merge_opt_hs(&a.from_schemas, &None)),
BoolOrObject::Bool(false) => None,
Expand Down Expand Up @@ -420,6 +443,8 @@ mod tests {
source_id_format: source_id_format.to_string(),
schemas: schemas.map(|s| s.iter().map(|s| (*s).to_string()).collect()),
id_columns: None,
clip_geom: None,
buffer: None,
})
}

Expand Down
4 changes: 2 additions & 2 deletions martin/src/pg/table_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub async fn query_available_tables(pool: &PgPool) -> Result<SqlTableInfoMapMapM
maxzoom: None,
srid: row.get("srid"), // casting i32 to u32?
extent: Some(DEFAULT_EXTENT),
buffer: Some(DEFAULT_BUFFER),
clip_geom: Some(DEFAULT_CLIP_GEOM),
buffer: None,
clip_geom: None,
geometry_type: row.get("type"),
properties: Some(json_to_hashmap(&row.get("properties"))),
prop_mapping: HashMap::new(),
Expand Down

0 comments on commit d984329

Please sign in to comment.