From 40fe091c4469d582c8ae28cd420d88ce4ac313ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:47:56 +0000 Subject: [PATCH 1/2] chore(deps): Bump xxhash-rust from 0.8.12 to 0.8.13 in the all-cargo-version-updates group (#1628) Bumps the all-cargo-version-updates group with 1 update: [xxhash-rust](https://github.com/DoumanAsh/xxhash-rust). Updates `xxhash-rust` from 0.8.12 to 0.8.13
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=xxhash-rust&package-manager=cargo&previous-version=0.8.12&new-version=0.8.13)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a95fb2e18..3dd8eb7f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5965,9 +5965,9 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" [[package]] name = "xxhash-rust" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" +checksum = "a08fd76779ae1883bbf1e46c2c46a75a0c4e37c445e68a24b01479d438f26ae6" [[package]] name = "yansi" From be642b4a6019d54494fd9134a5da3a3a018e6d96 Mon Sep 17 00:00:00 2001 From: Sam Santi Date: Sat, 21 Dec 2024 22:24:03 -0500 Subject: [PATCH 2/2] Add support for geography columns (#1627) Fixes #1503 --- martin/src/pg/query_tables.rs | 6 +-- .../src/pg/scripts/query_available_tables.sql | 43 +++++++++++++++-- martin/tests/pg_server_test.rs | 2 + martin/tests/pg_table_source_test.rs | 18 ++++++++ tests/expected/auto/catalog_auto.json | 3 ++ tests/expected/auto/save_config.yaml | 13 ++++++ .../martin-cp/flat-with-hash_save_config.yaml | 13 ++++++ .../expected/martin-cp/flat_save_config.yaml | 13 ++++++ .../martin-cp/normalized_save_config.yaml | 13 ++++++ tests/fixtures/tables/table_source_geog.sql | 46 +++++++++++++++++++ tests/test.sh | 2 + 11 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 tests/fixtures/tables/table_source_geog.sql diff --git a/martin/src/pg/query_tables.rs b/martin/src/pg/query_tables.rs index 9aea4d575..6879f4800 100644 --- a/martin/src/pg/query_tables.rs +++ b/martin/src/pg/query_tables.rs @@ -192,7 +192,7 @@ SELECT FROM ( SELECT ST_AsMVTGeom( - ST_Transform(ST_CurveToLine({geometry_column}), 3857), + ST_Transform(ST_CurveToLine({geometry_column}::geometry), 3857), ST_TileEnvelope($1::integer, $2::integer, $3::integer), {extent}, {buffer}, {clip_geom} ) AS geom @@ -223,11 +223,11 @@ async fn calc_bounds( .await? .query_one(&format!( r#" -WITH real_bounds AS (SELECT ST_SetSRID(ST_Extent({geometry_column}), {srid}) AS rb FROM {schema}.{table}) +WITH real_bounds AS (SELECT ST_SetSRID(ST_Extent({geometry_column}::geometry), {srid}) AS rb FROM {schema}.{table}) SELECT ST_Transform( CASE WHEN (SELECT ST_GeometryType(rb) FROM real_bounds LIMIT 1) = 'ST_Point' - THEN ST_SetSRID(ST_Extent(ST_Expand({geometry_column}, 1)), {srid}) + THEN ST_SetSRID(ST_Extent(ST_Expand({geometry_column}::geometry, 1)), {srid}) ELSE (SELECT * FROM real_bounds) END, 4326 diff --git a/martin/src/pg/scripts/query_available_tables.sql b/martin/src/pg/scripts/query_available_tables.sql index 783a0d30e..cbef43c9b 100755 --- a/martin/src/pg/scripts/query_available_tables.sql +++ b/martin/src/pg/scripts/query_available_tables.sql @@ -28,7 +28,8 @@ WITH JOIN pg_opclass op ON op.oid = ix.indclass[0] AND op.opcname IN ('gist_geometry_ops_2d', 'spgist_geometry_ops_2d', - 'brin_geometry_inclusion_ops_2d') + 'brin_geometry_inclusion_ops_2d', + 'gist_geography_ops') GROUP BY 1, 2, 3), -- annotated_geometry_columns AS ( @@ -38,6 +39,7 @@ WITH f_geometry_column AS geom, srid, type, + -- 'geometry' AS column_type COALESCE(class.relkind = 'v', false) AS is_view, bool_or(sic.column_name is not null) as geom_idx FROM geometry_columns @@ -50,6 +52,33 @@ WITH geometry_columns.f_table_name = sic.table_name AND geometry_columns.f_geometry_column = sic.column_name GROUP BY 1, 2, 3, 4, 5, 6), + -- + annotated_geography_columns AS ( + -- list of geography columns with additional metadata + SELECT f_table_schema AS schema, + f_table_name AS name, + f_geography_column AS geom, + srid, + type, + -- 'geography' AS column_type + COALESCE(class.relkind = 'v', false) AS is_view, + bool_or(sic.column_name is not null) as geom_idx + FROM geography_columns + JOIN pg_catalog.pg_class AS class + ON class.relname = geography_columns.f_table_name + JOIN pg_catalog.pg_namespace AS ns + ON ns.nspname = geography_columns.f_table_schema + LEFT JOIN spatially_indexed_columns AS sic ON + geography_columns.f_table_schema = sic.table_schema AND + geography_columns.f_table_name = sic.table_name AND + geography_columns.f_geography_column = sic.column_name + GROUP BY 1, 2, 3, 4, 5, 6), + -- + annotated_geo_columns AS ( + SELECT * FROM annotated_geometry_columns + UNION SELECT * FROM annotated_geography_columns + ), + -- descriptions AS ( -- comments on table/views SELECT @@ -69,12 +98,16 @@ SELECT schema, is_view, geom_idx, COALESCE( - jsonb_object_agg(columns.column_name, columns.type_name) - FILTER (WHERE columns.column_name IS NOT NULL AND columns.type_name != 'geometry'), - '{}'::jsonb + jsonb_object_agg(columns.column_name, columns.type_name) + FILTER ( + WHERE columns.column_name IS NOT NULL + AND columns.type_name != 'geometry' + AND columns.type_name != 'geography' + ), + '{}'::jsonb ) as properties, dc.description -FROM annotated_geometry_columns AS gc +FROM annotated_geo_columns AS gc LEFT JOIN columns ON gc.schema = columns.table_schema AND gc.name = columns.table_name AND diff --git a/martin/tests/pg_server_test.rs b/martin/tests/pg_server_test.rs index 34ca2dc0d..d826f8ff2 100644 --- a/martin/tests/pg_server_test.rs +++ b/martin/tests/pg_server_test.rs @@ -121,6 +121,8 @@ postgres: description: public.points3857.geom table_source: content_type: application/x-protobuf + table_source_geog: + content_type: application/x-protobuf table_source_multiple_geom: content_type: application/x-protobuf description: public.table_source_multiple_geom.geom1 diff --git a/martin/tests/pg_table_source_test.rs b/martin/tests/pg_table_source_test.rs index 817dcc017..5db4b01c2 100644 --- a/martin/tests/pg_table_source_test.rs +++ b/martin/tests/pg_table_source_test.rs @@ -82,6 +82,8 @@ async fn table_source() { description: public.points3857.geom table_source: content_type: application/x-protobuf + table_source_geog: + content_type: application/x-protobuf table_source_multiple_geom: content_type: application/x-protobuf description: public.table_source_multiple_geom.geom1 @@ -106,6 +108,22 @@ async fn table_source() { properties: gid: int4 "); + + let source2 = table(&mock, "table_source_geog"); + assert_yaml_snapshot!(source2, @r" + schema: public + table: table_source_geog + srid: 4326 + geometry_column: geog + bounds: + - -2 + - 0 + - 142.84131509869133 + - 45 + geometry_type: Geometry + properties: + gid: int4 + "); } #[actix_rt::test] diff --git a/tests/expected/auto/catalog_auto.json b/tests/expected/auto/catalog_auto.json index eb755495d..45a230f73 100644 --- a/tests/expected/auto/catalog_auto.json +++ b/tests/expected/auto/catalog_auto.json @@ -156,6 +156,9 @@ "table_source": { "content_type": "application/x-protobuf" }, + "table_source_geog": { + "content_type": "application/x-protobuf" + }, "table_source_multiple_geom": { "content_type": "application/x-protobuf", "description": "public.table_source_multiple_geom.geom1" diff --git a/tests/expected/auto/save_config.yaml b/tests/expected/auto/save_config.yaml index a6fc8d64c..f578a9aab 100644 --- a/tests/expected/auto/save_config.yaml +++ b/tests/expected/auto/save_config.yaml @@ -146,6 +146,19 @@ postgres: geometry_type: GEOMETRY properties: gid: int4 + table_source_geog: + schema: public + table: table_source_geog + srid: 4326 + geometry_column: geog + bounds: + - -2.0 + - 0.0 + - 142.84131509869133 + - 45.0 + geometry_type: Geometry + properties: + gid: int4 table_source_multiple_geom: schema: public table: table_source_multiple_geom diff --git a/tests/expected/martin-cp/flat-with-hash_save_config.yaml b/tests/expected/martin-cp/flat-with-hash_save_config.yaml index e3b1109ea..ea1fb2bf0 100644 --- a/tests/expected/martin-cp/flat-with-hash_save_config.yaml +++ b/tests/expected/martin-cp/flat-with-hash_save_config.yaml @@ -145,6 +145,19 @@ postgres: geometry_type: GEOMETRY properties: gid: int4 + table_source_geog: + schema: public + table: table_source_geog + srid: 4326 + geometry_column: geog + bounds: + - -2.0 + - 0.0 + - 142.84131509869133 + - 45.0 + geometry_type: Geometry + properties: + gid: int4 table_source_multiple_geom: schema: public table: table_source_multiple_geom diff --git a/tests/expected/martin-cp/flat_save_config.yaml b/tests/expected/martin-cp/flat_save_config.yaml index e3b1109ea..ea1fb2bf0 100644 --- a/tests/expected/martin-cp/flat_save_config.yaml +++ b/tests/expected/martin-cp/flat_save_config.yaml @@ -145,6 +145,19 @@ postgres: geometry_type: GEOMETRY properties: gid: int4 + table_source_geog: + schema: public + table: table_source_geog + srid: 4326 + geometry_column: geog + bounds: + - -2.0 + - 0.0 + - 142.84131509869133 + - 45.0 + geometry_type: Geometry + properties: + gid: int4 table_source_multiple_geom: schema: public table: table_source_multiple_geom diff --git a/tests/expected/martin-cp/normalized_save_config.yaml b/tests/expected/martin-cp/normalized_save_config.yaml index e3b1109ea..ea1fb2bf0 100644 --- a/tests/expected/martin-cp/normalized_save_config.yaml +++ b/tests/expected/martin-cp/normalized_save_config.yaml @@ -145,6 +145,19 @@ postgres: geometry_type: GEOMETRY properties: gid: int4 + table_source_geog: + schema: public + table: table_source_geog + srid: 4326 + geometry_column: geog + bounds: + - -2.0 + - 0.0 + - 142.84131509869133 + - 45.0 + geometry_type: Geometry + properties: + gid: int4 table_source_multiple_geom: schema: public table: table_source_multiple_geom diff --git a/tests/fixtures/tables/table_source_geog.sql b/tests/fixtures/tables/table_source_geog.sql new file mode 100644 index 000000000..aacef52bb --- /dev/null +++ b/tests/fixtures/tables/table_source_geog.sql @@ -0,0 +1,46 @@ +DROP TABLE IF EXISTS table_source_geog; +CREATE TABLE table_source_geog(gid serial PRIMARY KEY, geog geography(GEOMETRY, 4326)); + +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(0 0)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(-2 2)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;LINESTRING(0 0, 1 1)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;LINESTRING(2 2, 3 3)'::geography); + +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(30 10)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;LINESTRING(30 10, 10 30, 40 40)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POLYGON((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTIPOINT((10 40), (40 30), (20 20), (30 10))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTIPOINT(10 40, 40 30, 20 20, 30 10)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTILINESTRING((10 10, 20 20, 10 40),(40 40, 30 30, 40 20, 30 10))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTIPOLYGON(((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTIPOLYGON(((40 40, 20 45, 45 30, 40 40)),((20 35, 10 30, 10 10, 30 5, 45 20, 20 35),(30 20, 20 15, 20 25, 30 20)))'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10))'::geography); + +-- Curves are not supported in geography columns +-- INSERT INTO table_source_geog(geog) values ('SRID=4326;CIRCULARSTRING(1 5, 6 2, 7 3)'::geography); +-- INSERT INTO table_source_geog(geog) values ('SRID=4326;COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))'::geography); +-- INSERT INTO table_source_geog(geog) values ('SRID=4326;CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))'::geography); +-- INSERT INTO table_source_geog(geog) values ('SRID=4326;MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))'::geography); + +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84124343269863 11.927545216212339)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84022627741408 11.926919775099435)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84116724279622 11.926986082398354)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84129834730146 11.926483025982757)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84086326293937 11.92741281580712)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84083973422645 11.927188724740008)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.8407405154705 11.92659842381238)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84029057105903 11.92711170365923)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.8403402985401 11.927568375227375)'::geography); +INSERT INTO table_source_geog(geog) values ('SRID=4326;POINT(142.84131509869133 11.92781306544329)'::geography); + +-- DO NOT CREATE INDEX ON GEOGRAPHY COLUMN -- this table is used in a test case + +DO $do$ BEGIN + EXECUTE 'COMMENT ON TABLE table_source_geog IS $tj$' || $$ + { + "description": null, + "foo": {"bar": "foo"} + } + $$::json || '$tj$'; +END $do$; diff --git a/tests/test.sh b/tests/test.sh index 2bf4812bd..ca94d434f 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -291,6 +291,7 @@ test_jsn fnc_comment function_Mixed_Name kill_process "$MARTIN_PROC_ID" Martin test_log_has_str "$LOG_FILE" 'WARN martin::pg::query_tables] Table public.table_source has no spatial index on column geom' +test_log_has_str "$LOG_FILE" 'WARN martin::pg::query_tables] Table public.table_source_geog has no spatial index on column geog' test_log_has_str "$LOG_FILE" 'WARN martin::fonts] Ignoring duplicate font Overpass Mono Regular from tests' validate_log "$LOG_FILE" remove_line "${TEST_OUT_DIR}/save_config.yaml" " connection_string: " @@ -387,6 +388,7 @@ test_jsn fnc_comment_cfg fnc_Mixed_Name kill_process "$MARTIN_PROC_ID" Martin test_log_has_str "$LOG_FILE" 'WARN martin::pg::query_tables] Table public.table_source has no spatial index on column geom' +test_log_has_str "$LOG_FILE" 'WARN martin::pg::query_tables] Table public.table_source_geog has no spatial index on column geog' test_log_has_str "$LOG_FILE" 'WARN martin::fonts] Ignoring duplicate font Overpass Mono Regular from tests' validate_log "$LOG_FILE" remove_line "${TEST_OUT_DIR}/save_config.yaml" " connection_string: "