[mapserver-commits] r11774 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue May 31 17:36:32 EDT 2011
Author: tamas
Date: 2011-05-31 14:36:32 -0700 (Tue, 31 May 2011)
New Revision: 11774
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapunion.c
Log:
Union layer 3 new processing options added (#3900)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-05-31 19:00:43 UTC (rev 11773)
+++ trunk/mapserver/HISTORY.TXT 2011-05-31 21:36:32 UTC (rev 11774)
@@ -15,6 +15,8 @@
Current Version (SVN trunk, 6.1-dev, future 6.2):
-------------------------------------------------
+- Union layer 3 new processing options added (#3900)
+
- Changed msRemoveStyle to allow removing all styles (#3895)
- Fixed mssql2008 to return correct geometries with chart layer type (#3894)
Modified: trunk/mapserver/mapunion.c
===================================================================
--- trunk/mapserver/mapunion.c 2011-05-31 19:00:43 UTC (rev 11773)
+++ trunk/mapserver/mapunion.c 2011-05-31 21:36:32 UTC (rev 11774)
@@ -82,6 +82,47 @@
return MS_SUCCESS;
}
+int isScaleInRange(mapObj* map, layerObj *layer)
+{
+ if(map->scaledenom > 0)
+ {
+ int i;
+ /* layer scale boundaries should be checked first */
+ if((layer->maxscaledenom > 0) && (map->scaledenom > layer->maxscaledenom))
+ return MS_FALSE;
+
+ if((layer->minscaledenom > 0) && (map->scaledenom <= layer->minscaledenom))
+ return MS_FALSE;
+
+ /* now check class scale boundaries (all layers *must* pass these tests) */
+ if(layer->numclasses > 0)
+ {
+ for(i=0; i<layer->numclasses; i++)
+ {
+ if((layer->class[i]->maxscaledenom > 0) && (map->scaledenom > layer->class[i]->maxscaledenom))
+ continue; /* can skip this one, next class */
+ if((layer->class[i]->minscaledenom > 0) && (map->scaledenom <= layer->class[i]->minscaledenom))
+ continue; /* can skip this one, next class */
+
+ break; /* can't skip this class (or layer for that matter) */
+ }
+ if(i == layer->numclasses)
+ return MS_FALSE;
+
+ }
+
+ if (layer->maxscaledenom <= 0 && layer->minscaledenom <= 0)
+ {
+ if((layer->maxgeowidth > 0) && ((map->extent.maxx - map->extent.minx) > layer->maxgeowidth))
+ return MS_FALSE;
+
+ if((layer->mingeowidth > 0) && ((map->extent.maxx - map->extent.minx) < layer->mingeowidth))
+ return MS_FALSE;
+ }
+ }
+ return MS_TRUE;
+}
+
int msUnionLayerOpen(layerObj *layer)
{
msUnionLayerInfo *layerinfo;
@@ -89,6 +130,9 @@
mapObj* map;
int i;
int layerCount;
+ const char* pkey;
+ int status_check;
+ int scale_check;
if (layer->layerinfo != NULL)
{
@@ -121,6 +165,20 @@
layerinfo->layerCount = 0;
layerinfo->classText = NULL;
+
+ pkey = msLayerGetProcessingKey(layer, "UNION_STATUS_CHECK");
+ if(pkey && strcasecmp(pkey, "true") == 0)
+ status_check = MS_TRUE;
+ else
+ status_check = MS_FALSE;
+
+ pkey = msLayerGetProcessingKey(layer, "UNION_SCALE_CHECK");
+ if(pkey && strcasecmp(pkey, "false") == 0)
+ scale_check = MS_FALSE;
+ else
+ scale_check = MS_TRUE;
+
+ pkey = msLayerGetProcessingKey(layer, "UNION_SRCLAYER_CLOSE_CONNECTION");
layerNames = msStringSplit(layer->connection, ',', &layerCount);
@@ -176,9 +234,26 @@
return MS_FAILURE;
}
- /* disable the connection pool for this layer */
- msLayerSetProcessingKey(&layerinfo->layers[i], "CLOSE_CONNECTION", "ALWAYS");
+ if (pkey)
+ {
+ /* override connection flag */
+ msLayerSetProcessingKey(&layerinfo->layers[i], "CLOSE_CONNECTION", pkey);
+ }
+ /* check is we should skip this source (status check) */
+ if (status_check && layerinfo->layers[i].status == MS_OFF)
+ {
+ layerinfo->status[i] = MS_DONE;
+ continue;
+ }
+
+ /* check is we should skip this source (scale check) */
+ if (scale_check && isScaleInRange(map, &layerinfo->layers[i]) == MS_FALSE)
+ {
+ layerinfo->status[i] = MS_DONE;
+ continue;
+ }
+
layerinfo->status[i] = msLayerOpen(&layerinfo->layers[i]);
if (layerinfo->status[i] != MS_SUCCESS)
{
@@ -309,6 +384,9 @@
{
layerObj* srclayer = &layerinfo->layers[i];
+ if (layerinfo->status[i] != MS_SUCCESS)
+ continue; /* skip empty layers */
+
msUnionLayerFreeExpressionTokens(srclayer);
if (itemlist)
@@ -347,6 +425,9 @@
{
layerObj* srclayer = &layerinfo->layers[i];
+ if (layerinfo->status[i] != MS_SUCCESS)
+ continue; /* skip empty layers */
+
if (layer->styleitem && layer->numitems == 0)
{
/* need to initialize items */
@@ -590,6 +671,9 @@
for (i = 0; i < layerinfo->layerCount; i++)
{
+ if (layerinfo->status[i] != MS_SUCCESS)
+ continue; /* skip empty layers */
+
c = msLayerGetNumFeatures(&layerinfo->layers[i]);
if (c > 0)
numFeatures += c;
More information about the mapserver-commits
mailing list