parameters: (region, plate, output_dir)
return_statement: return region
docstring: Pull a TileRegion from the region_queue.
      Render the TileRegion to KML and write it to disk.
      Create a libkml NetworkLink object for the file and put it on the netlink_queue.
docstring_summary: Pull a TileRegion from the region_queue.
      Render the TileRegion to KML and write it to disk.
      Create a libkml NetworkLink object for the file and put it on the netlink_queue.
docstring_tokens: Pull a TileRegion from the region_queue . Render the TileRegion to KML and write it to disk . Create a libkml NetworkLink object for the file and put it on the netlink_queue .
function: def draw_region(region, plate, output_dir):
      """
      Pull a TileRegion from the region_queue.
      Render the TileRegion to KML and write it to disk.
      Create a libkml NetworkLink object for the file and put it on the netlink_queue.
      """
  
      goverlays = []
  
      tiles = search_tiles_by_region(plate, region)
      if len(tiles) == 0:
          return None
      #if len(tiles) > options.max_features:  # TODO: Implement (or remove) max features / netlinks
  
      t = tiles[0]
      region.tile_degree_size = math.sqrt(t.degree_width * t.degree_height) # this is actually consistent for the whole level.
      for t in tiles:
          goverlay = t.kml_overlay()
          goverlays.append(goverlay)
  
          region.latlon_bbox.expand(t.west,t.south)
          region.latlon_bbox.expand(t.east,t.north)
  
      folder = KML.Folder()
      for goverlay in goverlays:
          folder.append(goverlay)
  
      kml = KML.kml(folder)
      assert_valid(kml)
  
      kmlstr = etree.tostring(kml, pretty_print=True)
      kmzfile = zipfile.ZipFile(os.path.join(output_dir, region.kmz_filename), 'w')
      kmzfile.writestr('doc.kml', kmlstr)
      kmzfile.close()
  
      return region
function_tokens: def draw_region ( region , plate , output_dir ) : goverlays = [ ] tiles = search_tiles_by_region ( plate , region ) if len ( tiles ) == 0 : return None #if len(tiles) > options.max_features:  # TODO: Implement (or remove) max features / netlinks t = tiles [ 0 ] region . tile_degree_size = math . sqrt ( t . degree_width * t . degree_height ) # this is actually consistent for the whole level. for t in tiles : goverlay = t . kml_overlay ( ) goverlays . append ( goverlay ) region . latlon_bbox . expand ( t . west , t . south ) region . latlon_bbox . expand ( t . east , t . north ) folder = KML . Folder ( ) for goverlay in goverlays : folder . append ( goverlay ) kml = KML . kml ( folder ) assert_valid ( kml ) kmlstr = etree . tostring ( kml , pretty_print = True ) kmzfile = zipfile . ZipFile ( os . path . join ( output_dir , region . kmz_filename ) , 'w' ) kmzfile . writestr ( 'doc.kml' , kmlstr ) kmzfile . close ( ) return region