[Shapelib] Re: help with SHPWriteObject

mahesh_anandan at comcast.net mahesh_anandan at comcast.net
Tue Jun 20 16:30:26 EDT 2006


Jeff: You can try couple of things:

I did not see what "knotCounter" is from your sample code. The 2nd Parameter to SHPWriteObject expects a integer which points to the position of existing shape or you have to pass -1 (negative one) for creating a new shape. 

   -> nObject = SHPWriteObject( hShape, -1 , phObject );

Are you doing dynamic library load using Load Library or you are doing static linking with the shape lib source file? Make sure the SHPWriteObject method is exported and it must exist in the .EXP file. 

If your SHPWriteObject is throwing Access violation, its probably because one of the paramter to this method may not be valid or may be pointing to bad memory loc. 

Did you Assert the following? 
1. phObject is it a Pointer to SHPObject ?
2. is hShape Valid ? 

Thats all i can think off at this time. 

Good luck 

Mahesh 
 

 

            hShape = SHPCreate( szRemotePath, SHPT_POLYGON );

            hDBF = DBFCreate( szRemotePath );

 

            vPolygonNum.vt = VT_I4;

            vPolygonNum.iVal = 0;

            KSHAPEFILES_AddFieldsToDBFNoConnection( hDBF, nTypeInteger,
vPolygonNum, nPrecision1, nNumericScale0, strPolygonNumber );

 

                            phObject = SHPCreateSimpleObject(
SHPT_POLYGON, knotCounter, dXPos, dYPos, dZPos );

//                                  nObject = SHPWriteObject( hShape,
knotCounter, phObject );

                    SHPDestroyObject( phObject );

 

// Polygon Number

                                    vPolygonNum.iVal = nThisPolygonNum;

                                    KSHAPEFILES_WriteAttributeToDBF(
hDBF, knotCounter, 0, nTypeInteger, vPolygonNum.iVal );

 

DBFClose( hDBF );

SHPClose( hShape );

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20060620/7bbe0781/attachment.html


More information about the Shapelib mailing list