<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
This is usually according to the locale. Try set "C" locale like
this.<br>
<pre style="" class="lang-cpp prettyprint prettyprinted"><code><span class="pln">cha* </span></code><code><span class="pln"><span class="n">old_locale = </span>setlocale</span><span class="pun">(</span><span class="pln">LC_NUMERIC</span><span class="pun">,</span><span class="pln"> </span><span class="str">"C"</span><span class="pun">);
before opening datasource
and reset it back after reading all fetures
</span></code><span class="n"><code><span class="pln">setlocale</span><span class="pun">(</span><span class="pln">LC_NUMERIC</span><span class="pun">,</span><span class="pln"> </span></code>old_locale</span>);
</pre>
<br>
This is not the solution (I fixed it here
<a class="moz-txt-link-freetext" href="http://trac.osgeo.org/gdal/ticket/5461">http://trac.osgeo.org/gdal/ticket/5461</a>) but some kind of
workaround.<br>
<br>
<pre class="moz-signature" cols="72">Best regards,
Dmitry</pre>
27.07.2014 15:40, Thomas Sevaldrud пишет:<br>
</div>
<blockquote
cite="mid:CAJSDX1igpmvo6TAfYP_ZtGkSyQvUcwzCNre0KtJyph5YHnp5WA@mail.gmail.com"
type="cite">
<div dir="ltr">
<div><font face="arial, sans-serif">(Sorry about the repost, I
forgot the subject tag in the previous one..)</font></div>
<span style="font-family:arial,sans-serif;font-size:13px">
<div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div>
Hi, I'm having a strange problem that appears to be related to
the GeoJSON driver in GDAL 1.11.0</span>
<div style="font-family:arial,sans-serif;font-size:13px"><br>
</div>
<div style="font-family:arial,sans-serif;font-size:13px">
When reading a polygon geometry in geographical lat/lon
coordinates, all my coordinate values are returned in integer
degrees. When using ogrinfo it dumps the coordinate values
with correct decimals, so it must be something I have done
wrong... Here is the relevant code:</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br>
</div>
<div style="font-family:arial,sans-serif;font-size:13px">
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRDataSource</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(0,0,0)">ds</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRSFDriverRegistrar</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(0,0,0)">Open</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,0)">filename_</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">c_str</span><span style="color:rgb(0,0,0)">(),</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">FALSE</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">);</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">num_layers</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ds</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">GetLayerCount</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">i</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">i</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">num_layers</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">i</span><span style="color:rgb(0,0,0)">++)</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRLayer</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">layer</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ds</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">GetLayer</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">i</span><span style="color:rgb(0,0,0)">);</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">layer</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">ResetReading</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRFeature</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">feature</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">while</span><span style="color:rgb(0,0,0)">((</span><span style="color:rgb(0,0,0)">feature</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">layer</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">GetNextFeature</span><span style="color:rgb(0,0,0)">())</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">!=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">NULL</span><span style="color:rgb(0,0,0)">)</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRGeometry</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">geometry</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">feature</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">GetGeometryRef</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">geometry</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">==</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">NULL</span><span style="color:rgb(0,0,0)">)</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">continue</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">geom_type</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">wkbFlatten</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">geometry</span><span style="color:rgb(0,0,0)">-></span><span style="font-style:italic;color:rgb(0,0,0)">getGeometryType</span><span style="color:rgb(0,0,0)">());</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">if</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">geom_type</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">==</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">wkbPolygon</span><span style="color:rgb(0,0,0)">)</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRPolygon</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ogr_poly</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">OGRPolygon</span><span style="color:rgb(0,0,0)">*)</span><span style="color:rgb(0,0,0)">geometry</span><span style="color:rgb(0,0,0)">;</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">OGRLinearRing</span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ext_ring</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ogr_poly</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">getExteriorRing</span><span style="color:rgb(0,0,0)">();</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">for</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,128,0)">int</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">j</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">j</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)"><</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ext_ring</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">getNumPoints</span><span style="color:rgb(0,0,0)">()</span><span style="color:rgb(192,192,192)"> </span><spa
n style="color:rgb(0,0,0)">-</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">;</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">j</span><span style="color:rgb(0,0,0)">++)</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span><span style="color:rgb(192,192,192);font-family:arial"> </span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">double</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">x</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ext_ring</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">getX</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">j</span><span style="color:rgb(0,0,0)">);</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">double</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">y</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">ext_ring</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">getY</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">j</span><span style="color:rgb(0,0,0)">);</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)"> ...</span></pre>
<pre style="white-space:pre-wrap;margin-top:0px;margin-bottom:0px">
</pre>
Now, the x, and y values here are always truncated to integer
values. This does not happen with for example shp files.</div>
<div style="font-family:arial,sans-serif;font-size:13px"><br>
</div>
<div style="font-family:arial,sans-serif;font-size:13px">Any
ideas what I might have done wrong here?</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a></pre>
</blockquote>
<br>
</body>
</html>