@@ -3004,7 +3004,6 @@ static int msWFSComputeMatchingFeatures(mapObj *map,
3004
3004
int nWFSVersion )
3005
3005
{
3006
3006
int nMatchingFeatures = -1 ;
3007
- int j ;
3008
3007
3009
3008
if ( nWFSVersion >= OWS_2_0_0 )
3010
3009
{
@@ -3056,28 +3055,24 @@ static int msWFSComputeMatchingFeatures(mapObj *map,
3056
3055
if ( pszComputeNumberMatched != NULL &&
3057
3056
strcasecmp (pszComputeNumberMatched , "true" ) == 0 )
3058
3057
{
3059
- resultCacheObj * * saveResultCache = (resultCacheObj * * )
3060
- msSmallMalloc ( map -> numlayers * sizeof (resultCacheObj * ));
3061
-
3062
- /* Save the result cache that contains the features that we want to */
3063
- /* emit in the response */
3064
- for (j = 0 ; j < map -> numlayers ; j ++ ) {
3065
- layerObj * lp = GET_LAYER (map , j );
3066
- saveResultCache [j ] = lp -> resultcache ;
3067
- lp -> resultcache = NULL ;
3058
+ int j ;
3059
+ mapObj * mapTmp = (mapObj * )msSmallCalloc (1 , sizeof (mapObj ));
3060
+ initMap (mapTmp );
3061
+ msCopyMap (mapTmp , map );
3068
3062
3069
- /* Resent layer paging */
3063
+ /* Re-run the query but with no limit */
3064
+ mapTmp -> query .maxfeatures = -1 ;
3065
+ mapTmp -> query .startindex = -1 ;
3066
+ mapTmp -> query .only_cache_result_count = MS_TRUE ;
3067
+ for (j = 0 ; j < mapTmp -> numlayers ; j ++ ) {
3068
+ layerObj * lp = GET_LAYER (mapTmp , j );
3069
+ /* Reset layer paging */
3070
3070
lp -> maxfeatures = -1 ;
3071
3071
lp -> startindex = -1 ;
3072
3072
}
3073
3073
3074
- /* Re-run the query but with no limit */
3075
- map -> query .maxfeatures = -1 ;
3076
- map -> query .startindex = -1 ;
3077
- map -> query .only_cache_result_count = MS_TRUE ;
3078
-
3079
3074
nMatchingFeatures = 0 ;
3080
- msWFSRetrieveFeatures (map ,
3075
+ msWFSRetrieveFeatures (mapTmp ,
3081
3076
ows_request ,
3082
3077
paramsObj ,
3083
3078
pgmlinfo ,
@@ -3093,17 +3088,7 @@ static int msWFSComputeMatchingFeatures(mapObj *map,
3093
3088
& nMatchingFeatures ,
3094
3089
NULL );
3095
3090
3096
- /* Restore the original result cache */
3097
- for (j = 0 ; j < map -> numlayers ; j ++ ) {
3098
- layerObj * lp = GET_LAYER (map , j );
3099
- if (lp -> resultcache ) {
3100
- if (lp -> resultcache -> results ) free (lp -> resultcache -> results );
3101
- free (lp -> resultcache );
3102
- lp -> resultcache = NULL ;
3103
- }
3104
- lp -> resultcache = saveResultCache [j ];
3105
- }
3106
- msFree (saveResultCache );
3091
+ msFreeMap (mapTmp );
3107
3092
}
3108
3093
}
3109
3094
}
0 commit comments