parameters: (queue_name, output_bucket, tileset, image_tiles, input, tile_url, dryrun)
docstring: Populate the given SQS queue with tasks of the form [bucket, tileset, image_tiles, z, x, y],
      to be consumed by batch_process.py.
  
      Works well with cover.js. E.g.:
  
      ./cover.js file.geojson 15 16 | python segnet/queue.py my_queue my_bucket my_tileset "http://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token={MAPBOX_ACCESS_TOKEN}"
docstring_summary: Populate the given SQS queue with tasks of the form [bucket, tileset, image_tiles, z, x, y],
      to be consumed by batch_process.py.
docstring_tokens: Populate the given SQS queue with tasks of the form [ bucket tileset image_tiles z x y ] to be consumed by batch_process . py .
function: def populate(queue_name, output_bucket, tileset, image_tiles, input, tile_url, dryrun):
      """
      Populate the given SQS queue with tasks of the form [bucket, tileset, image_tiles, z, x, y],
      to be consumed by batch_process.py.
  
      Works well with cover.js. E.g.:
  
      ./cover.js file.geojson 15 16 | python segnet/queue.py my_queue my_bucket my_tileset "http://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?access_token={MAPBOX_ACCESS_TOKEN}"
      """
  
      try:
          input = click.open_file(input).readlines()
      except IOError:
          input = [input]
      batch = []
      count = 0
      for tile in input:
          tile = (x, y, z) = json.loads(tile.strip())
          count += 1
          batch.append(json.dumps((output_bucket, tileset, image_tiles, z, x, y)))
          if (len(batch) == 10):
              send(queue_name, batch, dryrun)
              batch = []
  
      if len(batch) > 0:
          send(queue_name, batch, dryrun)
  
      if not tile_url:
          tile_url = 'https://%s.s3.amazonaws.com/%s/{z}/{x}/{y}.png' % (output_bucket, tileset)
      tilejson = json.dumps({
          'tilejson': '2.0.0',
          'tiles': [tile_url]
      })
      key = '%s/index.json' % tileset
      click.echo('%s tiles queued. Pushing TileJSON to %s/%s' % (count, output_bucket, tileset))
      click.echo(tilejson)
      if not dryrun:
          s3.put_object(Body=tilejson, Bucket=output_bucket, Key=key, ContentType='application/json')
function_tokens: def populate ( queue_name , output_bucket , tileset , image_tiles , input , tile_url , dryrun ) : try : input = click . open_file ( input ) . readlines ( ) except IOError : input = [ input ] batch = [ ] count = 0 for tile in input : tile = ( x , y , z ) = json . loads ( tile . strip ( ) ) count += 1 batch . append ( json . dumps ( ( output_bucket , tileset , image_tiles , z , x , y ) ) ) if ( len ( batch ) == 10 ) : send ( queue_name , batch , dryrun ) batch = [ ] if len ( batch ) > 0 : send ( queue_name , batch , dryrun ) if not tile_url : tile_url = 'https://%s.s3.amazonaws.com/%s/{z}/{x}/{y}.png' % ( output_bucket , tileset ) tilejson = json . dumps ( { 'tilejson' : '2.0.0' , 'tiles' : [ tile_url ] } ) key = '%s/index.json' % tileset click . echo ( '%s tiles queued. Pushing TileJSON to %s/%s' % ( count , output_bucket , tileset ) ) click . echo ( tilejson ) if not dryrun : s3 . put_object ( Body = tilejson , Bucket = output_bucket , Key = key , ContentType = 'application/json' )