|
Algorithm 1 PCH Election |
| ← the M code of the CH
|
| Level i ← the level of the PCH |
| d ← the depth of the quadtree
|
| sink ← the location of Sink node
|
| Get PCH (, level i, d, sink)
|
| {
|
| begin
|
| [CHs] = [NW, NE, SW, SE]// Get the 4 CHs of the i-th level whose M code are
|
| [Xc,Yc] = (M,i)// Get the center coordinate of the area where the M code is
|
| [Xs,Ys] = sink //Get the coordinates of the sink node
|
| If(Xs>Xc)&(Ys>Yc)
|
| PCH =SE
|
| Else if(Xs<Xc)&(Ys>Yc)
|
| PCH = SW
|
| Else if(Xs<Xc)&(Ys>Yc)
|
| PCH = NW
|
| Else (Xs>Xc)&(Ys<Yc)
|
| PCH = NE
|
| end
|
| end
|
| Return PCH// Return the calculated PCH node
|
| } |