Skip to content
Permalink
Browse files

Fix for wfsprovider to better read geoserver data

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6443 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Jan 19, 2007
1 parent ebbf38f commit cb826e7afe002bb6b3bf23806e1746e105822847
Showing with 44 additions and 23 deletions.
  1. +9 −1 src/providers/wfs/qgswfsdata.cpp
  2. +35 −22 src/providers/wfs/qgswfsprovider.cpp
@@ -357,7 +357,15 @@ int QgsWFSData::readEpsgFromAttribute(int& epsgNr, const XML_Char** attr) const
if(strcmp(attr[i], "srsName") == 0)
{
QString epsgString(attr[i+1]);
QString epsgNrString = epsgString.section(":", 1, 1);
QString epsgNrString;
if(epsgString.startsWith("http")) //e.g. geoserver: "http://www.opengis.net/gml/srs/epsg.xml#4326"
{
epsgNrString = epsgString.section("#", 1, 1);
}
else //e.g. umn mapserver: "EPSG:4326">
{
epsgNrString = epsgString.section(":", 1, 1);
}
bool conversionOk;
int eNr = epsgNrString.toInt(&conversionOk);
if(!conversionOk)
@@ -501,33 +501,46 @@ int QgsWFSProvider::readAttributesFromSchema(QDomDocument& schemaDoc, QString& g
return 1;
}
QDomElement schemaElement = schemaNodeList.at(0).toElement();

//find <element name="tname" type = ...>
QString complexTypeType;
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
QDomElement typeElement = typeElementNodeList.at(0).toElement();
complexTypeType = typeElement.attribute("type");
QDomElement complexTypeElement; //the <complexType> element corresponding to the feature type

if(complexTypeType.isEmpty())
{
return 3;
}
//find out, on which lines the first <element> or the first <complexType> occur. If <element> occurs first (mapserver), read the type of the relevant <complexType> tag. If <complexType> occurs first (geoserver), search for information about the feature type directly under this first complexType element

int firstElementTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element").at(0).toElement().columnNumber();
int firstComplexTypeTagPos = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement().columnNumber();

//remove the namespace on complexTypeType
if(complexTypeType.contains(":"))
if(firstComplexTypeTagPos < firstElementTagPos)
{
complexTypeType = complexTypeType.section(":", 1, 1);
//geoserver
complexTypeElement = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType").at(0).toElement();
}

//find <complexType name=complexTypeType
QDomElement complexTypeElement;
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
for(int i = 0; i < complexTypeNodeList.length(); ++i)
else
{
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
//UMN mapserver
QString complexTypeType;
QDomNodeList typeElementNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
QDomElement typeElement = typeElementNodeList.at(0).toElement();
complexTypeType = typeElement.attribute("type");

if(complexTypeType.isEmpty())
{
complexTypeElement = complexTypeNodeList.at(i).toElement();
break;
return 3;
}

//remove the namespace on complexTypeType
if(complexTypeType.contains(":"))
{
complexTypeType = complexTypeType.section(":", 1, 1);
}

//find <complexType name=complexTypeType
QDomNodeList complexTypeNodeList = schemaElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "complexType");
for(int i = 0; i < complexTypeNodeList.length(); ++i)
{
if(complexTypeNodeList.at(i).toElement().attribute("name") == complexTypeType)
{
complexTypeElement = complexTypeNodeList.at(i).toElement();
break;
}
}
}

@@ -536,7 +549,7 @@ int QgsWFSProvider::readAttributesFromSchema(QDomDocument& schemaDoc, QString& g
return 4;
}

//now create the attributes
//we have the relevant <complexType> element. Now find out the geometry and the thematic attributes
QDomNodeList attributeNodeList = complexTypeElement.elementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "element");
if(attributeNodeList.size() < 1)
{

0 comments on commit cb826e7

Please sign in to comment.
You can’t perform that action at this time.