def create_leaflet_viewer(self, idaho_image_results, filename):
description = self.describe_images(idaho_image_results)<EOL>if len(description) > <NUM_LIT:0>:<EOL><INDENT>functionstring = '<STR_LIT>'<EOL>for catid, images in description.items():<EOL><INDENT>for partnum, part in images['<STR_LIT>'].items():<EOL><INDENT>num_images = len(list(part.keys()))<EOL>partname = None<EOL>if num_images == <NUM_LIT:1>:<EOL><INDENT>partname = [p for p in list(part.keys())][<NUM_LIT:0>]<EOL>pan_image_id = '<STR_LIT>'<EOL><DEDENT>elif num_images == <NUM_LIT:2>:<EOL><INDENT>partname = [p for p in list(part.keys()) if p is not '<STR_LIT>'][<NUM_LIT:0>]<EOL>pan_image_id = part['<STR_LIT>']['<STR_LIT:id>']<EOL><DEDENT>if not partname:<EOL><INDENT>self.logger.debug("<STR_LIT>")<EOL>continue<EOL><DEDENT>bandstr = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT:0>'<EOL>}.get(partname, '<STR_LIT>')<EOL>part_boundstr_wkt = part[partname]['<STR_LIT>']<EOL>part_polygon = from_wkt(part_boundstr_wkt)<EOL>bucketname = part[partname]['<STR_LIT>']<EOL>image_id = part[partname]['<STR_LIT:id>']<EOL>W, S, E, N = part_polygon.bounds<EOL>functionstring += "<STR_LIT>" % (<EOL>bucketname, image_id, W, S, E, N, pan_image_id)<EOL><DEDENT><DEDENT>__location__ = os.path.realpath(<EOL>os.path.join(os.getcwd(), os.path.dirname(__file__)))<EOL>try:<EOL><INDENT>with open(os.path.join(__location__, '<STR_LIT>'), '<STR_LIT:r>') as htmlfile:<EOL><INDENT>data = htmlfile.read().decode("<STR_LIT:utf8>")<EOL><DEDENT><DEDENT>except AttributeError:<EOL><INDENT>with open(os.path.join(__location__, '<STR_LIT>'), '<STR_LIT:r>') as htmlfile:<EOL><INDENT>data = htmlfile.read()<EOL><DEDENT><DEDENT>data = data.replace('<STR_LIT>', functionstring)<EOL>data = data.replace('<STR_LIT>', str(S))<EOL>data = data.replace('<STR_LIT>', str(W))<EOL>data = data.replace('<STR_LIT>', bandstr)<EOL>data = data.replace('<STR_LIT>', self.gbdx_connection.access_token)<EOL>with codecs.open(filename, '<STR_LIT:w>', '<STR_LIT:utf8>') as outputfile:<EOL><INDENT>self.logger.debug("<STR_LIT>" % filename)<EOL>outputfile.write(data)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print('<STR_LIT>')<EOL><DEDENT>
Create a leaflet viewer html file for viewing idaho images.

        Args:
            idaho_image_results (dict): IDAHO image result set as returned from
                                        the catalog.
            filename (str): Where to save output html file.