[gdal-dev] OFTReal values truncated to integer

diegogb diego.gnesi at gmail.com
Fri Apr 27 09:44:42 EDT 2012


I have a problem on storing double values on shapefiles fields.
If I execute this code:

//...
OGRFieldDefn zField("Elev", OFTReal);
layer->CreateField(&zField);
//...
OGRFeature *pointFeature = OGRFeature::CreateFeature(layer->GetLayerDefn());
OGRPoint thePoint;
thePoint.setX(1);
thePoint.setY(1);
thePoint.setZ(1);
pointFeature->SetGeometry(&thePoint);
double myVal = 1.3;
pointFeature->SetField("Elev", myVal);
layer->CreateFeature(pointFeature);
OGRFeature::DestroyFeature(pointFeature);
// Close data source etc.

When I open with Quantum GIS the file created by my program, the field
"Elev" does not contains 1.3 but 1. Why?!?
If i edit the file on QGIS, i can write 1.3 instead of 1, so the field type
is real and not integer...
I'm a GDAL newbie, but the code is so simple that i can't figure where is
the problem!

Thanks.

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/OFTReal-values-truncated-to-integer-tp4933952p4933952.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.


More information about the gdal-dev mailing list