Implement draw_probabilities()
This commit is contained in:
		
							parent
							
								
									8755d4d899
								
							
						
					
					
						commit
						e403694e5e
					
				
					 1 changed files with 42 additions and 15 deletions
				
			
		| 
						 | 
				
			
			@ -185,7 +185,7 @@ class SPCOutlookProbabilityArea(SPCOutlookArea):
 | 
			
		|||
    )
 | 
			
		||||
 | 
			
		||||
    def sort_value(self):
 | 
			
		||||
        if self.probability == 'SIGN':
 | 
			
		||||
        if self.sig:
 | 
			
		||||
            return 1.0
 | 
			
		||||
 | 
			
		||||
        return float(self.probability)
 | 
			
		||||
| 
						 | 
				
			
			@ -496,12 +496,22 @@ class SPCOutlookMap(EquirectMap):
 | 
			
		|||
    LOGO_MARGIN = 16
 | 
			
		||||
 | 
			
		||||
    __category_colors__ = {
 | 
			
		||||
        'TSTM': (212, 240, 213),
 | 
			
		||||
        'MRGL': ( 80, 201, 134),
 | 
			
		||||
        'SLGT': (255, 255,  81),
 | 
			
		||||
        'ENH':  (255, 192, 108),
 | 
			
		||||
        'MDT':  (255,  80,  80),
 | 
			
		||||
        'HIGH': (255,  80, 255)
 | 
			
		||||
        'TSTM': (212/255.0, 240/255.0, 213/255.0),
 | 
			
		||||
        'MRGL': ( 80/255.0, 201/255.0, 134/255.0),
 | 
			
		||||
        'SLGT': (255/255.0, 255/255.0,  81/255.0),
 | 
			
		||||
        'ENH':  (255/255.0, 192/255.0, 108/255.0),
 | 
			
		||||
        'MDT':  (255/255.0,  80/255.0,  80/255.0),
 | 
			
		||||
        'HIGH': (255/255.0,  80/255.0, 255/255.0)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    __probability_colors__ = {
 | 
			
		||||
        0.02: (148/255.0, 192/255.0, 224/255.0),
 | 
			
		||||
        0.05: (139/255.0,  71/255.0,  38/255.0),
 | 
			
		||||
        0.15: (255/255.0, 200/255.0,   0/255.0),
 | 
			
		||||
        0.30: (255/255.0,   0/255.0,   0/255.0),
 | 
			
		||||
        0.45: (255/255.0,   0/255.0, 255/255.0),
 | 
			
		||||
        0.60: (145/255.0,  44/255.0, 238/255.0),
 | 
			
		||||
        None: ( 20/255.0,  20/255.0,  20/255.0),
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
| 
						 | 
				
			
			@ -528,17 +538,11 @@ class SPCOutlookMap(EquirectMap):
 | 
			
		|||
 | 
			
		||||
        cr.show_text(text)
 | 
			
		||||
 | 
			
		||||
    def draw_categories(self,
 | 
			
		||||
                        cr: cairo.Context,
 | 
			
		||||
                        outlook: SPCOutlook):
 | 
			
		||||
    def draw_categories(self, cr: cairo.Context, outlook: SPCOutlook):
 | 
			
		||||
        cr.save()
 | 
			
		||||
 | 
			
		||||
        for category in outlook.sorted_categories():
 | 
			
		||||
            color = self.__category_colors__[category.category]
 | 
			
		||||
 | 
			
		||||
            r = color[0] / 255.0
 | 
			
		||||
            g = color[1] / 255.0
 | 
			
		||||
            b = color[2] / 255.0
 | 
			
		||||
            r, g, b = self.__category_colors__[category.category]
 | 
			
		||||
 | 
			
		||||
            cr.set_source_rgba(r, g, b, 0.35)
 | 
			
		||||
            self.draw_polygon(cr, category.poly)
 | 
			
		||||
| 
						 | 
				
			
			@ -549,3 +553,26 @@ class SPCOutlookMap(EquirectMap):
 | 
			
		|||
            cr.stroke()
 | 
			
		||||
 | 
			
		||||
        cr.restore()
 | 
			
		||||
 | 
			
		||||
    def draw_probabilities(self,
 | 
			
		||||
                           cr: cairo.Context,
 | 
			
		||||
                           outlook: SPCOutlook,
 | 
			
		||||
                           hazard: str):
 | 
			
		||||
        cr.save()
 | 
			
		||||
 | 
			
		||||
        for probability in outlook.sorted_probabilities():
 | 
			
		||||
            if probability.hazard != hazard:
 | 
			
		||||
                continue
 | 
			
		||||
 | 
			
		||||
            r, g, b = self.__probability_colors__[probability.probability]
 | 
			
		||||
 | 
			
		||||
            if not probability.sig:
 | 
			
		||||
                cr.set_source_rgba(r, g, b, 0.35)
 | 
			
		||||
                self.draw_polygon(cr, probability.poly)
 | 
			
		||||
                cr.fill()
 | 
			
		||||
 | 
			
		||||
            cr.set_source_rgba(r*0.75, g*0.75, b*0.75, 1.0)
 | 
			
		||||
            self.draw_polygon(cr, probability.poly)
 | 
			
		||||
            cr.stroke()
 | 
			
		||||
 | 
			
		||||
        cr.restore()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue