Skip to content

Commit

Permalink
Set the pagination control per driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Boudreault committed Jun 15, 2012
1 parent 3a03f4a commit 879ee18
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 16 deletions.
1 change: 1 addition & 0 deletions configure.in
Expand Up @@ -1285,6 +1285,7 @@ else
fi

dnl Try to locate include directory
test -f $ORA_HOME/include/oci.h && ORA_INCDIR="$ORA_HOME/include"
test -f $ORA_HOME/sdk/include/oci.h && ORA_INCDIR="$ORA_HOME/sdk/include"
test -f $ORA_HOME/rdbms/public/oci.h && ORA_INCDIR="$ORA_HOME/rdbms/public"
test -f $ORA_HOME/rdbms/demo/oci.h && ORA_INCDIR="$ORA_HOME/rdbms/public"
Expand Down
19 changes: 19 additions & 0 deletions maplayer.c
Expand Up @@ -1213,6 +1213,18 @@ msLayerApplyPlainFilterToLayer(FilterEncodingNode *psNode, mapObj *map,
#endif
}

int msLayerGetPaging(layerObj *layer)
{
if ( ! layer->vtable) {
int rv = msInitializeVirtualTable(layer);
if (rv != MS_SUCCESS) {
msSetError(MS_MISCERR, "Unable to initialize virtual table", "msLayerGetPaging()");
return;
}
}
return layer->vtable->LayerGetPaging(layer);
}

void msLayerEnablePaging(layerObj *layer, int value)
{
if ( ! layer->vtable) {
Expand Down Expand Up @@ -1269,6 +1281,11 @@ int LayerDefaultSupportsCommonFilters(layerObj *layer)
return MS_FALSE;
}

int msLayerDefaultGetPaging(layerObj *layer)
{
return MS_TRUE;
}

void msLayerDefaultEnablePaging(layerObj *layer, int value)
{
return;
Expand Down Expand Up @@ -1418,6 +1435,7 @@ static int populateVirtualTable(layerVTableObj *vtable)
vtable->LayerEscapePropertyName = LayerDefaultEscapePropertyName;

vtable->LayerEnablePaging = msLayerDefaultEnablePaging;
vtable->LayerGetPaging = msLayerDefaultGetPaging;

return MS_SUCCESS;
}
Expand Down Expand Up @@ -1654,6 +1672,7 @@ msINLINELayerInitializeVirtualTable(layerObj *layer)
/*layer->vtable->LayerEscapePropertyName, use default*/

/* layer->vtable->LayerEnablePaging, use default */
/* layer->vtable->LayerGetPaging, use default */

return MS_SUCCESS;
}
Expand Down
5 changes: 4 additions & 1 deletion mapogcfilter.c
Expand Up @@ -3676,6 +3676,7 @@ void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
layerObj *lp=NULL;
char szTmp[256];
const char *pszFullName = NULL;
int layerWasOpened = MS_FALSE;

#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR)

Expand All @@ -3685,6 +3686,7 @@ void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
FLTStripNameSpacesFromPropertyName(psFilterNode);

lp = GET_LAYER(map, i);
layerWasOpened = msLayerIsOpen(lp);
if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS)
{
for(i=0; i<lp->numitems; i++)
Expand All @@ -3699,7 +3701,8 @@ void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
lp->items[i]);
}
}
msLayerClose(lp);
if (!layerWasOpened) /* do not close the layer if it has been opened somewhere else (paging?) */
msLayerClose(lp);
}
}
#else
Expand Down
30 changes: 27 additions & 3 deletions maporaclespatial.c
Expand Up @@ -3500,6 +3500,22 @@ int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c,
return MS_FAILURE;
}

int msOrableSpatialGetPaging(layerObj *layer)
{
msOracleSpatialLayerInfo *layerinfo = NULL;

if (layer->debug)
msDebug("msOracleSpatialLayerGetPaging was called.\n");

if(!msOracleSpatialLayerIsOpen(layer))
return MS_TRUE;

assert( layer->layerinfo != NULL);
layerinfo = (msOracleSpatialLayerInfo *)layer->layerinfo;

return layerinfo->paging;
}

