diff --git a/docs/src/config-file.md b/docs/src/config-file.md index c10bc97c..8fe58a63 100644 --- a/docs/src/config-file.md +++ b/docs/src/config-file.md @@ -71,6 +71,12 @@ postgres: # If a table has no column with this name, `id_column` will not be set for that table. # If a list of strings is given, the first found column will be treated as a feature ID. id_columns: feature_id + # Boolean to control if geometries should be clipped or encoded as is, optional, default to true + clip_geom: true + # Buffer distance in tile coordinate space to optionally clip geometries, optional, default to 64 + buffer: 64 + # Tile extent in tile coordinate space, optional, default to 4096 + extent: 4096 functions: # Optionally set how source ID should be generated based on the function's name and schema source_id_format: '{schema}.{function}' diff --git a/martin/src/pg/config.rs b/martin/src/pg/config.rs index 85df68e9..8d420753 100644 --- a/martin/src/pg/config.rs +++ b/martin/src/pg/config.rs @@ -82,6 +82,12 @@ pub struct PgCfgPublishType { #[serde(skip_serializing_if = "Option::is_none")] #[serde(alias = "id_column")] pub id_columns: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + pub clip_geom: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub buffer: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub extent: Option, } impl PgConfig { @@ -196,9 +202,9 @@ mod tests { minzoom: 0 maxzoom: 30 bounds: [-180.0, -90.0, 180.0, 90.0] - extent: 4096 - buffer: 64 - clip_geom: true + extent: 2048 + buffer: 10 + clip_geom: false geometry_type: GEOMETRY properties: gid: int4 @@ -227,9 +233,9 @@ mod tests { minzoom: Some(0), maxzoom: Some(30), bounds: Some([-180, -90, 180, 90].into()), - extent: Some(4096), - buffer: Some(64), - clip_geom: Some(true), + extent: Some(2048), + buffer: Some(10), + clip_geom: Some(false), geometry_type: some("GEOMETRY"), properties: Some(HashMap::from([( "gid".to_string(), diff --git a/martin/src/pg/configurator.rs b/martin/src/pg/configurator.rs index f4290a54..d5fbf77d 100755 --- a/martin/src/pg/configurator.rs +++ b/martin/src/pg/configurator.rs @@ -28,6 +28,9 @@ pub struct PgBuilderAuto { source_id_format: String, schemas: Option>, id_columns: Option>, + clip_geom: Option, + buffer: Option, + extent: Option, } #[derive(Debug)] @@ -145,7 +148,7 @@ impl PgBuilder { continue; }; db_inf.srid = srid; - update_id_column(&id2, &mut db_inf, auto_tables); + update_auto_fields(&id2, &mut db_inf, auto_tables); info!("Discovered source {id2} from {}", summary(&db_inf)); pending.push(table_to_query( id2, @@ -262,9 +265,19 @@ impl PgBuilder { } } -/// Try to find any ID column in a list of table columns (properties) that match one of the given `id_column` values. -/// If found, modify `id_column` value on the table info. -fn update_id_column(id: &str, inf: &mut TableInfo, auto_tables: &PgBuilderAuto) { +fn update_auto_fields(id: &str, inf: &mut TableInfo, auto_tables: &PgBuilderAuto) { + if inf.clip_geom.is_none() { + inf.clip_geom = auto_tables.clip_geom; + } + if inf.buffer.is_none() { + inf.buffer = auto_tables.buffer; + } + if inf.extent.is_none() { + inf.extent = auto_tables.extent; + } + + // Try to find any ID column in a list of table columns (properties) that match one of the given `id_column` values. + // If found, modify `id_column` value on the table info. let Some(props) = inf.properties.as_mut() else { return; }; @@ -317,6 +330,9 @@ fn new_auto_publish(config: &PgConfig, is_function: bool) -> Option Option default(merge_opt_hs(&a.from_schemas, &None)), BoolOrObject::Bool(false) => None, @@ -420,6 +460,9 @@ 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, + extent: None, }) } diff --git a/martin/src/pg/table_source.rs b/martin/src/pg/table_source.rs index 38fb1161..9fe61a91 100644 --- a/martin/src/pg/table_source.rs +++ b/martin/src/pg/table_source.rs @@ -44,25 +44,16 @@ pub async fn query_available_tables(pool: &PgPool) -> Result