Skip to content

Commit 19c1714

Browse files
author
mhugent
committed
wfs client: support for <coord>-type bounding boxes
git-svn-id: http://svn.osgeo.org/qgis/trunk@6055 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent a734c7d commit 19c1714

File tree

2 files changed

+58
-18
lines changed

2 files changed

+58
-18
lines changed

src/gui/qgisapp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en
18201820

18211821
// create the layer
18221822

1823-
QgsVectorLayer *layer = new QgsVectorLayer(*it, base, "ogr");
1823+
QgsVectorLayer *layer = new QgsVectorLayer(*it, base, "GML");
18241824
Q_CHECK_PTR( layer );
18251825
// set the visibility based on user preference for newly added
18261826
// layers

src/providers/wfs/qgswfsprovider.cpp

+57-17
Original file line numberDiff line numberDiff line change
@@ -478,29 +478,69 @@ int QgsWFSProvider::getExtentFromGML2(QgsRect* extent, const QDomElement& wfsCol
478478
}
479479

480480
QDomNode coordinatesNode = childNode.firstChild();
481-
if(coordinatesNode.localName() != "coordinates")
481+
if(coordinatesNode.localName() == "coordinates")
482482
{
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;
484501
}
485-
486-
std::list<QgsPoint> boundingPoints;
487-
if(readGML2Coordinates(boundingPoints, coordinatesNode.toElement()) != 0)
502+
else if(coordinatesNode.localName() == "coord")
488503
{
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;
490539
}
491-
492-
if(boundingPoints.size() != 2)
540+
else
493541
{
494-
return 6;
542+
return 11; //no valid tag for the bounding box
495543
}
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;
504544
}
505545

506546
int QgsWFSProvider::setSRSFromGML2(const QDomElement& wfsCollectionElement)

0 commit comments

Comments
 (0)