void msOrableSpatialEnablePaging(layerObj *layer, int value)
{
msOracleSpatialLayerInfo *layerinfo = NULL;
Expand All @@ -3511,11 +3527,11 @@ void msOrableSpatialEnablePaging(layerObj *layer, int value)
msOracleSpatialLayerOpen(layer);

assert( layer->layerinfo != NULL);
layerinfo = (msOracleSpatialLayerInfo *)layer->layerinfo
layerinfo = (msOracleSpatialLayerInfo *)layer->layerinfo;

layerinfo->paging = value;

return;
return;
}

#else
Expand Down Expand Up @@ -3586,12 +3602,18 @@ int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c,
return MS_FAILURE;
}

void msOrableSpatialEnablePaging(int value)
void msOrableSpatialEnablePaging(layerObj *layer, int value)
{
msSetError( MS_ORACLESPATIALERR, "OracleSpatial is not supported", "msLayerEnablePaging()" );
return;
}

int msOrableSpatialGetPaging(layerObj *layer)
{
msSetError( MS_ORACLESPATIALERR, "OracleSpatial is not supported", "msLayerGetPaging()" );
return;
}

#endif

#ifdef USE_ORACLE_PLUGIN
Expand Down Expand Up @@ -3621,6 +3643,7 @@ PluginInitializeVirtualTable(layerVTableObj* vtable, layerObj *layer)
/* layer->vtable->LayerGetNumFeatures, use default */
/* layer->vtable->LayerGetAutoProjection = msOracleSpatialLayerGetAutoProjection; Disabled until tested */
vtable->LayerEnablePaging = msOrableSpatialEnablePaging;
vtable->LayerGetPaging = msOrableSpatialGetPaging;

return MS_SUCCESS;
}
Expand Down Expand Up @@ -3650,6 +3673,7 @@ int msOracleSpatialLayerInitializeVirtualTable(layerObj *layer)
/* layer->vtable->LayerGetNumFeatures, use default */
/* layer->vtable->LayerGetAutoProjection = msOracleSpatialLayerGetAutoProjection; Disabled until tested */
layer->vtable->LayerEnablePaging = msOrableSpatialEnablePaging;
layer->vtable->LayerGetPaging = msOrableSpatialGetPaging;

return MS_SUCCESS;
}
Expand Down
20 changes: 19 additions & 1 deletion mappostgis.c
Expand Up @@ -3317,6 +3317,23 @@ void msPostGISEnablePaging(layerObj *layer, int value) {
return;
}

int msPostGISGetPaging(layerObj *layer) {

msPostGISLayerInfo *layerinfo = NULL;

if (layer->debug) {
msDebug("msPostGISGetPaging called.\n");
}

if(!msPostGISLayerIsOpen(layer))
return MS_TRUE;

assert( layer->layerinfo != NULL);

layerinfo = (msPostGISLayerInfo *)layer->layerinfo;
return layerinfo->paging;
}

int msPostGISLayerInitializeVirtualTable(layerObj *layer) {
assert(layer != NULL);
assert(layer->vtable != NULL);
Expand All @@ -3341,7 +3358,8 @@ int msPostGISLayerInitializeVirtualTable(layerObj *layer) {
/* layer->vtable->LayerGetAutoProjection, use defaut*/

layer->vtable->LayerEscapeSQLParam = msPostGISEscapeSQLParam;
layer->vtable->LayerEnablePaging = msPostGISEnablePaging;
layer->vtable->LayerEnablePaging = msPostGISEnablePaging;
layer->vtable->LayerGetPaging = msPostGISGetPaging;

return MS_SUCCESS;
}
32 changes: 22 additions & 10 deletions mapquery.c
Expand Up @@ -503,10 +503,10 @@ int msQueryByIndex(mapObj *map)
}

msLayerClose(lp); /* reset */
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);
status = msLayerOpen(lp);
if(status != MS_SUCCESS) return(MS_FAILURE);
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
Expand Down Expand Up @@ -598,6 +598,7 @@ int msQueryByAttributes(mapObj *map)
rectObj searchrect;

shapeObj shape;
int paging;

int nclasses = 0;
int *classgroup = NULL;
Expand Down Expand Up @@ -653,12 +654,15 @@ int msQueryByAttributes(mapObj *map)

msInitShape(&shape);

