Skip to content

Commit

Permalink
gdallocationinfo: in -E echo mode, always report input coordinates, n…
Browse files Browse the repository at this point in the history
…ot pixel,line
  • Loading branch information
rouault committed Aug 13, 2024
1 parent d2d00c1 commit 028f632
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apps/gdallocationinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ MAIN_START(argc, argv)
while (inputAvailable)
{
int iPixel, iLine;
const double dfXIn = dfGeoX;
const double dfYIn = dfGeoY;

if (hCT)
{
Expand Down Expand Up @@ -411,7 +413,7 @@ MAIN_START(argc, argv)
}
else if (bEcho)
{
printf("%d%s%d%s", iPixel, osFieldSep.c_str(), iLine,
printf("%.15g%s%.15g%s", dfXIn, osFieldSep.c_str(), dfYIn,
osFieldSep.c_str());
}

Expand Down
14 changes: 14 additions & 0 deletions autotest/utilities/test_gdallocationinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,20 @@ def test_gdallocationinfo_echo(gdallocationinfo_path):
)
assert "1,2,132" in ret

ret = gdaltest.runexternal(
gdallocationinfo_path
+ ' -geoloc -E -valonly -field_sep "," ../gcore/data/byte.tif',
strin="440780.5 3751200.5",
)
assert "440780.5,3751200.5,132" in ret

ret = gdaltest.runexternal(
gdallocationinfo_path
+ ' -geoloc -E -valonly -field_sep "," ../gcore/data/byte.tif',
strin="440780.5 3751200.5 extra_content",
)
assert "440780.5,3751200.5,132,extra_content" in ret


###############################################################################
# Test out of raster coordinates
Expand Down

0 comments on commit 028f632

Please sign in to comment.