Skip to content

Commit 8461fee

Browse files
authored
closes #1893 (#1900)
1 parent 818856e commit 8461fee

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/plotting.cpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ namespace lib
15481548
char *i;
15491549
//special cases, since plplot gives approximate zero values, not strict zeros.
15501550
bool logWithPlainNumbers=false;
1551-
DFloat range=ptr->End-ptr->Start;
1551+
DDouble range=ptr->End-ptr->Start;
15521552
if (ptr->isLog) {
15531553
range=log10(ptr->End)-log10(ptr->Start);
15541554
if (range < 8) {
@@ -1577,7 +1577,7 @@ namespace lib
15771577
// 10^1->N (positive logs) give zero precision (integer numbers)
15781578
// < 1 numbers precision will be the abs of negative magnitude
15791579
int prec = 0;
1580-
int mag = log10(ptr->Start);
1580+
int mag = log10(float(ptr->Start)); // float() see #1887
15811581
if (mag < 0) prec = -mag;
15821582
snprintf(label, length, "%.*f", prec, pow(10, value));
15831583
return;
@@ -1683,7 +1683,7 @@ namespace lib
16831683
else if (what.substr(0, 6) == "MINUTE") convcode = 5;
16841684
else if (what.substr(0, 6) == "SECOND") convcode = 6;
16851685
else if (what.substr(0, 4) == "TIME") {
1686-
DFloat range=ptr->End-ptr->Start;
1686+
DDouble range=ptr->End-ptr->Start;
16871687
if (range >= 366) convcode = 1;
16881688
else if (range >= 32) convcode = 2;
16891689
else if (range >= 1.1) convcode = 3;
@@ -3684,7 +3684,7 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {
36843684

36853685

36863686
gdlGetDesiredAxisTickGet(e, axisId, TickInterval, Start, End, Log);
3687-
3687+
36883688
if (Start == End) return;
36893689
if (Log && (Start <= 0 || End <= 0)) return; //important protection
36903690
bool doplot = ((AxisStyle & 4) != 4);
@@ -3854,6 +3854,8 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {
38543854
tickdata.e = e;
38553855
tickdata.isLog = Log;
38563856
tickdata.Start = (Start>End)?End:Start;
3857+
//protect against (plplot) bug #1893
3858+
if (TickInterval + tickdata.Start == tickdata.Start) return; //the best we can do?
38573859
tickdata.End = (Start>End)?Start:End;
38583860
tickdata.nchars = 0;
38593861
tickdata.TickFormat = NULL;
@@ -3912,7 +3914,8 @@ void SelfNormLonLat(DDoubleGDL *lonlat) {
39123914
for (auto i = 0; i < tickdata.nTickUnits; ++i) //loop on TICKUNITS axis
39133915
{
39143916
if (i > 0 || TickInterval == 0) TickInterval = gdlComputeAxisTickInterval(e, axisId, Start, End, Log, i/*, (AxisStyle & 1) == 0*/);
3915-
3917+
//protect against (plplot) bug #1893
3918+
if (TickInterval+tickdata.Start == tickdata.Start) continue;
39163919
tickdata.nchars = 0; //set nchars to 0, at the end nchars will be the maximum size.
39173920
if (i == 1) tickOpt = (TickLayout == 2) ? tickLayout2 : additionalAxesTickOpt; //change style of ticks for supplemental axes
39183921
defineLabeling(a, axisId, gdlNoLabelTickFunc, &tickdata); //prevent plplot to write labels (but writes something, so that label positions are reported in getLabelingValues())

src/plotting.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ struct GDL_TICKDATA {
155155
SizeT nTickUnits;
156156
DStringGDL* TickUnits;
157157
SizeT counter;
158-
DFloat Start; //used where the span of values in axis matters. //FLOATS as IDL rounds range on floats. Probably uses only floats for graphics. I would do the same.
159-
DFloat End; //used where the spand of values in axis matters.
158+
DDouble Start; //used where the span of values in axis matters.
159+
DDouble End; //used where the spand of values in axis matters.
160160
double nchars; //length of string *returned* after formatting. Can be non-integer.
161161
int tickOptionCode;
162162
int tickLayoutCode;

0 commit comments

Comments
 (0)