<br><br>
<div><span class="gmail_quote">On 7/26/07, <b class="gmail_sendername">Frank Warmerdam</b> <<a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">abhay menon wrote:<br>> Hello all,<br>><br>> How do I verify that GEOS compilation is working with my GDAL utility.
<br>><br>> I have compiled the gdal-1.4.1 with geos-3.0.0-rc4 in vs2003 for some<br>> process to build in vc6.<br>><br>> OGRPolygon *poPolygon = new OGRPolygon();<br>> OGRPoint *pSt = new OGRPoint();
<br>><br>> when I issue this :<br>><br>> 1) int i = poPolygon->PointOnSurface(pSt);<br>><br>> result pSt is empty and i = 6.<br>> and when I try this :<br><br>Abhay,<br><br>I'm afraid PointOnSurface() is not implemented. It appears to have
<br>been a "good intention" based on the OGC geometry model I added to<br>the api 7-8 years ago and never implemented.<br><br>> 2) int i = poPolygon->Centroid(pSt);<br>><br>> it gives me an error and the application quits
<br>><br>> But when I tried the same with vs2003 the 2) step breaks at getX();<br>> 1) step result the same as earlier.<br><br>Hmm. Is pSt a pointer to an existing OGRPoint? I don't know why<br>things are crashing but at least this indicates that OGR is trying
<br>to use GEOS as otherwise it wouldn't do anything - just return<br>OGRERR_FAILURE.<br><br>At the core of the Centroid() method is this:<br><br> hOtherGeosGeom = GEOSGetCentroid( hThisGeosGeom );<br> OGRPoint *poCentroid = (OGRPoint *)
<br> OGRGeometryFactory::createFromGEOS( hOtherGeosGeom );<br><br> GEOSGeom_destroy( hThisGeosGeom );<br> GEOSGeom_destroy( hOtherGeosGeom );<br><br> if( poPoint == NULL<br> || wkbFlatten(poPoint->getGeometryType()) != wkbPoint )
<br> return OGRERR_FAILURE;<br><br> poPoint->setX( poCentroid->getX() );<br> poPoint->setY( poCentroid->getY() );<br><br> delete poCentroid;<br><br>I wonder if the return result (poCentroid) is invalid in
<br>some fashion that isn't tested for?<br><br>I see the OGR autotests includes this python test:<br><br> g1 = ogr.CreateGeometryFromWkt( 'POLYGON((0 0, 10 10, 10 0, 0 0))' )<br><br> centroid = g1.Centroid
()<br><br> g1.Destroy()<br><br> if ogrtest.check_feature_geometry( centroid,<br> 'POINT(6.666666667 3.333333333)') != 0:<br> print 'Got: ', centroid.ExportToWkt
()<br> return 'fail'<br><br> centroid.Destroy()<br><br>So it seems that Centroid() usually works.<br><br>I guess you will need to debug into the code to try and narrow down<br>what is happening. You might want to determine whether other GEOS
<br>based functions such as Union() work or not. It may be a general problem<br>with using GEOS rather than Centroid() specific.<br><br>Best regards,<br>--<br>---------------------------------------+--------------------------------------
<br>I set the clouds in motion - turn up | Frank Warmerdam, <a href="mailto:warmerdam@pobox.com">warmerdam@pobox.com</a><br>light and sound - activate the windows | <a href="http://pobox.com/~warmerdam">http://pobox.com/~warmerdam
</a><br>and watch the world go round - Rush | President OSGeo, <a href="http://osgeo.org">http://osgeo.org</a><br><br></blockquote></div>
<div> </div>
<div>Hi Frank,</div>
<div>Thanks for the info about PointOnSuface. </div>
<div>But it would be really useful if the GDAL supported the PointOnSurface function of GEOS as most of the GIS application will creating a Centriod of a irregular polygon creates point inside the polygon which is not the real centriod but an output of PointOnSurface or InnerPoint.
</div>
<div> </div>
<div>Hmm.. about the Centroid part.</div>
<div>I use the build for msvc80 in GEOS trunk to create the MSVC 8 compatible version which I am able to call in VC++6.</div>
<div>I will let know on the problem that is being created on VC7.1. once I get time for that. And let you know what happened within.</div>
<div><br clear="all"><br>-- <br>Best Regards<br><br> Abhay Menon<br> <a href="http://abhaymenon.info">http://abhaymenon.info</a></div>