Skip to content

Commit

Permalink
nest polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
whitewillem committed Mar 2, 2019
1 parent 60f8bf7 commit 2b3512d
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 5 deletions.
4 changes: 3 additions & 1 deletion config/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@
$excludeNestMons = [2,3,5,6,8,9,11,12,14,15,17,18,20,22,24,26,28,29,30,31,32,33,34,36,38,40,42,44,45,49,51,53,55,57,59,61,62,64,65,67,68,70,71,73,75,76,78,80,82,83,85,87,88,89,91,93,94,97,99,101,103,105,106,107,108,109,110,112,113,114,115,117,119,121,122,128,130,131,132,134,135,136,137,139,142,143,144,145,146,147,148,149,150,151,153,154,156,157,159,160,161,162,163,164,165,166,167,168,169,171,172,173,174,175,176,177,178,179,180,181,182,183,184,186,187,188,189,191,192,194,195,196,197,199,201,204,205,207,208,210,212,214,217,218,219,221,222,223,224,225,228,229,230,232,233,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,253,254,256,257,259,260,262,263,264,265,266,267,268,269,270,271,272,274,275,276,277,279,280,281,282,284,286,287,288,289,290,291,292,293,294,295,297,298,301,303,304,305,306,308,310,313,314,316,317,319,321,323,324,326,327,328,329,330,331,332,334,335,336,337,338,339,340,342,344,346,348,349,350,351,352,354,356,357,358,359,360,361,362,363,364,365,366,367,368,369,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386];
$nestCoords = array(); //$nestCoords = array(array('lat1' => 42.8307723529682, 'lng1' => -88.7527692278689, 'lat2' => 42.1339901128552, 'lng2' => -88.0688703020877),array( 'lat1' => 42.8529250952743,'lng1' => -88.1292951067752,'lat2' => 41.7929306950085,'lng2' => -87.5662457903689));


$noNestPolygon = false;
$enableNestPolygon = 'false';
$nestGeoJSONfile = 'custom/nest.json'; // path to geoJSON file provided by https://github.com/M4d40/PMSFnestScript
//-----------------------------------------------------
// Areas
//-----------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion config/example.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@
$excludeNestMons = [2,3,5,6,8,9,11,12,14,15,17,18,20,22,24,26,28,29,30,31,32,33,34,36,38,40,42,44,45,49,51,53,55,57,59,61,62,64,65,67,68,70,71,73,75,76,78,80,82,83,85,87,88,89,91,93,94,97,99,101,103,105,106,107,108,109,110,112,113,114,115,117,119,121,122,128,130,131,132,134,135,136,137,139,142,143,144,145,146,147,148,149,150,151,153,154,156,157,159,160,161,162,163,164,165,166,167,168,169,171,172,173,174,175,176,177,178,179,180,181,182,183,184,186,187,188,189,191,192,194,195,196,197,199,201,204,205,207,208,210,212,214,217,218,219,221,222,223,224,225,228,229,230,232,233,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,253,254,256,257,259,260,262,263,264,265,266,267,268,269,270,271,272,274,275,276,277,279,280,281,282,284,286,287,288,289,290,291,292,293,294,295,297,298,301,303,304,305,306,308,310,313,314,316,317,319,321,323,324,326,327,328,329,330,331,332,334,335,336,337,338,339,340,342,344,346,348,349,350,351,352,354,356,357,358,359,360,361,362,363,364,365,366,367,368,369,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386];
$nestCoords = array(); //$nestCoords = array(array('lat1' => 42.8307723529682, 'lng1' => -88.7527692278689, 'lat2' => 42.1339901128552, 'lng2' => -88.0688703020877),array( 'lat1' => 42.8529250952743,'lng1' => -88.1292951067752,'lat2' => 41.7929306950085,'lng2' => -87.5662457903689));


