<br><font size=2 face="sans-serif">Hi,</font>
<br><font size=2 face="sans-serif">I am having some success in reading
shapefiles using shapelib and am very happy to have found this library.
In the code below I am reading a shapefile that I know to contain
a number of polygons. However when I read the geometry of the polygons
- the points represent straight lines. I think I'm accessing the
shapefile correctly. If anyone has any idea's on why my polygons
read as lines I would appreciate the help.</font>
<br>
<br><font size=2 face="sans-serif">thanks,</font>
<br><font size=2 face="sans-serif">rich</font>
<br>
<br>
<br>
<br><font size=2 color=blue face="Courier New">void</font><font size=2 face="Courier New">
MeshBCCoverage::importShapefile(LPCTSTR pathName, </font><font size=2 color=blue face="Courier New">double</font><font size=2 face="Courier New">
xOffset, </font><font size=2 color=blue face="Courier New">double</font><font size=2 face="Courier New">
yOffset)</font>
<br><font size=2 face="Courier New">{</font>
<br><font size=2 color=#008000 face="Courier New">//
CString fext = openDlg.GetFileExt();</font>
<br><font size=2 face="Courier New">
SHPHandle shpHandle;</font>
<br><font size=2 face="Courier New">
shpHandle = SHPOpen(pathName, "rb");</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">int</font><font size=2 face="Courier New">
pnEntities, pnShapeType;</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">double</font><font size=2 face="Courier New">
padfMinBound[4], padfMaxBound[4];</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">double</font><font size=2 face="Courier New">
tx, ty, tz;</font>
<br><font size=2 face="Courier New">
SbVec3f point;</font>
<br><font size=2 face="Courier New">
SHPGetInfo(shpHandle, &pnEntities, &pnShapeType,
padfMinBound, padfMaxBound);</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">for</font><font size=2 face="Courier New">(</font><font size=2 color=blue face="Courier New">int</font><font size=2 face="Courier New">
i = 0; i < pnEntities; i++) {</font>
<br><font size=2 face="Courier New">
SHPObject*
shpObject = SHPReadObject(shpHandle, i);</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">switch</font><font size=2 face="Courier New">(shpObject->nSHPType)
{</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">case</font><font size=2 face="Courier New">
(SHPT_POLYGON):</font>
<br><font size=2 face="Courier New">
{</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">this</font><font size=2 face="Courier New">->createNewLine();</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">for</font><font size=2 face="Courier New">(</font><font size=2 color=blue face="Courier New">int</font><font size=2 face="Courier New">
j = 0; j < shpObject->nVertices; j++) {</font>
<br><font size=2 face="Courier New">
tx = *shpObject->padfX+j;</font>
<br><font size=2 face="Courier New">
ty = *shpObject->padfY+j;</font>
<br><font size=2 face="Courier New">
tz = *shpObject->padfZ+j;</font>
<br><font size=2 face="Courier New">
point.setValue(tx-xOffset,
ty-yOffset, </font><font size=2 color=blue face="Courier New">this</font><font size=2 face="Courier New">->curIndex+1);</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">this</font><font size=2 face="Courier New">->addPoint(point);</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">this</font><font size=2 face="Courier New">->rbrBandPoint(point);</font>
<br><font size=2 face="Courier New">
}</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">this</font><font size=2 face="Courier New">->finishLine();</font>
<br><font size=2 face="Courier New">
}</font>
<br><font size=2 face="Courier New">
</font><font size=2 color=blue face="Courier New">break</font><font size=2 face="Courier New">;</font>
<br><font size=2 face="Courier New">
}</font>
<br><font size=2 face="Courier New">
}</font>
<br>
<br><font size=2 face="Courier New">}</font>
<br>
<br>
<br><font size=2 face="sans-serif">Rich McDonald<br>
Research Hydrologist<br>
USGS Geomorphology and Sediment Transport Laboratory<br>
4620 Technology Drive, Suite 400<br>
Golden, CO 80403<br>
303 278 7952<br>
rmcd@usgs.gov</font>