Skip to content

Support direct path to a raster file in file_path parameter#1192

Merged
honza2 merged 1 commit into2.4.xfrom
file-path-single-raster
May 1, 2026
Merged

Support direct path to a raster file in file_path parameter#1192
honza2 merged 1 commit into2.4.xfrom
file-path-single-raster

Conversation

@honza2
Copy link
Copy Markdown
Collaborator

@honza2 honza2 commented Mar 20, 2026

Part of issue #1180

  • Tests
  • [ ] Layman Test Client (including docker image at docker hub)
  • Changelog
  • Documentation

@honza2 honza2 force-pushed the file-path-single-raster branch from c75128b to 0ae1da4 Compare March 20, 2026 06:52
@honza2 honza2 self-assigned this Mar 20, 2026
@honza2 honza2 added this to the Release v2.4 milestone Mar 20, 2026
@honza2 honza2 added the enhancement New feature or request label Mar 20, 2026
@honza2 honza2 requested review from index-git and jirik March 20, 2026 11:30
@honza2 honza2 marked this pull request as ready for review March 26, 2026 15:07
Comment thread src/layman/layer/util.py Outdated
})

tif_files = get_file_path_geotiff_files(file_path_absolute)
if os.path.isdir(file_path_absolute) and len(tif_files) > 1 and not time_regex:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like, that conditions are repeasted through this file. Like os.path.isdir(file_path_absolute) is here three times. Also check and error raise are split into many methods.

os.makedirs(single_file_dir, exist_ok=True)
shutil.copy2(sample_file, os.path.join(single_file_dir, 'raster.tif'))
target_dirs.append(single_file_dir)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to have also test for vector file.

Comment thread src/layman/layer/util.py Outdated
return get_geotiff_files(file_path_absolute)
if os.path.isfile(file_path_absolute):
ext = os.path.splitext(file_path_absolute)[1].lower()
if ext in settings.FILE_PATH_MAIN_FILE_EXTENSIONS:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You realy on fact, that FILE_PATH_MAIN_FILE_EXTENSIONS are lower case.

Comment thread src/layman/layer/util.py Outdated
})
elif os.path.isfile(file_path_absolute):
ext = os.path.splitext(file_path_absolute)[1].lower()
if ext not in settings.FILE_PATH_MAIN_FILE_EXTENSIONS:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You realy on fact, that FILE_PATH_MAIN_FILE_EXTENSIONS are lower case.

unsupported_file.write(b'not-a-geotiff')
target_dirs.append(unsupported_file_dir)

single_file_dir = os.path.join(layers_dir, TEST_UUID_SINGLE)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to

- if directory is used, it must contain at least one GeoTIFF file (with extension `.tif` or `.tiff`)
- if directory contains more than one raster file, `time_regex` parameter is required

directory with one file should be working, but from this test name, it seems it is negative test.

@honza2 honza2 force-pushed the file-path-single-raster branch from 0ae1da4 to 4de89c3 Compare April 8, 2026 15:06
@honza2 honza2 requested a review from index-git April 8, 2026 15:47
@honza2 honza2 dismissed index-git’s stale review May 1, 2026 07:12

Addressed the requested changes and re-requested review.
Closing this review as outdated.

@honza2 honza2 merged commit 203ff27 into 2.4.x May 1, 2026
10 checks passed
@honza2 honza2 deleted the file-path-single-raster branch May 1, 2026 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants