[Shapelib] Reading Shapefile Polygon is Line
    Richard R McDonald 
    rmcd at usgs.gov
       
    Fri Mar  2 13:54:00 EST 2007
    
    
  
My Apologies,
I figured it out.  Should have read points as shpObject->padfX[j].
Again - thanks for the great library.
rich
Rich McDonald
Research Hydrologist
USGS Geomorphology and Sediment Transport Laboratory
4620 Technology Drive, Suite 400
Golden, CO 80403
303 278 7952
rmcd at usgs.gov
Richard R McDonald <rmcd at usgs.gov> 
Sent by: shapelib-bounces at lists.maptools.org
03/02/2007 11:36 AM
Please respond to
Shapelib Development <shapelib at lists.maptools.org>
To
shapelib at lists.maptools.org
cc
Subject
[Shapelib] Reading Shapefile Polygon is Line
Hi, 
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. 
thanks, 
rich 
void MeshBCCoverage::importShapefile(LPCTSTR pathName, double xOffset, 
double yOffset) 
{ 
//                        CString fext = openDlg.GetFileExt(); 
                SHPHandle shpHandle; 
                shpHandle = SHPOpen(pathName, "rb"); 
                int pnEntities, pnShapeType; 
                double padfMinBound[4], padfMaxBound[4]; 
                double tx, ty, tz; 
                SbVec3f point; 
                SHPGetInfo(shpHandle, &pnEntities, &pnShapeType, 
padfMinBound, padfMaxBound); 
                for(int i = 0; i < pnEntities; i++) { 
                        SHPObject* shpObject = SHPReadObject(shpHandle, 
i); 
                        switch(shpObject->nSHPType) { 
                                case (SHPT_POLYGON): 
                                        { 
                                                this->createNewLine(); 
                                                for(int j = 0; j < 
shpObject->nVertices; j++) { 
                                                        tx = 
*shpObject->padfX+j; 
                                                        ty = 
*shpObject->padfY+j; 
                                                        tz = 
*shpObject->padfZ+j; 
 point.setValue(tx-xOffset, ty-yOffset, this->curIndex+1); 
                                                        this
->addPoint(point); 
                                                        this
->rbrBandPoint(point); 
                                                } 
                                                this->finishLine(); 
                                        } 
                                        break; 
                        } 
                } 
} 
Rich McDonald
Research Hydrologist
USGS Geomorphology and Sediment Transport Laboratory
4620 Technology Drive, Suite 400
Golden, CO 80403
303 278 7952
rmcd at usgs.gov_______________________________________________
Shapelib mailing list
Shapelib at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/shapelib
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/shapelib/attachments/20070302/c3dfaa9a/attachment.html
    
    
More information about the Shapelib
mailing list