Пример #1
0
    def test_style(self):
        """See if style() output correspond to expected lookup.
        """
        IconStyle(
            fews_filter=None, fews_location=None, fews_parameter=None, icon="icon.png", mask="mask.png", color="ff00ff"
        ).save()
        IconStyle(
            fews_filter=self.filter1,
            fews_location=None,
            fews_parameter=None,
            icon="filter1.png",
            mask="mask.png",
            color="00ffff",
        ).save()
        IconStyle(
            fews_filter=None,
            fews_location=self.location1,
            fews_parameter=None,
            icon="par1.png",
            mask="mask.png",
            color="00ffff",
        ).save()
        IconStyle(
            fews_filter=self.filter1,
            fews_location=self.location1,
            fews_parameter=None,
            icon="loc1.png",
            mask="mask.png",
            color="00ffff",
        ).save()
        IconStyle(
            fews_filter=self.filter1,
            fews_location=self.location1,
            fews_parameter=self.parameter1,
            icon="par1.png",
            mask="mask.png",
            color="00ffff",
        ).save()
        IconStyle(
            fews_filter=None,
            fews_location=self.location1,
            fews_parameter=self.parameter1,
            icon="loc1par1.png",
            mask="mask.png",
            color="00ffff",
        ).save()

        expected1 = ("::::", {"icon": "icon.png", "mask": ("mask.png",), "color": (1.0, 0.0, 1.0, 1.0)})
        self.assertEqual(IconStyle.style(self.filter2, self.location2, self.parameter2), expected1)
        self.assertEqual(IconStyle.style(self.filter2, self.location2, self.parameter2, ignore_cache=True), expected1)
Пример #2
0
def fews_symbol_name(
    fews_filter_pk, fews_location_pk, fews_parameter_pk,
    nodata=False, styles=None, lookup=None):

    """Find fews symbol name"""

    # determine icon layout by looking at filter.id
    # if str(fews_filter.fews_id) in LAYER_STYLES:
    #     icon_style = copy.deepcopy(LAYER_STYLES[str(fews_filter.fews_id)])
    # else:
    #     icon_style = copy.deepcopy(LAYER_STYLES['default'])
    style_name, icon_style = IconStyle.style(
        fews_filter_pk, fews_location_pk, fews_parameter_pk, styles, lookup)

    #make icon grey
    if nodata:
        icon_style['color'] = (0.9, 0.9, 0.9, 0)

    # apply icon layout using symbol manager
    symbol_manager = SymbolManager(
        ICON_ORIGINALS,
        os.path.join(settings.MEDIA_ROOT, 'generated_icons'))
    output_filename = symbol_manager.get_symbol_transformed(
        icon_style['icon'], **icon_style)

    return style_name, output_filename
Пример #3
0
    def test_empty(self):
        """Do not crash when no iconstyles are available, just return default.
        """

        expected = (
            "::::",
            {"icon": "meetpuntPeil.png", "mask": ("meetpuntPeil_mask.png",), "color": (0.0, 0.5, 1.0, 1.0)},
        )

        self.assertEqual(IconStyle.style(self.filter2, self.location1, self.parameter1), expected)