Skip to content
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

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from

Conversation

codename-art
Copy link

@codename-art codename-art commented Jan 3, 2018

Description

Adds visualization of weather to the main page. There are three display options:

  • weather icons for the present weather,
  • mesh of s2cells (size 10), each cell have the same weather,
  • weather alers: add color for cells with alert.

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
image
s2Cells
image
different weather allerts
image
Weather info and wind direction on top bar if screen covers more then a half of s2cell
image
Weather report for all cells in browser (/weather)
image
Weather report for all cells in console
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Great participation in the development took @SkOODaT

@Alderon86
Copy link
Contributor

Awesome work <3

@ghost
Copy link

ghost commented Jan 3, 2018

The S2 cells are working as intended, but I'm getting undefined undefined on the top-bar and no weather icons on the map itself.
screenshot 2018-01-02 18 28 59

@ghost
Copy link

ghost commented Jan 3, 2018

^ It's starting to populate the icons now as areas are being rescanned but shows what's in the above screenshot until I zoom in.

So the behavior i'm getting is:

Zoomed out really far - No weather icons in the top-bar. Assuming that's intended.

Zoomed into to fit 2 s2 cells in the viewport - top-bar displays: undefined undefined

Zoomed into to fit most of 1 s2 cell in the viewport - top-bar displays weather status, but the words and icons need a little padding between them:
screenshot 2018-01-02 18 47 11

This is in Chrome, by the way.

@Alderon86
Copy link
Contributor

@blakewenloe weather on top bar only shows up if a single s2cell is on the screen otherwise it wont show any, theres weather Alert for that. undefined as u said shouldnt pop up at anytime, you are right.

@ghost
Copy link

ghost commented Jan 3, 2018

I also think it would be a good idea to display what type of "extreme" weather is in the cells versus just the extreme icon. Maybe the weather icons with ! marker on them or just with the extreme weather icon color? Because the extreme weather icon isn't really informative in itself. This is an awesome PR and i'm excited to use it!
screenshot 2018-01-02 18 56 13

@codename-art
Copy link
Author

@blakewenloe There is a red alert for extreme severity too. When a warning appears, weather bonuses stop working.

@ghost
Copy link

ghost commented Jan 3, 2018

@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.

@codename-art
Copy link
Author

@blakewenloe maybe I have wrong or outdated information. I'll figure out how to do it right.

@ghost
Copy link

ghost commented Jan 3, 2018

@codename-art this is an example of the prompts we go through in extreme weather if that helps.
20180102_201152
20180102_201136

@@ -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))
Copy link
Contributor

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.

Copy link

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

Copy link
Author

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.

imageUrl = imageUrl.replace('weather_', 'weather_light_')
}
return imageUrl
}
Copy link
Contributor

@ClarkyKent ClarkyKent Jan 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding a default "unknown weather" icon is necessary as sometimes in-game weather does not function. It will fix undefined pic/weather error.
rocketmap - google chrome_2

position: item.center,
icon: image
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to resize the weather icons while zooming out. If someone have bigger map. Weather icons can get out of s2cell and overlap.
rocketmap - google chrome_4

@SkOODaT
Copy link

SkOODaT commented Jan 3, 2018

awesome it got submitted for default RM, this is my backend work and A.R.Ts front end work :)

@SkOODaT
Copy link

SkOODaT commented Jan 3, 2018

@codename-art ive made some more changes to my copy since weather alerts are passable now you might want to pull them
~ i removed the alert icons off the tiles and moved the alert icon in the top to its own space (since we can click through now)
~ Webhooks have been added
~ If someone wants to make a PR for pokealarm from my git feel free im not a great git user yet, everything is there needed for weather alerts and changes ~ Unfortunately A.R.T Doesnt use PA (why no PR yet :))
https://imgur.com/a/GXJMj

@peterbaumert
Copy link

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.

@pogo-excalibur
Copy link
Contributor

pogo-excalibur commented Jan 3, 2018

@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.

@peterbaumert
Copy link

@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.

@sirlindqvist
Copy link
Contributor

Please remove ingame icons since they can’t be distributed in this pr

@SkOODaT
Copy link

SkOODaT commented Jan 4, 2018

yes they will half to be removed for public ops lol

@SkOODaT
Copy link

SkOODaT commented Jan 4, 2018

@codename-art
Copy link
Author

@sirlindqvist i used this icons for this PR http://adamwhitcroft.com/climacons/ and https://commons.wikimedia.org/wiki/File:Exclamation_Circle_Red.svg
@peterbaumert weather info passed from niantic server with s2cell_id, level of cell can be calculated from this id. The only problem is that this information is not used for drawing lines, that would be able to draw them without scanning. Nevertheless, when displaying icons and warnings, the coordinates from the niantic are used. In the case of cell-level changes will be noticeable differences with lines.

@sebastienvercammen
Copy link
Member

@codename-art Think you can fix the Travis issues?

@codename-art
Copy link
Author

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
Copy link
Contributor

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

Copy link

@SkOODaT SkOODaT Jan 11, 2018

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

Copy link
Contributor

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

Copy link
Author

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.

$.each(mapData.weather, (i, item) => {
if (item.hasOwnProperty('marker') && item.marker) {
item.marker.setIcon(createMarkerIcon(item.marker.icon.url))
item.marker.setMap(map)
Copy link
Contributor

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

Copy link
Member

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?

Copy link
Contributor

@michikrug michikrug Mar 14, 2018

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.

Copy link
Member

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?

Copy link
Contributor

@michikrug michikrug Mar 14, 2018

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.

Copy link
Member

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'
Copy link
Contributor

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)

1. Possible weather conditions:

| Status | Description |
| ------ | ------------------------------------------ |
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor

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)
)
Copy link
Contributor

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))
Copy link
Contributor

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
Copy link
Contributor

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.' +
Copy link
Contributor

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',
Copy link
Contributor

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)
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Member

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)))
Copy link
Contributor

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)))

* @param item
* @returns {*}
*/
function getalertImageUrl(item) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getalertImageUrl => getAlertImageUrl

* @returns {*}
*/
function getalertImageUrl(item) {
var alertimageUrl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alertimageUrl => alertImageUrl

}
})
}

Copy link
Contributor

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.

@tomballgithub
Copy link
Contributor

tomballgithub commented Mar 14, 2018

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

  • 's2cells' option needs to be renamed for clarity. 'Weather cells'? or 'Weather boundaries'?

  • Tint each S2 cell a color according to its current condition. This is needed because you can't see weather icon when zoomed in

  • 'Weather alerts' selection is not clear. It could be understood as alerts for when weather is going to change. Add 'extreme' in there since this option is to 'Show Extreme Weather'

  • Time zone of 'last scanned' is not correct on /weather page

  • Make clicking the weather in the title bar go to /weather page. There's not other way to get there besides typing the link and no one will know to do that

I need to go retest if any of this has been addressed. It's not obvious from commits above.

@tomballgithub
Copy link
Contributor

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.

@tomballgithub
Copy link
Contributor

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.

@pogo-excalibur
Copy link
Contributor

world_time in this case is an enum: { 'Day', 'Night' }

@billyjbryant
Copy link
Contributor

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.

@The-Real-Ketchum-Dev
Copy link

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

@billyjbryant
Copy link
Contributor

billyjbryant commented Mar 15, 2018 via email

Copy link
Contributor

@Alderon86 Alderon86 left a 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.

Copy link
Contributor

@ClarkyKent ClarkyKent left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet