Skip to content

Commit

Permalink
0.42.14 Awards - Refactoring and added North of 60 and LT awards
Browse files Browse the repository at this point in the history
  • Loading branch information
classaxe committed Mar 6, 2020
1 parent 42df36e commit aa6382a
Show file tree
Hide file tree
Showing 21 changed files with 348 additions and 113 deletions.
5 changes: 3 additions & 2 deletions public/js/functions.js
@@ -1,8 +1,8 @@
/*
* Project: RXX - NDB Logging Database
* Homepage: https://rxx.classaxe.com
* Version: 0.42.5
* Date: 2020-03-01
* Version: 0.42.14
* Date: 2020-03-06
* Licence: LGPL
* Copyright: 2020 Martin Francis
*/
Expand Down Expand Up @@ -41,6 +41,7 @@ var popWinSpecs = {
'signals_[id]' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_logs' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_listeners' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_map' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_weather' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'states_*' : 'width=720,height=760,resizable=1',
'states_aus' : 'width=720,height=240,resizable=1',
Expand Down
6 changes: 3 additions & 3 deletions public/js/functions.min.js

Large diffs are not rendered by default.

111 changes: 79 additions & 32 deletions src/Controller/Web/Listeners/ListenerAwards.php
Expand Up @@ -63,17 +63,22 @@ public function controller(
}
$family = explode('_', $type)[0];
switch($family) {
case 'continental':
$awards[$type] = $this->getContinentalDx($type);
break;
case 'country':
$awards[$type] = $this->getCountryDx($type);
break;
case 'daytime':
case 'longranger':
$awards[$type] = $this->getBestDx($type);
break;
case 'region':
$awards[$type] = $this->getRegionDx($type);
case 'lt':
$awards[$type] = $this->getSingle($type);
break;
case 'country':
$awards[$type] = $this->getCountryDx($type);
case 'north60':
$awards[$type] = $this->getNorth60($type);
break;

}
}

Expand Down Expand Up @@ -126,6 +131,47 @@ private function getBestDx($award)
return $result;
}

private function getContinentalDx($award)
{
$ranges = $this->awardRepository->getAwardSpec($award);
$region = explode('_', $award)[1];
$result = [ 'total' => 0 ];
foreach ($ranges as $range) {
$result[$range] = [];
}
$places = [];
foreach ($this->signals as $signal) {
if ($signal['region'] !== $region) {
continue;
}
switch ($signal['place']) {
case "HI":
$place = 'HWA';
break;
case "PR":
$place = 'PTR';
break;
default:
$place = $signal['place'];
break;
}
$places[$place] = true;
}
$places = array_keys($places);
sort($places);
$offset = 0;
$result['total'] = count($places);
foreach ($ranges as $range) {
for ($i = 0; $i < $range - $offset; $i++) {
if (count($places)) {
$result[$range][] = array_shift($places);
}
}
$offset = $range;
}
return $result;
}

private function getCountryDx($award)
{
$spec = $this->awardRepository->getAwardSpec($award);
Expand Down Expand Up @@ -182,44 +228,45 @@ private function getCountryDx($award)
return $result;
}

