diff --git a/martin/src/pg/config_table.rs b/martin/src/pg/config_table.rs index 9ef086a46..ac173403a 100644 --- a/martin/src/pg/config_table.rs +++ b/martin/src/pg/config_table.rs @@ -83,6 +83,7 @@ impl PgInfo for TableInfo { format!("{}.{}.{}", self.schema, self.table, self.geometry_column) } + /// the `source_id` may not be taken if `self.layer_id` is set. And the `TileJson` by SQL comment if provided will be merged into. fn to_tilejson(&self, source_id: String) -> TileJSON { let mut tilejson = tilejson::tilejson! { tiles: vec![], // tile source is required, but not yet known @@ -92,8 +93,15 @@ impl PgInfo for TableInfo { tilejson.minzoom = self.minzoom; tilejson.maxzoom = self.maxzoom; tilejson.bounds = self.bounds; + + let layer_id = if let Some(id) = &self.layer_id { + id.clone() + } else { + source_id + }; + let layer = VectorLayer { - id: source_id, + id: layer_id, fields: self.properties.clone().unwrap_or_default(), description: None, maxzoom: None,