Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/gen/osm2pgsql-gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,32 @@ tile_extent get_extent_from_db(pg_conn_t const &db_connection,
result = db_connection.exec(
"SELECT ST_XMin(extent), ST_YMin(extent),"
" ST_XMax(extent), ST_YMax(extent)"
" FROM raster_columns WHERE r_table_schema='{}'"
" AND r_table_name='{}' AND r_raster_column = '{}'",
" FROM ("
" SELECT ST_Transform(extent, 3857) AS extent"
" FROM raster_columns WHERE r_table_schema='{}'"
" AND r_table_name='{}' AND r_raster_column = '{}'"
" ) a",
schema, table, column);
} else {
result = db_connection.exec(
"WITH srid AS ("
" SELECT ST_SRID({}) AS srid FROM {} LIMIT 1"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The column and table name should be quoted.

ST_SRID("{}") AS srid FROM "{}" LIMIT 1

")"
"SELECT ST_XMin(e), ST_YMin(e), ST_XMax(e), ST_YMax(e)"
" FROM ST_EstimatedExtent('{}', '{}', '{}') AS e",
" FROM "
" (SELECT CASE WHEN srid.srid = 0"
" THEN ST_EstimatedExtent('{}', '{}', '{}')"
" ELSE"
" ST_Transform("
" ST_SetSRID("
" ST_EstimatedExtent('{}', '{}', '{}'), "
" srid.srid"
" ),"
" 3857)"
" END AS e"
" FROM srid) e",
column, qualified_name(schema, table),
schema, table, column,
schema, table, column);
}

Expand Down