Skip to main content
. 2019 May 22;19(10):2363. doi: 10.3390/s19102363
Algorithm 1 PCH Election
 m ← 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 (m, level i, d, sink)
 {
 begin
  [CHs] = [NW, NE, SW, SE]// Get the 4 CHs of the i-th level whose M code are m
 [Xc,Yc] = (M,i)// Get the center coordinate of the area where the M code is m
  [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
 }