[mapserver-commits] r11482 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Apr 6 18:26:42 EDT 2011
Author: assefa
Date: 2011-04-06 15:26:42 -0700 (Wed, 06 Apr 2011)
New Revision: 11482
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapdraw.c
trunk/mapserver/mapkmlrenderer.cpp
trunk/mapserver/mapkmlrenderer.h
trunk/mapserver/maplayer.c
trunk/mapserver/mapserver.h
Log:
Allow users to set the maximum number of vector features to be drawn (#3739)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/HISTORY.TXT 2011-04-06 22:26:42 UTC (rev 11482)
@@ -15,6 +15,8 @@
Current Version (SVN trunk):
----------------------------
+- Allow users to set the maximum number of vector features to be drawn (#3739)
+
- Fixed FCGI on Windows problem related to lexer (#3812)
- KML: Add ows/kml_exclude_items (#3560)
Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/mapdraw.c 2011-04-06 22:26:42 UTC (rev 11482)
@@ -777,8 +777,11 @@
int nclasses = 0;
int *classgroup = NULL;
double minfeaturesize = -1;
+ int maxfeatures=-1;
+ int featuresdrawn=0;
-
+ if (image)
+ maxfeatures=msLayerGetMaxFeaturesToDraw(layer, image->format);
//TODO TBT: draw as raster layer in vector renderers
@@ -855,6 +858,13 @@
continue;
}
+ if (maxfeatures >=0 && featuresdrawn >= maxfeatures)
+ {
+ status = MS_DONE;
+ break;
+ }
+ featuresdrawn++;
+
cache = MS_FALSE;
if(layer->type == MS_LAYER_LINE && (layer->class[shape.classindex]->numstyles > 1 ||
(layer->class[shape.classindex]->numstyles == 1 && layer->class[shape.classindex]->styles[0]->outlinewidth>0)))
@@ -884,6 +894,7 @@
if(annotate && (layer->class[shape.classindex]->text.string || layer->labelitem) && layer->class[shape.classindex]->label.size != -1)
shape.text = msShapeGetAnnotation(layer, &shape);
+
if (cache) {
int i;
for (i = 0; i < layer->class[shape.classindex]->numstyles; i++) {
Modified: trunk/mapserver/mapkmlrenderer.cpp
===================================================================
--- trunk/mapserver/mapkmlrenderer.cpp 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/mapkmlrenderer.cpp 2011-04-06 22:26:42 UTC (rev 11482)
@@ -39,6 +39,7 @@
# include "cpl_vsi.h"
#endif
+#define KML_MAXFEATURES_TODRAW 1000
KmlRenderer::KmlRenderer(int width, int height, outputFormatObj *format, colorObj* color/*=NULL*/)
: Width(width), Height(height), MapCellsize(1.0), XmlDoc(NULL), LayerNode(NULL), GroundOverlayNode(NULL),
@@ -216,10 +217,14 @@
/* */
/* Set parameters that make sense to a kml output. */
/************************************************************************/
-void KmlRenderer::processLayer(layerObj *layer)
+void KmlRenderer::processLayer(layerObj *layer, outputFormatObj *format)
{
int i;
const char *asRaster = NULL;
+ int nMaxFeatures = -1;
+ const char *pszTmp;
+ char szTmp[10];
+
if (!layer)
return;
@@ -252,6 +257,26 @@
msLayerAddProcessing(layer, "RENDERER=png24");
+ /*set a maxfeaturestodraw, if not already set*/
+
+ pszTmp = msLookupHashTable(&layer->metadata, "maxfeaturestodraw");
+ if (pszTmp)
+ nMaxFeatures = atoi(pszTmp);
+ else
+ {
+ pszTmp = msLookupHashTable(&layer->map->web.metadata, "maxfeaturestodraw");
+ if (pszTmp)
+ nMaxFeatures = atoi(pszTmp);
+ }
+ if (nMaxFeatures < 0 && format)
+ nMaxFeatures = atoi(msGetOutputFormatOption( format, "maxfeaturestodraw", "-1"));
+
+ if (nMaxFeatures < 0 && format)
+ {
+ snprintf(szTmp, sizeof(szTmp), "%d", KML_MAXFEATURES_TODRAW);
+ msSetOutputFormatOption( format, "maxfeaturestodraw", szTmp);
+ }
+
}
/************************************************************************/
@@ -292,7 +317,7 @@
return pszAlias;
}
-int KmlRenderer::startNewLayer(imageObj *, layerObj *layer)
+int KmlRenderer::startNewLayer(imageObj *img, layerObj *layer)
{
char *layerName=NULL;
const char *value=NULL;
@@ -366,7 +391,10 @@
}
/*pre process the layer to set things that make sense for kml output*/
- processLayer(layer);
+ if (img)
+ processLayer(layer, img->format);
+ else
+ processLayer(layer, NULL);
if (msLookupHashTable(&layer->metadata, "kml_description"))
pszLayerDescMetadata = msLookupHashTable(&layer->metadata, "kml_description");
Modified: trunk/mapserver/mapkmlrenderer.h
===================================================================
--- trunk/mapserver/mapkmlrenderer.h 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/mapkmlrenderer.h 2011-04-06 22:26:42 UTC (rev 11482)
@@ -138,7 +138,7 @@
void flushPlacemark();
xmlNodePtr getGeomParentNode(const char *geomName);
char* getLayerName(layerObj *layer);
- void processLayer(layerObj *layer);
+ void processLayer(layerObj *layer, outputFormatObj *format);
void addLineStyleToList(strokeStyleObj *style);
const char *getAliasName(layerObj *lp, char *pszItemName, const char *namespaces);
Modified: trunk/mapserver/maplayer.c
===================================================================
--- trunk/mapserver/maplayer.c 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/maplayer.c 2011-04-06 22:26:42 UTC (rev 11482)
@@ -767,6 +767,36 @@
return NULL;
}
+
+/************************************************************************/
+/* msLayerGetMaxFeaturesToDraw */
+/* */
+/* Check to see if maxfeaturestodraw is set as a metadata or an */
+/* output format option. Used for vector layers to limit the */
+/* number of fatures rendered. */
+/************************************************************************/
+int msLayerGetMaxFeaturesToDraw(layerObj *layer, outputFormatObj *format)
+{
+ int nMaxFeatures = -1;
+ const char *pszTmp = NULL;
+ if (layer && format)
+ {
+ pszTmp = msLookupHashTable(&layer->metadata, "maxfeaturestodraw");
+ if (pszTmp)
+ nMaxFeatures = atoi(pszTmp);
+ else
+ {
+ pszTmp = msLookupHashTable(&layer->map->web.metadata, "maxfeaturestodraw");
+ if (pszTmp)
+ nMaxFeatures = atoi(pszTmp);
+ }
+ if (nMaxFeatures < 0)
+ nMaxFeatures = atoi(msGetOutputFormatOption( format, "maxfeaturestodraw", "-1"));
+ }
+
+ return nMaxFeatures;
+
+}
int msLayerClearProcessing( layerObj *layer ) {
if (layer->numprocessing > 0) {
msFreeCharArray( layer->processing, layer->numprocessing );
@@ -1441,3 +1471,5 @@
return MS_SUCCESS;
}
+
+
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2011-04-06 21:50:35 UTC (rev 11481)
+++ trunk/mapserver/mapserver.h 2011-04-06 22:26:42 UTC (rev 11482)
@@ -2086,6 +2086,8 @@
MS_DLL_EXPORT int msLayerSupportsPaging(layerObj *layer);
+MS_DLL_EXPORT int msLayerGetMaxFeaturesToDraw(layerObj *layer, outputFormatObj *format);
+
/* These are special because SWF is using these */
int msOGRLayerNextShape(layerObj *layer, shapeObj *shape);
int msOGRLayerGetItems(layerObj *layer);
More information about the mapserver-commits
mailing list