Skip to content

Commit

Permalink
Do not pass unsupported types to ST_MakeValid
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandro Santilli committed Mar 27, 2012
1 parent f0b5511 commit f262a47
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cartodb_vector.js
Expand Up @@ -115,9 +115,14 @@ CartoDB.get_tile_data_sql = function(projection, table, x, y, zoom) {
// Make valid (both ST_Snap and ST_SnapToGrid and ST_Expand
var ENABLE_FIXING = 1
if ( ENABLE_FIXING ) {
geom_column = 'ST_MakeValid(' + geom_column + ')';
geom_column = 'ST_CollectionExtract(' + geom_column + ', ST_Dimension( '
+ geom_column_orig + ') + 1 )';
// NOTE: up to PostGIS-2.0.0 beta5 ST_MakeValid did not accept
// points nor GeometryCollection objects
geom_column = 'CASE WHEN ST_Dimension('
+ geom_column + ') = 0 OR GeometryType('
+ geom_column + ") = 'GEOMETRYCOLLECTION' THEN "
+ geom_column + ' ELSE ST_CollectionExtract(ST_MakeValid('
+ geom_column + '), ST_Dimension(' + geom_column_orig
+ ') + 1 ) END';
}

// clip by box
Expand Down

0 comments on commit f262a47

Please sign in to comment.