app/models/concerns/tilestache.rb
#config file to be sent to s3 as well
config file to be sent to s3 as well
config file to be sent to s3 as well
def tile_config_json(options)
    layer_name = options[:item_id].to_s
    layer_name = "map-"+ layer_name if options[:item_type] == "map"
    tiles_host = APP_CONFIG['cdn_tiles_host'].blank? ? "https://storage.googleapis.com/#{APP_CONFIG['google_tiles_bucket']}" : APP_CONFIG['cdn_tiles_host']
    name = self.title if options[:item_type] == "map"
    name = self.name if options[:item_type] == "layer"
    name = ActionController::Base.helpers.sanitize(name,  :tags => [])
    max_zoom = options[:max_zoom].to_i || 21
    description  =  ActionController::Base.helpers.sanitize(self.description)
    site_url = APP_CONFIG['host_with_scheme']
    site_name  =  APP_CONFIG['site_name']
    attribution ="From: <a href='#{site_url}/#{self.class.to_s.downcase}s/#{self.id}/'>#{site_name}</a>" 
    bbox = self.bbox.split(",")
    tile_bbox = [bbox[0].to_f,bbox[1].to_f,bbox[2].to_f,bbox[3].to_f]
    centroid_y = tile_bbox[1] + ((tile_bbox[3] -  tile_bbox[1]) / 2)
    centroid_x = tile_bbox[0] + ((tile_bbox[2] -  tile_bbox[0]) / 2)
    config = {
      "tilejson"      => "2.0.0",
      "autoscale"   => true,
      "name"        => "#{name}",
      "description" => "#{description}",
      "version"     => "1.5.0",
      "attribution" => "#{attribution}",
      "scheme"      => "xyz",
      "tiles"       => ["#{tiles_host}/#{layer_name}/{z}/{x}/{y}.png"],
      "minzoom"     => 1,
      "maxzoom"     => max_zoom,
      "bounds"      => tile_bbox,
      "center"      => [centroid_x, centroid_y, max_zoom ]
    }
    return JSON.pretty_generate(config)
  end
def tile_config_json ( options ) layer_name = options [ :item_id ] . to_s layer_name = "map-" + layer_name if options [ :item_type ] == "map" tiles_host = APP_CONFIG [ 'cdn_tiles_host' ] . blank? ? "https://storage.googleapis.com/#{APP_CONFIG['google_tiles_bucket']}" : APP_CONFIG [ 'cdn_tiles_host' ] name = self . title if options [ :item_type ] == "map" name = self . name if options [ :item_type ] == "layer" name = ActionController :: Base . helpers . sanitize ( name , :tags => [ ] ) max_zoom = options [ :max_zoom ] . to_i || 21 description = ActionController :: Base . helpers . sanitize ( self . description ) site_url = APP_CONFIG [ 'host_with_scheme' ] site_name = APP_CONFIG [ 'site_name' ] attribution = "From: <a href='#{site_url}/#{self.class.to_s.downcase}s/#{self.id}/'>#{site_name}</a>" bbox = self . bbox . split ( "," ) tile_bbox = [ bbox [ 0 ] . to_f , bbox [ 1 ] . to_f , bbox [ 2 ] . to_f , bbox [ 3 ] . to_f ] centroid_y = tile_bbox [ 1 ] + ( ( tile_bbox [ 3 ] - tile_bbox [ 1 ] ) / 2 ) centroid_x = tile_bbox [ 0 ] + ( ( tile_bbox [ 2 ] - tile_bbox [ 0 ] ) / 2 ) config = { "tilejson" => "2.0.0" , "autoscale" => true , "name" => "#{name}" , "description" => "#{description}" , "version" => "1.5.0" , "attribution" => "#{attribution}" , "scheme" => "xyz" , "tiles" => [ "#{tiles_host}/#{layer_name}/{z}/{x}/{y}.png" ] , "minzoom" => 1 , "maxzoom" => max_zoom , "bounds" => tile_bbox , "center" => [ centroid_x , centroid_y , max_zoom ] } return JSON . pretty_generate ( config ) end
config file to be sent to s3 as well
config file to be sent to s3 as well
options
<not_specific>