41
41
* this function
42
42
*/
43
43
int msDrawLegendIcon (mapObj * map , layerObj * lp , classObj * theclass ,
44
- int width , int height , imageObj * image , int dstX , int dstY )
44
+ int width , int height , imageObj * image , int dstX , int dstY ,
45
+ int scale_independant )
45
46
{
46
47
int i , type , hasmarkersymbol ;
47
48
double offset ;
@@ -145,13 +146,23 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
145
146
marker .y = dstY + MS_NINT (height / 2.0 );
146
147
hasmarkersymbol = 0 ;
147
148
for (i = 0 ; i < theclass -> numstyles ; i ++ ) {
148
- if (theclass -> styles [i ]-> symbol < map -> symbolset .numsymbols && theclass -> styles [i ]-> symbol > 0 ) {
149
- hasmarkersymbol = 1 ;
150
- break ;
151
- }
149
+ if (!scale_independant && map -> scaledenom > 0 ) {
150
+ styleObj * lp = theclass -> styles [i ];
151
+ if ((lp -> maxscaledenom > 0 ) && (map -> scaledenom > lp -> maxscaledenom )) continue ;
152
+ if ((lp -> minscaledenom > 0 ) && (map -> scaledenom <= lp -> minscaledenom )) continue ;
153
+ }
154
+ if (theclass -> styles [i ]-> symbol < map -> symbolset .numsymbols && theclass -> styles [i ]-> symbol > 0 ) {
155
+ hasmarkersymbol = 1 ;
156
+ break ;
157
+ }
152
158
}
153
159
if (hasmarkersymbol ) {
154
160
for (i = 0 ; i < theclass -> numstyles ; i ++ )
161
+ if (!scale_independant && map -> scaledenom > 0 ) {
162
+ styleObj * lp = theclass -> styles [i ];
163
+ if ((lp -> maxscaledenom > 0 ) && (map -> scaledenom > lp -> maxscaledenom )) continue ;
164
+ if ((lp -> minscaledenom > 0 ) && (map -> scaledenom <= lp -> minscaledenom )) continue ;
165
+ }
155
166
msDrawMarkerSymbol (& map -> symbolset , image_draw , & marker , theclass -> styles [i ], lp -> scalefactor );
156
167
} else if (theclass -> labels && theclass -> numlabels > 0 ) {
157
168
labelObj * label = theclass -> labels [0 ]; /* use the first label definition */
@@ -204,8 +215,14 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
204
215
msDrawMarkerSymbol (& map -> symbolset ,image_draw ,& marker ,& imgStyle ,lp -> scalefactor );
205
216
/* TO DO: we may want to handle this differently depending on the relative size of the keyimage */
206
217
} else {
207
- for (i = 0 ; i < theclass -> numstyles ; i ++ )
218
+ for (i = 0 ; i < theclass -> numstyles ; i ++ ) {
219
+ if (!scale_independant && map -> scaledenom > 0 ) {
220
+ styleObj * lp = theclass -> styles [i ];
221
+ if ((lp -> maxscaledenom > 0 ) && (map -> scaledenom > lp -> maxscaledenom )) continue ;
222
+ if ((lp -> minscaledenom > 0 ) && (map -> scaledenom <= lp -> minscaledenom )) continue ;
223
+ }
208
224
msDrawMarkerSymbol (& map -> symbolset , image_draw , & marker , theclass -> styles [i ], lp -> scalefactor );
225
+ }
209
226
}
210
227
break ;
211
228
case MS_LAYER_LINE :
@@ -232,8 +249,14 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
232
249
zigzag .line [0 ].point [3 ].x = dstX + width - offset ;
233
250
zigzag .line [0 ].point [3 ].y = dstY + offset ;
234
251
235
- for (i = 0 ; i < theclass -> numstyles ; i ++ )
252
+ for (i = 0 ; i < theclass -> numstyles ; i ++ ) {
253
+ if (!scale_independant && map -> scaledenom > 0 ) {
254
+ styleObj * lp = theclass -> styles [i ];
255
+ if ((lp -> maxscaledenom > 0 ) && (map -> scaledenom > lp -> maxscaledenom )) continue ;
256
+ if ((lp -> minscaledenom > 0 ) && (map -> scaledenom <= lp -> minscaledenom )) continue ;
257
+ }
236
258
msDrawLineSymbol (& map -> symbolset , image_draw , & zigzag , theclass -> styles [i ], lp -> scalefactor );
259
+ }
237
260
238
261
free (zigzag .line [0 ].point );
239
262
free (zigzag .line );
@@ -242,8 +265,14 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
242
265
case MS_LAYER_RASTER :
243
266
case MS_LAYER_CHART :
244
267
case MS_LAYER_POLYGON :
245
- for (i = 0 ; i < theclass -> numstyles ; i ++ )
268
+ for (i = 0 ; i < theclass -> numstyles ; i ++ ) {
269
+ if (!scale_independant && map -> scaledenom > 0 ) {
270
+ styleObj * lp = theclass -> styles [i ];
271
+ if ((lp -> maxscaledenom > 0 ) && (map -> scaledenom > lp -> maxscaledenom )) continue ;
272
+ if ((lp -> minscaledenom > 0 ) && (map -> scaledenom <= lp -> minscaledenom )) continue ;
273
+ }
246
274
msDrawShadeSymbol (& map -> symbolset , image_draw , & box , theclass -> styles [i ], lp -> scalefactor );
275
+ }
247
276
break ;
248
277
default :
249
278
return MS_FAILURE ;
@@ -308,7 +337,7 @@ int msDrawLegendIcon(mapObj *map, layerObj *lp, classObj *theclass,
308
337
}
309
338
310
339
311
- imageObj * msCreateLegendIcon (mapObj * map , layerObj * lp , classObj * class , int width , int height )
340
+ imageObj * msCreateLegendIcon (mapObj * map , layerObj * lp , classObj * class , int width , int height , int scale_independant )
312
341
{
313
342
imageObj * image ;
314
343
outputFormatObj * format = NULL ;
@@ -344,10 +373,10 @@ imageObj *msCreateLegendIcon(mapObj* map, layerObj* lp, classObj* class, int wid
344
373
msClearLayerPenValues (lp ); /* just in case the mapfile has already been processed */
345
374
#endif
346
375
if (class ) {
347
- msDrawLegendIcon (map , lp , class , width , height , image , 0 , 0 );
376
+ msDrawLegendIcon (map , lp , class , width , height , image , 0 , 0 , scale_independant );
348
377
} else {
349
378
for (i = 0 ; i < lp -> numclasses ; i ++ ) {
350
- msDrawLegendIcon (map , lp , lp -> class [i ], width , height , image , 0 , 0 );
379
+ msDrawLegendIcon (map , lp , lp -> class [i ], width , height , image , 0 , 0 , scale_independant );
351
380
}
352
381
}
353
382
}
@@ -594,7 +623,7 @@ imageObj *msDrawLegend(mapObj *map, int scale_independent)
594
623
map -> cellsize = msAdjustExtent (& (map -> extent ), map -> width , map -> height );
595
624
cur -> layer -> scalefactor = (msInchesPerUnit (cur -> layer -> sizeunits ,0 )/msInchesPerUnit (map -> units ,0 )) / map -> cellsize ;
596
625
}
597
- if (msDrawLegendIcon (map , cur -> layer , cur -> theclass , map -> legend .keysizex , map -> legend .keysizey , image , HMARGIN , (int ) pnt .y ) != MS_SUCCESS )
626
+ if (msDrawLegendIcon (map , cur -> layer , cur -> theclass , map -> legend .keysizex , map -> legend .keysizey , image , HMARGIN , (int ) pnt .y , scale_independent ) != MS_SUCCESS )
598
627
return NULL ;
599
628
600
629
/*
0 commit comments