$noNestPolygon = false;
$enableNestPolygon = 'false';
$nestGeoJSONfile = 'custom/nest.json'; // path to geoJSON file provided by https://github.com/M4d40/PMSFnestScript
//-----------------------------------------------------
// Areas
//-----------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion gym_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$scanner = new \Scanner\Monocle_PMSF();
}
} elseif (strtolower($map) === "rdm") {
if (strtolower($fork) === "public") {
if (strtolower($fork) === "default") {
$scanner = new \Scanner\RDM();
} else {
$scanner = new \Scanner\RDM_beta();
Expand Down
15 changes: 15 additions & 0 deletions pre-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,19 @@ class="onoffswitch-checkbox" checked>
</label>
</div>
</div>';
} ?>
<?php
if ( ! $noNestPolygon && ! $noNests ) {
echo '<div class="form-control switch-container">
<h3>' . i8ln( 'Nest Polygon' ) . '</h3>
<div class="onoffswitch">
<input id="nest-polygon-switch" type="checkbox" name="nest-polygon-switch" class="onoffswitch-checkbox">
<label class="onoffswitch-label" for="nest-polygon-switch">
<span class="switch-label" data-on="On" data-off="Off"></span>
<span class="switch-handle"></span>
</label>
</div>
</div>';
} ?>
<div id="pokemon-filter-wrapper" style="display:none">
<?php
Expand Down Expand Up @@ -1940,6 +1953,8 @@ class="fa fa-comments"
var noWeatherShadow = <?php echo $noWeatherShadow === true ? 'true' : 'false' ?>;
var noRaidTimer = <?php echo $noRaidTimer === true ? 'true' : 'false' ?>;
var enableRaidTimer = <?php echo $noRaidTimer ? 'false' : $enableRaidTimer ?>;
var enableNestPolygon = <?php echo $noNestPolygon ? 'false' : $enableNestPolygon ?>;
var nestGeoJSONfile = '<?php echo $noNestPolygon ? '' : $nestGeoJSONfile ?>';
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<script src="static/dist/js/map.common.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion raw_data.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
$scanner = new \Scanner\Monocle_PMSF();
}
} elseif (strtolower($map) === "rdm") {
if (strtolower($fork) === "public") {
if (strtolower($fork) === "default") {
$scanner = new \Scanner\RDM();
} else {
$scanner = new \Scanner\RDM_beta();
Expand Down
5 changes: 5 additions & 0 deletions static/js/map.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,11 @@ var StoreOptions = {
default: enableScanPolygon,
type: StoreTypes.Boolean
},
'showNestPolygon':
{
default: enableNestPolygon,
type: StoreTypes.Boolean
},
'playSound':
{
default: notifySound,
Expand Down
29 changes: 28 additions & 1 deletion static/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ var gymLayerGroup = new L.LayerGroup()
var stopLayerGroup = new L.LayerGroup()
var scanAreaGroup = new L.LayerGroup()
var scanAreas = []
var nestLayerGroup = new L.LayerGroup()
/*
text place holders:
<pkm> - pokemon name
Expand Down Expand Up @@ -276,7 +277,7 @@ function initMap() { // eslint-disable-line no-unused-vars
minZoom: minZoom,
maxZoom: maxZoom,
zoomControl: false,
layers: [weatherLayerGroup, exLayerGroup, gymLayerGroup, stopLayerGroup, scanAreaGroup]
layers: [weatherLayerGroup, exLayerGroup, gymLayerGroup, stopLayerGroup, scanAreaGroup, nestLayerGroup]
})

setTileLayer(Store.get('map_style'))
Expand Down Expand Up @@ -345,6 +346,7 @@ function initMap() { // eslint-disable-line no-unused-vars
updateWeatherOverlay()
updateS2Overlay()
buildScanPolygons()
buildNestPolygons()

map.on('moveend', function () {
updateS2Overlay()
Expand Down Expand Up @@ -490,6 +492,21 @@ function buildScanPolygons() {
})
}

function buildNestPolygons() {
if (!Store.get(['showNestPolygon'])) {
return false
}

$.getJSON(nestGeoJSONfile, function (data) {
var nestGeoPolys = L.geoJson(data, {
onEachFeature: function (features, featureLayer) {
featureLayer.bindPopup(features.properties.name)
}
})
nestLayerGroup.addLayer(nestGeoPolys)
})
}

function initSidebar() {
$('#gyms-switch').prop('checked', Store.get('showGyms'))
$('#nests-switch').prop('checked', Store.get('showNests'))
Expand Down Expand Up @@ -539,6 +556,7 @@ function initSidebar() {
$('#direction-provider').val(Store.get('directionProvider'))
$('#ranges-switch').prop('checked', Store.get('showRanges'))
$('#scan-area-switch').prop('checked', Store.get('showScanPolygon'))
$('#nest-polygon-switch').prop('checked', Store.get('showNestPolygon'))
$('#raid-timer-switch').prop('checked', Store.get('showRaidTimer'))
$('#sound-switch').prop('checked', Store.get('playSound'))
$('#cries-switch').prop('checked', Store.get('playCries'))
Expand Down Expand Up @@ -6285,6 +6303,15 @@ $(function () {
}
})

$('#nest-polygon-switch').change(function () {
Store.set('showNestPolygon', this.checked)
if (this.checked) {
buildNestPolygons()
} else {
nestLayerGroup.clearLayers()
}
})

$('#raid-timer-switch').change(function () {
Store.set('showRaidTimer', this.checked)
lastgyms = false
Expand Down

0 comments on commit 2b3512d

Please sign in to comment.