<div dir="ltr"><div>Is it possible the problem is the use of std:fixed ?  (Which is invoked if the trim option = FALSE, which is the default).</div><div><br></div><div>Currently in WKTWriter.writeNumber there is this code (and the defaults invoke fixed precision):</div><div><br></div><div>if(! trim) {<br></div>        ss << std::fixed;<br>    }<br><div>    ss << std::setprecision(decimalPlaces >= 0 ? decimalPlaces : 0) << d;</div><div><br></div><div>This results in the following (as noted on the GeoSwift issue)</div><div><br></div><div>POINT (-0.4225977 46.3406448). ==>. POINT (-0.4225977000000000 46.3406447999999997)</div><div><br></div><div>This carries too much precision, obviously.  I think it might be exposing the IEEE-754 guard digits unnecessarily.  FP output is notoriously tricky, and I suspect it's better to let C++ just do the right thing.</div><div><br></div><div>Also, running reducePrecision causes problems, again I suspect due to to imprecise FP representation:</div><div><br></div><div>bin/geosop -a "Point (-0.4225977 46.3406448)" -f wkt reducePrecision 100<br></div><div>POINT (-0.4200000000000000 46.3400000000000034)<br></div><div><br></div><div>If the std::fixed setting is dropped, the output looks more reasonable:<br></div><div><br></div><div>POINT (-0.4225977 46.3406448). ==>. POINT (-0.4225977234 46.3406448)</div><div><br></div><div>Check that all input sig digits are shown:</div><div><br></div><div>POINT (-0.4225977234 46.3406448) ==> POINT (-0.4225977234 46.3406448)<br></div><div><br></div><div>Reduced precision displays as expected:</div><div>bin/geosop -a "Point (-0.4225977 46.3406448)" -f wkt reducePrecision 100<br>POINT (-0.42 46.34)<br></div><div><br></div><div><br></div><div>Is the "trim" option needed at all?</div><div><br></div><div>On Tue, Jan 5, 2021 at 3:41 PM Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca">pramsey@cleverelephant.ca</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
What do people think is the best practice for outputing WKT precision?<br>
</blockquote></div></div>