parameters: (self)
return_statement: return s
docstring: Template for openlayers.html, with the tiles as overlays, and base layers.
  
          It returns filled string.
docstring_summary: Template for openlayers.html, with the tiles as overlays, and base layers.
docstring_tokens: Template for openlayers . html with the tiles as overlays and base layers .
function: def generate_openlayers(self) -> str:
          """
          Template for openlayers.html, with the tiles as overlays, and base layers.
  
          It returns filled string.
          """
  
          args = {}
          args['xml_escaped_title'] = gdal.EscapeString(self.options.title, gdal.CPLES_XML)
          args['bingkey'] = self.options.bingkey
          args['minzoom'] = self.tminz
          args['maxzoom'] = self.tmaxz
          args['tile_size'] = self.tile_size
          args['tileformat'] = self.tileext
          args['publishurl'] = self.options.url
          args['copyright'] = self.options.copyright
          if self.options.xyz:
              args['sign_y'] = ''
          else:
              args['sign_y'] = '-'
  
          args['ominx'] = self.ominx
          args['ominy'] = self.ominy
          args['omaxx'] = self.omaxx
          args['omaxy'] = self.omaxy
          args['center_x'] = (self.ominx + self.omaxx) / 2
          args['center_y'] = (self.ominy + self.omaxy) / 2
  
          s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>%(xml_escaped_title)s</title>
      <meta http-equiv='imagetoolbar' content='no'/>
      <style type="text/css"> v\:* {behavior:url(#default#VML);}
          html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; }
          body { margin: 10px; background: #fff; }
          h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; }
          #header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; }
          #subheader { height: 12px; text-align: right; font-size: 10px; color: #555;}
          #map { height: 90%%; border: 1px solid #888; }
      </style>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css" type="text/css">
      <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>
      <script src="https://unpkg.com/ol-layerswitcher@3.5.0"></script>
      <link rel="stylesheet" href="https://unpkg.com/ol-layerswitcher@3.5.0/src/ol-layerswitcher.css" />
  </head>
  <body>
      <div id="header"><h1>%(xml_escaped_title)s</h1></div>
      <div id="subheader">Generated by <a href="https://gdal.org/programs/gdal2tiles.html">GDAL2Tiles</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
      <div id="map" class="map"></div>
      <div id="mouse-position"></div>
      <script type="text/javascript">
          var mousePositionControl = new ol.control.MousePosition({
              className: 'custom-mouse-position',
              target: document.getElementById('mouse-position'),
              undefinedHTML: '&nbsp;'
          });
          var map = new ol.Map({
              controls: ol.control.defaults().extend([mousePositionControl]),
              target: 'map',
  """ % args
  
          if self.options.profile == 'mercator' or self.options.profile == 'geodetic':
              s += """
              layers: [
                  new ol.layer.Group({
                          title: 'Base maps',
                          layers: [
                              new ol.layer.Tile({
                                  title: 'OpenStreetMap',
                                  type: 'base',
                                  visible: true,
                                  source: new ol.source.OSM()
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Roads',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'Road'
                                  })
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Aerial',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'Aerial'
                                  })
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Hybrid',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'AerialWithLabels'
                                  })
                              }),
                          ]
                  }),""" % args    # noqa
  
          if self.options.profile == 'mercator':
              s += """
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.XYZ({
                                  attributions: '%(copyright)s',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  url: './{z}/{x}/{%(sign_y)sy}.%(tileformat)s',
                                  tileSize: [%(tile_size)d, %(tile_size)d]
                              })
                          }),
                      ]
                  }),""" % args    # noqa
  
          elif self.options.profile == 'geodetic':
  
              if self.options.tmscompatible:
                  base_res = 180. / self.tile_size
              else:
                  base_res = 360. / self.tile_size
              resolutions = [ base_res / 2**i for i in range(self.tmaxz+1) ]
              args['resolutions'] = '[' + ','.join('%.18g' % res for res in resolutions) + ']'
  
              if self.options.xyz:
                  if self.options.tmscompatible:
                      args['origin'] = '[-180,90]'
                  else:
                      args['origin'] = '[-180,270]'
                  args['y_formula'] = 'tileCoord[2]'
              else:
                  args['origin'] = '[-180,-90]'
                  args['y_formula'] = '- 1 - tileCoord[2]'
  
              s += """
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  projection: 'EPSG:4326',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: [-180,-90,180,90],
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args    # noqa
  
          elif self.options.profile == 'raster':
  
              base_res =  2**(self.nativezoom) * self.out_gt[1]
              resolutions = [ base_res / 2**i for i in range(self.tmaxz+1) ]
              args['maxres'] = resolutions[self.tminz]
              args['resolutions'] = '[' + ','.join('%.18g' % res for res in resolutions) + ']'
              args['tilegrid_extent'] = '[%.18g,%.18g,%.18g,%.18g]' % (self.ominx, self.ominy, self.omaxx, self.omaxy)
  
              if self.options.xyz:
                  args['origin'] = '[%.18g,%.18g]' % (self.ominx, self.omaxy)
                  args['y_formula'] = 'tileCoord[2]'
              else:
                  args['origin'] = '[%.18g,%.18g]' % (self.ominx, self.ominy)
                  args['y_formula'] = '- 1 - tileCoord[2]'
  
              s += """
              layers: [
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: %(tilegrid_extent)s,
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args    # noqa
  
          else:
  
              tms = tmsMap[self.options.profile]
              base_res = tms.resolution
              resolutions = [ base_res / 2**i for i in range(self.tmaxz+1) ]
              args['maxres'] = resolutions[self.tminz]
              args['resolutions'] = '[' + ','.join('%.18g' % res for res in resolutions) + ']'
              args['matrixsizes'] = '[' + ','.join('[%d,%d]' % (tms.matrix_width << i, tms.matrix_height << i) for i in range(len(resolutions))) + ']'
  
              if self.options.xyz:
                  args['origin'] = '[%.18g,%.18g]' % (tms.topleft_x, tms.topleft_y)
                  args['y_formula'] = 'tileCoord[2]'
              else:
                  args['origin'] = '[%.18g,%.18g]' % (tms.topleft_x, tms.topleft_y - tms.resolution * tms.tile_size)
                  args['y_formula'] = '- 1 - tileCoord[2]'
  
              args['tilegrid_extent'] = '[%.18g,%.18g,%.18g,%.18g]' % ( \
                  tms.topleft_x,
                  tms.topleft_y - tms.matrix_height * tms.resolution * tms.tile_size,
                  tms.topleft_x + tms.matrix_width * tms.resolution * tms.tile_size,
                  tms.topleft_y)
  
              s += """
              layers: [
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: %(tilegrid_extent)s,
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      sizes: %(matrixsizes)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args    # noqa
  
          s += """
              ],
              view: new ol.View({
                  center: [%(center_x)f, %(center_y)f],""" % args  # noqa
  
          if self.options.profile in ('mercator', 'geodetic'):
              args['view_zoom'] = args['minzoom']
              if self.options.profile == 'geodetic' and self.options.tmscompatible:
                  args['view_zoom'] += 1
              s += """
                  zoom: %(view_zoom)d,""" % args  # noqa
          else:
              s += """
                  resolution: %(maxres)f,""" % args  # noqa
  
          if self.options.profile == 'geodetic':
              s += """
                  projection: 'EPSG:4326',"""
          elif self.options.profile != 'mercator':
              if self.in_srs and self.in_srs.IsProjected() and self.in_srs.GetAuthorityName(None) == 'EPSG':
                  s += """
                  projection: new ol.proj.Projection({code: 'EPSG:%s', units:'m'}),""" % self.in_srs.GetAuthorityCode(None)
  
          s += """
              })
          });"""
          if self.options.profile in ('mercator', 'geodetic'):
              s += """
          map.addControl(new ol.control.LayerSwitcher());"""
          s += """
      </script>
  </body>
  </html>"""
  
          return s
function_tokens: def generate_openlayers ( self ) -> str : args = { } args [ 'xml_escaped_title' ] = gdal . EscapeString ( self . options . title , gdal . CPLES_XML ) args [ 'bingkey' ] = self . options . bingkey args [ 'minzoom' ] = self . tminz args [ 'maxzoom' ] = self . tmaxz args [ 'tile_size' ] = self . tile_size args [ 'tileformat' ] = self . tileext args [ 'publishurl' ] = self . options . url args [ 'copyright' ] = self . options . copyright if self . options . xyz : args [ 'sign_y' ] = '' else : args [ 'sign_y' ] = '-' args [ 'ominx' ] = self . ominx args [ 'ominy' ] = self . ominy args [ 'omaxx' ] = self . omaxx args [ 'omaxy' ] = self . omaxy args [ 'center_x' ] = ( self . ominx + self . omaxx ) / 2 args [ 'center_y' ] = ( self . ominy + self . omaxy ) / 2 s = r"""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>%(xml_escaped_title)s</title>
      <meta http-equiv='imagetoolbar' content='no'/>
      <style type="text/css"> v\:* {behavior:url(#default#VML);}
          html, body { overflow: hidden; padding: 0; height: 100%%; width: 100%%; font-family: 'Lucida Grande',Geneva,Arial,Verdana,sans-serif; }
          body { margin: 10px; background: #fff; }
          h1 { margin: 0; padding: 6px; border:0; font-size: 20pt; }
          #header { height: 43px; padding: 0; background-color: #eee; border: 1px solid #888; }
          #subheader { height: 12px; text-align: right; font-size: 10px; color: #555;}
          #map { height: 90%%; border: 1px solid #888; }
      </style>
      <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/css/ol.css" type="text/css">
      <script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.3.1/build/ol.js"></script>
      <script src="https://unpkg.com/ol-layerswitcher@3.5.0"></script>
      <link rel="stylesheet" href="https://unpkg.com/ol-layerswitcher@3.5.0/src/ol-layerswitcher.css" />
  </head>
  <body>
      <div id="header"><h1>%(xml_escaped_title)s</h1></div>
      <div id="subheader">Generated by <a href="https://gdal.org/programs/gdal2tiles.html">GDAL2Tiles</a>&nbsp;&nbsp;&nbsp;&nbsp;</div>
      <div id="map" class="map"></div>
      <div id="mouse-position"></div>
      <script type="text/javascript">
          var mousePositionControl = new ol.control.MousePosition({
              className: 'custom-mouse-position',
              target: document.getElementById('mouse-position'),
              undefinedHTML: '&nbsp;'
          });
          var map = new ol.Map({
              controls: ol.control.defaults().extend([mousePositionControl]),
              target: 'map',
  """ % args if self . options . profile == 'mercator' or self . options . profile == 'geodetic' : s += """
              layers: [
                  new ol.layer.Group({
                          title: 'Base maps',
                          layers: [
                              new ol.layer.Tile({
                                  title: 'OpenStreetMap',
                                  type: 'base',
                                  visible: true,
                                  source: new ol.source.OSM()
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Roads',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'Road'
                                  })
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Aerial',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'Aerial'
                                  })
                              }),
                              new ol.layer.Tile({
                                  title: 'Bing Hybrid',
                                  type: 'base',
                                  visible: false,
                                  source: new ol.source.BingMaps({
                                      key: "%(bingkey)s",
                                      imagerySet: 'AerialWithLabels'
                                  })
                              }),
                          ]
                  }),""" % args # noqa if self . options . profile == 'mercator' : s += """
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.XYZ({
                                  attributions: '%(copyright)s',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  url: './{z}/{x}/{%(sign_y)sy}.%(tileformat)s',
                                  tileSize: [%(tile_size)d, %(tile_size)d]
                              })
                          }),
                      ]
                  }),""" % args # noqa elif self . options . profile == 'geodetic' : if self . options . tmscompatible : base_res = 180. / self . tile_size else : base_res = 360. / self . tile_size resolutions = [ base_res / 2 ** i for i in range ( self . tmaxz + 1 ) ] args [ 'resolutions' ] = '[' + ',' . join ( '%.18g' % res for res in resolutions ) + ']' if self . options . xyz : if self . options . tmscompatible : args [ 'origin' ] = '[-180,90]' else : args [ 'origin' ] = '[-180,270]' args [ 'y_formula' ] = 'tileCoord[2]' else : args [ 'origin' ] = '[-180,-90]' args [ 'y_formula' ] = '- 1 - tileCoord[2]' s += """
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  projection: 'EPSG:4326',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: [-180,-90,180,90],
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args # noqa elif self . options . profile == 'raster' : base_res = 2 ** ( self . nativezoom ) * self . out_gt [ 1 ] resolutions = [ base_res / 2 ** i for i in range ( self . tmaxz + 1 ) ] args [ 'maxres' ] = resolutions [ self . tminz ] args [ 'resolutions' ] = '[' + ',' . join ( '%.18g' % res for res in resolutions ) + ']' args [ 'tilegrid_extent' ] = '[%.18g,%.18g,%.18g,%.18g]' % ( self . ominx , self . ominy , self . omaxx , self . omaxy ) if self . options . xyz : args [ 'origin' ] = '[%.18g,%.18g]' % ( self . ominx , self . omaxy ) args [ 'y_formula' ] = 'tileCoord[2]' else : args [ 'origin' ] = '[%.18g,%.18g]' % ( self . ominx , self . ominy ) args [ 'y_formula' ] = '- 1 - tileCoord[2]' s += """
              layers: [
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: %(tilegrid_extent)s,
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args # noqa else : tms = tmsMap [ self . options . profile ] base_res = tms . resolution resolutions = [ base_res / 2 ** i for i in range ( self . tmaxz + 1 ) ] args [ 'maxres' ] = resolutions [ self . tminz ] args [ 'resolutions' ] = '[' + ',' . join ( '%.18g' % res for res in resolutions ) + ']' args [ 'matrixsizes' ] = '[' + ',' . join ( '[%d,%d]' % ( tms . matrix_width << i , tms . matrix_height << i ) for i in range ( len ( resolutions ) ) ) + ']' if self . options . xyz : args [ 'origin' ] = '[%.18g,%.18g]' % ( tms . topleft_x , tms . topleft_y ) args [ 'y_formula' ] = 'tileCoord[2]' else : args [ 'origin' ] = '[%.18g,%.18g]' % ( tms . topleft_x , tms . topleft_y - tms . resolution * tms . tile_size ) args [ 'y_formula' ] = '- 1 - tileCoord[2]' args [ 'tilegrid_extent' ] = '[%.18g,%.18g,%.18g,%.18g]' % ( tms . topleft_x , tms . topleft_y - tms . matrix_height * tms . resolution * tms . tile_size , tms . topleft_x + tms . matrix_width * tms . resolution * tms . tile_size , tms . topleft_y ) s += """
              layers: [
                  new ol.layer.Group({
                      title: 'Overlay',
                      layers: [
                          new ol.layer.Tile({
                              title: 'Overlay',
                              // opacity: 0.7,
                              extent: [%(ominx)f, %(ominy)f,%(omaxx)f, %(omaxy)f],
                              source: new ol.source.TileImage({
                                  attributions: '%(copyright)s',
                                  minZoom: %(minzoom)d,
                                  maxZoom: %(maxzoom)d,
                                  tileGrid: new ol.tilegrid.TileGrid({
                                      extent: %(tilegrid_extent)s,
                                      origin: %(origin)s,
                                      resolutions: %(resolutions)s,
                                      sizes: %(matrixsizes)s,
                                      tileSize: [%(tile_size)d, %(tile_size)d]
                                  }),
                                  tileUrlFunction: function(tileCoord) {
                                      return ('./{z}/{x}/{y}.%(tileformat)s'
                                          .replace('{z}', String(tileCoord[0]))
                                          .replace('{x}', String(tileCoord[1]))
                                          .replace('{y}', String(%(y_formula)s)));
                                  },
                              })
                          }),
                      ]
                  }),""" % args # noqa s += """
              ],
              view: new ol.View({
                  center: [%(center_x)f, %(center_y)f],""" % args # noqa if self . options . profile in ( 'mercator' , 'geodetic' ) : args [ 'view_zoom' ] = args [ 'minzoom' ] if self . options . profile == 'geodetic' and self . options . tmscompatible : args [ 'view_zoom' ] += 1 s += """
                  zoom: %(view_zoom)d,""" % args # noqa else : s += """
                  resolution: %(maxres)f,""" % args # noqa if self . options . profile == 'geodetic' : s += """
                  projection: 'EPSG:4326',""" elif self . options . profile != 'mercator' : if self . in_srs and self . in_srs . IsProjected ( ) and self . in_srs . GetAuthorityName ( None ) == 'EPSG' : s += """
                  projection: new ol.proj.Projection({code: 'EPSG:%s', units:'m'}),""" % self . in_srs . GetAuthorityCode ( None ) s += """
              })
          });""" if self . options . profile in ( 'mercator' , 'geodetic' ) : s += """
          map.addControl(new ol.control.LayerSwitcher());""" s += """
      </script>
  </body>
  </html>""" return s