Skip to content

Commit

Permalink
rename bounds to auto-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Oct 22, 2023
1 parent e3151b9 commit b938430
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion debian/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ worker_processes: 8
# default_srid: 4326
# pool_size: 20
# max_feature_count: 1000
# bounds: skip
# auto_bounds: skip

# pmtiles:
# paths:
Expand Down
2 changes: 1 addition & 1 deletion docs/src/config-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ postgres:
# 'calc' - compute table geometry bounds on startup.
# 'quick' - same as 'calc', but the calculation will be aborted if it takes more than 5 seconds.
# 'skip' - do not compute table geometry bounds on startup.
bounds: skip
auto_bounds: skip

# Enable automatic discovery of tables and functions.
# You may set this to `false` to disable.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/run-with-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Options:
-W, --workers <WORKERS>
Number of web server workers

-b, --bounds <BOUNDS>
-b, --auto-bounds <BOUNDS>
Specify how bounds should be computed for the spatial PG tables. [DEFAULT: quick]

Possible values:
Expand Down
4 changes: 2 additions & 2 deletions martin/src/args/pg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum BoundsCalcType {
pub struct PgArgs {
/// Specify how bounds should be computed for the spatial PG tables. [DEFAULT: quick]
#[arg(short = 'b', long)]
pub bounds: Option<BoundsCalcType>,
pub auto_bounds: Option<BoundsCalcType>,
/// Loads trusted root certificates from a file. The file should contain a sequence of PEM-formatted CA certificates.
#[arg(long)]
pub ca_root_file: Option<std::path::PathBuf>,
Expand Down Expand Up @@ -60,7 +60,7 @@ impl PgArgs {
connection_string: Some(s),
ssl_certificates: certs.clone(),
default_srid,
bounds: self.bounds,
auto_bounds: self.auto_bounds,
max_feature_count: self.max_feature_count,
pool_size: self.pool_size,
auto_publish: OptBoolObj::NoValue,
Expand Down
6 changes: 3 additions & 3 deletions martin/src/pg/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct PgConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub default_srid: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bounds: Option<BoundsCalcType>,
pub auto_bounds: Option<BoundsCalcType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub max_feature_count: Option<usize>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -130,8 +130,8 @@ impl PgConfig {
// warn only if default bounds timeout has already passed
DEFAULT_BOUNDS_TIMEOUT.add(Duration::from_secs(1)),
|| {
if pg.bounds() == BoundsCalcType::Skip {
warn!("Discovering tables in PostgreSQL database '{}' is taking too long. Make sure your table geo columns have a GIS index, or use '--bounds skip' CLI/config to skip bbox calculation.", pg.get_id());
if pg.auto_bounds() == BoundsCalcType::Skip {
warn!("Discovering tables in PostgreSQL database '{}' is taking too long. Make sure your table geo columns have a GIS index, or use '--auto-bounds skip' CLI/config to skip bbox calculation.", pg.get_id());
} else {
warn!("Discovering tables in PostgreSQL database '{}' is taking too long. Bounds calculation is already disabled. You may need to tune your database.", pg.get_id());
}
Expand Down
12 changes: 6 additions & 6 deletions martin/src/pg/configurator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct PgBuilderTables {
pub struct PgBuilder {
pool: PgPool,
default_srid: Option<i32>,
bounds: BoundsCalcType,
auto_bounds: BoundsCalcType,
max_feature_count: Option<usize>,
auto_functions: Option<PgBuilderFuncs>,
auto_tables: Option<PgBuilderTables>,
Expand Down Expand Up @@ -98,7 +98,7 @@ impl PgBuilder {
Ok(Self {
pool,
default_srid: config.default_srid,
bounds: config.bounds.unwrap_or_default(),
auto_bounds: config.auto_bounds.unwrap_or_default(),
max_feature_count: config.max_feature_count,
id_resolver,
tables: config.tables.clone().unwrap_or_default(),
Expand All @@ -108,8 +108,8 @@ impl PgBuilder {
})
}

pub fn bounds(&self) -> BoundsCalcType {
self.bounds
pub fn auto_bounds(&self) -> BoundsCalcType {
self.auto_bounds
}

pub fn get_id(&self) -> &str {
Expand Down Expand Up @@ -161,7 +161,7 @@ impl PgBuilder {
id2,
merged_inf,
self.pool.clone(),
self.bounds,
self.auto_bounds,
self.max_feature_count,
));
}
Expand Down Expand Up @@ -207,7 +207,7 @@ impl PgBuilder {
id2,
db_inf,
self.pool.clone(),
self.bounds,
self.auto_bounds,
self.max_feature_count,
));
}
Expand Down
2 changes: 1 addition & 1 deletion martin/src/pg/table_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub async fn table_to_query(
info.bounds = bounds?;
} else {
warn!(
"Timeout computing {} bounds for {id}, aborting query. Use --bounds=calc to wait until complete, or check the table for missing indices.",
"Timeout computing {} bounds for {id}, aborting query. Use --auto-bounds=calc to wait until complete, or check the table for missing indices.",
info.format_id(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/generated_config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
listen_addresses: localhost:3111
postgres:
default_srid: 900913
bounds: calc
auto_bounds: calc
auto_publish: true
tables:
MixPoints:
Expand Down
2 changes: 1 addition & 1 deletion tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ echo "Test auto configured Martin"
TEST_OUT_DIR="$(dirname "$0")/output/auto"
mkdir -p "$TEST_OUT_DIR"

ARG=(--default-srid 900913 --bounds calc --save-config "$(dirname "$0")/output/generated_config.yaml" tests/fixtures/mbtiles tests/fixtures/pmtiles)
ARG=(--default-srid 900913 --auto-bounds calc --save-config "$(dirname "$0")/output/generated_config.yaml" tests/fixtures/mbtiles tests/fixtures/pmtiles)
set -x
$MARTIN_BIN "${ARG[@]}" 2>&1 | tee "${TMP_DIR}/test_log_1.txt" &
PROCESS_ID=`jobs -p`
Expand Down

0 comments on commit b938430

Please sign in to comment.