MCPcopy Create free account
hub / github.com/MapServer/MapServer / UpdateShapeAttributes

Function UpdateShapeAttributes

mapcluster.c:538–594  ·  view source on GitHub ↗

update the shape attributes (aggregate) */

Source from the content-addressed store, hash-verified

536
537/* update the shape attributes (aggregate) */
538static void UpdateShapeAttributes(layerObj* layer, clusterInfo* base, clusterInfo* current)
539{
540 int i;
541 int* itemindexes = layer->iteminfo;
542
543 for (i = 0; i < layer->numitems; i++)
544 {
545 if (base->shape.numvalues <= i)
546 break;
547
548 if (itemindexes[i] == MSCLUSTER_FEATURECOUNTINDEX ||
549 itemindexes[i] == MSCLUSTER_GROUPINDEX)
550 continue;
551
552 if (current->shape.numvalues <= i)
553 break;
554
555 if (current->shape.values[i])
556 {
557 if (EQUALN(layer->items[i], "Min:", 4))
558 {
559 if (strcasecmp(base->shape.values[i], current->shape.values[i]) > 0)
560 {
561 msFree(base->shape.values[i]);
562 base->shape.values[i] = msStrdup(current->shape.values[i]);
563 }
564 }
565 else if (EQUALN(layer->items[i], "Max:", 4))
566 {
567 if (strcasecmp(base->shape.values[i], current->shape.values[i]) < 0)
568 {
569 msFree(base->shape.values[i]);
570 base->shape.values[i] = msStrdup(current->shape.values[i]);
571 }
572 }
573 else if (EQUALN(layer->items[i], "Sum:", 4))
574 {
575 double sum = atof(base->shape.values[i]) + atof(current->shape.values[i]);
576 msFree(base->shape.values[i]);
577 base->shape.values[i] = msDoubleToString(sum, MS_FALSE);
578 }
579 else if (EQUALN(layer->items[i], "Count:", 6))
580 {
581 int count = atoi(base->shape.values[i]) + 1;
582 msFree(base->shape.values[i]);
583 base->shape.values[i] = msIntToString(count);
584 }
585 else if (!EQUAL(base->shape.values[i], current->shape.values[i])
586 && !EQUAL(base->shape.values[i], ""))
587 {
588 /* clear the value if that doesn't match */
589 msFree(base->shape.values[i]);
590 base->shape.values[i] = msStrdup("");
591 }
592 }
593 }
594}
595

Callers 1

RebuildClustersFunction · 0.85

Calls 5

strcasecmpFunction · 0.85
msFreeFunction · 0.85
msStrdupFunction · 0.85
msDoubleToStringFunction · 0.85
msIntToStringFunction · 0.85

Tested by

no test coverage detected