Skip to content

Commit

Permalink
wfs client: support for <coord>-type bounding boxes
Browse files Browse the repository at this point in the history
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 e5ba35f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/gui/qgisapp.cpp
Expand Up @@ -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
Expand Down
74 changes: 57 additions & 17 deletions src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -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)
Expand Down

0 comments on commit e5ba35f

Please sign in to comment.