Skip to content

Instantly share code, notes, and snippets.

@demimismo
Created November 19, 2012 16:45
Show Gist options
  • Save demimismo/4111756 to your computer and use it in GitHub Desktop.
Save demimismo/4111756 to your computer and use it in GitHub Desktop.
# Fix for bubblemaps
# Applying an SQL to polygon tables with bubble maps until Mapnik 2.1.1 is released
if data_layer.options['tile_style'].present? &&
table.the_geom_type == "multipolygon" &&
data_layer.options['tile_style'] =~ /.*marker-placement:\s*point.*/
fields = table.schema(:reload => true).map {|i| i.first.to_s } - ["the_geom_webmercator"]
data_layer.options['query'] = "SELECT #{fields.join(',')}, ST_PointOnSurface(the_geom_webmercator) as the_geom_webmercator FROM #{table.name}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment