public static function Apco($date1, $date2, array $ebpv, array $ehp, $x,
          $y, $s, $theta, $elong, $phi, $hm, $xp, $yp, $sp, $refa, $refb,
          iauASTROM &$astrom) {

    $sl;
    $cl;
    $r   = [];
    $pvc = [];
    $pv  = [[],[]];

    /* Longitude with adjustment for TIO locator s'. */
    $astrom->along = $elong + $sp;

    /* Polar motion, rotated onto the local meridian. */
    $sl          = sin($astrom->along);
    $cl          = cos($astrom->along);
    $astrom->xpl = $xp * $cl - $yp * $sl;
    $astrom->ypl = $xp * $sl + $yp * $cl;

    /* Functions of latitude. */
    $astrom->sphi = sin($phi);
    $astrom->cphi = cos($phi);

    /* Refraction constants. */
    $astrom->refa = $refa;
    $astrom->refb = $refb;

    /* Local Earth rotation angle. */
    IAU::Aper($theta, $astrom);

    /* Disable the (redundant) diurnal aberration step. */
    $astrom->diurab = 0.0;

    /* CIO based BPN matrix. */
    IAU::C2ixys($x, $y, $s, $r);

    /* Observer's geocentric position and velocity (m, m/s, CIRS). */
    IAU::Pvtob($elong, $phi, $hm, $xp, $yp, $sp, $theta, $pvc);

    /* Rotate into GCRS. */
    IAU::Trxpv($r, $pvc, $pv);

    /* ICRS <-> GCRS parameters. */
    IAU::Apcs($date1, $date2, $pv, $ebpv, $ehp, $astrom);

    /* Store the CIO based BPN matrix. */
    IAU::Cr($r, $astrom->bpn);

    /* Finished. */
  }