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

Function findRelatedShapesRemove

mapcluster.c:456–497  ·  view source on GitHub ↗

traverse the quadtree to find the neighbouring shapes and update some data on the related shapes (when removing a feature) */

Source from the content-addressed store, hash-verified

454/* traverse the quadtree to find the neighbouring shapes and update some data
455on the related shapes (when removing a feature) */
456static void findRelatedShapesRemove(msClusterLayerInfo* layerinfo, clusterTreeNode *node, clusterInfo* current)
457{
458 int i;
459 clusterInfo* s;
460
461 /* -------------------------------------------------------------------- */
462 /* Does this node overlap the area of interest at all? If not, */
463 /* return without adding to the list at all. */
464 /* -------------------------------------------------------------------- */
465 if(!msRectOverlap(&node->rect, &current->bounds))
466 return;
467
468 /* Modify the feature count of the related shapes */
469 s = node->shapes;
470 while (s)
471 {
472 if (layerinfo->fnCompare(current, s))
473 {
474 if (s->numsiblings > 0)
475 {
476 /* calculating the average positions */
477 s->avgx = (s->avgx * (s->numsiblings + 1) - current->x) / s->numsiblings;
478 s->avgy = (s->avgy * (s->numsiblings + 1) - current->y) / s->numsiblings;
479 /* calculating the variance */
480 s->varx = (s->varx - (current->x - s->avgx) * (current->x - s->avgx) / s->numsiblings) *
481 (s->numsiblings + 1) / s->numsiblings;
482 s->vary = (s->vary - (current->y - s->avgy) * (current->y - s->avgy) / s->numsiblings) *
483 (s->numsiblings + 1) / s->numsiblings;
484 --s->numsiblings;
485 ++s->numremoved;
486 }
487 }
488 s = s->next;
489 }
490
491 /* Recurse to subnodes if they exist */
492 for (i = 0; i < 4; i++)
493 {
494 if (node->subnode[i])
495 findRelatedShapesRemove(layerinfo, node->subnode[i], current);
496 }
497}
498
499/* setting the aggregated attributes */
500static void InitShapeAttributes(layerObj* layer, clusterInfo* base)

Callers 1

RebuildClustersFunction · 0.85

Calls 1

msRectOverlapFunction · 0.85

Tested by

no test coverage detected