Skip to content

Commit 611325e

Browse files
committed
Merge remote-tracking branch 'maplibre/main' into quickbounds
2 parents f6a4f64 + ac0c457 commit 611325e

File tree

16 files changed

+241
-36
lines changed

16 files changed

+241
-36
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ jobs:
722722

723723
- name: Publish
724724
if: startsWith(github.ref, 'refs/tags/')
725-
uses: softprops/action-gh-release@v1
725+
uses: softprops/action-gh-release@v2
726726
with:
727727
draft: true
728728
files: 'target/files/*'

Cargo.lock

Lines changed: 15 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

martin-tile-utils/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ lints.workspace = true
44
name = "martin-tile-utils"
55
version = "0.4.1"
66
authors = ["Yuri Astrakhan <[email protected]>", "MapLibre contributors"]
7-
description = "Utilites to help with map tile processing, such as type and compression detection. Used by the MapLibre's Martin tile server."
7+
description = "Utilities to help with map tile processing, such as type and compression detection. Used by the MapLibre's Martin tile server."
88
keywords = ["maps", "tiles", "mvt", "tileserver"]
99
categories = ["science::geo", "parsing"]
1010
exclude = [

martin/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,13 @@ bit-set = { workspace = true, optional = true }
7979
brotli.workspace = true
8080
clap.workspace = true
8181
deadpool-postgres = { workspace = true, optional = true }
82+
enum-display.workspace = true
8283
env_logger.workspace = true
8384
flate2.workspace = true
8485
futures.workspace = true
8586
itertools.workspace = true
8687
json-patch = { workspace = true, optional = true }
88+
lambda-web = { workspace = true, optional = true }
8789
log.workspace = true
8890
martin-tile-utils.workspace = true
8991
mbtiles = { workspace = true, optional = true }
@@ -92,8 +94,8 @@ num_cpus.workspace = true
9294
pbf_font_tools = { workspace = true, optional = true }
9395
pmtiles = { workspace = true, optional = true }
9496
postgis = { workspace = true, optional = true }
95-
postgres-protocol = { workspace = true, optional = true }
9697
postgres = { workspace = true, optional = true }
98+
postgres-protocol = { workspace = true, optional = true }
9799
regex.workspace = true
98100
rustls-native-certs.workspace = true
99101
rustls-pemfile.workspace = true
@@ -110,7 +112,6 @@ tilejson.workspace = true
110112
tokio = { workspace = true, features = ["io-std"] }
111113
tokio-postgres-rustls = { workspace = true, optional = true }
112114
url.workspace = true
113-
lambda-web = { workspace = true, optional = true }
114115

115116
[dev-dependencies]
116117
cargo-husky.workspace = true

martin/src/args/pg.rs

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::time::Duration;
22

33
use clap::ValueEnum;
4+
use enum_display::EnumDisplay;
45
use log::{info, warn};
56
use serde::{Deserialize, Serialize};
67

@@ -13,8 +14,11 @@ use crate::utils::{OptBoolObj, OptOneMany};
1314
// Must match the help string for BoundsType::Quick
1415
pub const DEFAULT_BOUNDS_TIMEOUT: Duration = Duration::from_secs(5);
1516

16-
#[derive(PartialEq, Eq, Default, Debug, Clone, Copy, Serialize, Deserialize, ValueEnum)]
17+
#[derive(
18+
PartialEq, Eq, Default, Debug, Clone, Copy, Serialize, Deserialize, ValueEnum, EnumDisplay,
19+
)]
1720
#[serde(rename_all = "lowercase")]
21+
#[enum_display(case = "Kebab")]
1822
pub enum BoundsCalcType {
1923
/// Compute table geometry bounds, but abort if it takes longer than 5 seconds.
2024
#[default]
@@ -37,7 +41,7 @@ pub struct PgArgs {
3741
/// If a spatial PG table has SRID 0, then this default SRID will be used as a fallback.
3842
#[arg(short, long)]
3943
pub default_srid: Option<i32>,
40-
#[arg(help = format!("Maximum Postgres connections pool size [DEFAULT: {}]", POOL_SIZE_DEFAULT), short, long)]
44+
#[arg(help = format!("Maximum Postgres connections pool size [DEFAULT: {POOL_SIZE_DEFAULT}]"), short, long)]
4145
pub pool_size: Option<usize>,
4246
/// Limit the number of features in a tile from a PG table source.
4347
#[arg(short, long)]
@@ -76,31 +80,46 @@ impl PgArgs {
7680
}
7781
}
7882

83+
/// Apply CLI parameters from `self` to the configuration loaded from the config file `pg_config`
7984
pub fn override_config<'a>(self, pg_config: &mut OptOneMany<PgConfig>, env: &impl Env<'a>) {
80-
if self.default_srid.is_some() {
81-
info!("Overriding configured default SRID to {} on all Postgres connections because of a CLI parameter", self.default_srid.unwrap());
85+
// This ensures that if a new parameter is added to the struct, it will not be forgotten here
86+
let Self {
87+
default_srid,
88+
pool_size,
89+
auto_bounds,
90+
max_feature_count,
91+
ca_root_file,
92+
} = self;
93+
94+
if let Some(value) = default_srid {
95+
info!("Overriding configured default SRID to {value} on all Postgres connections because of a CLI parameter");
8296
pg_config.iter_mut().for_each(|c| {
83-
c.default_srid = self.default_srid;
97+
c.default_srid = default_srid;
8498
});
8599
}
86-
if self.pool_size.is_some() {
87-
info!("Overriding configured pool size to {} on all Postgres connections because of a CLI parameter", self.pool_size.unwrap());
100+
if let Some(value) = pool_size {
101+
info!("Overriding configured pool size to {value} on all Postgres connections because of a CLI parameter");
88102
pg_config.iter_mut().for_each(|c| {
89-
c.pool_size = self.pool_size;
103+
c.pool_size = pool_size;
90104
});
91105
}
92-
if self.max_feature_count.is_some() {
93-
info!("Overriding maximum feature count to {} on all Postgres connections because of a CLI parameter", self.max_feature_count.unwrap());
106+
if let Some(value) = auto_bounds {
107+
info!("Overriding auto_bounds to {value} on all Postgres connections because of a CLI parameter");
94108
pg_config.iter_mut().for_each(|c| {
95-
c.max_feature_count = self.max_feature_count;
109+
c.auto_bounds = auto_bounds;
96110
});
97111
}
98-
99-
if self.ca_root_file.is_some() {
112+
if let Some(value) = max_feature_count {
113+
info!("Overriding maximum feature count to {value} on all Postgres connections because of a CLI parameter");
114+
pg_config.iter_mut().for_each(|c| {
115+
c.max_feature_count = max_feature_count;
116+
});
117+
}
118+
if let Some(ref value) = ca_root_file {
100119
info!("Overriding root certificate file to {} on all Postgres connections because of a CLI parameter",
101-
self.ca_root_file.as_ref().unwrap().display());
120+
value.display());
102121
pg_config.iter_mut().for_each(|c| {
103-
c.ssl_certificates.ssl_root_cert = self.ca_root_file.clone();
122+
c.ssl_certificates.ssl_root_cert = ca_root_file.clone();
104123
});
105124
}
106125

martin/src/args/srv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use crate::srv::{SrvConfig, KEEP_ALIVE_DEFAULT, LISTEN_ADDRESSES_DEFAULT};
66
#[derive(clap::Args, Debug, PartialEq, Default)]
77
#[command(about, version)]
88
pub struct SrvArgs {
9-
#[arg(help = format!("Connection keep alive timeout. [DEFAULT: {}]", KEEP_ALIVE_DEFAULT), short, long)]
9+
#[arg(help = format!("Connection keep alive timeout. [DEFAULT: {KEEP_ALIVE_DEFAULT}]"), short, long)]
1010
pub keep_alive: Option<u64>,
11-
#[arg(help = format!("The socket address to bind. [DEFAULT: {}]", LISTEN_ADDRESSES_DEFAULT), short, long)]
11+
#[arg(help = format!("The socket address to bind. [DEFAULT: {LISTEN_ADDRESSES_DEFAULT}]"), short, long)]
1212
pub listen_addresses: Option<String>,
1313
/// Set TileJSON URL path prefix, ignoring X-Rewrite-URL header. Must begin with a `/`. Examples: `/`, `/tiles`
1414
#[arg(long)]

martin/src/utils/rectangle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ mod tests {
118118
}
119119

120120
#[test]
121-
fn test_tile_range_is_ovelapping() {
121+
fn test_tile_range_is_overlapping() {
122122
let r1 = TileRect::new(0, 0, 0, 0, 0);
123123
let r2 = TileRect::new(0, 0, 0, 0, 0);
124124
assert!(r1.is_overlapping(&r2));

martin/tests/pg_server_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ postgres:
5757
fonts: {}
5858
sprites: {}
5959
tiles:
60+
"-function.withweired---_-characters":
61+
content_type: application/x-protobuf
62+
description: a function source with special characters
63+
".-Points---quote":
64+
content_type: application/x-protobuf
65+
description: Escaping test table
6066
MixPoints:
6167
content_type: application/x-protobuf
6268
description: a description from comment on table

martin/tests/pg_table_source_test.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ async fn table_source() {
1818
let mock = mock_sources(mock_pgcfg("connection_string: $DATABASE_URL")).await;
1919
assert_yaml_snapshot!(mock.0.tiles.get_catalog(), @r###"
2020
---
21+
"-function.withweired---_-characters":
22+
content_type: application/x-protobuf
23+
description: a function source with special characters
24+
".-Points---quote":
25+
content_type: application/x-protobuf
26+
description: Escaping test table
2127
MixPoints:
2228
content_type: application/x-protobuf
2329
description: a description from comment on table

tests/expected/auto/catalog_auto.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"tiles": {
3+
"-function.withweired---_-characters": {
4+
"content_type": "application/x-protobuf",
5+
"description": "a function source with special characters"
6+
},
7+
".-Points---quote": {
8+
"content_type": "application/x-protobuf",
9+
"description": "Escaping test table"
10+
},
311
"MixPoints": {
412
"content_type": "application/x-protobuf",
513
"description": "a description from comment on table"

0 commit comments

Comments
 (0)