Selon diegogb <[email protected]>: > 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!
Nothing strikes me as wrong in your code snippet. I'm pretty sure this should work. Perhaps it is an issue with your locale setting, for example if the decimal separator is comma instead of point. Perhaps you could open the .dbf file with an hexadecimal editor and look for your 1.3 value in it (it should be readable in ASCII characters after the binary header). > > 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. > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
