New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add weather layer on main page #2420
base: develop
Are you sure you want to change the base?
Add weather layer on main page #2420
Conversation
Awesome work <3 |
@blakewenloe weather on top bar only shows up if a single s2cell is on the screen otherwise it wont show any, theres |
@blakewenloe There is a red alert for extreme severity too. When a warning appears, weather bonuses stop working. |
@codename-art I thought they patched that to where the user just has to tap the "I'm safe" button and weather bonuses still apply? I may be wrong, but I'm seeing that in my personal game (we have extreme weather alert right now) at least. |
@blakewenloe maybe I have wrong or outdated information. I'll figure out how to do it right. |
@codename-art this is an example of the prompts we go through in extreme weather if that helps. |
@@ -2333,6 +2459,8 @@ def parse_map(args, map_dict, scan_coords, scan_location, db_update_queue, | |||
db_update_queue.put((ScanSpawnPoint, scan_spawn_points)) | |||
if sightings: | |||
db_update_queue.put((SpawnpointDetectionData, sightings)) | |||
if weather: | |||
db_update_queue.put((Weather, weather)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We know that weather updates every hour. So may be we can update db every hour or so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i set it up to update continuously because of severity alerts, i have also added everything needed for this to work with poke alarm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added check for ignoring updates in same hour.
static/js/weather.js
Outdated
imageUrl = imageUrl.replace('weather_', 'weather_light_') | ||
} | ||
return imageUrl | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static/js/weather.js
Outdated
position: item.center, | ||
icon: image | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome it got submitted for default RM, this is my backend work and A.R.Ts front end work :) |
@codename-art ive made some more changes to my copy since weather alerts are passable now you might want to pull them |
There is a lot of evidence that weather is based on Level 11 cells. I won’t say that this is 100% certain but at least i would make the cell level configurable so people can decide themselves. |
@peterbaumert From inspecting the data coming back from API requests we have concluded that weather is based on strictly level 10 cells. If this changes we can consider making the cells dynamic, but for various reasons relating to Niantic's approach for pulling data this seems unlikely. |
@pogo-excalibur ok if api data proofs it, it’s fine with me. I will crosscheck once released with my two spots where weather changes ingame and which are only level 11 borders. |
Please remove ingame icons since they can’t be distributed in this pr |
yes they will half to be removed for public ops lol |
@sirlindqvist i used this icons for this PR http://adamwhitcroft.com/climacons/ and https://commons.wikimedia.org/wiki/File:Exclamation_Circle_Red.svg |
@codename-art Think you can fix the Travis issues? |
finally figured out the flake8 warnings. Idea automatically performed the formatting of the modified code before commit and canceled my changes |
pogom/app.py
Outdated
lines += td(WeatherAlert.Severity.Name(s['severity'])) | ||
lines += td(s['warn_weather']) | ||
lines += td(s['last_updated']) | ||
lines += td(pgoapi.protos.pogoprotos.networking.responses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't that be:
pgoapi.protos.pogoprotos.networking.responses.get_map_objects_response_pb2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to be honest im not sure what art did here, i have it as
lines += td(GetMapObjectsResponse.TimeOfDay.Name(s['world_time']))
This doesn't need to be included ~ def get_weather(self, page=1): .......before art did the nice frontend for weather i just set this up as a temp status page to be able to see the info from a browser, its technically not needed anymore, i think art just merged ALL my changes lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, some imports were refactored and thus the access to the protos was changed.
But here something got lost, which leads to an exception. :)
I kinda like the little status page. It is ugly and even missing basic html tags, but it works. xD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rework this page with template. Looks the same, but propper html tags and custom.js / custom.css acceptable.
static/js/weather.js
Outdated
$.each(mapData.weather, (i, item) => { | ||
if (item.hasOwnProperty('marker') && item.marker) { | ||
item.marker.setIcon(createMarkerIcon(item.marker.icon.url)) | ||
item.marker.setMap(map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you should call setMap again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michikrug You're right, it might not affect anything as we only update the icon. That being said, the old icon can still be drawn on the map if the GMaps API doesn't remove it from the map when we update the marker.
In other code for removal, we use
old.setMap(null)
new.setMap(map)
Thoughts? Have you experimented with GMaps' redraws? Did you test your code changes, and did they actually fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think when you call setIcon the marker icon is just replaced. There is no need to remove the "old" one.
I use the code in my fork and faced no issues so far.
The removal from the map is only necessary if we want to completely remove or replace the whole marker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michikrug That's what I assumed, but then these code updates haven't changed the behavior of the drawing or updating, so the overlap issue should persist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. Before we were calling the setIcon and setMap on every map scale event for every added marker, which could lead to again adding "old" markers to the map.
The scale event listener for old markers was never removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michikrug You're absolutely correct. 👍 I forgot that the events were being added on each marker (wow...).
pogom/app.py
Outdated
@@ -433,6 +501,19 @@ def raw_data(self): | |||
d['main_workers'] = MainWorker.get_all() | |||
d['workers'] = WorkerStatus.get_all() | |||
|
|||
if (request.args.get('weather', 'false') == 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move all the weather request handles above the if request.args.get('status', 'false') == 'true':
above and fix indentation (it's currently inside the if for status page)
docs/extras/webhooks.md
Outdated
1. Possible weather conditions: | ||
|
||
| Status | Description | | ||
| ------ | ------------------------------------------ | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should probably include option 0: No weather
gameplay_weather = SmallIntegerField(null=True, index=True, default=0) | ||
severity = SmallIntegerField(null=True, index=True, default=0) | ||
warn_weather = SmallIntegerField(null=True, index=True, default=0) | ||
world_time = SmallIntegerField(null=True, index=True, default=0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why SmallIntegerField
rather than DateTimeField
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrap this, I've remembered the relevant proto: It's an enum value representing night/day, not actually a time.
pogom/models.py
Outdated
now = datetime.now() | ||
weather_last_updated = status['weather_last_updated'].get( | ||
s2_cell_id, datetime.utcfromtimestamp(1) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation.
pogom/models.py
Outdated
|
||
del map_dict['responses']['GET_MAP_OBJECTS'] | ||
# Convert cell to lat, lng. | ||
cell_id = s2sphere.CellId(long(s2_cell_id)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the long()
here necessary?
pogom/models.py
Outdated
|
||
# Hourly weather update (on the hour). | ||
if display_weather: | ||
gameplayweather = gameplay_weather.gameplay_condition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gameplayweather
=> weather_condition
(Or something similar)
pogom/search.py
Outdated
# Print the status_text for the current screen. | ||
status_text.append(( | ||
'Page {}/{}. Page number to switch pages. F to show on hold ' + | ||
'accounts. H to show hash status. <ENTER> alone to switch ' + | ||
'accounts. H to show hash status. W to show weather status.' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standardise where the spaces are:
'accounts. H to show hash status. W to show weather status. ' +
'<ENTER> alone to switch ' +
pogom/utils.py
Outdated
@@ -416,6 +420,11 @@ def get_args(): | |||
'after last valid scan. ' | |||
'Default: 0, 0 to disable.'), | |||
type=int, default=0) | |||
group.add_argument('-DCs2', '--db-cleanup-s2-weather', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that the s2
prefix is necessary here.
I'd prefer -DCwe
over -DCs2
.
pogom/utils.py
Outdated
def degrees_to_cardinal(d): | ||
dirs = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", | ||
"S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"] | ||
ix = int((d + 11.25)/22.5 - 0.02) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces and brackets (check I've put them in the right place): int(((d + 11.25) / 22.5) - 0.02)
return db_weathers | ||
|
||
|
||
# Workaround due a bug in POGOprotos. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Including details of the bug would be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a comment from the original author, who is MIA. I assume this might no longer be an issue, but if it's not an issue (and it never overflows) then it'll always follow the else
branch. To be on the safe side, we'll keep it as is.
pogom/app.py
Outdated
] | ||
|
||
max_weather_per_page = 25 | ||
max_page = int(math.ceil(len(db_weather)/float(max_weather_per_page))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spaces: int(math.ceil(len(db_weather) / float(max_weather_per_page)))
static/js/weather.js
Outdated
* @param item | ||
* @returns {*} | ||
*/ | ||
function getalertImageUrl(item) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getalertImageUrl
=> getAlertImageUrl
static/js/weather.js
Outdated
* @returns {*} | ||
*/ | ||
function getalertImageUrl(item) { | ||
var alertimageUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertimageUrl
=> alertImageUrl
} | ||
}) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extra newline.
Standardise the newlines - some breaks have one and some have two.
I am repeating some feedback from above that may have been lost. This is from many users on my map providing feedback. I think these should be straightforward to implement and make a lot of sense
I need to go retest if any of this has been addressed. It's not obvious from commits above. |
I personally think the weather in the top bar is confusing. I think the most intuitive use would be to show current weather condition at your location. But it is actually showing the weather of where you have moved to, which is already being shown by an icon on the map or color coding (if suggestion above is taken) so this seems redundant and not intuitive. |
115aa2d
to
f1d51c4
Compare
f1d51c4
to
a3c2d45
Compare
I see in the .md file that the time is listed as 'world time'. As I mentioned above, that is not particularly useful for most users and the time should be localized like everywhere else (or most everywhere) in RM. |
|
Based on conversation in Reviewers, we should set a limit to how far out the map can be zoomed before we stop attempting to draw the cells on the map. This fixes potentially performance impacting issue where the map attempts to generate the cell boundaries for whatever portion of the map is visible. |
As far as i can tell weather is only shown in the cells that are scanned though unless i am reading this wrong.. No matter the zoom on my setup anyway only the scanned area shows any weather activity |
but all cells, despite whether they contain information, are drawn on the
map, which takes time to calculate the boundaries of each cell and display
it.
…On Thu, Mar 15, 2018 at 9:10 AM, TᴀͪsͤʜᴋᴇᴛᴄʜͬᴜͤᴍͣL ***@***.*** > wrote:
As far as i can tell weather is only shown in the cells that are scanned
though unless i am reading this wrong.. No matter the zoom on my setup
anyway only the scanned area shows any weather activity
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2420 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC37vVKf5pMkibtJGw755wYLJb0RDlSXks5temg0gaJpZM4RROYp>
.
--
*Billy J Bryant*
*Certified IT Professional*
billy@billyjbryant.com
www.billyjbryant.com
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldnt reproduce the duplicated icon bug after latest changes. also i think the ideas in the discussion should be noticed and adressed later with seperate prs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from zooming limit for S2Cell, everything is fine.
Description
Adds visualization of weather to the main page. There are three display options:
Motivation and Context
Weather conditions strongly affect the game mechanics. Visualizing the weather on the map will help, for example, in finding raids with weather boosts. Also weather updates can help in finding of obsolete encounter info.
How Has This Been Tested?
On my own map
Screenshots (if appropriate):
Weather icons
s2Cells
different weather allerts
Weather info and wind direction on top bar if screen covers more then a half of s2cell
Weather report for all cells in browser (/weather)
Weather report for all cells in console
Types of changes
Checklist:
Great participation in the development took @SkOODaT