<div dir="ltr">Hi all,<div><br></div><div>I've just found that a declaration of this type solved my problem:</div><div><br></div><div><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">OGRFieldDefn</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">oField</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box;color:rgb(187,136,68)">"Val dbl"</span><span style="box-sizing:border-box">,</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">OFTReal</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">);</span>

</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">// oField</span><span style="box-sizing:border-box">.</span><span style="box-sizing:border-box">SetWidth</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(0,153,153)">64</span><span style="box-sizing:border-box">);</span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box"><br></span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">I have no idea why.</span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">I suggest that the tutorial is updated to reflect this (common) case.</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">Kind regards,</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">Roland</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box"><br></span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box"><br></span></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le sam. 14 oct. 2023 à 16:12, Roland Baviere <<a href="mailto:roland.baviere@districtlab.eu">roland.baviere@districtlab.eu</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear Community,<div><br></div><div>I hope this e-mel finds you well.</div><div><br></div><div>I am trying to write a shaprfile from a C++ application (windows), following the tutorial found here: <a href="https://gdal.org/tutorials/vector_api_tut.html#writing-to-ogr" target="_blank">https://gdal.org/tutorials/vector_api_tut.html#writing-to-ogr</a></div><div><br></div><div>Everything works fine except for Fields of the OFTReal type, which are systematically truncated in the produced shapefile, as if they were declared as integer.</div><div><br></div><div>The example illustrates the declaration of a string type:</div><div><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">OGRFieldDefn</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">oField</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box;color:rgb(187,136,68)">"Name"</span><span style="box-sizing:border-box">,</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">OFTString</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">);</span>

<span style="box-sizing:border-box">oField</span><span style="box-sizing:border-box">.</span><span style="box-sizing:border-box">SetWidth</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(0,153,153)">32</span><span style="box-sizing:border-box">);</span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">I tried to adapt it to the case were I want to serialize a field of the double type:</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">OGRFieldDefn</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">oField</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box;color:rgb(187,136,68)">"Val dbl"</span><span style="box-sizing:border-box">,</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">OFTReal</span><span style="box-sizing:border-box;color:rgb(187,187,187)"> </span><span style="box-sizing:border-box">);</span>

</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><span style="box-sizing:border-box">oField</span><span style="box-sizing:border-box">.</span><span style="box-sizing:border-box">SetWidth</span><span style="box-sizing:border-box">(</span><span style="box-sizing:border-box;color:rgb(0,153,153)">64</span><span style="box-sizing:border-box">);</span></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">but the aforementionned truncation error occurs.</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">What am I doing wrong?</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">Thanks a lot for your help and time.</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">Kind regards,</pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)"><br></pre><pre style="box-sizing:border-box;line-height:1.5;font-family:"Source Code Pro","Andale Mono WT","Andale Mono","Lucida Console","Lucida Sans Typewriter","DejaVu Sans Mono","Bitstream Vera Sans Mono","Liberation Mono","Nimbus Mono L",Monaco,"Courier New",Courier,monospace;font-size:12px;background-color:rgb(248,248,248);margin-top:0px;margin-bottom:0px;padding:12px;overflow:auto;color:rgb(51,51,51)">Roland BAVIERE <br></pre></div><div><br></div></div>
</blockquote></div>