From 0e66bab67c81d412807aacc7c4f4bda90f257921 Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Mon, 30 Jun 2025 17:59:07 +0200 Subject: [PATCH 1/2] Formatting fixes for SQL examples --- .../modules/main/spatial_functions_scalar.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/spatial/modules/main/spatial_functions_scalar.cpp b/src/spatial/modules/main/spatial_functions_scalar.cpp index a4ff26ef..2776c09a 100644 --- a/src/spatial/modules/main/spatial_functions_scalar.cpp +++ b/src/spatial/modules/main/spatial_functions_scalar.cpp @@ -442,7 +442,7 @@ struct ST_Area { )"; static constexpr const char *EXAMPLE = R"( - select ST_Area('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geometry); + SELECT ST_Area('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::GEOMETRY); -- 1.0 )"; @@ -768,20 +768,20 @@ struct ST_AsGeoJSON { )"; static constexpr auto EXAMPLE = R"( - select ST_AsGeoJSON('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geometry); + SELECT ST_AsGeoJSON('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::GEOMETRY); ---- - {"type":"Polygon","coordinates":[[[0.0,0.0],[0.0,1.0],[1.0,1.0],[1.0,0.0],[0.0,0.0]]]} + {"type":"Polygon","coordinates":[[[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]]]} -- Convert a geometry into a full GeoJSON feature (requires the JSON extension to be loaded) SELECT CAST({ type: 'Feature', - geometry: ST_AsGeoJSON(ST_Point(1,2)), + geometry: ST_AsGeoJSON(ST_Point(1, 2)), properties: { name: 'my_point' } } AS JSON); ---- - {"type":"Feature","geometry":{"type":"Point","coordinates":[1.0,2.0]},"properties":{"name":"my_point"}} + {"type":"Feature","geometry":{"type":"Point","coordinates":[1.0, 2.0]},"properties":{"name":"my_point"}} )"; //------------------------------------------------------------------------------------------------------------------ @@ -873,7 +873,7 @@ struct ST_AsText { )"; static constexpr const char *EXAMPLE = R"( - SELECT ST_AsText(ST_MakeEnvelope(0,0,1,1)); + SELECT ST_AsText(ST_MakeEnvelope(0, 0, 1, 1)); ---- POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0)) )"; @@ -1014,7 +1014,7 @@ struct ST_AsHEXWKB { )"; static constexpr const char *EXAMPLE = R"( - SELECT ST_AsHexWKB('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geometry); + SELECT ST_AsHexWKB('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::GEOMETRY); ---- 01030000000100000005000000000000000000000000000... )"; @@ -1889,7 +1889,7 @@ struct ST_CollectionExtract { )"; static constexpr auto EXAMPLE = R"( - select st_collectionextract('MULTIPOINT(1 2,3 4)'::geometry, 1); + SELECT ST_CollectionExtract('MULTIPOINT(1 2, 3 4)'::GEOMETRY, 1); -- MULTIPOINT (1 2, 3 4) )"; @@ -2117,7 +2117,7 @@ struct ST_Dimension { )"; static constexpr auto EXAMPLE = R"( - select st_dimension('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::geometry); + SELECT ST_Dimension('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))'::GEOMETRY); ---- 2 )"; @@ -2472,15 +2472,15 @@ struct ST_Dump { static constexpr auto DESCRIPTION = R"( Dumps a geometry into a list of sub-geometries and their "path" in the original geometry. - You can use the `UNNEST(res, recursive := true)` function to explode resulting list of structs into multiple rows. + You can use the `unnest(res, recursive := true)` function to explode the resulting list of structs into multiple rows. )"; static constexpr auto EXAMPLE = R"( - select st_dump('MULTIPOINT(1 2,3 4)'::geometry); + SELECT ST_Dump('MULTIPOINT(1 2, 3 4)'::GEOMETRY); ---- [{'geom': 'POINT(1 2)', 'path': [0]}, {'geom': 'POINT(3 4)', 'path': [1]}] - select unnest(st_dump('MULTIPOINT(1 2,3 4)'::geometry), recursive := true); + SELECT unnest(ST_Dump('MULTIPOINT(1 2, 3 4)'::GEOMETRY), recursive := true); -- ┌─────────────┬─────────┐ -- │ geom │ path │ -- │ geometry │ int32[] │ @@ -4069,7 +4069,7 @@ struct ST_GeomFromGeoJSON { )"; static constexpr auto EXAMPLE = R"( - SELECT ST_GeomFromGeoJSON('{"type":"Point","coordinates":[1.0,2.0]}'); + SELECT ST_GeomFromGeoJSON('{"type": "Point", "coordinates": [1.0, 2.0]}'); ---- POINT (1 2) )"; @@ -7053,11 +7053,11 @@ struct ST_Points { )"; static constexpr auto EXAMPLE = R"( - select st_points('LINESTRING(1 1, 2 2)'::geometry); + SELECT ST_Points('LINESTRING(1 1, 2 2)'::GEOMETRY); ---- MULTIPOINT (1 1, 2 2) - select st_points('MULTIPOLYGON Z EMPTY'::geometry); + SELECT ST_Points('MULTIPOLYGON Z EMPTY'::GEOMETRY); ---- MULTIPOINT Z EMPTY )"; @@ -7185,7 +7185,7 @@ struct ST_QuadKey { )"; static constexpr auto EXAMPLE = R"( - SELECT ST_QuadKey(st_point(11.08, 49.45), 10); + SELECT ST_QuadKey(ST_Point(11.08, 49.45), 10); ---- 1333203202 )"; From cd99909481520a7fd7d61da2e68b0ce59a4440a0 Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Mon, 30 Jun 2025 17:59:47 +0200 Subject: [PATCH 2/2] Formatting fix --- src/spatial/modules/osm/osm_module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spatial/modules/osm/osm_module.cpp b/src/spatial/modules/osm/osm_module.cpp index 397c9523..210fd471 100644 --- a/src/spatial/modules/osm/osm_module.cpp +++ b/src/spatial/modules/osm/osm_module.cpp @@ -860,7 +860,7 @@ static unique_ptr ReadOsmPBFReplacementScan(ClientContext &context, Re // static constexpr DocTag DOC_TAGS[] = {{"ext", "spatial"}}; static constexpr const char *DOC_DESCRIPTION = R"( - The `ST_ReadOsm()` table function enables reading compressed OpenStreetMap data directly from a `.osm.pbf file.` + The `ST_ReadOsm()` table function enables reading compressed OpenStreetMap data directly from a `.osm.pbf` file. This function uses multithreading and zero-copy protobuf parsing which makes it a lot faster than using the `ST_Read()` OSM driver, however it only outputs the raw OSM data (Nodes, Ways, Relations), without constructing any geometries. For simple node entities (like PoI's) you can trivially construct POINT geometries, but it is also possible to construct LINESTRING and POLYGON geometries by manually joining refs and nodes together in SQL, although with available memory usually being a limiting factor. The `ST_ReadOSM()` function also provides a "replacement scan" to enable reading from a file directly as if it were a table. This is just syntax sugar for calling `ST_ReadOSM()` though. Example: