[mapserver-commits] r11042 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Mar 3 09:10:45 EST 2011
Author: tamas
Date: 2011-03-03 06:10:45 -0800 (Thu, 03 Mar 2011)
New Revision: 11042
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapdraw.c
trunk/mapserver/maplayer.c
trunk/mapserver/mapogr.cpp
trunk/mapserver/maporaclespatial.c
trunk/mapserver/mapserver.h
Log:
Fixed OGR query handling according to RFC 65 (#3647)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/HISTORY.TXT 2011-03-03 14:10:45 UTC (rev 11042)
@@ -14,6 +14,8 @@
Current Version (SVN trunk):
----------------------------
+- Fixed OGR query handling according to RFC 65 (#3647)
+
- Implement CLOSE_CONNECTION=ALWAYS to suppress the connection pooling
for a particular layer.
Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/mapdraw.c 2011-03-03 14:10:45 UTC (rev 11042)
@@ -898,7 +898,7 @@
/* style parameters for this shape. */
if(layer->styleitem) {
if(strcasecmp(layer->styleitem, "AUTO") == 0) {
- if (msLayerGetAutoStyle(map, layer, layer->class[shape.classindex], shape.tileindex, shape.index) != MS_SUCCESS) {
+ if (msLayerGetAutoStyle(map, layer, layer->class[shape.classindex], &shape) != MS_SUCCESS) {
retcode = MS_FAILURE;
break;
}
@@ -1074,6 +1074,9 @@
if (msCopyLayer(&tmp_layer, layer) != MS_SUCCESS)
return(MS_FAILURE);
+ /* disable the connection pool for this layer */
+ msLayerSetProcessingKey(&tmp_layer, "CLOSE_CONNECTION", "ALWAYS");
+
status = msDrawLayer(map, &tmp_layer, image);
freeLayer(&tmp_layer);
Modified: trunk/mapserver/maplayer.c
===================================================================
--- trunk/mapserver/maplayer.c 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/maplayer.c 2011-03-03 14:10:45 UTC (rev 11042)
@@ -628,8 +628,7 @@
** twice.
**
*/
-int msLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
- int tile, long record)
+int msLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, shapeObj* shape)
{
if ( ! layer->vtable) {
int rv = msInitializeVirtualTable(layer);
@@ -1124,7 +1123,7 @@
return MS_FAILURE;
}
-int LayerDefaultGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, int tile, long record)
+int LayerDefaultGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, shapeObj* shape)
{
msSetError(MS_MISCERR, "'STYLEITEM AUTO' not supported for this data source.", "msLayerGetAutoStyle()");
return MS_FAILURE;
Modified: trunk/mapserver/mapogr.cpp
===================================================================
--- trunk/mapserver/mapogr.cpp 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/mapogr.cpp 2011-03-03 14:10:45 UTC (rev 11042)
@@ -82,7 +82,7 @@
static int msOGRLayerIsOpen(layerObj *layer);
static int msOGRLayerInitItemInfo(layerObj *layer);
static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
- int tile, long record);
+ shapeObj* shape);
static void msOGRCloseConnection( void *conn_handle );
/* ==================================================================
@@ -1914,8 +1914,8 @@
shape->type = MS_SHAPE_NULL;
}
- /* TODO: Need to set result index too! */
- shape->index = psInfo->last_record_index_read;
+ shape->index = OGR_F_GetFID( hFeature );;
+ shape->resultindex = psInfo->last_record_index_read;
shape->tileindex = psInfo->nTileId;
if (layer->debug >= MS_DEBUGLEVEL_VVV)
@@ -2037,7 +2037,17 @@
}
- shape->index = record;
+ if (record_is_fid)
+ {
+ shape->index = record;
+ shape->resultindex = -1;
+ }
+ else
+ {
+ shape->index = OGR_F_GetFID( hFeature );
+ shape->resultindex = record;
+ }
+
shape->tileindex = psInfo->nTileId;
// Keep ref. to last feature read in case we need style info.
@@ -2672,10 +2682,14 @@
long shapeindex = record->shapeindex;
int tileindex = record->tileindex;
int resultindex = record->resultindex;
+ int record_is_fid = TRUE;
- /*
- ** TODO: Merge logic from msOGRLayerResultGetShape() based on result->resultindex (if not -1).
- */
+ /* set the resultindex as shapeindex if available */
+ if (resultindex >= 0)
+ {
+ record_is_fid = FALSE;
+ shapeindex = resultindex;
+ }
if (psInfo == NULL || psInfo->hLayer == NULL)
{
@@ -2684,7 +2698,7 @@
}
if( layer->tileindex == NULL )
- return msOGRFileGetShape(layer, shape, shapeindex, psInfo, TRUE );
+ return msOGRFileGetShape(layer, shape, shapeindex, psInfo, record_is_fid );
else
{
if( psInfo->poCurTile == NULL
@@ -2694,7 +2708,7 @@
return MS_FAILURE;
}
- return msOGRFileGetShape(layer, shape, shapeindex, psInfo->poCurTile, TRUE );
+ return msOGRFileGetShape(layer, shape, shapeindex, psInfo->poCurTile, record_is_fid );
}
#else
/* ------------------------------------------------------------------
@@ -2709,52 +2723,6 @@
}
/**********************************************************************
- * msOGRLayerResultGetShape()
- *
- * Returns shape from OGR data source by index into the current results
- * set. TODO: THIS FUNCTION GOES AWAY!
- *
- * Returns MS_SUCCESS/MS_FAILURE
- **********************************************************************/
-int msOGRLayerResultGetShape(layerObj *layer, shapeObj *shape, int tile,
- long record)
-{
-#ifdef USE_OGR
- msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
-
- if (psInfo == NULL || psInfo->hLayer == NULL)
- {
- msSetError(MS_MISCERR, "Assertion failed: OGR layer not opened!!!",
- "msOGRLayerNextShape()");
- return(MS_FAILURE);
- }
-
- if( layer->tileindex == NULL )
- return msOGRFileGetShape(layer, shape, record, psInfo, FALSE );
- else
- {
- if( psInfo->poCurTile == NULL
- || psInfo->poCurTile->nTileId != tile )
- {
- if( msOGRFileReadTile( layer, psInfo, tile ) != MS_SUCCESS )
- return MS_FAILURE;
- }
-
- return msOGRFileGetShape(layer, shape, record, psInfo->poCurTile, FALSE );
- }
-#else
-/* ------------------------------------------------------------------
- * OGR Support not included...
- * ------------------------------------------------------------------ */
-
- msSetError(MS_MISCERR, "OGR support is not available.",
- "msOGRLayerGetShape()");
- return(MS_FAILURE);
-
-#endif /* USE_OGR */
-}
-
-/**********************************************************************
* msOGRLayerGetExtent()
*
* Returns the layer extents.
@@ -3589,7 +3557,7 @@
* the next call and that shouldn't be freed by the caller.
**********************************************************************/
static int msOGRLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c,
- int tile, long record)
+ shapeObj* shape)
{
#ifdef USE_OGR
msOGRFileInfo *psInfo =(msOGRFileInfo*)layer->layerinfo;
@@ -3603,7 +3571,7 @@
if( layer->tileindex != NULL )
{
- if( (psInfo->poCurTile == NULL || tile != psInfo->poCurTile->nTileId)
+ if( (psInfo->poCurTile == NULL || shape->tileindex != psInfo->poCurTile->nTileId)
&& msOGRFileReadTile( layer, psInfo ) != MS_SUCCESS )
return MS_FAILURE;
@@ -3615,7 +3583,7 @@
* ------------------------------------------------------------------ */
ACQUIRE_OGR_LOCK;
if (psInfo->hLastFeature == NULL ||
- psInfo->last_record_index_read != record)
+ psInfo->last_record_index_read != shape->resultindex)
{
RELEASE_OGR_LOCK;
msSetError(MS_MISCERR,
@@ -3760,7 +3728,6 @@
layer->vtable->LayerIsOpen = msOGRLayerIsOpen;
layer->vtable->LayerWhichShapes = msOGRLayerWhichShapes;
layer->vtable->LayerNextShape = msOGRLayerNextShape;
- // layer->vtable->LayerResultsGetShape = msOGRLayerResultGetShape;
layer->vtable->LayerGetShape = msOGRLayerGetShape;
layer->vtable->LayerClose = msOGRLayerClose;
layer->vtable->LayerGetItems = msOGRLayerGetItems;
Modified: trunk/mapserver/maporaclespatial.c
===================================================================
--- trunk/mapserver/maporaclespatial.c 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/maporaclespatial.c 2011-03-03 14:10:45 UTC (rev 11042)
@@ -3482,7 +3482,7 @@
/* nothing to do */
}
-int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c, int tile, long record )
+int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c, shapeObj *shape )
{
msSetError( MS_ORACLESPATIALERR, "Function not implemented yet", "msLayerGetAutoStyle()" );
return MS_FAILURE;
@@ -3550,7 +3550,7 @@
msSetError( MS_ORACLESPATIALERR, "OracleSpatial is not supported", "msOracleSpatialLayerFreeItemInfo()" );
}
-int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c, int tile, long record )
+int msOracleSpatialLayerGetAutoStyle( mapObj *map, layerObj *layer, classObj *c, shapeObj *shape )
{
msSetError( MS_ORACLESPATIALERR, "OracleSpatial is not supported", "msLayerGetAutoStyle()" );
return MS_FAILURE;
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2011-03-03 13:50:48 UTC (rev 11041)
+++ trunk/mapserver/mapserver.h 2011-03-03 14:10:45 UTC (rev 11042)
@@ -1623,7 +1623,7 @@
int (*LayerClose)(layerObj *layer);
int (*LayerGetItems)(layerObj *layer);
int (*LayerGetExtent)(layerObj *layer, rectObj *extent);
- int (*LayerGetAutoStyle)(mapObj *map, layerObj *layer, classObj *c, int tile, long record);
+ int (*LayerGetAutoStyle)(mapObj *map, layerObj *layer, classObj *c, shapeObj* shape);
int (*LayerCloseConnection)(layerObj *layer);
int (*LayerSetTimeFilter)(layerObj *layer, const char *timestring, const char *timefield);
int (*LayerApplyFilterToLayer)(FilterEncodingNode *psNode, mapObj *map, int iLayerIndex);
@@ -2038,7 +2038,7 @@
MS_DLL_EXPORT int msLayerGetShape(layerObj *layer, shapeObj *shape, resultObj *record);
MS_DLL_EXPORT int msLayerGetExtent(layerObj *layer, rectObj *extent);
MS_DLL_EXPORT int msLayerSetExtent( layerObj *layer, double minx, double miny, double maxx, double maxy);
-MS_DLL_EXPORT int msLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, int tile, long record);
+MS_DLL_EXPORT int msLayerGetAutoStyle(mapObj *map, layerObj *layer, classObj *c, shapeObj* shape);
MS_DLL_EXPORT int msLayerGetFeatureStyle(mapObj *map, layerObj *layer, classObj *c, shapeObj* shape);
MS_DLL_EXPORT void msLayerAddProcessing( layerObj *layer, const char *directive );
MS_DLL_EXPORT void msLayerSetProcessingKey( layerObj *layer, const char *key,
More information about the mapserver-commits
mailing list