MCPcopy Index your code
hub / github.com/MapServer/MapServer / msAddLabel

Function msAddLabel

maplabel.c:305–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303}
304
305int msAddLabel(mapObj *map, int layerindex, int classindex, shapeObj *shape, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label )
306{
307 int i;
308 labelCacheSlotObj *cacheslot;
309
310 labelCacheMemberObj *cachePtr=NULL;
311 layerObj *layerPtr=NULL;
312 classObj *classPtr=NULL;
313
314 if(!string) return(MS_SUCCESS); /* not an error */
315
316 layerPtr = (GET_LAYER(map, layerindex)); /* set up a few pointers for clarity */
317 classPtr = GET_LAYER(map, layerindex)->class[classindex];
318
319 if( label == NULL )
320 label = &(classPtr->label);
321
322 if(map->scaledenom > 0) {
323 if((label->maxscaledenom != -1) && (map->scaledenom >= label->maxscaledenom))
324 return(MS_SUCCESS);
325 if((label->minscaledenom != -1) && (map->scaledenom < label->minscaledenom))
326 return(MS_SUCCESS);
327 }
328
329 /* Validate label priority value and get ref on label cache for it */
330 if (label->priority < 1)
331 label->priority = 1;
332 else if (label->priority > MS_MAX_LABEL_PRIORITY)
333 label->priority = MS_MAX_LABEL_PRIORITY;
334
335 cacheslot = &(map->labelcache.slots[label->priority-1]);
336
337 if(cacheslot->numlabels == cacheslot->cachesize) { /* just add it to the end */
338 cacheslot->labels = (labelCacheMemberObj *) realloc(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT));
339 MS_CHECK_ALLOC(cacheslot->labels, sizeof(labelCacheMemberObj)*(cacheslot->cachesize+MS_LABELCACHEINCREMENT), MS_FAILURE);
340 cacheslot->cachesize += MS_LABELCACHEINCREMENT;
341 }
342
343 cachePtr = &(cacheslot->labels[cacheslot->numlabels]);
344
345 cachePtr->layerindex = layerindex; /* so we can get back to this *raw* data if necessary */
346 cachePtr->classindex = classindex;
347
348 if(shape) {
349 cachePtr->tileindex = shape->tileindex;
350 cachePtr->shapeindex = shape->index;
351 cachePtr->shapetype = shape->type;
352 } else {
353 cachePtr->tileindex = cachePtr->shapeindex = -1;
354 cachePtr->shapetype = MS_SHAPE_POINT;
355 }
356
357 /* Store the label point or the label path (Bug #1620) */
358 if ( point ) {
359 cachePtr->point = *point; /* the actual label point */
360 cachePtr->point.x = MS_NINT(cachePtr->point.x);
361 cachePtr->point.y = MS_NINT(cachePtr->point.y);
362 cachePtr->labelpath = NULL;

Callers 4

msEmbedScalebarFunction · 0.85
msDrawShapeFunction · 0.85
msDrawPointFunction · 0.85
msEmbedLegendFunction · 0.85

Calls 11

MS_NINTFunction · 0.85
msStrdupFunction · 0.85
msSmallMallocFunction · 0.85
initStyleFunction · 0.85
msCopyStyleFunction · 0.85
initLabelFunction · 0.85
msCopyLabelFunction · 0.85
msInitShapeFunction · 0.85
msGetMarkerSizeFunction · 0.85
msSetErrorFunction · 0.85
msRectToPolygonFunction · 0.85

Tested by

no test coverage detected