code: void assignPrimaryID() {
          if (pointCount == 0) {
              primaryID = -1;
          } else if (primaryID <= 0) {
              // No primary ID is assigned. Assign a new ID arbitrarily.
              primaryID = points[0].id;
          } else {
              for (int i = 0; i < pointCount; i++) {
                  if (points[i].id == primaryID) {
                      // The old primary ID is still valid
                      return;
                  }
              }
              // assign a new primary ID
              primaryID = points[0].id;
          }
      }
docs: Updates the primary point ID