@@ -117,65 +117,21 @@ QDomDocument QgsWFSServer::getCapabilities()
117
117
getCapabilitiesElement.appendChild ( dcpTypeElement );
118
118
QDomElement httpElement = doc.createElement ( " HTTP" /* wfs:HTTP*/ );
119
119
dcpTypeElement.appendChild ( httpElement );
120
-
120
+
121
121
// Prepare url
122
- // Some client requests already have http://<SERVER_NAME> in the REQUEST_URI variable
123
- QString hrefString;
124
- QString requestUrl = getenv ( " REQUEST_URI" );
125
- QUrl mapUrl ( requestUrl );
126
- mapUrl.setHost ( QString ( getenv ( " SERVER_NAME" ) ) );
127
-
128
- // Add non-default ports to url
129
- QString portString = getenv ( " SERVER_PORT" );
130
- if ( !portString.isEmpty () )
131
- {
132
- bool portOk;
133
- int portNumber = portString.toInt ( &portOk );
134
- if ( portOk )
135
- {
136
- if ( portNumber != 80 )
137
- {
138
- mapUrl.setPort ( portNumber );
139
- }
140
- }
141
- }
142
-
143
- if ( QString ( getenv ( " HTTPS" ) ).compare ( " on" , Qt::CaseInsensitive ) == 0 )
122
+ QString hrefString = mConfigParser ->wfsServiceUrl ();
123
+ if ( hrefString.isEmpty () )
144
124
{
145
- mapUrl. setScheme ( " https " );
125
+ hrefString = mConfigParser -> serviceUrl ( );
146
126
}
147
- else
127
+ if ( hrefString. isEmpty () )
148
128
{
149
- mapUrl. setScheme ( " http " );
129
+ hrefString = serviceUrl ( );
150
130
}
151
131
152
- QList<QPair<QString, QString> > queryItems = mapUrl.queryItems ();
153
- QList<QPair<QString, QString> >::const_iterator queryIt = queryItems.constBegin ();
154
- for ( ; queryIt != queryItems.constEnd (); ++queryIt )
155
- {
156
- if ( queryIt->first .compare ( " REQUEST" , Qt::CaseInsensitive ) == 0 )
157
- {
158
- mapUrl.removeQueryItem ( queryIt->first );
159
- }
160
- else if ( queryIt->first .compare ( " VERSION" , Qt::CaseInsensitive ) == 0 )
161
- {
162
- mapUrl.removeQueryItem ( queryIt->first );
163
- }
164
- else if ( queryIt->first .compare ( " SERVICE" , Qt::CaseInsensitive ) == 0 )
165
- {
166
- mapUrl.removeQueryItem ( queryIt->first );
167
- }
168
- else if ( queryIt->first .compare ( " _DC" , Qt::CaseInsensitive ) == 0 )
169
- {
170
- mapUrl.removeQueryItem ( queryIt->first );
171
- }
172
- }
173
- hrefString = mapUrl.toString ();
174
-
175
132
// only Get supported for the moment
176
133
QDomElement getElement = doc.createElement ( " Get" /* wfs:Get*/ );
177
134
httpElement.appendChild ( getElement );
178
- requestUrl.truncate ( requestUrl.indexOf ( " ?" ) + 1 );
179
135
getElement.setAttribute ( " onlineResource" , hrefString );
180
136
QDomElement getCapabilitiesDhcTypePostElement = dcpTypeElement.cloneNode ().toElement ();// this is the same as for 'GetCapabilities'
181
137
getCapabilitiesDhcTypePostElement.firstChild ().firstChild ().toElement ().setTagName ( " Post" );
@@ -1025,35 +981,18 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
1025
981
else
1026
982
{
1027
983
// Prepare url
1028
- // Some client requests already have http://<SERVER_NAME> in the REQUEST_URI variable
1029
- QString hrefString;
1030
- QString requestUrl = getenv ( " REQUEST_URI" );
1031
- QUrl mapUrl ( requestUrl );
1032
- mapUrl.setHost ( QString ( getenv ( " SERVER_NAME" ) ) );
1033
-
1034
- // Add non-default ports to url
1035
- QString portString = getenv ( " SERVER_PORT" );
1036
- if ( !portString.isEmpty () )
1037
- {
1038
- bool portOk;
1039
- int portNumber = portString.toInt ( &portOk );
1040
- if ( portOk )
1041
- {
1042
- if ( portNumber != 80 )
1043
- {
1044
- mapUrl.setPort ( portNumber );
1045
- }
1046
- }
1047
- }
1048
-
1049
- if ( QString ( getenv ( " HTTPS" ) ).compare ( " on" , Qt::CaseInsensitive ) == 0 )
984
+ QString hrefString = mConfigParser ->wfsServiceUrl ();
985
+ if ( hrefString.isEmpty () )
1050
986
{
1051
- mapUrl. setScheme ( " https " );
987
+ hrefString = mConfigParser -> serviceUrl ( );
1052
988
}
1053
- else
989
+ if ( hrefString. isEmpty () )
1054
990
{
1055
- mapUrl. setScheme ( " http " );
991
+ hrefString = serviceUrl ( );
1056
992
}
993
+ QUrl mapUrl ( hrefString );
994
+ mapUrl.addQueryItem ( " SERVICE" , " WFS" );
995
+ mapUrl.addQueryItem ( " VERSION" , " 1.0.0" );
1057
996
1058
997
QList<QPair<QString, QString> > queryItems = mapUrl.queryItems ();
1059
998
QList<QPair<QString, QString> >::const_iterator queryIt = queryItems.constBegin ();
@@ -1062,7 +1001,6 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
1062
1001
if ( queryIt->first .compare ( " REQUEST" , Qt::CaseInsensitive ) == 0 )
1063
1002
{
1064
1003
mapUrl.removeQueryItem ( queryIt->first );
1065
- mapUrl.addQueryItem ( queryIt->first , " DescribeFeatureType" );
1066
1004
}
1067
1005
else if ( queryIt->first .compare ( " FORMAT" , Qt::CaseInsensitive ) == 0 )
1068
1006
{
@@ -1088,6 +1026,10 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
1088
1026
{
1089
1027
mapUrl.removeQueryItem ( queryIt->first );
1090
1028
}
1029
+ else if ( queryIt->first .compare ( " EXP_FILTER" , Qt::CaseInsensitive ) == 0 )
1030
+ {
1031
+ mapUrl.removeQueryItem ( queryIt->first );
1032
+ }
1091
1033
else if ( queryIt->first .compare ( " MAXFEATURES" , Qt::CaseInsensitive ) == 0 )
1092
1034
{
1093
1035
mapUrl.removeQueryItem ( queryIt->first );
@@ -1101,6 +1043,7 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
1101
1043
mapUrl.removeQueryItem ( queryIt->first );
1102
1044
}
1103
1045
}
1046
+ mapUrl.addQueryItem ( " REQUEST" , " DescribeFeatureType" );
1104
1047
mapUrl.addQueryItem ( " TYPENAME" , mTypeNames .join ( " ," ) );
1105
1048
mapUrl.addQueryItem ( " OUTPUTFORMAT" , " XMLSCHEMA" );
1106
1049
hrefString = mapUrl.toString ();
@@ -1804,3 +1747,55 @@ QDomElement QgsWFSServer::createFeatureGML3( QgsFeature* feat, QDomDocument& doc
1804
1747
return featureElement;
1805
1748
}
1806
1749
1750
+ QString QgsWFSServer::serviceUrl () const
1751
+ {
1752
+ QUrl mapUrl ( getenv ( " REQUEST_URI" ) );
1753
+ mapUrl.setHost ( getenv ( " SERVER_NAME" ) );
1754
+
1755
+ // Add non-default ports to url
1756
+ QString portString = getenv ( " SERVER_PORT" );
1757
+ if ( !portString.isEmpty () )
1758
+ {
1759
+ bool portOk;
1760
+ int portNumber = portString.toInt ( &portOk );
1761
+ if ( portOk )
1762
+ {
1763
+ if ( portNumber != 80 )
1764
+ {
1765
+ mapUrl.setPort ( portNumber );
1766
+ }
1767
+ }
1768
+ }
1769
+
1770
+ if ( QString ( getenv ( " HTTPS" ) ).compare ( " on" , Qt::CaseInsensitive ) == 0 )
1771
+ {
1772
+ mapUrl.setScheme ( " https" );
1773
+ }
1774
+ else
1775
+ {
1776
+ mapUrl.setScheme ( " http" );
1777
+ }
1778
+
1779
+ QList<QPair<QString, QString> > queryItems = mapUrl.queryItems ();
1780
+ QList<QPair<QString, QString> >::const_iterator queryIt = queryItems.constBegin ();
1781
+ for ( ; queryIt != queryItems.constEnd (); ++queryIt )
1782
+ {
1783
+ if ( queryIt->first .compare ( " REQUEST" , Qt::CaseInsensitive ) == 0 )
1784
+ {
1785
+ mapUrl.removeQueryItem ( queryIt->first );
1786
+ }
1787
+ else if ( queryIt->first .compare ( " VERSION" , Qt::CaseInsensitive ) == 0 )
1788
+ {
1789
+ mapUrl.removeQueryItem ( queryIt->first );
1790
+ }
1791
+ else if ( queryIt->first .compare ( " SERVICE" , Qt::CaseInsensitive ) == 0 )
1792
+ {
1793
+ mapUrl.removeQueryItem ( queryIt->first );
1794
+ }
1795
+ else if ( queryIt->first .compare ( " _DC" , Qt::CaseInsensitive ) == 0 )
1796
+ {
1797
+ mapUrl.removeQueryItem ( queryIt->first );
1798
+ }
1799
+ }
1800
+ return mapUrl.toString ();
1801
+ }
0 commit comments