Skip to content
Permalink
Browse files
wfs client: support for <coord>-type bounding boxes
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6055 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Nov 6, 2006
1 parent dde9fa6 commit e5ba35fc15aa64dc59a9856de8ad864147a97a4a
Showing with 58 additions and 18 deletions.
  1. +1 −1 src/gui/qgisapp.cpp
  2. +57 −17 src/providers/wfs/qgswfsprovider.cpp
@@ -1820,7 +1820,7 @@ bool QgisApp::addLayer(QStringList const &theLayerQStringList, const QString& en

// create the layer

QgsVectorLayer *layer = new QgsVectorLayer(*it, base, "ogr");
QgsVectorLayer *layer = new QgsVectorLayer(*it, base, "GML");
Q_CHECK_PTR( layer );
// set the visibility based on user preference for newly added
// layers
@@ -478,29 +478,69 @@ int QgsWFSProvider::getExtentFromGML2(QgsRect* extent, const QDomElement& wfsCol
}

QDomNode coordinatesNode = childNode.firstChild();
if(coordinatesNode.localName() != "coordinates")
if(coordinatesNode.localName() == "coordinates")
{
return 4;
std::list<QgsPoint> boundingPoints;
if(readGML2Coordinates(boundingPoints, coordinatesNode.toElement()) != 0)
{
return 5;
}

if(boundingPoints.size() != 2)
{
return 6;
}

std::list<QgsPoint>::const_iterator it = boundingPoints.begin();
extent->setXmin(it->x());
extent->setYmin(it->y());
++it;
extent->setXmax(it->x());
extent->setYmax(it->y());
return 0;
}

std::list<QgsPoint> boundingPoints;
if(readGML2Coordinates(boundingPoints, coordinatesNode.toElement()) != 0)
else if(coordinatesNode.localName() == "coord")
{
return 5;
//first <coord> element
QDomElement xElement, yElement;
bool conversion1, conversion2; //string->double conversion success
xElement = coordinatesNode.firstChild().toElement();
yElement = xElement.nextSibling().toElement();
if(xElement.isNull() || yElement.isNull())
{
return 7;
}
double x1 = xElement.text().toDouble(&conversion1);
double y1 = yElement.text().toDouble(&conversion2);
if(!conversion1 || !conversion2)
{
return 8;
}

//second <coord> element
coordinatesNode = coordinatesNode.nextSibling();
xElement = coordinatesNode.firstChild().toElement();
yElement = xElement.nextSibling().toElement();
if(xElement.isNull() || yElement.isNull())
{
return 9;
}
double x2 = xElement.text().toDouble(&conversion1);
double y2 = yElement.text().toDouble(&conversion2);
if(!conversion1 || !conversion2)
{
return 10;
}
extent->setXmin(x1);
extent->setYmin(y1);
extent->setXmax(x2);
extent->setYmax(y2);
return 0;
}

if(boundingPoints.size() != 2)
else
{
return 6;
return 11; //no valid tag for the bounding box
}

std::list<QgsPoint>::const_iterator it = boundingPoints.begin();
extent->setXmin(it->x());
extent->setYmin(it->y());
++it;
extent->setXmax(it->x());
extent->setYmax(it->y());
return 0;
}

int QgsWFSProvider::setSRSFromGML2(const QDomElement& wfsCollectionElement)

0 comments on commit e5ba35f

Please sign in to comment.