<?php
require_once "../../../config/settings.inc.php";
define("IEM_APPID", 133);
require_once "../../../include/myview.php";
require_once "../../../include/forms.php";
require_once "../../../include/request_gis.php";

$t = new MyView();
$t->title = "Download CWSU Center Weather Advisory (CWA) Shapefile/KML";
$content = <<<EOM
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/nws/">NWS Mainpage</a></li>
<li class="breadcrumb-item active" aria-current="page">CWSU CWA Download</li>
</ol>
</nav>

<header class="mb-4">
  <h1 class="h3 mb-3">Download CWSU Center Weather Advisories</h1>
  <p class="mb-0">Download archived Center Weather Advisories by issuance time in UTC as shapefile or KML.</p>
</header>

<p>The IEM has a database archive of
<a href="https://www.aviationweather.gov/cwamis">CWSU Center Weather Advisories</a>.
The archive presently dates back to 1 January 2014 and is updated in real-time as
new products are received and processed.  Robust processing of the CWA has been
problematic as the raw products are more free-form text than adhering to a format
specification.  Presently, attempts are not made at processing cancellation statements.
</p>
EOM;

$content .= aviation_request_related_links("cwas.phtml");

$content .= <<<EOM

<div class="alert alert-warning">
<p>The data presented here is beta quality and refinements are being made yet
to improve text parsing robustness.  This message will be removed once more
quality control checks are done to ensure fidelity.</p>
</div>

<p><a href="/cgi-bin/request/gis/cwas.py?help" class="btn btn-secondary">
<i class="bi bi-file-text" aria-hidden="true"></i> Backend documentation</a> exists for those
wishing to script against this service.</p>

<form method="GET" action="/cgi-bin/request/gis/cwas.py">
<table class="table">
<thead><tr><th colspan="6">Time Interval for CWA Issuance (UTC)</th></tr></thead>
<tr>
    <td></td><th>Year</th><th>Month</th><th>Day</th>
    <th>Hour</th><th>Minute</th>
</tr>

<tr>
EOM;
$content .= "<th>Start:</th>
    <td>
     ". yearSelect(2014, date("Y"), "year1") ."
    </td>
    <td>
     ". monthSelect(0,"month1") ."
    </td>
    <td>
     ". daySelect(0, "day1") ."
    </td>
    <td>
     ". gmtHourSelect(0, "hour1") ."
    </td>
    <td>
     ". minuteSelect(0, "minute1") ."
    </td>
  </tr>

  <tr>
    <th>End:</th>
    <td>
     ". yearSelect(2014, date("Y"), "year2") ."
    </td>
    <td>
     ". monthSelect(date("m"), "month2") ."
    </td>
    <td>
     ". daySelect(date("d"), "day2") ."
    </td>
    <td>
     ". gmtHourSelect(0, "hour2") ."
    </td>
    <td>
     ". minuteSelect(0, "minute2") ."
    </td>
  </tr>
</table>";

$content .= <<<EOM

<p><strong>Format:</strong><br />
<input type="radio" name="format" value="shp" checked="checked" id="shp" />
<label for="shp">Shapefile</label>
<input type="radio" name="format" value="kml" id="kml" />
<label for="kml">KML</label>

<p><input type="submit" value="Giveme data right now!"></p>
</form>

<h4>Shapefile DBF schema:</h4>
<pre>
Field 0: Type=C/String, Title='CENTER', CWSU Center ID
Field 1: Type=C/String, Title='ISSUE', UTC CWA Issuance Time
Field 2: Type=C/String, Title='EXPIRE', UTC CWA Expiration Time
Field 3: Type=C/String, Title='PROD_ID', IEM Text Product Identifier
Field 4: Type=C/String, Title='NARRATIV', Text Narrative found in raw text
Field 5: Type=N/Double, Title='NUMBER', CWA Number
</pre>

<h4>Archive / Usage Notes:</h4>
<ol>
</ol>
</form>
EOM;

$t->content = $content;
$t->render('single.phtml');
