[QGIS Commit] r8677 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Tue Jun 24 05:51:41 EDT 2008
Author: jef
Date: 2008-06-24 05:51:41 -0400 (Tue, 24 Jun 2008)
New Revision: 8677
Modified:
trunk/qgis/src/core/qgsvectorfilewriter.cpp
Log:
fix #1131
Modified: trunk/qgis/src/core/qgsvectorfilewriter.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorfilewriter.cpp 2008-06-24 08:11:12 UTC (rev 8676)
+++ trunk/qgis/src/core/qgsvectorfilewriter.cpp 2008-06-24 09:51:41 UTC (rev 8677)
@@ -111,6 +111,8 @@
const QgsField& attrField = fldIt.value();
OGRFieldType ogrType = OFTString; //default to string
+ int ogrWidth = -1;
+ int ogrPrecision = -1;
switch (attrField.type())
{
case QVariant::String:
@@ -118,9 +120,12 @@
break;
case QVariant::Int:
ogrType = OFTInteger;
+ ogrWidth = 10;
break;
case QVariant::Double:
ogrType = OFTReal;
+ ogrWidth = 32;
+ ogrPrecision = 3;
break;
default:
//assert(0 && "invalid variant type!");
@@ -130,13 +135,21 @@
// create field definition
OGRFieldDefnH fld = OGR_Fld_Create(mCodec->fromUnicode(attrField.name()), ogrType);
- OGR_Fld_SetWidth(fld,attrField.length());
- OGR_Fld_SetPrecision(fld,attrField.precision());
+ if(ogrWidth>0)
+ {
+ OGR_Fld_SetWidth(fld, ogrWidth);
+ }
+ if(ogrPrecision>=0)
+ {
+ OGR_Fld_SetPrecision(fld, ogrPrecision);
+ }
+
// create the field
QgsDebugMsg("creating field " + attrField.name() +
" type " + QString(QVariant::typeToName(attrField.type())) +
- " width length " + QString::number(attrField.length()));
+ " width " + QString::number(ogrWidth) +
+ " precision " + QString::number(ogrPrecision));
if (OGR_L_CreateField(mLayer,fld,TRUE) != OGRERR_NONE)
{
QgsDebugMsg("error creating field " + attrField.name());
More information about the QGIS-commit
mailing list