コード例 #1
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
    def _build_radar_image(self,
                           tower_id,
                           radar_type_string,
                           background='#000000',
                           include_topography=True,
                           include_legend=True,
                           include_counties=True,
                           include_warnings=True,
                           include_highways=True,
                           include_cities=True,
                           include_rivers=True):
        radar_type_string = radar_type_string.upper()
        tower_id = tower_id.upper()

        logger.debug("Tower ID: %s", tower_id)
        logger.debug("Type: %s", radar_type_string)
        logger.debug("Background: %s", background)
        logger.debug("Include Topography: %s", include_topography)
        logger.debug("Include Legend: %s", include_legend)
        logger.debug("Include Counties: %s", include_counties)
        logger.debug("Include Warnings: %s", include_warnings)
        logger.debug("Include Highways: %s", include_highways)
        logger.debug("Include Cities: %s", include_cities)
        logger.debug("Include Rivers: %s", include_rivers)

        radar = get_image_from_url(
            self._ridge_radar_format.format(radar_type_string,
                                            tower_id)).convert("RGBA")

        combined_image = Image.new("RGB", radar.size, background)

        if include_topography:
            self._add_topography(radar_type_string, tower_id, combined_image)

        combined_image.paste(radar, (0, 0), mask=radar)

        if include_rivers:
            self._add_rivers(radar_type_string, tower_id, combined_image)

        if include_counties:
            self._add_counties(radar_type_string, tower_id, combined_image)

        if include_highways:
            self._add_highways(radar_type_string, tower_id, combined_image)

        if include_cities:
            self._add_cities(radar_type_string, tower_id, combined_image)

        if include_warnings:
            self._add_warnings(radar_type_string, tower_id, combined_image)

        if include_legend:
            self._add_legend(radar_type_string, tower_id, combined_image)

        return combined_image
コード例 #2
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
    def _build_radar_image(self, tower_id, radar_type_string, background='#000000', include_topography=True, include_legend=True,
                           include_counties=True, include_warnings=True, include_highways=True, include_cities=True,
                           include_rivers=True):
        radar_type_string = radar_type_string.upper()
        tower_id = tower_id.upper()

        logger.debug("Tower ID: %s", tower_id)
        logger.debug("Type: %s", radar_type_string)
        logger.debug("Background: %s", background)
        logger.debug("Include Topography: %s", include_topography)
        logger.debug("Include Legend: %s", include_legend)
        logger.debug("Include Counties: %s", include_counties)
        logger.debug("Include Warnings: %s", include_warnings)
        logger.debug("Include Highways: %s", include_highways)
        logger.debug("Include Cities: %s", include_cities)
        logger.debug("Include Rivers: %s", include_rivers)

        radar = get_image_from_url(self._ridge_radar_format.format(radar_type_string, tower_id)).convert("RGBA")

        combined_image = Image.new("RGB", radar.size, background)

        if include_topography:
            self._add_topography(radar_type_string, tower_id, combined_image)

        combined_image.paste(radar, (0, 0), mask=radar)

        if include_rivers:
            self._add_rivers(radar_type_string, tower_id, combined_image)

        if include_counties:
            self._add_counties(radar_type_string, tower_id, combined_image)

        if include_highways:
            self._add_highways(radar_type_string, tower_id, combined_image)

        if include_cities:
            self._add_cities(radar_type_string, tower_id, combined_image)

        if include_warnings:
            self._add_warnings(radar_type_string, tower_id, combined_image)

        if include_legend:
            self._add_legend(radar_type_string, tower_id, combined_image)

        return combined_image
コード例 #3
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_rivers(self, type, tower_id, image):
     if self._radar_type_map[type][1] == 'Short':
         cities = get_image_from_url(self._ridge_rivers_format.format(self._radar_type_map[type][1], tower_id)).convert("RGBA")
         self._overlay(image, cities)
コード例 #4
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_highways(self, type, tower_id, image):
     highway = get_image_from_url(self._ridge_highway_format.format(self._radar_type_map[type][1], tower_id)).convert("RGBA")
     self._overlay(image, highway)
コード例 #5
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_counties(self, type, tower_id, image):
     county = get_image_from_url(self._ridge_county_format.format(self._radar_type_map[type][1], tower_id)).convert("RGBA")
     self._overlay(image, county)
コード例 #6
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_warnings(self, type, tower_id, image):
     warnings = get_image_from_url(self._ridge_warning_format.format(self._radar_type_map[type][1], tower_id)).convert("RGBA")
     self._overlay(image, warnings)
コード例 #7
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_legend(self, type, tower_id, image):
     legend = get_image_from_url(self._ridge_legend_format.format(type, tower_id)).convert("RGBA")
     self._overlay(image, legend)
コード例 #8
0
ファイル: radar.py プロジェクト: chaddotson/noaa_radar
 def _add_topography(self, type, tower_id, image):
     topo = get_image_from_url(self._ridge_topography_format.format(self._radar_type_map[type][1], tower_id)).convert("RGBA")
     self._overlay(image, topo)
コード例 #9
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_rivers(self, type, tower_id, image):
     if self._radar_type_map[type][1] == 'Short':
         cities = get_image_from_url(
             self._ridge_rivers_format.format(self._radar_type_map[type][1],
                                              tower_id)).convert("RGBA")
         self._overlay(image, cities)
コード例 #10
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_highways(self, type, tower_id, image):
     highway = get_image_from_url(
         self._ridge_highway_format.format(self._radar_type_map[type][1],
                                           tower_id)).convert("RGBA")
     self._overlay(image, highway)
コード例 #11
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_counties(self, type, tower_id, image):
     county = get_image_from_url(
         self._ridge_county_format.format(self._radar_type_map[type][1],
                                          tower_id)).convert("RGBA")
     self._overlay(image, county)
コード例 #12
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_warnings(self, type, tower_id, image):
     warnings = get_image_from_url(
         self._ridge_warning_format.format(self._radar_type_map[type][1],
                                           tower_id)).convert("RGBA")
     self._overlay(image, warnings)
コード例 #13
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_legend(self, type, tower_id, image):
     legend = get_image_from_url(
         self._ridge_legend_format.format(type, tower_id)).convert("RGBA")
     self._overlay(image, legend)
コード例 #14
0
ファイル: radar.py プロジェクト: ghulands/noaa_radar
 def _add_topography(self, type, tower_id, image):
     topo = get_image_from_url(
         self._ridge_topography_format.format(self._radar_type_map[type][1],
                                              tower_id)).convert("RGBA")
     self._overlay(image, topo)