@@ -5441,7 +5441,12 @@ int QgsGeometry::lineContainedInLine( const GEOSGeometry* line1, const GEOSGeome
5441
5441
return -1 ;
5442
5442
}
5443
5443
5444
+
5444
5445
double bufferDistance = 0.00001 ;
5446
+ if ( geomInDegrees ( line2 ) ) // use more accurate tolerance for degrees
5447
+ {
5448
+ bufferDistance = 0.00000001 ;
5449
+ }
5445
5450
GEOSGeometry* bufferGeom = GEOSBuffer ( line2, bufferDistance, DEFAULT_QUADRANT_SEGMENTS );
5446
5451
if ( !bufferGeom )
5447
5452
{
@@ -5476,6 +5481,10 @@ int QgsGeometry::pointContainedInLine( const GEOSGeometry* point, const GEOSGeom
5476
5481
}
5477
5482
5478
5483
double bufferDistance = 0.000001 ;
5484
+ if ( geomInDegrees ( line ) )
5485
+ {
5486
+ bufferDistance = 0.00000001 ;
5487
+ }
5479
5488
GEOSGeometry* lineBuffer = GEOSBuffer ( line, bufferDistance, 8 );
5480
5489
if ( !lineBuffer )
5481
5490
{
@@ -5492,6 +5501,50 @@ int QgsGeometry::pointContainedInLine( const GEOSGeometry* point, const GEOSGeom
5492
5501
return contained;
5493
5502
}
5494
5503
5504
+ bool QgsGeometry::geomInDegrees ( const GEOSGeometry* geom )
5505
+ {
5506
+ GEOSGeometry* bbox = GEOSEnvelope ( geom );
5507
+ if ( !bbox )
5508
+ {
5509
+ return false ;
5510
+ }
5511
+
5512
+ const GEOSGeometry* bBoxRing = GEOSGetExteriorRing ( bbox );
5513
+ if ( !bBoxRing )
5514
+ {
5515
+ return false ;
5516
+ }
5517
+ const GEOSCoordSequence* bBoxCoordSeq = GEOSGeom_getCoordSeq ( bBoxRing );
5518
+
5519
+ if ( !bBoxCoordSeq )
5520
+ {
5521
+ return false ;
5522
+ }
5523
+
5524
+ unsigned int nCoords = 0 ;
5525
+ if ( !GEOSCoordSeq_getSize ( bBoxCoordSeq, &nCoords ) )
5526
+ {
5527
+ return false ;
5528
+ }
5529
+
5530
+ double x, y;
5531
+ for ( int i = 0 ; i < ( nCoords - 1 ); ++i )
5532
+ {
5533
+ GEOSCoordSeq_getX ( bBoxCoordSeq, i, &x );
5534
+ if ( x > 180 || x < -180 )
5535
+ {
5536
+ return false ;
5537
+ }
5538
+ GEOSCoordSeq_getY ( bBoxCoordSeq, i, &y );
5539
+ if ( y > 90 || y < -90 )
5540
+ {
5541
+ return false ;
5542
+ }
5543
+ }
5544
+
5545
+ return true ;
5546
+ }
5547
+
5495
5548
int QgsGeometry::numberOfGeometries ( GEOSGeometry* g ) const
5496
5549
{
5497
5550
if ( !g )
0 commit comments