[Shapelib] Re: help with SHPWriteObject
Jeff.Mosch at dtn.com
Wed Jun 21 12:24:29 PDT 2006
I was able to track the problem to the knotCounter (number of
points)value. The values for it are 0 based versus the
SHPCreateSimpleObject and SHPWriteObject expect a value of 1 or greater.
I just added 1 to the knotCounter values when calling these routines and
that fixed it up. Thanks....
From: shapelib-bounces at lists.maptools.org
[mailto:shapelib-bounces at lists.maptools.org] On Behalf Of
mahesh_anandan at comcast.net
Sent: Tuesday, June 20, 2006 3:30 PM
To: shapelib at lists.maptools.org
Subject: [Shapelib] Re: help with SHPWriteObject
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.
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 );
// ! & nbsp; nObject = SHPWriteObject(
knotCounter, phObject );
SHPDestroyObject( phObject );
// Polygon Number
vPolygonNum.iVal = nThisPolygonNum;
hDBF, knotCounter, 0, nTypeInteger, vPolygonNum.iVal );
DBFClose( hDBF );
SHPCl ose( hShape );
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Shapelib