def get_layer_info(workspace, layername): input_files = get_layer_input_files( workspace, layername, ) if input_files.saved_paths: # input_files.raw_or_archived_main_file_path is None if user sent ZIP file by chunks without main file inside main_file_path = input_files.raw_or_archived_main_file_path or input_files.saved_paths[ 0] rel_main_filepath = os.path.relpath( main_file_path, common_util.get_workspace_dir(workspace)) file_type = get_file_type(rel_main_filepath) result = { 'file': { 'path': rel_main_filepath, 'file_type': file_type, }, '_file': { 'path': main_file_path, 'gdal_path': input_files.main_file_path_for_gdal, }, } elif os.path.exists(util.get_layer_dir(workspace, layername)): result = {'name': layername} else: result = {} return result
def get_map_info(workspace, mapname): map_file_path = get_map_file(workspace, mapname) result = {} if os.path.exists(map_file_path): with open(map_file_path, 'r') as map_file: map_json = json.load(map_file) map_file_path = os.path.relpath( map_file_path, common_util.get_workspace_dir(workspace)) result = { 'file': { 'path': map_file_path, 'url': url_for('rest_workspace_map_file.get', mapname=mapname, workspace=workspace), }, '_file': { 'url': url_for('rest_workspace_map_file.get', mapname=mapname, workspace=workspace, internal=True), }, 'title': map_json['title'] or '', 'description': map_json['abstract'] or '', } elif os.path.exists(util.get_map_dir(workspace, mapname)): result = {'name': mapname} return result
def get(workspace, mapname): app.logger.info(f"GET Map Thumbnail, actor={g.user}") thumbnail_info = thumbnail.get_map_info(workspace, mapname) if thumbnail_info: workspace_dir = get_workspace_dir(workspace) thumbnail_path = thumbnail_info['thumbnail']['path'] thumbnail_path = os.path.join(workspace_dir, thumbnail_path) return send_file(thumbnail_path, mimetype='image/png') raise LaymanError(16, {'mapname': mapname})
def get(workspace, layername): app.logger.info(f"GET Layer Thumbnail, user={g.user}") thumbnail_info = thumbnail.get_layer_info(workspace, layername) if thumbnail_info: userdir = get_workspace_dir(workspace) thumbnail_path = thumbnail_info['thumbnail']['path'] thumbnail_path = os.path.join(userdir, thumbnail_path) return send_file(thumbnail_path, mimetype='image/png') raise LaymanError(16, {'layername': layername})
def get_layer_info(workspace, layername): thumbnail_path = get_layer_thumbnail_path(workspace, layername) if os.path.exists(thumbnail_path): return { 'thumbnail': { 'url': url_for('rest_workspace_layer_thumbnail.get', workspace=workspace, layername=layername), 'path': os.path.relpath(thumbnail_path, common_util.get_workspace_dir(workspace)) }, '_thumbnail': { 'path': thumbnail_path, }, } return {}
def get_layer_info(workspace, layername): input_file_dir = get_layer_input_file_dir(workspace, layername) pattern = os.path.join(input_file_dir, layername + '.*') filenames = glob.glob(pattern) main_filename = get_main_file_name(filenames) if main_filename is not None: main_filename = os.path.relpath( main_filename, common_util.get_workspace_dir(workspace)) result = {'file': {'path': main_filename}} elif os.path.exists(util.get_layer_dir(workspace, layername)): result = {'name': layername} else: result = {} return result
def get_map_info(workspace, mapname): thumbnail_path = get_map_thumbnail_path(workspace, mapname) if os.path.exists(thumbnail_path): return { 'thumbnail': { 'url': url_for('rest_workspace_map_thumbnail.get', workspace=workspace, mapname=mapname), 'path': os.path.relpath(thumbnail_path, common_util.get_workspace_dir(workspace)) } } return {}