[mapserver-commits] r10982 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Thu Feb 10 20:37:11 EST 2011
Author: aboudreault
Date: 2011-02-10 17:37:11 -0800 (Thu, 10 Feb 2011)
New Revision: 10982
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/mapdraw.c
trunk/mapserver/mapfile.c
trunk/mapserver/mapserver.h
Log:
Added minfeaturesize support at layer or class level (#1340)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2011-02-10 21:54:54 UTC (rev 10981)
+++ trunk/mapserver/HISTORY.TXT 2011-02-11 01:37:11 UTC (rev 10982)
@@ -14,6 +14,8 @@
Current Version (SVN trunk):
----------------------------
+- Added minfeaturesize support at layer or class level (#1340)
+
- Implemented support in for classifying rasters using the new
expression parsing (msGetClass()...) (#3663)
Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c 2011-02-10 21:54:54 UTC (rev 10981)
+++ trunk/mapserver/mapdraw.c 2011-02-11 01:37:11 UTC (rev 10982)
@@ -1372,7 +1372,7 @@
double r; /* circle radius */
int csz; /* clip over size */
double buffer;
- int minfeaturesize;
+ int shapeMinfeaturesize = -1, labelMinfeaturesize;
int numpaths = 1, numpoints = 1, numRegularLines = 0;
labelPathObj **annopaths = NULL; /* Curved label path. Bug #1620 implementation */
@@ -1431,7 +1431,7 @@
cliprect.miny = map->extent.miny - csz*map->cellsize;
cliprect.maxx = map->extent.maxx + csz*map->cellsize;
cliprect.maxy = map->extent.maxy + csz*map->cellsize;
- minfeaturesize = layer->class[c]->label.minfeaturesize*image->resolutionfactor;
+ labelMinfeaturesize = layer->class[c]->label.minfeaturesize*image->resolutionfactor;
if(msBindLayerToShape(layer, shape, querymapMode) != MS_SUCCESS)
return MS_FAILURE; /* error message is set in msBindLayerToShape() */
@@ -1507,9 +1507,9 @@
msTransformShape(&annoshape, map->extent, map->cellsize, image);
if(layer->class[c]->label.anglemode == MS_FOLLOW ) {
- annopaths = msPolylineLabelPath(map,image,&annoshape, minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
+ annopaths = msPolylineLabelPath(map,image,&annoshape, labelMinfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
} else {
- annopoints = msPolylineLabelPoint(&annoshape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
+ annopoints = msPolylineLabelPoint(&annoshape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
}
msFreeShape(&annoshape);
@@ -1538,7 +1538,7 @@
free(regularLines);
regularLines = NULL;
}
- annopaths = msPolylineLabelPath(map,image,shape, minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
+ annopaths = msPolylineLabelPath(map,image,shape, labelMinfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
}
for (i = 0; i < numpaths; i++)
@@ -1573,7 +1573,7 @@
if (numRegularLines > 0)
{
- annopoints = msPolylineLabelPointExtended(shape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, regularLines, numRegularLines, MS_FALSE);
+ annopoints = msPolylineLabelPointExtended(shape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, regularLines, numRegularLines, MS_FALSE);
for (i = 0; i < numpoints; i++)
{
@@ -1611,7 +1611,7 @@
angles = NULL;
lengths = NULL;
}
- annopoints = msPolylineLabelPoint(shape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
+ annopoints = msPolylineLabelPoint(shape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
}
for (i = 0; i < numpoints; i++) {
@@ -1675,8 +1675,8 @@
/* No-clip labeling support */
if(shape->text && msLayerGetProcessingKey(layer, "LABEL_NO_CLIP") != NULL) {
bLabelNoClip = MS_TRUE;
- if (minfeaturesize > 0)
- annocallret = msPolygonLabelPoint(shape, &annopnt, map->cellsize*minfeaturesize);
+ if (labelMinfeaturesize > 0)
+ annocallret = msPolygonLabelPoint(shape, &annopnt, map->cellsize*labelMinfeaturesize);
else
annocallret = msPolygonLabelPoint(shape, &annopnt, -1);
@@ -1692,7 +1692,7 @@
msOffsetShapeRelativeTo(shape, layer);
if ((bLabelNoClip == MS_TRUE && annocallret == MS_SUCCESS) ||
- (msPolygonLabelPoint(shape, &annopnt, minfeaturesize) == MS_SUCCESS)) {
+ (msPolygonLabelPoint(shape, &annopnt, labelMinfeaturesize) == MS_SUCCESS)) {
labelObj label = layer->class[c]->label;
if(label.angle != 0)
@@ -1820,6 +1820,18 @@
layer->project = MS_FALSE;
#endif
+ if (layer->minfeaturesize > 0)
+ shapeMinfeaturesize = layer->minfeaturesize;
+ if (layer->class[c]->minfeaturesize > 0)
+ shapeMinfeaturesize = layer->class[c]->minfeaturesize;
+
+ if (shapeMinfeaturesize > 0) {
+ double dx = (shape->bounds.maxx-shape->bounds.minx);
+ double dy = (shape->bounds.maxy-shape->bounds.miny);
+ if (pow(shapeMinfeaturesize*image->resolutionfactor*map->cellsize,2.0) > (pow(dx,2.0)+pow(dy,2.0)))
+ return MS_SUCCESS;
+ }
+
/* No-clip labeling support. For lines we copy the shape, though this is */
/* inefficient. msPolylineLabelPath/msPolylineLabelPoint require that */
/* the shape is transformed prior to calling them */
@@ -1832,9 +1844,9 @@
msTransformShape(&annoshape, map->extent, map->cellsize, image);
if(layer->class[c]->label.anglemode == MS_FOLLOW) {
- annopaths = msPolylineLabelPath(map,image,&annoshape, minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
+ annopaths = msPolylineLabelPath(map,image,&annoshape, labelMinfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
} else {
- annopoints = msPolylineLabelPoint(&annoshape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
+ annopoints = msPolylineLabelPoint(&annoshape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
}
msFreeShape(&annoshape);
}
@@ -1908,7 +1920,7 @@
free(regularLines);
regularLines = NULL;
}
- annopaths = msPolylineLabelPath(map,image,shape, minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
+ annopaths = msPolylineLabelPath(map,image,shape, labelMinfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &numpaths, ®ularLines, &numRegularLines);
}
for (i = 0; i < numpaths; i++)
@@ -1934,7 +1946,7 @@
if (numRegularLines > 0)
{
- annopoints = msPolylineLabelPointExtended(shape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, regularLines, numRegularLines, MS_FALSE);
+ annopoints = msPolylineLabelPointExtended(shape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, regularLines, numRegularLines, MS_FALSE);
for (i = 0; i < numpoints; i++)
{
@@ -1969,7 +1981,7 @@
angles = NULL;
lengths = NULL;
}
- annopoints = msPolylineLabelPoint(shape, minfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
+ annopoints = msPolylineLabelPoint(shape, labelMinfeaturesize, (layer->class[c]->label).repeatdistance, &angles, &lengths, &numpoints, layer->class[c]->label.anglemode);
}
for (i = 0; i < numpoints; i++) {
@@ -2037,11 +2049,23 @@
layer->project = MS_FALSE;
#endif
+ if (layer->minfeaturesize > 0)
+ shapeMinfeaturesize = layer->minfeaturesize;
+ if (layer->class[c]->minfeaturesize > 0)
+ shapeMinfeaturesize = layer->class[c]->minfeaturesize;
+
+ if (shapeMinfeaturesize > 0) {
+ double dx = (shape->bounds.maxx-shape->bounds.minx);
+ double dy = (shape->bounds.maxy-shape->bounds.miny);
+ if (pow(shapeMinfeaturesize*image->resolutionfactor*map->cellsize,2.0) > (pow(dx,2.0)+pow(dy,2.0)))
+ return MS_SUCCESS;
+ }
+
/* No-clip labeling support */
if(shape->text && msLayerGetProcessingKey(layer, "LABEL_NO_CLIP") != NULL) {
bLabelNoClip = MS_TRUE;
if (layer->class[c]->label.minfeaturesize > 0)
- annocallret = msPolygonLabelPoint(shape, &annopnt, map->cellsize*minfeaturesize);
+ annocallret = msPolygonLabelPoint(shape, &annopnt, map->cellsize*labelMinfeaturesize);
else
annocallret = msPolygonLabelPoint(shape, &annopnt, -1);
@@ -2097,16 +2121,16 @@
continue;
}
if(curStyle->_geomtransform.type == MS_GEOMTRANSFORM_NONE)
- msDrawShadeSymbol(&map->symbolset, image, shape, curStyle, layer->scalefactor);
+ msDrawShadeSymbol(&map->symbolset, image, shape, curStyle, layer->scalefactor);
else
- msDrawTransformedShape(map, &map->symbolset, image, &nonClippedShape, curStyle, layer->scalefactor);
+ msDrawTransformedShape(map, &map->symbolset, image, &nonClippedShape, curStyle, layer->scalefactor);
}
if(hasGeomTransform)
msFreeShape(&nonClippedShape);
if(shape->text) {
if((bLabelNoClip == MS_TRUE && annocallret == MS_SUCCESS) ||
- (msPolygonLabelPoint(shape, &annopnt, minfeaturesize) == MS_SUCCESS)) {
+ (msPolygonLabelPoint(shape, &annopnt, labelMinfeaturesize) == MS_SUCCESS)) {
labelObj label = layer->class[c]->label;
if(label.angle != 0)
Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c 2011-02-10 21:54:54 UTC (rev 10981)
+++ trunk/mapserver/mapfile.c 2011-02-11 01:37:11 UTC (rev 10982)
@@ -2585,6 +2585,7 @@
initHashTable(&(class->validation));
class->maxscaledenom = class->minscaledenom = -1.0;
+ class->minfeaturesize = -1; /* no limit */
/* Set maxstyles = 0, styles[] will be allocated as needed on first call
* to msGrowClassStyles()
@@ -2835,6 +2836,9 @@
case(MINSCALEDENOM):
if(getDouble(&(class->minscaledenom)) == -1) return(-1);
break;
+ case(MINFEATURESIZE):
+ if(getInteger(&(class->minfeaturesize)) == -1) return(-1);
+ break;
case(NAME):
if(getString(&class->name) == MS_FAILURE) return(-1);
break;
@@ -3058,6 +3062,7 @@
writeNumber(stream, indent, "MAXSCALEDENOM", -1, class->maxscaledenom);
writeHashTable(stream, indent, "METADATA", &(class->metadata));
writeNumber(stream, indent, "MINSCALEDENOM", -1, class->minscaledenom);
+ writeNumber(stream, indent, "MINFEATURESIZE", -1, class->minfeaturesize);
writeKeyword(stream, indent, "STATUS", class->status, 1, MS_OFF, "OFF");
for(i=0; i<class->numstyles; i++) writeStyle(stream, indent, class->styles[i]);
writeString(stream, indent, "TEMPLATE", NULL, class->template);
@@ -3103,6 +3108,7 @@
layer->scalefactor = 1.0;
layer->maxscaledenom = -1.0;
layer->minscaledenom = -1.0;
+ layer->minfeaturesize = -1; /* no limit */
layer->maxgeowidth = -1.0;
layer->mingeowidth = -1.0;
@@ -3534,6 +3540,9 @@
case(MINGEOWIDTH):
if(getDouble(&(layer->mingeowidth)) == -1) return(-1);
break;
+ case(MINFEATURESIZE):
+ if(getInteger(&(layer->minfeaturesize)) == -1) return(-1);
+ break;
case(NAME):
if(getString(&layer->name) == MS_FAILURE) return(-1);
break;
@@ -3762,6 +3771,7 @@
writeHashTable(stream, indent, "METADATA", &(layer->metadata));
writeNumber(stream, indent, "MINGEOWIDTH", -1, layer->mingeowidth);
writeNumber(stream, indent, "MINSCALEDENOM", -1, layer->minscaledenom);
+ writeNumber(stream, indent, "MINFEATURESIZE", -1, layer->minfeaturesize);
writeString(stream, indent, "NAME", NULL, layer->name);
writeColor(stream, indent, "OFFSITE", &(layer->offsite));
writeString(stream, indent, "PLUGIN", NULL, layer->plugin_library_original);
Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h 2011-02-10 21:54:54 UTC (rev 10981)
+++ trunk/mapserver/mapserver.h 2011-02-11 01:37:11 UTC (rev 10982)
@@ -990,6 +990,7 @@
#endif /* SWIG */
double minscaledenom, maxscaledenom;
+ int minfeaturesize; /* minimum feature size (in pixels) to shape */
#ifdef SWIG
%immutable;
#endif /* SWIG */
@@ -1335,6 +1336,7 @@
double symbolscaledenom; /* scale at which symbols are default size */
double minscaledenom, maxscaledenom;
+ int minfeaturesize; /* minimum feature size (in pixels) to shape */
double labelminscaledenom, labelmaxscaledenom;
double mingeowidth, maxgeowidth; /* map width (in map units) at which the layer should be drawn */
More information about the mapserver-commits
mailing list