<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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….</span></font><font
size=2 color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'><o:p></o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>From:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
shapelib-bounces@lists.maptools.org
[mailto:shapelib-bounces@lists.maptools.org] <b><span style='font-weight:bold'>On
Behalf Of </span></b>mahesh_anandan@comcast.net<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, June 20, 2006 3:30
PM<br>
<b><span style='font-weight:bold'>To:</span></b> shapelib@lists.maptools.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [Shapelib] Re: help with
SHPWriteObject </span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Jeff: You can try couple of things:<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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. <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>   -> nObject = SHPWriteObject( hShape, -1 , phObject );<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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. <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>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. <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Did you Assert the following? <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>1. phObject is it a Pointer to SHPObject ?<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>2. is hShape Valid ? <o:p></o:p></span></font></p>

</div>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Thats all i can think off at this time. <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Good luck <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Mahesh <o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'> <br>
<br>
 <br>
<br>
            hShape =
SHPCreate( szRemotePath, SHPT_POLYGON );<br>
<br>
            hDBF =
DBFCreate( szRemotePath );<br>
<br>
<br>
<br>
           
vPolygonNum.vt = VT_I4;<br>
<br>
           
vPolygonNum.iVal = 0;<br>
<br>
            KSHAPEFILES_AddFieldsToDBFNoConnection(
hDBF, nTypeInteger,<br>
vPolygonNum, nPrecision1, nNumericScale0, strPolygonNumber );<br>
<br>
<br>
<br>
                           
phObject = SHPCreateSimpleObject(<br>
SHPT_POLYGON, knotCounter, dXPos, dYPos, dZPos );<br>
<br>
//         !  & nbsp;                      
nObject = SHPWriteObject( hShape,<br>
knotCounter, phObject );<br>
<br>
                   
SHPDestroyObject( phObject );<br>
<br>
<br>
<br>
// Polygon Number<br>
<br>
                                   
vPolygonNum.iVal = nThisPolygonNum;<br>
<br>
                                   
KSHAPEFILES_WriteAttributeToDBF(<br>
hDBF, knotCounter, 0, nTypeInteger, vPolygonNum.iVal );<br>
<br>
<br>
<br>
DBFClose( hDBF );<br>
<B!  R>SHPCl ose( hShape );<br>
<br>
 <o:p></o:p></span></font></p>

</div>

</div>

</body>

</html>