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

$t = new MyView();
$t->title = "Download SPC Mesoscale Convective Discussion (MCD) Shapefile";
$content = <<<EOM
<div class="container-fluid">
<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">Storm Prediction Center Mesoscale Convective Discussions (MCD)</li>
  </ol>
</nav>

<div class="alert alert-info" role="alert">
  <div class="d-flex">
    <div class="flex-shrink-0">
      <i class="bi bi-info-circle"></i>
    </div>
    <div class="flex-grow-1 ms-3">
      <p class="mb-2">The IEM has a database archive of SPC MCDs since 2003. The
      download offered here does not contain the MCD text discussion, but the
      polygon geometry along with some metadata. The backend database that
      services this download updates in realtime, so the data should be as current
      as your download.</p>
      <a href="/cgi-bin/request/gis/spc_mcd.py?help" class="btn btn-outline-primary btn-sm">
        <i class="bi bi-file-text"></i> Backend Documentation
      </a>
    </div>
  </div>
</div>

<div class="mb-4">
  <h5 class="mb-3"><i class="bi bi-link-45deg me-2"></i>Related Services</h5>
  <div class="d-flex flex-wrap gap-2">
    <a class="btn btn-outline-secondary btn-sm" href="misc.phtml">
      <i class="bi bi-geo"></i> NWS Misc Polygons
    </a>
    <a class="btn btn-outline-secondary btn-sm" href="watchwarn.phtml">
      <i class="bi bi-exclamation-triangle"></i> NWS VTEC Watch Warning Advisory
    </a>
    <a class="btn btn-outline-secondary btn-sm" href="outlooks.phtml">
      <i class="bi bi-eye"></i> SPC/WPC Outlooks
    </a>
    <a class="btn btn-outline-secondary btn-sm" href="spc_watch.phtml">
      <i class="bi bi-shield-exclamation"></i> SPC Watch Polygons
    </a>
    <a class="btn btn-outline-secondary btn-sm" href="wpc_mpd.phtml">
      <i class="bi bi-cloud-rain"></i> WPC Precip Discussions
    </a>
  </div>
</div>

<form method="GET" action="/cgi-bin/request/gis/spc_mcd.py" class="mb-4">
<div class="card">
  <div class="card-header bg-primary text-white">
    <h5 class="card-title mb-0">
      <i class="bi bi-calendar-range"></i> Time Interval for MCD Issuance (UTC)
    </h5>
  </div>
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-borderless">
        <thead>
          <tr>
            <th scope="col"></th>
            <th scope="col">Year</th>
            <th scope="col">Month</th>
            <th scope="col">Day</th>
            <th scope="col">Hour</th>
            <th scope="col">Minute</th>
          </tr>
        </thead>
        <tbody>
EOM;
$content .= "<tr>
    <th scope=\"row\" class=\"text-success\">
      <i class=\"bi bi-play-fill\"></i> Start:
    </th>
    <td>
     ". yearSelect(2003, 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 scope=\"row\" class=\"text-danger\">
      <i class=\"bi bi-stop-fill\"></i> End:
    </th>
    <td>
     ". yearSelect(2003, 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>
        </tbody>
      </table>
    </div>
  </div>
</div>";

$content .= <<<EOM

<div class="d-grid gap-2 mb-4">
  <button type="submit" class="btn btn-primary btn-lg">
    <i class="bi bi-download"></i> Download Data
  </button>
</div>
</form>

<div class="card mb-4">
  <div class="card-header bg-secondary text-white">
    <h5 class="card-title mb-0">
      <i class="bi bi-table"></i> Shapefile DBF Schema
    </h5>
  </div>
  <div class="card-body">
    <div class="table-responsive">
      <table class="table table-sm">
        <thead class="table-dark">
          <tr>
            <th>Field</th>
            <th>Type</th>
            <th>Title</th>
            <th>Description</th>
          </tr>
        </thead>
        <tbody>
          <tr><td>0</td><td><span class="badge bg-info">String</span></td><td><code>ISSUE</code></td><td>UTC Issuance Timestamp YYYYmmddHHMM</td></tr>
          <tr><td>1</td><td><span class="badge bg-info">String</span></td><td><code>EXPIRE</code></td><td>UTC MCD Expiration Timestamp</td></tr>
          <tr><td>2</td><td><span class="badge bg-info">String</span></td><td><code>PROD_ID</code></td><td>IEM Product ID (see below)</td></tr>
          <tr><td>3</td><td><span class="badge bg-warning text-dark">Double</span></td><td><code>YEAR</code></td><td>YEAR of MCD</td></tr>
          <tr><td>4</td><td><span class="badge bg-warning text-dark">Double</span></td><td><code>NUM</code></td><td>SPC MCD Number</td></tr>
          <tr><td>5</td><td><span class="badge bg-warning text-dark">Double</span></td><td><code>CONFIDEN</code></td><td>SPC Watch issuance confidence</td></tr>
          <tr><td>6</td><td><span class="badge bg-info">String</span></td><td><code>CONCERN</code></td><td>SPC MCD concerning heading</td></tr>
          <tr><td>7</td><td><span class="badge bg-info">String</span></td><td><code>MP_TORN</code></td><td>SPC MCD Most Probable Tornado Intensity</td></tr>
          <tr><td>8</td><td><span class="badge bg-info">String</span></td><td><code>MP_HAIL</code></td><td>SPC MCD Most Probable Hail Intensity</td></tr>
          <tr><td>9</td><td><span class="badge bg-info">String</span></td><td><code>MP_GUST</code></td><td>SPC MCD Most Probable Gust Intensity</td></tr>
        </tbody>
      </table>
    </div>
  </div>
</div>

<div class="card">
  <div class="card-header bg-light">
    <h5 class="card-title mb-0">
      <i class="bi bi-info-circle"></i> Archive / Usage Notes
    </h5>
  </div>
  <div class="card-body">
    <div class="alert alert-primary" role="alert">
      <strong><i class="bi bi-api"></i> API Integration:</strong> The <code>PROD_ID</code> DBF field is a string the IEM uses to identify
      NWS Text products and can be used to call an IEM API to fetch the text of
      this product: <code>{$EXTERNAL_BASEURL}/api/1/nwstext/{PROD_ID}</code>
    </div>
    <div class="alert alert-info" role="alert">
      <strong><i class="bi bi-link-45deg"></i> SPC Integration:</strong> The <code>YEAR</code> and <code>NUM</code> fields can be used to construct
      a stable URL into SPC's website like so: <code>https://www.spc.noaa.gov/products/md/{year}/md{NUM:04i}.html</code>
    </div>
  </div>
</div>
</div>
EOM;

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