On 7/29/05, Canfield, Andrew <[EMAIL PROTECTED]> wrote: > I have a loop that goes through all the items in a tab file that looks > about like this: > > pFeat = table->GetNextFeature(); > if(//check to see if it's a polygon etc... then if it is I get it's > geometry and cast it to a polygon > > OGRGeometry *poGeom = pFeat->GetGeometryRef(); > OGRPolygon *poPolygon = (OGRPolygon*)poGeom; > OGRPoint *pPt = new OGRPoint; > poPolygon->Centroid(pPt); > > Now if I call: > pPt->getX() > > or > > pPt->getY() > > They always return 0.0 yet if I extract the rings I can calculate the > Center of gravity just fine. > > Does anyone know what I might be doing wrong?
Andy, The Centroid() method is implemented using GEOS. If you don't have GEOS configured into your GDAL/OGR build, it will leave the passed point unchanged, and return OGRERR_FAILURE. I suspect this is what is happening in your case. Best regards, -- ---------------------------------------+-------------------------------------- I set the clouds in motion - turn up | Frank Warmerdam, [EMAIL PROTECTED] light and sound - activate the windows | http://pobox.com/~warmerdam and watch the world go round - Rush | Geospatial Programmer for Rent ------------------------ Yahoo! Groups Sponsor --------------------~--> <font face=arial size=-1><a href="http://us.ard.yahoo.com/SIG=12h5kg3vn/M=362329.6886308.7839368.1510227/D=groups/S=1705007389:TM/Y=YAHOO/EXP=1122763769/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992 ">Fair play? Video games influencing politics. Click and talk back!</a>.</font> --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/mitab/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
