* msBuildWFSLayerGetURL() * * Build a WFS GetFeature URL for a Get Request. * * Returns a reference to a newly allocated string that should be freed * by the caller. **********************************************************************/
| 302 | * by the caller. |
| 303 | **********************************************************************/ |
| 304 | static char *msBuildWFSLayerGetURL(mapObj *map, layerObj *lp, rectObj *bbox, |
| 305 | wfsParamsObj *psParams) |
| 306 | { |
| 307 | char *pszURL = NULL, *pszOnlineResource=NULL; |
| 308 | const char *pszTmp; |
| 309 | char *pszVersion, *pszService, *pszTypename = NULL; |
| 310 | int bVersionInConnection = 0, bServiceInConnection = 0; |
| 311 | int bTypenameInConnection = 0; |
| 312 | size_t bufferSize = 0; |
| 313 | |
| 314 | if (lp->connectiontype != MS_WFS || lp->connection == NULL) |
| 315 | { |
| 316 | msSetError(MS_WFSCONNERR, "Call supported only for CONNECTIONTYPE WFS", |
| 317 | "msBuildWFSLayerGetURL()"); |
| 318 | return NULL; |
| 319 | } |
| 320 | |
| 321 | /* -------------------------------------------------------------------- */ |
| 322 | /* Find out request version. Look first for the wfs_version */ |
| 323 | /* metedata. If not available try to find out if the CONNECTION */ |
| 324 | /* string contains the version. This last test is done for */ |
| 325 | /* backward compatiblity but is depericated. */ |
| 326 | /* -------------------------------------------------------------------- */ |
| 327 | pszVersion = psParams->pszVersion; |
| 328 | if (!pszVersion) |
| 329 | { |
| 330 | if ((pszTmp = strstr(lp->connection, "VERSION=")) == NULL && |
| 331 | (pszTmp = strstr(lp->connection, "version=")) == NULL ) |
| 332 | { |
| 333 | msSetError(MS_WFSCONNERR, "Metadata wfs_version must be set in the layer", "msBuildWFSLayerGetURL()"); |
| 334 | return NULL; |
| 335 | } |
| 336 | pszVersion = strchr(pszTmp, '=')+1; |
| 337 | bVersionInConnection = 1; |
| 338 | } |
| 339 | |
| 340 | |
| 341 | if (strncmp(pszVersion, "0.0.14", 6) != 0 && |
| 342 | strncmp(pszVersion, "1.0.0", 5) != 0 && |
| 343 | strncmp(pszVersion, "1.1", 3) != 0) |
| 344 | { |
| 345 | msSetError(MS_WFSCONNERR, "MapServer supports only WFS 1.0.0 or 0.0.14 (please verify the version metadata wfs_version).", "msBuildWFSLayerGetURL()"); |
| 346 | return NULL; |
| 347 | } |
| 348 | |
| 349 | /* -------------------------------------------------------------------- */ |
| 350 | /* Find out the service. It is always set to WFS in function */ |
| 351 | /* msBuildRequestParms (check Bug 1302 for details). */ |
| 352 | /* -------------------------------------------------------------------- */ |
| 353 | pszService = psParams->pszService; |
| 354 | |
| 355 | |
| 356 | /* -------------------------------------------------------------------- */ |
| 357 | /* Find out the typename. Look first for the wfs_tyename */ |
| 358 | /* metadata. If not available try to find out if the CONNECTION */ |
| 359 | /* string contains it. This last test is done for */ |
| 360 | /* backward compatiblity but is depericated. */ |
| 361 | /* -------------------------------------------------------------------- */ |
no test coverage detected