Skip to content

Commit

Permalink
Merge pull request #1652 from weather-gov/mgwalker/afd-links-1568-1617
Browse files Browse the repository at this point in the history
Add current AFD links
  • Loading branch information
greg-does-weather authored Aug 28, 2024
2 parents 6901d96 + fb0a4e1 commit 2877dc8
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 94 deletions.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions web/modules/weather_data/src/Service/AFDParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,8 @@ public function getStructureForTwig()
"code" => $preambleCode,
"text" => $preambleText,
],
"body" => $body,
"epilogue" => $epilogueNodes,
"body" => array_values($body),
"epilogue" => array_values($epilogueNodes),
];
}

Expand Down
219 changes: 202 additions & 17 deletions web/modules/weather_data/src/Service/Test/AFDParser.php.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class AFDParserTest extends TestCase
"type" => "text",
"content" =>
"A nearly stationary front will remain near the coast through" .
" Thursday. The front will then return northward Thursday night into Friday.",
" Thursday. The front will then return northward Thursday night into Friday.",
],
];

Expand All @@ -47,11 +47,13 @@ final class AFDParserTest extends TestCase
public function testHeaderWithoutNewline(): void
{
$source = ".SPOTTER INFORMATION STATEMENT...";
$expected = [[
"type" => "header",
"content" => "SPOTTER INFORMATION STATEMENT",
"postHeader" => null
]];
$expected = [
[
"type" => "header",
"content" => "SPOTTER INFORMATION STATEMENT",
"postHeader" => null,
],
];

$parser = new AFDParser($source);
$actual = $parser->parse();
Expand Down Expand Up @@ -85,9 +87,9 @@ final class AFDParserTest extends TestCase
"type" => "text",
"content" =>
"Improvement to MVFR cigs by mid-morning for any sites " .
"that are not already MVFR. Slow improvement then to " .
"VFR starting from the north in the late afternoon and " .
"reaching the NYC terminals late this evening.",
"that are not already MVFR. Slow improvement then to " .
"VFR starting from the north in the late afternoon and " .
"reaching the NYC terminals late this evening.",
],
];

Expand Down Expand Up @@ -228,7 +230,7 @@ final class AFDParserTest extends TestCase
"type" => "text",
"content" =>
"A nearly stationary front will remain near the coast through" .
" Thursday. The front will then return northward Thursday night into Friday.",
" Thursday. The front will then return northward Thursday night into Friday.",
],
[
"type" => "text",
Expand All @@ -244,7 +246,7 @@ final class AFDParserTest extends TestCase
"type" => "text",
"content" =>
"Forecast mainly on track. Much cooler air mass has worked into the " .
"region with the stationary front just of the of the area.",
"region with the stationary front just of the of the area.",
],
[
"type" => "subheader",
Expand All @@ -254,26 +256,27 @@ final class AFDParserTest extends TestCase
"type" => "text",
"content" =>
"High pressure builds down from the north into tonight, which will " .
"only reinforce some of the lower level cooler and drier air.",
"only reinforce some of the lower level cooler and drier air.",
],
[
"type" => "header",
"content" => "OKX WATCHES / WARNINGS / ADVISORIES",
"content" =>
"OKX WATCHES / WARNINGS / ADVISORIES",
"postHeader" => null,
],
[
"type" => "text",
"content" =>
"CT...None.\nNY...None.\nNJ...None.\nMARINE" .
"...Small Craft Advisory until 11 PM EDT " .
"this evening for ANZ350-353-355.",
"...Small Craft Advisory until 11 PM EDT " .
"this evening for ANZ350-353-355.",
],
[
"type" => "epilogueText",
"content" =>
"SYNOPSIS...JT/DW\nNEAR TERM...DS/DW\nSHORT" .
" TERM...DW\nLONG TERM...JT\nMARINE..." .
"JT/DW\nHYDROLOGY...JT/DW\nTIDES/COASTAL FLOODING...",
" TERM...DW\nLONG TERM...JT\nMARINE..." .
"JT/DW\nHYDROLOGY...JT/DW\nTIDES/COASTAL FLOODING...",
],
];

Expand All @@ -282,4 +285,186 @@ final class AFDParserTest extends TestCase

$this->assertEquals($expected, $actual);
}

/**
* @group unit
* @group afd-parser
*/
public function testPOPsTable(): void
{
$raw = "Place A 1 2 3 4 / 5 6 7 8
Place B 0 9 8 7 / 6 5 4 3";
// Remove leading spaces on test data.
$raw = preg_replace("/^\s*/m", "", $raw);

$expected = [
[
"type" => "temps-table",
"rows" => [
[
"type" => "temps-table-row",
"numbers" => ["1", "2", "3", "4", "5", "6", "7", "8"],
"name" => "Place A",
],
[
"type" => "temps-table-row",
"numbers" => ["0", "9", "8", "7", "6", "5", "4", "3"],
"name" => "Place B",
],
],
],
];

$parser = new AFDParser($raw);
$actual = [];
$parser->parseTempsTableContent($raw, $actual);

$this->assertEquals($expected, $actual);
}

