Ejemplo n.º 1
0
 def test_process_pdf(self):
     event = AshEvent(
         working_dir=self.data_dir('temp'),
         volcano_name='Nama Gunung',
         volcano_location=[124.2, 6.9],
         eruption_height=7000,
         event_time=datetime.datetime.now().replace(
             tzinfo=timezone('Asia/Jakarta')),
         region='East Java',
         alert_level='Siaga',
         hazard_path=self.data_dir('hazard.tif'))
     event.impact_exists = True
     event.hazard_path = self.data_dir('hazard.tif')
     event.map_report_path = self.data_dir('temp/temp.pdf')
     event.nearby_html_path = self.data_dir('nearby-table.html')
     event.population_html_path = self.data_dir('population-table.html')
     event.landcover_html_path = self.data_dir('landcover-table.html')
     event.calculate_impact()
     event.generate_report()
Ejemplo n.º 2
0
def process_event(
        working_dir,
        locale_option='en',
        event_time=None,
        volcano_name=None,
        volcano_location=None,
        eruption_height=None,
        region=None,
        alert_level=None,
        hazard_url=None):
    """

    :param working_dir: The working directory of floodmaps report
    :param locale_option: the locale of the report
    :param event_time:
    :param volcano_name:
    :param volcano_location:
    :param eruption_height:
    :param region:
    :param alert_level:
    :param hazard_url:
    :return:
    """
    population_path = os.environ['INASAFE_ASH_POPULATION_PATH']
    landcover_path = os.environ['INASAFE_ASH_LANDCOVER_PATH']
    cities_path = os.environ['INASAFE_ASH_CITIES_PATH']
    airport_path = os.environ['INASAFE_ASH_AIRPORT_PATH']
    volcano_path = os.environ['INASAFE_ASH_VOLCANO_PATH']
    highlight_base_path = os.environ['INASAFE_ASH_HIGHLIGHT_BASE_PATH']
    overview_path = os.environ['INASAFE_ASH_OVERVIEW_PATH']

    # We always want to generate en products too so we manipulate the locale
    # list and loop through them:
    locale_list = [locale_option]
    if 'en' not in locale_list:
        locale_list.append('en')

    for locale in locale_list:
        LOGGER.info('Creating Ash Event for locale %s.' % locale)
        event = AshEvent(
            working_dir=working_dir,
            locale='en',
            event_time=event_time,
            volcano_name=volcano_name,
            volcano_location=volcano_location,
            eruption_height=eruption_height,
            region=region,
            alert_level=alert_level,
            overview_path=overview_path,
            population_path=population_path,
            highlight_base_path=highlight_base_path,
            volcano_path=volcano_path,
            landcover_path=landcover_path,
            cities_path=cities_path,
            airport_path=airport_path,
            # It will be processed either if it is a file or a url
            hazard_path=hazard_url)

        event.calculate_impact()
        event.generate_report()
        ret = push_ash_event_to_rest(ash_event=event)
        LOGGER.info('Is Push successful? %s.' % bool(ret))
Ejemplo n.º 3
0
def process_event(working_dir,
                  locale_option='en',
                  event_time=None,
                  volcano_name=None,
                  volcano_location=None,
                  eruption_height=None,
                  region=None,
                  alert_level=None,
                  hazard_url=None):
    """

    :param working_dir: The working directory of floodmaps report
    :param locale_option: the locale of the report
    :param event_time:
    :param volcano_name:
    :param volcano_location:
    :param eruption_height:
    :param region:
    :param alert_level:
    :param hazard_url:
    :return:
    """
    population_path = os.environ['INASAFE_ASH_POPULATION_PATH']
    landcover_path = os.environ['INASAFE_ASH_LANDCOVER_PATH']
    cities_path = os.environ['INASAFE_ASH_CITIES_PATH']
    airport_path = os.environ['INASAFE_ASH_AIRPORT_PATH']
    volcano_path = os.environ['INASAFE_ASH_VOLCANO_PATH']
    highlight_base_path = os.environ['INASAFE_ASH_HIGHLIGHT_BASE_PATH']
    overview_path = os.environ['INASAFE_ASH_OVERVIEW_PATH']

    # We always want to generate en products too so we manipulate the locale
    # list and loop through them:
    locale_list = [locale_option]
    if 'en' not in locale_list:
        locale_list.append('en')

    for locale in locale_list:
        LOGGER.info('Creating Ash Event for locale %s.' % locale)
        event = AshEvent(
            working_dir=working_dir,
            locale='en',
            event_time=event_time,
            volcano_name=volcano_name,
            volcano_location=volcano_location,
            eruption_height=eruption_height,
            region=region,
            alert_level=alert_level,
            overview_path=overview_path,
            population_path=population_path,
            highlight_base_path=highlight_base_path,
            volcano_path=volcano_path,
            landcover_path=landcover_path,
            cities_path=cities_path,
            airport_path=airport_path,
            # It will be processed either if it is a file or a url
            hazard_path=hazard_url)

        event.calculate_impact()
        event.generate_report()
        ret = push_ash_event_to_rest(ash_event=event)
        LOGGER.info('Is Push successful? %s.' % bool(ret))