[mapserver-commits] r11450 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Sun Apr 3 12:48:56 EDT 2011
Author: tamas
Date: 2011-04-03 09:48:56 -0700 (Sun, 03 Apr 2011)
New Revision: 11450
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapcluster.c
Log:
Add support for simple aggregates for the cluster layer attributes (#3700)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-04-02 22:19:06 UTC (rev 11449)
+++ trunk/mapserver/HISTORY.TXT 2011-04-03 16:48:56 UTC (rev 11450)
@@ -15,6 +15,8 @@
Current Version (SVN trunk):
----------------------------
+- Add support for simple aggregates for the cluster layer attributes (#3700)
+
- Improved error reporting in msSaveImage() (#3733)
- configure: look for libxslt.so under lib64 as well
Modified: trunk/mapserver/mapcluster.c
===================================================================
--- trunk/mapserver/mapcluster.c 2011-04-02 22:19:06 UTC (rev 11449)
+++ trunk/mapserver/mapcluster.c 2011-04-03 16:48:56 UTC (rev 11450)
@@ -527,10 +527,17 @@
else
base->shape.values[i] = msStrdup("");
}
+ else if (EQUALN(layer->items[i], "Count:", 6))
+ {
+ if (base->shape.values[i])
+ msFree(base->shape.values[i]);
+
+ base->shape.values[i] = msStrdup("1"); // initial count
+ }
}
}
-/* update the shape attributes (the non matching attributes are set to empty) */
+/* update the shape attributes (aggregate) */
static void UpdateShapeAttributes(layerObj* layer, clusterInfo* base, clusterInfo* current)
{
int i;
@@ -550,14 +557,34 @@
if (current->shape.values[i])
{
- if (EQUAL(base->shape.values[i], "Cluster:Empty"))
- continue; // already cleared
-
- if (!EQUAL(base->shape.values[i], current->shape.values[i]))
+ if (EQUALN(layer->items[i], "Min:", 4))
{
+ if (strcasecmp(base->shape.values[i], current->shape.values[i]) > 0)
+ {
+ msFree(base->shape.values[i]);
+ base->shape.values[i] = msStrdup(current->shape.values[i]);
+ }
+ }
+ else if (EQUALN(layer->items[i], "Max:", 4))
+ {
+ if (strcasecmp(base->shape.values[i], current->shape.values[i]) < 0)
+ {
+ msFree(base->shape.values[i]);
+ base->shape.values[i] = msStrdup(current->shape.values[i]);
+ }
+ }
+ else if (EQUALN(layer->items[i], "Sum:", 4))
+ {
+ double sum = atof(base->shape.values[i]) + atof(current->shape.values[i]);
msFree(base->shape.values[i]);
- base->shape.values[i] = msStrdup("Cluster:Empty");
+ base->shape.values[i] = msDoubleToString(sum, MS_FALSE);
}
+ else if (EQUALN(layer->items[i], "Count:", 6))
+ {
+ int count = atoi(base->shape.values[i]) + 1;
+ msFree(base->shape.values[i]);
+ base->shape.values[i] = msIntToString(count);
+ }
}
}
}
@@ -1242,7 +1269,18 @@
for (i = 0; i < layer->numitems; i++)
{
if (itemindexes[i] >= 0)
- layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i]);
+ {
+ if (EQUALN(layer->items[i], "Min:", 4))
+ layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4);
+ else if (EQUALN(layer->items[i], "Max:", 4))
+ layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4);
+ else if (EQUALN(layer->items[i], "Sum:", 4))
+ layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 4);
+ else if (EQUALN(layer->items[i], "Count:", 6))
+ layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i] + 6);
+ else
+ layerinfo->srcLayer.items[itemindexes[i]] = msStrdup(layer->items[i]);
+ }
}
if (msLayerInitItemInfo(&layerinfo->srcLayer) != MS_SUCCESS)
More information about the mapserver-commits
mailing list