| 749 | **********************************************************************/ |
| 750 | |
| 751 | int msWFSLayerOpen(layerObj *lp, |
| 752 | const char *pszGMLFilename, rectObj *defaultBBOX) |
| 753 | { |
| 754 | #ifdef USE_WFS_LYR |
| 755 | int status = MS_SUCCESS; |
| 756 | msWFSLayerInfo *psInfo = NULL; |
| 757 | |
| 758 | if ( msCheckParentPointer(lp->map,"map")==MS_FAILURE ) |
| 759 | return MS_FAILURE; |
| 760 | |
| 761 | if (lp->wfslayerinfo != NULL) |
| 762 | { |
| 763 | psInfo =(msWFSLayerInfo*)lp->wfslayerinfo; |
| 764 | |
| 765 | /* Layer already opened. If explicit filename requested then check */ |
| 766 | /* that file was already opened with the same filename. */ |
| 767 | /* If no explicit filename requested then we'll try to reuse the */ |
| 768 | /* previously opened layer... this will happen in a msDrawMap() call. */ |
| 769 | if (pszGMLFilename == NULL || |
| 770 | (psInfo->pszGMLFilename && pszGMLFilename && |
| 771 | strcmp(psInfo->pszGMLFilename, pszGMLFilename) == 0) ) |
| 772 | { |
| 773 | if (lp->layerinfo == NULL) |
| 774 | { |
| 775 | if (msWFSLayerWhichShapes(lp, psInfo->rect, MS_FALSE) == MS_FAILURE) /* no access to context (draw vs. query) here, although I doubt it matters... */ |
| 776 | return MS_FAILURE; |
| 777 | } |
| 778 | return MS_SUCCESS; /* Nothing to do... layer is already opened */ |
| 779 | } |
| 780 | else |
| 781 | { |
| 782 | /* Hmmm... should we produce a fatal error? */ |
| 783 | /* For now we'll just close the layer and reopen it. */ |
| 784 | if (lp->debug) |
| 785 | msDebug("msWFSLayerOpen(): Layer already opened (%s)\n", |
| 786 | lp->name?lp->name:"(null)" ); |
| 787 | msWFSLayerClose(lp); |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | /* ------------------------------------------------------------------ |
| 792 | * Alloc and fill msWFSLayerInfo inside layer obj |
| 793 | * ------------------------------------------------------------------ */ |
| 794 | lp->wfslayerinfo = psInfo = msAllocWFSLayerInfo(); |
| 795 | |
| 796 | if (pszGMLFilename) |
| 797 | psInfo->pszGMLFilename = msStrdup(pszGMLFilename); |
| 798 | else |
| 799 | { |
| 800 | psInfo->pszGMLFilename = msTmpFile(lp->map, |
| 801 | lp->map->mappath, |
| 802 | NULL, |
| 803 | "tmp.gml"); |
| 804 | } |
| 805 | |
| 806 | if (defaultBBOX) |
| 807 | { |
| 808 | /* __TODO__ If new bbox differs from current one then we should */ |
no test coverage detected