@@ -478,29 +478,69 @@ int QgsWFSProvider::getExtentFromGML2(QgsRect* extent, const QDomElement& wfsCol
478
478
}
479
479
480
480
QDomNode coordinatesNode = childNode.firstChild ();
481
- if (coordinatesNode.localName () ! = " coordinates" )
481
+ if (coordinatesNode.localName () = = " coordinates" )
482
482
{
483
- return 4 ;
483
+ std::list<QgsPoint> boundingPoints;
484
+ if (readGML2Coordinates (boundingPoints, coordinatesNode.toElement ()) != 0 )
485
+ {
486
+ return 5 ;
487
+ }
488
+
489
+ if (boundingPoints.size () != 2 )
490
+ {
491
+ return 6 ;
492
+ }
493
+
494
+ std::list<QgsPoint>::const_iterator it = boundingPoints.begin ();
495
+ extent->setXmin (it->x ());
496
+ extent->setYmin (it->y ());
497
+ ++it;
498
+ extent->setXmax (it->x ());
499
+ extent->setYmax (it->y ());
500
+ return 0 ;
484
501
}
485
-
486
- std::list<QgsPoint> boundingPoints;
487
- if (readGML2Coordinates (boundingPoints, coordinatesNode.toElement ()) != 0 )
502
+ else if (coordinatesNode.localName () == " coord" )
488
503
{
489
- return 5 ;
504
+ // first <coord> element
505
+ QDomElement xElement, yElement;
506
+ bool conversion1, conversion2; // string->double conversion success
507
+ xElement = coordinatesNode.firstChild ().toElement ();
508
+ yElement = xElement.nextSibling ().toElement ();
509
+ if (xElement.isNull () || yElement.isNull ())
510
+ {
511
+ return 7 ;
512
+ }
513
+ double x1 = xElement.text ().toDouble (&conversion1);
514
+ double y1 = yElement.text ().toDouble (&conversion2);
515
+ if (!conversion1 || !conversion2)
516
+ {
517
+ return 8 ;
518
+ }
519
+
520
+ // second <coord> element
521
+ coordinatesNode = coordinatesNode.nextSibling ();
522
+ xElement = coordinatesNode.firstChild ().toElement ();
523
+ yElement = xElement.nextSibling ().toElement ();
524
+ if (xElement.isNull () || yElement.isNull ())
525
+ {
526
+ return 9 ;
527
+ }
528
+ double x2 = xElement.text ().toDouble (&conversion1);
529
+ double y2 = yElement.text ().toDouble (&conversion2);
530
+ if (!conversion1 || !conversion2)
531
+ {
532
+ return 10 ;
533
+ }
534
+ extent->setXmin (x1);
535
+ extent->setYmin (y1 );
536
+ extent->setXmax (x2);
537
+ extent->setYmax (y2);
538
+ return 0 ;
490
539
}
491
-
492
- if (boundingPoints.size () != 2 )
540
+ else
493
541
{
494
- return 6 ;
542
+ return 11 ; // no valid tag for the bounding box
495
543
}
496
-
497
- std::list<QgsPoint>::const_iterator it = boundingPoints.begin ();
498
- extent->setXmin (it->x ());
499
- extent->setYmin (it->y ());
500
- ++it;
501
- extent->setXmax (it->x ());
502
- extent->setYmax (it->y ());
503
- return 0 ;
504
544
}
505
545
506
546
int QgsWFSProvider::setSRSFromGML2 (const QDomElement& wfsCollectionElement)
0 commit comments