[PROJ] Minor bug in src/apps/cct.cpp
Houder
houder at xs4all.nl
Sun Nov 15 03:23:13 PST 2020
Hi,
It would be nice if this minor bug in src/apps/cct.cpp could be
repaired.
I noticed a (to me irritating) difference in the output of the cct
command
when an "angular" unit is printed.
Angular? Radian or degree.
A width of 14 is used when printing radians and a width of 13 is used
when
printing degrees.
Looking around, I found the bug in cct.cpp around line 390 ...
Here is the code:
if "radians"[1] { // what about degrees?
proj_todeg // convert to degrees (cct is supposed to output degrees)
print %14.*f decimals_angles, degrees // decimals_angles = 10 by
default
} else // meters etc. ... Well, that is the intention, but ...
print %13.*f decimals_distances, meters // decimals_distances = 4 by
default
--
[1] proj_angular_output (i.e. should really be called
proj_radian_output)
Before v7, proj_degree_output() did not exist; but now it does, cct.cpp
can
be modified (repaired) as follows:
if "radians"[1] OR "degrees"[2] { // i.e. not meters etc. ...
if "radians"
proj_todeg // convert to degrees (cct is supposed to output degrees)
print %14.*f decimals_angles, degrees // decimals_angles = 10 by
default
} else // meters etc. !
print %13.*f decimals_distances, meters // decimals_distances = 4 by
default
--
[1] proj_angular_output
[2] proj_degree_output
The above has been verified against v7.2.0
Regards,
Henri
Here is the real code:
/* Time to print the result */
// Note: proj_angular_output() should be called
proj_radian_output()
if (proj_angular_output (P, direction)
|| proj_degree_output (P, direction)) {
if (proj_angular_output (P, direction)) {
point.lpzt.lam = proj_todeg (point.lpzt.lam);
point.lpzt.phi = proj_todeg (point.lpzt.phi);
}
print (PJ_LOG_NONE, "%14.*f %14.*f %12.*f %12.4f%s%s",
decimals_angles, point.xyzt.x,
decimals_angles, point.xyzt.y,
decimals_distances, point.xyzt.z,
point.xyzt.t, comment_delimiter, comment
);
}
else
print (PJ_LOG_NONE, "%13.*f %13.*f %12.*f %12.4f%s%s",
decimals_distances, point.xyzt.x,
decimals_distances, point.xyzt.y,
decimals_distances, point.xyzt.z,
point.xyzt.t, comment_delimiter, comment
);
}
=====
More information about the PROJ
mailing list