original_docstring: 
          Mapnik representation of the scenario results
          
docstring: Mapnik representation of the scenario results
docstring_tokens: Mapnik representation of the scenario results
code: def mapnik_xml(self):
          """
          Mapnik representation of the scenario results
          """
          path = self.mapnik_xml_path
          sql = self.thunderstorm_sql()
  
          if not os.path.exists(path):
              dbs = settings.DATABASES['default']
              context = dbs.copy()
              context['sql'] = sql
              context['a'] = settings.MARXAN_NUMREPS - 2
              context['b'] = round(settings.MARXAN_NUMREPS * 0.7)
              context['c'] = round(settings.MARXAN_NUMREPS * 0.5)
              context['d'] = round(settings.MARXAN_NUMREPS * 0.4)
              context['e'] = round(settings.MARXAN_NUMREPS * 0.3)
              context['f'] = round(settings.MARXAN_NUMREPS * 0.2)
  
              with open(path, 'w') as fh:
                  xml = """<?xml version="1.0"?>
                  <!DOCTYPE Map [
                  <!ENTITY google_mercator "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
                  ]>
                  <Map srs="&google_mercator;">
                      <Style name="pu" filter-mode="first">
                          
                                  <Rule>
                                      <Filter>([hits] &gt;= %(a)s)</Filter>
                                      <PolygonSymbolizer fill="#0c2c84" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(b)s)</Filter>
                                      <PolygonSymbolizer fill="#225ea8" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(c)s)</Filter>
                                      <PolygonSymbolizer fill="#1d91c0" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(d)s)</Filter>
                                      <PolygonSymbolizer fill="#41b6c4" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(e)s)</Filter>
                                      <PolygonSymbolizer fill="#7fcdbb" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(f)s)</Filter>
                                      <PolygonSymbolizer fill="#c7e9b4" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= 1)</Filter>
                                      <PolygonSymbolizer fill="#ffffcc" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] = 0)</Filter>
                                      <PolygonSymbolizer fill="#ffffff" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                              
                      </Style>
                      <!--
                      <Style name="pu_best">
                          <Rule>
                              <Filter>([bests] &gt;= 1)</Filter>
                              <PointSymbolizer/> 
                              <PolygonSymbolizer fill="#081d58" fill-opacity="1.0" gamma=".45" />
                          </Rule>
                      </Style>
                      -->
                      <Layer name="layer" srs="&google_mercator;">
                          <StyleName>pu</StyleName>
                          <!--
                          <StyleName>pu_best</StyleName>
                          -->
                          <Datasource>
                              <Parameter name="type">postgis</Parameter>
                              <Parameter name="host">%(HOST)s</Parameter>
                              <Parameter name="dbname">%(NAME)s</Parameter>
                              <Parameter name="user">%(USER)s</Parameter>
                              <Parameter name="password">%(PASSWORD)s</Parameter>
                              <Parameter name="table">%(sql)s</Parameter>
                              <Parameter name="estimate_extent">false</Parameter>
                          </Datasource>
                      </Layer>
                  </Map>""" % context
  
                  fh.write(xml)
  
          return path
code_tokens: def mapnik_xml ( self ) : path = self . mapnik_xml_path sql = self . thunderstorm_sql ( ) if not os . path . exists ( path ) : dbs = settings . DATABASES [ 'default' ] context = dbs . copy ( ) context [ 'sql' ] = sql context [ 'a' ] = settings . MARXAN_NUMREPS - 2 context [ 'b' ] = round ( settings . MARXAN_NUMREPS * 0.7 ) context [ 'c' ] = round ( settings . MARXAN_NUMREPS * 0.5 ) context [ 'd' ] = round ( settings . MARXAN_NUMREPS * 0.4 ) context [ 'e' ] = round ( settings . MARXAN_NUMREPS * 0.3 ) context [ 'f' ] = round ( settings . MARXAN_NUMREPS * 0.2 ) with open ( path , 'w' ) as fh : xml = """<?xml version="1.0"?>
                  <!DOCTYPE Map [
                  <!ENTITY google_mercator "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
                  ]>
                  <Map srs="&google_mercator;">
                      <Style name="pu" filter-mode="first">
                          
                                  <Rule>
                                      <Filter>([hits] &gt;= %(a)s)</Filter>
                                      <PolygonSymbolizer fill="#0c2c84" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(b)s)</Filter>
                                      <PolygonSymbolizer fill="#225ea8" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(c)s)</Filter>
                                      <PolygonSymbolizer fill="#1d91c0" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(d)s)</Filter>
                                      <PolygonSymbolizer fill="#41b6c4" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(e)s)</Filter>
                                      <PolygonSymbolizer fill="#7fcdbb" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= %(f)s)</Filter>
                                      <PolygonSymbolizer fill="#c7e9b4" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] &gt;= 1)</Filter>
                                      <PolygonSymbolizer fill="#ffffcc" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                                  <Rule>
                                      <Filter>([hits] = 0)</Filter>
                                      <PolygonSymbolizer fill="#ffffff" fill-opacity="1.0" gamma=".45" />
                                  </Rule>
                              
                      </Style>
                      <!--
                      <Style name="pu_best">
                          <Rule>
                              <Filter>([bests] &gt;= 1)</Filter>
                              <PointSymbolizer/> 
                              <PolygonSymbolizer fill="#081d58" fill-opacity="1.0" gamma=".45" />
                          </Rule>
                      </Style>
                      -->
                      <Layer name="layer" srs="&google_mercator;">
                          <StyleName>pu</StyleName>
                          <!--
                          <StyleName>pu_best</StyleName>
                          -->
                          <Datasource>
                              <Parameter name="type">postgis</Parameter>
                              <Parameter name="host">%(HOST)s</Parameter>
                              <Parameter name="dbname">%(NAME)s</Parameter>
                              <Parameter name="user">%(USER)s</Parameter>
                              <Parameter name="password">%(PASSWORD)s</Parameter>
                              <Parameter name="table">%(sql)s</Parameter>
                              <Parameter name="estimate_extent">false</Parameter>
                          </Datasource>
                      </Layer>
                  </Map>""" % context fh . write ( xml ) return path
short_docstring: Mapnik representation of the scenario results
short_docstring_tokens: Mapnik representation of the scenario results
comment: """
          Mapnik representation of the scenario results
          """