
    .6i                     h    S r SSKrSSKJr  SSKJr  SSKJr  S rS rS r	S	 r
\S
:X  a  \
" 5         gg)z
Generate a simple HTML gallery for a state's exported heatmap artifacts.

The report references PNG previews (including hotspot overlays) and links to
the GeoTIFF rasters for download.
    N)datetime)escape)Pathc                      [         R                  " SS9n U R                  SSS9  U R                  SS SS9  U R                  S	[        S S
S9  U R	                  5       $ )Nz<Generate an HTML report summarizing exported heatmap assets.)descriptionstatezState name (e.g., alabama).)helpz--titlezHOptional title for the HTML page (defaults to '<State> Heatmap Report').)defaultr	   z--outputz5Optional output HTML path (defaults to state folder).)typer
   r	   )argparseArgumentParseradd_argumentr   
parse_args)parsers    ./data2/heatmap/scripts/generate_html_report.pyr   r      sy    $$RF &CD
W  
 D	       c                    / nU H,  nUR                  [        U R                  U5      5      5        M.     / n[        5       nU HC  nXe;  d  M
  UR	                  5       (       d  M!  UR                  U5        UR                  U5        ME     U$ )N)extendsortedglobsetis_fileappendadd)	state_dirpatternsmatchespatternuniqueseenpaths          r   gather_filesr"   "   so    GvinnW567 F5DMM$HHTN  Mr   c                 2   [         R                  " 5       R                  5       n/ nU HE  nUR                  nUR	                  S[        U5       S[        U5       S[        U5       S35        MG     / nU H9  nUR                  nUR	                  S[        U5       S[        U5       S35        M;     U(       a  SR                  U5      OS	n	U(       a  S
SR                  U5      -   S-   OSn
S[        U 5       S[        U 5       S[        U5       SU	 SU
 S3$ )Nz(
        <figure>
            <img src="z" alt="z*" loading="lazy">
            <figcaption>z(</figcaption>
        </figure>
        z<li><a href="z">z	</a></li>
z<p>No images found.</p>z<ul>z</ul>z <p>No GeoTIFF rasters found.</p>zO<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>a-  </title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 2rem;
            background-color: #f7f7f7;
            color: #333;
        }
        h1, h2 {
            color: #111;
        }
        figure {
            margin: 1rem 0;
        }
        img {
            max-width: 100%;
            border: 1px solid #ccc;
            box-shadow: 0 1px 3px rgba(0,0,0,0.2);
        }
        figcaption {
            margin-top: 0.5rem;
            font-size: 0.9rem;
        }
    </style>
</head>
<body>
    <h1>z</h1>
    <p>Generated: z? UTC</p>
    <section>
        <h2>Image Previews</h2>
        zI
    </section>
    <section>
        <h2>GeoTIFF Downloads</h2>
        z 
    </section>
</body>
</html>
)r   utcnow	isoformatnamer   r   join)titleimagesrasters	timestampimg_sectionsimager'   raster_linksrasterimages_htmlrasters_htmls              r   
build_htmlr3   /   s>   !++-ILzzd|nGF4L> : '		
  L{{mF4L>F4L>ST  .:$))L)?XK  	<((72/  5M? 	4 
 )$% &	 
 	 
 M* *r   c                  F   [        5       n U R                  R                  5       n[        S5      S-  U-  nUR	                  5       (       a  UnO[        S5      U-  nUR	                  5       (       d  [        SU 35      eU R                  =(       d    UR                  5        S3nU R                  =(       d    X1 S3-  n/ SQnS/n[        X65      n[        X75      n	U(       d  U	(       d  [        SU 35      e[        XHU	5      n
UR                  U
S	S
9  [        SU 35        g )Noutputgermanyu   ❌ State directory not found: z Heatmap Reportz_report.html)z*heatmap*.pngz*road_density_*km.pngz*hotspots*.pngz*layers*.pngz*road_density_*km.tifu&   ⚠️ No exported artifacts found in zutf-8)encodingu   📄 Saved HTML report to: )r   r   lowerr   exists
SystemExitr)   
capitalizer5   r"   r3   
write_textprint)argsr   germany_dirr   r)   output_pathimage_patternsraster_patternsr*   r+   html_contents              r   mainrD   v   s   <DJJE x.9,u4K	NU*	:9+FGGJJ@U--/0@E++E)|.D"DKN //O)4F96G'A)MNNeW5L<':	'}
56r   __main__)__doc__r   r   htmlr   pathlibr   r   r"   r3   rD   __name__ r   r   <module>rK      sC       &
DN!7H zF r   