private function getRegionDx($award)
private function getNorth60($award)
{
$ranges = $this->awardRepository->getAwardSpec($award);
$region = explode('_', $award)[1];
$result = [ 'total' => 0 ];
foreach ($ranges as $range) {
$spec = $this->awardRepository->getAwardSpec($award);
$result = [ 'total' => 10 ];
foreach ($spec as $range) {
$result[$range] = [];
}
$places = [];
foreach ($this->signals as $signal) {
if ($signal['region'] !== $region) {
$filtered = [];
foreach ($this->signals as $s) {
if ($s['lat'] < 60) {
continue;
}
switch ($signal['place']) {
case "HI":
$place = 'HWA';
break;
case "PR":
$place = 'PTR';
break;
default:
$place = $signal['place'];
break;
}
$places[$place] = true;
$filtered[$s['khz'].'-'.$s['call']] = $s;
}
$places = array_keys($places);
sort($places);
$result['total'] = count($filtered);
$offset = 0;
$result['total'] = count($places);
foreach ($ranges as $range) {
for ($i = 0; $i < $range - $offset; $i++) {
if (count($places)) {
$result[$range][] = array_shift($places);
foreach ($spec as $range) {
$taken = count($result[$range]);
for ($i = 0; $i < $range - $offset - $taken; $i++) {
if (count($filtered)) {
$f = array_shift($filtered);
$f['required'] = false;
$result[$range][] = $f;
}
}
$offset = $range;
}
return $result;
}

private function getSingle($award)
{
$spec = $this->awardRepository->getAwardSpec($award);
foreach ($this->signals as $s) {
if ($s['call'] === $spec['call'] && (float)$s['khz'] === (float)$spec['khz']) {
return $s;
}
}
return false;
}

}
50 changes: 26 additions & 24 deletions src/Repository/AwardRepository.php
Expand Up @@ -5,30 +5,14 @@
class AwardRepository
{
const AWARDSPEC = [
'daytime' => [
[ 250, 499, 402, 804 ],
[ 500, 749, 805, 1205 ],
[ 750, 999, 1206, 1607 ],
[ 1000, 1249, 1608, 2010 ],
[ 1250, 0, 1608, 0 ]
],
'longranger' => [
[ 500, 999, 805, 1607 ],
[ 1000, 1499, 1608, 2413 ],
[ 1500, 1999, 2414, 3217 ],
[ 2000, 2499, 3218, 4022 ],
[ 2500, 2999, 4023, 4826 ],
[ 3000, 4999, 4827, 8044 ],
[ 5000, 0, 8045, 0 ]
],
'region_eu' => [ 10, 20, 30, 40 ],
'region_na' => [ 10, 30, 45, 60 ],
'region_ca' => [ 3, 10, 15, 20 ],
'region_sa' => [ 1, 3, 5, 10 ],
'region_af' => [ 1, 5, 10, 15 ],
'region_as' => [ 1, 3, 5, 10 ],
'region_oc' => [ 1, 3, 5, 10 ],
'region_an' => [ 1 ],
'continental_eu' => [ 10, 20, 30, 40 ],
'continental_na' => [ 10, 30, 45, 60 ],
'continental_ca' => [ 3, 10, 15, 20 ],
'continental_sa' => [ 1, 3, 5, 10 ],
'continental_af' => [ 1, 5, 10, 15 ],
'continental_as' => [ 1, 3, 5, 10 ],
'continental_oc' => [ 1, 3, 5, 10 ],
'continental_an' => [ 1 ],
'country_benelux' => [
'ALL' => true,
'ITU' => [ 'BEL', 'HOL', 'LUX' ],
Expand Down Expand Up @@ -64,6 +48,24 @@ class AwardRepository
'ITU' => [ 'ESP', 'POR', 'BAL' ],
'QTY' => [ 20, 40, 60, 90 ]
],
'daytime' => [
[ 250, 499, 402, 804 ],
[ 500, 749, 805, 1205 ],
[ 750, 999, 1206, 1607 ],
[ 1000, 1249, 1608, 2010 ],
[ 1250, 0, 1608, 0 ]
],
'north60' => [ 5, 10, 20, 30 ],
'longranger' => [
[ 500, 999, 805, 1607 ],
[ 1000, 1499, 1608, 2413 ],
[ 1500, 1999, 2414, 3217 ],
[ 2000, 2499, 3218, 4022 ],
[ 2500, 2999, 4023, 4826 ],
[ 3000, 4999, 4827, 8044 ],
[ 5000, 0, 8045, 0 ]
],
'lt' => [ 'call' => 'LT', 'khz' => 305 ]
];

/**
Expand Down
1 change: 1 addition & 0 deletions src/js/_globals.js
Expand Up @@ -33,6 +33,7 @@ var popWinSpecs = {
'signals_[id]' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_logs' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_listeners' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_map' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'signals_[id]_weather' : 'width=1040,height=800,status=1,scrollbars=1,resizable=1',
'states_*' : 'width=720,height=760,resizable=1',
'states_aus' : 'width=720,height=240,resizable=1',
Expand Down
6 changes: 5 additions & 1 deletion templates/i18n.html.twig
Expand Up @@ -819,14 +819,18 @@
{% trans %}This certificate recognises reception of NDBs located in France at the following levels:{% endtrans %}
{% trans %}German NDB Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located in Germany at the following levels:{% endtrans %}
{% trans %}Scandanavian NDB Award{% endtrans %}
{% trans %}Scandinavian NDB Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located in Sweden, Norway, Finland or Denmark (but excluding Iceland and island dependencies in the North Atlantic) at the following levels:{% endtrans %}
{% trans %}UK and Irish NDB Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located in the United Kingdom (including Northern Ireland, the Channel Island, the Isle of Man and the Shetland Islands) and the republic of Ireland at the following levels:{% endtrans %}
{% trans %}Italian NDB Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located in Italy (including Sardinia and Sicily) at the following levels:{% endtrans %}
{% trans %}Iberian NDB Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located in Spain and Portugal (including the Baleric Islands but excluding the Azores, the Canary Islands and spanish enclaves in Morocco) at the following levels:{% endtrans %}
{% trans %}LT Award{% endtrans %}
{% trans %}This certificate recognises reception of a single NDBs: LT on 305 KHz, at Alert, Nunavut, in Canada. This is the highest latitude NDB known in the Northern Hemisphere.{% endtrans %}
{% trans %}North of 60 Award{% endtrans %}
{% trans %}This certificate recognises reception of NDBs located at least 60 Degrees of latitude north of the Equator. This area includes Iceland, Greenland and Alaska as well as most of Scandinavia and parts of Russia and Canada.{% endtrans %}
{% trans %}{% endtrans %}
{% endif %}

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions templates/listener/awards/awards.html.twig
Expand Up @@ -16,15 +16,15 @@
<p>{% trans %}Virtually all listeners who desire them can get at least one in each category. The 'difficulty factor' in each ranges from modest to a level that even experienced listeners will find challenging. In setting these requirements, we have kept in mind the fact that the vast majority of List members are in either Europe or North America.{% endtrans %}</p>
<p>{% trans %}To request an award, click on the shopping-cart icon besides the award name and category.{% endtrans %}</p>
</div>
{% include 'listener/awards/dx_list.html.twig' %}
{% include 'listener/awards/daytime.html.twig' %}
{% include 'listener/awards/longranger.html.twig' %}
{% include 'listener/awards/continental.html.twig' %}
{% include 'listener/awards/country_list.html.twig' %}
{% include 'listener/awards/north60.html.twig' %}
{% include 'listener/awards/lt.html.twig' %}
{% include 'listener/awards/transatlantic.html.twig' %}
{% include 'listener/awards/transpacific.html.twig' %}
{% include 'listener/awards/canadiantranscontinental.html.twig' %}
{% include 'listener/awards/region_list.html.twig' %}
{% include 'listener/awards/country_list.html.twig' %}
</div>
</div>
</div>
Expand Down
39 changes: 39 additions & 0 deletions templates/listener/awards/continental.html.twig
@@ -0,0 +1,39 @@
{% set award = 'continental_eu' %}
{% set award_title = "European NDB DX Awards" | trans %}
{% set award_info = "This certificate recognises reception of NDBs located in Europe at the levels shown below." | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_na' %}
{% set award_title = "North American NDB DX Awards" | trans %}
{% set award_info = "This certificate recognises reception of NDBs located in in North America. Remember that each US state and Canadian province is considered a separate 'country'." | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_ca' %}
{% set award_title = "Caribbean / Central American NDB DX Awards" | trans %}
{% set award_info = "Available in the following categories:" | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_sa' %}
{% set award_title = "South American NDB DX Awards" | trans %}
{% set award_info = "Available in the following categories:" | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_af' %}
{% set award_title = "African NDB DX Awards" | trans %}
{% set award_info = "Available in the following categories:" | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_as' %}
{% set award_title = "Asian NDB DX Awards" | trans %}
{% set award_info = "Available in the following categories:" | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_oc' %}
{% set award_title = "Australian and Pacific Islands NDB DX Awards" | trans %}
{% set award_info = "Get it in these 'denominations'" | trans %}
{% include 'listener/awards/_continental.html.twig' %}

{% set award = 'continental_an' %}
{% set award_title = "Antarctic NDB DX Awards" | trans %}
{% set award_info = "If anyone hears a NDB from this frozen place, they will definately receive an award!" | trans %}
{% include 'listener/awards/_continental.html.twig' %}
4 changes: 4 additions & 0 deletions templates/listener/awards/daytime.html.twig
@@ -0,0 +1,4 @@
{% set award = 'daytime' %}
{% set award_title = "Daytime DX Awards (Daytime hours are %START% - %END% hrs UTC)" | trans({ '%START%' : daytime_start, '%END%' : daytime_end }) %}
{% set award_info = "This certificate recognises long distance reception of NDBs between the hours of 1000 and 1400 local standard time - that is, two hours before and afer noon in the listener's timezone." | trans %}
{% include 'listener/awards/dx.html.twig' %}
9 changes: 0 additions & 9 deletions templates/listener/awards/dx_list.html.twig

This file was deleted.

4 changes: 4 additions & 0 deletions templates/listener/awards/longranger.html.twig
@@ -0,0 +1,4 @@
{% set award = 'longranger' %}
{% set award_title = "Long Ranger DX Awards" | trans %}
{% set award_info = "This certificate recognises really long distance reception of NDBs particularly at night when skywave propagation is possible that is, two hours before and afer noon in the listener's timezone." | trans %}
{% include 'listener/awards/dx.html.twig' %}
4 changes: 4 additions & 0 deletions templates/listener/awards/lt.html.twig
@@ -0,0 +1,4 @@
{% set award = 'lt' %}
{% set award_title = "LT Award" | trans %}
{% set award_info = "This certificate recognises reception of a single NDBs: LT on 305 KHz, at Alert, Nunavut, in Canada. This is the highest latitude NDB known in the Northern Hemisphere." | trans %}
{% include 'listener/awards/signal.html.twig' %}
4 changes: 4 additions & 0 deletions templates/listener/awards/north60.html.twig
@@ -0,0 +1,4 @@
{% set award = 'north60' %}
{% set award_title = "North of 60 Award" | trans %}
{% set award_info = "This certificate recognises reception of NDBs located at least 60 Degrees of latitude north of the Equator. This area includes Iceland, Greenland and Alaska as well as most of Scandinavia and parts of Russia and Canada." | trans %}
{% include 'listener/awards/signals.html.twig' %}
39 changes: 0 additions & 39 deletions templates/listener/awards/region_list.html.twig

This file was deleted.

0 comments on commit aa6382a

Please sign in to comment.