[gdal-dev] Bug in SetField

Mohammed Rashad mohammedrashadkm at gmail.com
Thu Feb 24 12:17:13 EST 2011


rashadkm at 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 at 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 <warmerdam at pobox.com>wrote:

> 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,
> warmerdam at 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 at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Thanks && Regards
Rashad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110224/6bcd75cc/attachment.html


More information about the gdal-dev mailing list