1
1
/******************************************************************************
2
* $Id: ogrlinearring.cpp 18676 2010-01-27 23:18:08Z rouault $
2
* $Id: ogrlinearring.cpp 22555 2011-06-22 12:16:54Z rouault $
4
4
* Project: OpenGIS Simple Features Reference Implementation
5
5
* Purpose: The OGRLinearRing geometry class.
338
double dx0, dy0, dx1, dy1, crossproduct;
338
double dx0, dy0, dx1, dy1, crossproduct;
339
int bUseFallback = FALSE;
340
341
if( nPointCount < 2 )
356
/* Vertices may be duplicate, we have to go to nearest different in each direction */
363
next = nPointCount - 1 - 1;
366
if( !epsilonEqual(paoPoints[next].x, paoPoints[v].x, EPSILON)
367
|| !epsilonEqual(paoPoints[next].y, paoPoints[v].y, EPSILON) )
372
if ( next == v ) /* So we cannot get into endless loop */
361
next = nPointCount - 1 - 1;
364
if( epsilonEqual(paoPoints[next].x, paoPoints[v].x, EPSILON) &&
365
epsilonEqual(paoPoints[next].y, paoPoints[v].y, EPSILON) )
367
/* Don't try to be too clever by retrying with a next point */
368
/* This can lead to false results as in the case of #3356 */
380
372
dx0 = paoPoints[next].x - paoPoints[v].x;
381
373
dy0 = paoPoints[next].y - paoPoints[v].y;
388
if ( next >= nPointCount - 1 )
393
if ( !epsilonEqual(paoPoints[next].x, paoPoints[v].x, EPSILON)
394
|| !epsilonEqual(paoPoints[next].y, paoPoints[v].y, EPSILON) )
399
if ( next == v ) /* So we cannot get into endless loop */
378
if ( next >= nPointCount - 1 )
383
if( epsilonEqual(paoPoints[next].x, paoPoints[v].x, EPSILON) &&
384
epsilonEqual(paoPoints[next].y, paoPoints[v].y, EPSILON) )
386
/* Don't try to be too clever by retrying with a next point */
387
/* This can lead to false results as in the case of #3356 */
407
391
dx1 = paoPoints[next].x - paoPoints[v].x;
408
392
dy1 = paoPoints[next].y - paoPoints[v].y;
410
394
crossproduct = dx1 * dy0 - dx0 * dy1;
412
if ( crossproduct > 0 ) /* CCW */
414
else if ( crossproduct < 0 ) /* CW */
398
if ( crossproduct > 0 ) /* CCW */
400
else if ( crossproduct < 0 ) /* CW */
417
404
/* ok, this is a degenerate case : the extent of the polygon is less than EPSILON */
405
/* or 2 nearly identical points were found */
418
406
/* Try with Green Formula as a fallback, but this is not a guarantee */
419
407
/* as we'll probably be affected by numerical instabilities */