[gdal-dev] Bug in SetField
my code field - fieldname is of string type and 0th field poFeature-SetField(fieldname,value); poFeature-GetFieldAsString(0); returns v instead of value; I dont know is it bug or my problem but I opened the shapefile in OpenJUMP and QGIS both shows field names as only v instead of value I am working with shapefiles -- Thanks Regards Rashad ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Bug in SetField
On 11-02-24 11:56 AM, Mohammed Rashad wrote: my code field - fieldname is of string type and 0th field poFeature-SetField(fieldname,value); poFeature-GetFieldAsString(0); returns v instead of value; I dont know is it bug or my problem but I opened the shapefile in OpenJUMP and QGIS both shows field names as only v instead of value I am working with shapefiles Mohammed, What does the ogrinfo report on the field definitions look? ie. ogrinfo -so -al abc.shp I suspect the field fieldname was defined with a width of one. SetField() will automatically truncate the value in such a case. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Bug in SetField
rashadkm@rashad-laptop:~/wt/examples/vrgeo/shp$ ogrinfo -so -al layerff.shp ERROR 4: Unable to open layerff.shp or layerff.SHP. Had to open data source read-only. INFO: Open of `layerff.shp' using driver `ESRI Shapefile' successful. Layer name: layerff Geometry: Polygon Feature Count: 5 Extent: (76.199480, 9.727064) - (76.863570, 10.255923) Layer SRS WKT: (unknown) fieldname: String (1.0) rashadkm@rashad-laptop:~/wt/examples/vrgeo/shp$ but i had set the feild width to 132 OGRFieldDefn oField( field, OFTString ); oField.SetWidth(132); On Thu, Feb 24, 2011 at 10:39 PM, Frank Warmerdam warmer...@pobox.comwrote: On 11-02-24 11:56 AM, Mohammed Rashad wrote: my code field - fieldname is of string type and 0th field poFeature-SetField(fieldname,value); poFeature-GetFieldAsString(0); returns v instead of value; I dont know is it bug or my problem but I opened the shapefile in OpenJUMP and QGIS both shows field names as only v instead of value I am working with shapefiles Mohammed, What does the ogrinfo report on the field definitions look? ie. ogrinfo -so -al abc.shp I suspect the field fieldname was defined with a width of one. SetField() will automatically truncate the value in such a case. Best regards, -- ---+-- I set the clouds in motion - turn up | Frank Warmerdam, warmer...@pobox.com light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush| Geospatial Programmer for Rent ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev -- Thanks Regards Rashad ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev
Re: [gdal-dev] Bug in SetField
Le jeudi 24 février 2011 18:17:13, Mohammed Rashad a écrit : rashadkm@rashad-laptop:~/wt/examples/vrgeo/shp$ ogrinfo -so -al layerff.shp ERROR 4: Unable to open layerff.shp or layerff.SHP. Had to open data source read-only. INFO: Open of `layerff.shp' using driver `ESRI Shapefile' successful. Layer name: layerff Geometry: Polygon Feature Count: 5 Extent: (76.199480, 9.727064) - (76.863570, 10.255923) Layer SRS WKT: (unknown) fieldname: String (1.0) Yes that matches Frank hypothesis ! rashadkm@rashad-laptop:~/wt/examples/vrgeo/shp$ but i had set the feild width to 132 OGRFieldDefn oField( field, OFTString ); oField.SetWidth(132); You cannot change a field definition of an existing file. You can only set it when creating a new field with the OGRLayer::CreateField() API ___ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev