splashblot / dronedb

Location Intelligence & Data Visualization tool
http://carto.com
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Shared vis with raster with org member doesn't render raster layer #74

Closed apercas closed 6 years ago

apercas commented 6 years ago

When a given user shares a visualisation containing a raster dataset with a member of the same organisation, this second user doesn't get to see the raster dataset.

My guess: it tries to get first user's apikey to render it.

apercas commented 6 years ago

This currently works for new imported maps in beta: https://splashblot.tileo-beta.co/u/adrian/builder/385fd9bf-d4df-466d-92b7-7b251bf7d45a/embed

apercas commented 6 years ago

We're updating previously uploaded rasters with a db migration.

ivanprado commented 6 years ago

That's the script needed to migrate old maps so that they can be shared with the new code:

good_style = <<eos
#layer{raster-opacity: 1}
#layer['mapnik::geometry_type'=1] {
    marker-width: 7;
    marker-fill: #FFB927;
    marker-fill-opacity: 0.9;
    marker-line-color: #FFF;
    marker-line-width: 1;
    marker-line-opacity: 1;
    marker-placement: point;
    marker-type: ellipse;
    marker-allow-overlap: true;
  }
  #layer['mapnik::geometry_type'=2] {
    line-color: #3EBCAE;
    line-width: 1.5;
    line-opacity: 1;
  }
  #layer['mapnik::geometry_type'=3] {
    polygon-fill: #374C70;
    polygon-opacity: 0.9;
    ::outline {
      line-color: #FFF;
      line-width: 1;
      line-opacity: 0.5;
    }
  }
eos

Carto::Layer.find_each do |row| 
    opts = row.options
    table_name = opts['table_name']
    if table_name =~ /raster/i
        old_style = opts['tile_style']
        if !old_style.include? "raster-opacity"
            puts "#{table_name}"
            puts "#{old_style}"
            puts "------------"
            opts['tile_style'] = good_style
            row.update_attributes(:options => opts)
        end
    end
end

It can be executed through rails console