Skip to content

Commit

Permalink
Use layer id if it is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
zhugecunfuzyj committed Sep 5, 2024
1 parent bc3803c commit fef864f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion martin/src/pg/config_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit fef864f

Please sign in to comment.