def generate_geojson_and_save_db(scale_range): catalogue = repo.get_latest_catalogue() chartsDB = [] for scale in scale_range: geojson = Geojson() if scale == SCALE_ALL_TEXT: chartsDB = Chart.objects.using(DB_SNC).filter(catalogue=catalogue) # .latest('id') geojson.scale_range = scale_range else: chartsDB = Chart.objects.using(DB_SNC).filter(catalogue=catalogue, max_scale_category=scale) # .latest('id') geojson.scale_range = scale print(scale) charts = service_converters.chartsDB_2_chartsDTO(chartsDB) if len(charts) > 0: gjson = generate_geojson(charts) geojson.json = gjson geojson.catalogue = catalogue geojson.cat_id = catalogue.id geojson.ready = True geojson.save(using=DB_SNC) return 'generated and saved in DB geojson for charts: ' + ', '.join(scale_range)
def get_SCALE7_charts_context(): chartsDB = repo.find_charts_SCALE_7() charts = service_converters.chartsDB_2_chartsDTO(chartsDB) # print('number of charts: ' + str(len(charts))) context = { 'catalogue': charts[0].catalogue_id, 'charts': charts, } ctx = {**get_index_context(), **context} return ctx
def get_SCALE1_charts_context(): chartsDB = repo.find_charts_SCALE_1() charts = service_converters.chartsDB_2_chartsDTO(chartsDB) # print('number of charts: ' + str(len(charts))) context = { 'catalogue': charts[0].catalogue_id, 'charts': charts, 'search_multi_ok': 'Found ' + str(len(charts)) + ' chart(s)' } ctx = {**get_index_context(), **context} return ctx