Extract ROI extent mode produces wrong output
Description
If upper left and lower right corners are wrong in extent
mode, the application hapily generates a wrong output.
Steps to reproduce
With gdal, if you invert upper-left and lower-right corners, you get an error:
$ gdal_translate -projwin 7.2 45.2 7.3 45.3 -projwin_srs EPSG:4326 N45E007.hgt test.tif
Input file size is 3601, 3601
ERROR 1: Error: Computed -srcwin 720 2880 360 -360 has negative width and/or height.
$ gdal_translate -projwin 7.2 45.3 7.3 45.2 -projwin_srs EPSG:4326 N45E007.hgt test.tif
Input file size is 3601, 3601
0...10...20...30...40...50...60...70...80...90...100 - done.
In ExtractROI
, you get a wrong image without notice.
In correct case, size is consistent with the output from gdal (361x361):
$ otbcli_ExtractROI -in N45E007.hgt -out test.tif int16 -mode extent -mode.extent.unit lonlat -mode.extent.uly 45.3 -mode.extent.lry 45.2 -mode.extent.ulx 7.2 -mode.extent.lrx 7.3
2018-06-01 08:48:01 (INFO): No kwl metadata found in file N45E007.hgt
2018-06-01 08:48:01 (INFO): Default RAM limit for OTB is 128 MB
2018-06-01 08:48:01 (INFO): GDAL maximum cache size is 12854 MB
2018-06-01 08:48:01 (INFO): OTB will use at most 48 threads
2018-06-01 08:48:01 (INFO): Estimated memory for full processing: 1.47233MB (avail.: 128 MB), optimal image partitioning: 1 blocks
2018-06-01 08:48:01 (INFO): File test.tif will be written in 1 blocks of 361x361 pixels
Writing test.tif...: 100% [**************************************************] (1 seconds)
If we invert uly
and lry
, no error but the output size is 361x721 and probably correspond to a wrong roi:
$ otbcli_ExtractROI -in N45E007.hgt -out test.tif int16 -mode extent -mode.extent.unit lonlat -mode.extent.uly 45.2 -mode.extent.lry 45.3 -mode.extent.ulx 7.2 -mode.extent.lrx 7.3
2018-06-01 08:50:48 (INFO): No kwl metadata found in file N45E007.hgt
2018-06-01 08:50:48 (INFO): Default RAM limit for OTB is 128 MB
2018-06-01 08:50:48 (INFO): GDAL maximum cache size is 12854 MB
2018-06-01 08:50:48 (INFO): OTB will use at most 48 threads
2018-06-01 08:50:48 (INFO): Estimated memory for full processing: 2.95961MB (avail.: 128 MB), optimal image partitioning: 1 blocks
2018-06-01 08:50:48 (INFO): File test.tif will be written in 1 blocks of 361x721 pixels
Writing test.tif...: 100% [**************************************************] (0 seconds)
This probably comes from not checking properly computed coordinates in extent mode.
Configuration information
All.