Ramiro, The C API function OGR_R_IsValid( OGRGeometryH ) may help you.
On Fri, Mar 26, 2010 at 2:02 AM, Ramiro Gonzalez < [email protected]> wrote: > I won't calculate the area. I'll show an 'invalid area' message to the > user. > > Thanks. > > 2010/3/19 Peter J Halls <[email protected]> > > Whilst I agree with Chris that the 'winding' method for calculating polygon >> areas would need tweaking to work with a shape like this, the 'complementary >> areas' method or the triangulation method would. See Stephen Wise, GIS >> Basics, London: Taylor & Francis (2002) pp61-64 or Joseph O'Rourke, >> Computational Geometry in C, Cambridge (2nd Edn): Cambridge University Press >> (1998) pp18-22. >> >> Best wishes, >> >> Peter >> >> >> Chris 'Xenon' Hanson wrote: >> >>> On 3/18/2010 10:20 AM, Ramiro Gonzalez wrote: >>> >>>> I use gdal to calculate the area of polygons drawn by a user over a map. >>>> The points are added to the polygon in same order the user selects them. >>>> An hourglass shaped polygon can be created adding 4 points like a 'z'. >>>> When the polygon has the shape of an hourglass, the measure returned by >>>> get_Area() is smaller than the sum of the areas of the two independent >>>> triangles. >>>> I'd like to know if there is a way to calculate the area in this >>>> situation? >>>> I tried to intersect the polygon with another that contains it but the >>>> operation fails when the polygon cross itself(return NULL). I could use >>>> this to inform that the area calculated is invalid, but I'd like to know >>>> if there is a better way of knowing this. >>>> >>> >>> I'm pretty sure this would be considered nonsensical topology. Area >>> calculations usually >>> rely on the points in a polygon winding either consistently clockwise or >>> counter-clockwise, but yours are mixed. >>> >>> Don't do that. It's bad. >>> >>> If you want to measure the area of a shape like that, create it out of >>> two normal >>> consistently-wound triangles stacked tip-to-tip. >>> >>> Thanks, >>>> Ramiro >>>> >>> >>> >> -- >> >> -------------------------------------------------------------------------------- >> Peter J Halls, GIS Advisor, University of York >> Telephone: 01904 433806 Fax: 01904 433740 >> Snail mail: Computing Service, University of York, Heslington, York YO10 >> 5DD >> This message has the status of a private and personal communication >> >> -------------------------------------------------------------------------------- >> >> _______________________________________________ >> gdal-dev mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/gdal-dev >> > > > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > -- Best regards, Chaitanya kumar CH. /tʃaɪθənjə/ /kʊmɑr/ +91-9848167848 17.2416N 80.1426E
_______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
