Hi,

This is usually according to the locale. Try set "C" locale like this.

|cha*||old_locale =setlocale(LC_NUMERIC,  "C");

before opening datasource

and reset it back after reading all fetures

||setlocale(LC_NUMERIC,  |old_locale);


This is not the solution (I fixed it here http://trac.osgeo.org/gdal/ticket/5461) but some kind of workaround.

Best regards,
    Dmitry

27.07.2014 15:40, Thomas Sevaldrud пишет:
(Sorry about the repost, I forgot the subject tag in the previous one..)

Hi, I'm having a strange problem that appears to be related to the GeoJSON driver in GDAL 1.11.0

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:

    OGRDataSource  *ds  =  OGRSFDriverRegistrar::Open(filename_.c_str(),  FALSE 
 );
    int  num_layers  =  ds->GetLayerCount();
    for(int  i  =  0;  i  <  num_layers;  i++)
    {
       OGRLayer*  layer  =  ds->GetLayer(i);
       layer->ResetReading();
       OGRFeature*  feature;
       while((feature  =  layer->GetNextFeature())  !=  NULL)
       {
          OGRGeometry*  geometry  =  feature->GetGeometryRef();
          if(geometry  ==  NULL)
             continue;
          int  geom_type  =  wkbFlatten(geometry->getGeometryType());
          if(geom_type  ==  wkbPolygon)
          {
             OGRPolygon*  ogr_poly  =  (OGRPolygon*)geometry;
             OGRLinearRing*  ext_ring  =  ogr_poly->getExteriorRing();
             for(int  j  =  0;  j  <  ext_ring->getNumPoints()  -  1;  j++)
{ double x = ext_ring->getX(j);
                double  y  =  ext_ring->getY(j);
                ...
Now, the x, and y values here are always truncated to integer values. This does not happen with for example shp files.

Any ideas what I might have done wrong here?


_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to