Skip to content

Commit aa66da4

Browse files
committed
Remove hardcoded column name, don't return error for srid=0
1 parent 89b7685 commit aa66da4

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/gen/osm2pgsql-gen.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,25 @@ tile_extent get_extent_from_db(pg_conn_t const &db_connection,
122122
schema, table, column);
123123
} else {
124124
result = db_connection.exec(
125+
"WITH srid AS ("
126+
" SELECT ST_SRID({}) AS srid FROM {} LIMIT 1"
127+
")"
125128
"SELECT ST_XMin(e), ST_YMin(e), ST_XMax(e), ST_YMax(e)"
126-
" FROM ST_Transform("
127-
" ST_SetSRID("
128-
" ST_EstimatedExtent('{}', '{}', '{}'), "
129-
" (SELECT ST_SRID(way) FROM {} LIMIT 1)"
130-
" ), 3857) e",
131-
schema, table, column, qualified_name(schema, table));
129+
" FROM "
130+
" (SELECT CASE WHEN srid.srid = 0"
131+
" THEN ST_EstimatedExtent('{}', '{}', '{}')"
132+
" ELSE"
133+
" ST_Transform("
134+
" ST_SetSRID("
135+
" ST_EstimatedExtent('{}', '{}', '{}'), "
136+
" srid.srid"
137+
" ),"
138+
" 3857)"
139+
" END AS e"
140+
" FROM srid) e",
141+
column, qualified_name(schema, table),
142+
schema, table, column,
143+
schema, table, column);
132144
}
133145

134146
if (result.num_tuples() == 0 || result.is_null(0, 0)) {

0 commit comments

Comments
 (0)