/* Paging could have been disabled before */
paging = msLayerGetPaging(lp);
msLayerClose(lp); /* reset */
status = msLayerOpen(lp);
if(status != MS_SUCCESS) {
msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
return(MS_FAILURE);
}
msLayerEnablePaging(lp, paging);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
Expand Down Expand Up @@ -839,11 +843,10 @@ int msQueryByFilter(mapObj *map)
}

msLayerClose(lp); /* reset */
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);

status = msLayerOpen(lp);
if(status != MS_SUCCESS) goto query_error;
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
Expand Down Expand Up @@ -967,7 +970,8 @@ int msQueryByRect(mapObj *map)
shapeObj shape, searchshape;
rectObj searchrect;
double layer_tolerance = 0, tolerance = 0;


int paging;
int nclasses = 0;
int *classgroup = NULL;
double minfeaturesize = -1;
Expand Down Expand Up @@ -1037,10 +1041,13 @@ int msQueryByRect(mapObj *map)
continue;
}

/* Paging could have been disabled before */
paging = msLayerGetPaging(lp);
msLayerClose(lp); /* reset */
status = msLayerOpen(lp);
if(status != MS_SUCCESS) return(MS_FAILURE);

msLayerEnablePaging(lp, paging);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
if(status != MS_SUCCESS) return(MS_FAILURE);
Expand Down Expand Up @@ -1252,6 +1259,7 @@ int msQueryByFeatures(mapObj *map)
msLayerClose(lp); /* reset */
status = msLayerOpen(lp);
if(status != MS_SUCCESS) return(MS_FAILURE);
msLayerEnablePaging(lp, MS_FALSE);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
Expand Down Expand Up @@ -1482,6 +1490,7 @@ int msQueryByPoint(mapObj *map)

layerObj *lp;

int paging;
char status;
rectObj rect, searchrect;
shapeObj shape;
Expand Down Expand Up @@ -1558,10 +1567,13 @@ int msQueryByPoint(mapObj *map)
rect.miny = map->query.point.y - t;
rect.maxy = map->query.point.y + t;

/* Paging could have been disabled before */
paging = msLayerGetPaging(lp);
msLayerClose(lp); /* reset */
status = msLayerOpen(lp);
if(status != MS_SUCCESS) return(MS_FAILURE);

msLayerEnablePaging(lp, paging);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
if(status != MS_SUCCESS) return(MS_FAILURE);
Expand Down Expand Up @@ -1759,10 +1771,10 @@ int msQueryByShape(mapObj *map)
tolerance = layer_tolerance * (msInchesPerUnit(lp->toleranceunits,0)/msInchesPerUnit(map->units,0));

msLayerClose(lp); /* reset */
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);
status = msLayerOpen(lp);
if(status != MS_SUCCESS) return(MS_FAILURE);
/* disable driver paging */
msLayerEnablePaging(lp, MS_FALSE);

/* build item list, we want *all* items */
status = msLayerWhichItems(lp, MS_TRUE, NULL);
Expand Down
4 changes: 3 additions & 1 deletion mapserver.h
Expand Up @@ -1757,7 +1757,8 @@ struct layerVTable {
int (*LayerGetAutoProjection)(layerObj *layer, projectionObj *projection);
char* (*LayerEscapeSQLParam)(layerObj *layer, const char* pszString);
char* (*LayerEscapePropertyName)(layerObj *layer, const char* pszString);
void (*LayerEnablePaging)(layerObj *layer, int value);
void (*LayerEnablePaging)(layerObj *layer, int value);
int (*LayerGetPaging)(layerObj *layer);
};
#endif /*SWIG*/

Expand Down Expand Up @@ -2201,6 +2202,7 @@ MS_DLL_EXPORT int msLayerGetNumFeatures(layerObj *layer);
MS_DLL_EXPORT int msLayerSupportsPaging(layerObj *layer);

MS_DLL_EXPORT void msLayerEnablePaging(layerObj *layer, int value);
MS_DLL_EXPORT int msLayerGetPaging(layerObj *layer);

MS_DLL_EXPORT int msLayerGetMaxFeaturesToDraw(layerObj *layer, outputFormatObj *format);

Expand Down

0 comments on commit 879ee18

Please sign in to comment.