/**
* @group unit
* @group afd-parser
*/
public function testGetStructureForTwig(): void
{
$raw = "\n";
$raw .= "000\n";
$raw .= "FXUS61 KOKX 071443\n";
$raw .= "AFDOKX\n";
$raw .= "\n";
$raw .= "Area Forecast Discussion\n";
$raw .= "National Weather Service New York NY\n";
$raw .= "1043 AM EDT Wed Aug 7 2024\n";
$raw .= "\n";
$raw .= ".SYNOPSIS...\n";
$raw .=
"A nearly stationary front will remain near the coast through \n";
$raw .=
"Thursday. The front will then return northward Thursday night\n";
$raw .= "into Friday. \n";
$raw .= "\n";
$raw .=
"Please refer to the latest official forecast on Debby from the \n";
$raw .= "National Hurricane Center.\n";
$raw .= "\n";
$raw .= "&&\n";
$raw .= "\n";
$raw .= ".NEAR TERM /THROUGH TONIGHT/...\n";
$raw .=
"Forecast mainly on track. Much cooler air mass has worked into the \n";
$raw .= "region with the stationary front just of the of the area.\n";
$raw .= "\n\n ...NY Metro (KEWR/KLGA/KJFK/KTEB) TAF Uncertainty...\n";
$raw .=
"High pressure builds down from the north into tonight, which will \n";
$raw .=
"only reinforce some of the lower level cooler and drier air. \n";
$raw .= "\n";
$raw .= ".OKX WATCHES/WARNINGS/ADVISORIES...\n";
$raw .= "CT...None.\n";
$raw .= "NY...None.\n";
$raw .= "NJ...None.\n";
$raw .=
"MARINE...Small Craft Advisory until 11 PM EDT this evening for ANZ350-\n";
$raw .= " 353-355.\n";
$raw .= "\n";
$raw .= " &&\n";
$raw .= "\n";
$raw .= " $$\n";
$raw .= "\n";
$raw .= " SYNOPSIS...JT/DW\n";
$raw .= " NEAR TERM...DS/DW\n";
$raw .= " SHORT TERM...DW\n";
$raw .= " LONG TERM...JT\n";
$raw .= " MARINE...JT/DW \n";
$raw .= " HYDROLOGY...JT/DW \n";
$raw .= " TIDES/COASTAL FLOODING...\n";

$expected = [
"preamble" => [
"code" => [
[
"type" => "preambleCode",
"content" => "000\nFXUS61 KOKX 071443\nAFDOKX",
],
],
"text" => [
[
"type" => "preambleText",
"content" =>
"Area Forecast Discussion\nNational Weather Service " .
"New York NY\n1043 AM EDT Wed Aug 7 2024",
],
],
],
"body" => [
[
"type" => "header",
"content" => "SYNOPSIS",
"postHeader" => null,
],
[
"type" => "text",
"content" =>
"A nearly stationary front will remain near the coast through" .
" Thursday. The front will then return northward Thursday night into Friday.",
],
[
"type" => "text",
"content" =>
"Please refer to the latest official forecast on Debby from the National Hurricane Center.",
],
[
"type" => "header",
"content" => "NEAR TERM /THROUGH TONIGHT/",
"postHeader" => null,
],
[
"type" => "text",
"content" =>
"Forecast mainly on track. Much cooler air mass has worked into the " .
"region with the stationary front just of the of the area.",
],
[
"type" => "subheader",
"content" =>
"NY Metro (KEWR/KLGA/KJFK/KTEB) TAF Uncertainty",
],
[
"type" => "text",
"content" =>
"High pressure builds down from the north into tonight, which will " .
"only reinforce some of the lower level cooler and drier air.",
],
[
"type" => "header",
"content" =>
"OKX WATCHES / WARNINGS / ADVISORIES",
"postHeader" => null,
],
[
"type" => "text",
"content" =>
"CT...None.\nNY...None.\nNJ...None.\nMARINE" .
"...Small Craft Advisory until 11 PM EDT " .
"this evening for ANZ350-353-355.",
],
],
"epilogue" => [
[
"type" => "epilogueText",
"content" =>
"SYNOPSIS...JT/DW\nNEAR TERM...DS/DW\nSHORT" .
" TERM...DW\nLONG TERM...JT\nMARINE..." .
"JT/DW\nHYDROLOGY...JT/DW\nTIDES/COASTAL FLOODING...",
],
],
];

$parser = new AFDParser($raw);
$parser->parse();
$actual = $parser->getStructureForTwig();

$this->assertEquals($expected, $actual);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% if content.title %}
{{ attach_library("new_weather_theme/localize-timestamps") }}
<div class="grid-container padding-bottom-2 padding-x-0 tablet:padding-x-2">
<div class="margin-x-2 tablet:margin-x-auto tablet:grid-container margin-bottom-1 padding-x-0 tablet:padding-x-2">
<div class="grid-row">
<div class="grid-col-12 tablet-lg:grid-offset-2 tablet-lg:grid-col-8">
<div class="usa-accordion usa-accordion--bordered margin-bottom-1" id="weather-story">
<div class="usa-accordion usa-accordion--bordered" id="weather-story">
<h3 class="usa-accordion__heading font-heading-lg">
<button
type="button"
Expand Down
Loading

0 comments on commit 2877dc8

Please sign in to comment.