int deg, minute, sec;
    protected String latlong2GEOREF(double latitude, double longitude) {        int i;        char tmp = 'A'; // no reason for 'A'        char tmp1 = 'A';        char tmp2 = 'A';        int deg, minute, sec;        // These serve as tmps in integer form.        int tmpi, tmpi1, tmpi2;        /*         * this portion of the code calculates the longitudinal part         * of the         */        /*         * GEOREF number. I can't explain the logic -- I don't         * understand         */        /* how it works. All that I know is that it seems to. */        LatLonPoint llp = new LatLonPoint((float) latitude, (float) longitude);        DMSLatLonPoint dmsp = new DMSLatLonPoint(llp);        char[] GEOSTRING = new char[6];        if (longitude == 0.0000) {            tmp = 'N';            tmp1 = 'A';            tmp2 = '0';        } else if (longitude == -180.0000) {            tmp = 'A';            tmp1 = 'A';            tmp2 = '0';        } else if (longitude == 180.0000) {            tmp = 'Z';            tmp1 = 'Q';            tmp2 = '9';        } else if (longitude > 0.0000) {            tmpi = dmsp.lon_degrees / 15;            tmpi += 78;            if (tmpi >= 79) {                tmpi += 1;            }            if (tmpi > 90) {                tmpi = 90;            }            tmp = (char) tmpi;            // Setting i to a certain value, based on longitude.            for (i = 0; i * 15 < (int) (longitude + 0.9999); i++)                ;            tmpi1 = 15 * i - (int) (longitude);            if ((tmpi1 >= 3) && (tmpi1 < 8)) {                tmpi1 += 1;            } else if (tmpi1 >= 8) {                tmpi1 += 2;            }            if (tmpi1 != 0) {                tmpi1 = 82 - tmpi1;                tmp1 = (char) tmpi1;            } else {                tmp1 = 'A';            }            if (tmp1 == 'R') {                tmp1 = 'A';            }            tmpi2 = (int) ('0') + (dmsp.lon_minutes / 10);            tmp2 = (char) tmpi2;        } else if (longitude <= 0.0000) {            tmpi = (int) (((double) dmsp.lon_degrees) / 15.0 - 0.999);            tmpi = 77 - Math.abs(tmpi);            if (tmpi >= 73) {                tmpi += 1;            }            if (tmpi > 77) {                tmpi = 77;            }            tmp = (char) tmpi;            /* DKS changed from abs to fabs */            for (i = 0; i * 15 < (int) (Math.abs((longitude - 0.9999))); i++)                ;            /* DKS changed from abs to fabs */            tmpi1 = i * 15 - (int) (Math.abs((longitude - 0.9999)));            if ((tmpi1 >= 8) && (tmpi1 < 13)) {                tmpi1 += 1;            } else if (tmpi1 >= 13) {                tmpi1 += 2;            }            if (tmpi1 > 16) {                tmpi1 = 16;            }            tmpi1 += 65;            tmp1 = (char) tmpi1;            if ((int) (dmsp.lon_minutes / 10) != 0) {                tmpi2 = ((int) '0') + (6 - (int) (dmsp.lon_minutes / 10));                tmp2 = (char) tmpi2;            } else {                tmp2 = '0';            }        }        GEOSTRING[0] = tmp;        GEOSTRING[2] = tmp1;        GEOSTRING[4] = tmp2;        /*         * this portion of the code calculates the latitudinal part of         * the         */        /*         * GEOREF number. I can't explain the logic -- I don't         * understand         */        /* how it works. All that I know is that it seems to. */        if (latitude == 0.0000) {            tmp = 'G';            tmp1 = 'A';            tmp2 = '0';        } else if (latitude == 90.0000) {            tmp = 'M';            tmp1 = 'Q';            tmp2 = '9';        } else if (latitude == -90.0000) {            tmp = 'A';            tmp1 = 'A';            tmp2 = '0';        } else if (latitude > 0.0000) {            tmpi = dmsp.lat_degrees / 15;            tmpi += 71;            if (tmpi >= 73) {                tmpi += 1;            }            if (tmpi > 77) {                tmpi = 77;            }            tmp = (char) tmpi;            for (i = 0; i * 15 < (int) (latitude + 0.9999); i++)                ;            tmpi1 = 15 * i - (int) (latitude);            if ((tmpi1 >= 3) && (tmpi1 < 8)) {                tmpi1 += 1;            } else if (tmpi1 >= 8) {                tmpi1 += 2;            }            tmpi1 = 82 - tmpi1;            tmp1 = (char) tmpi1;            if (tmp1 == 'R') {                tmp1 = 'A';            }            if ((dmsp.lat_minutes / 10) != 0) {                tmpi2 = ((int) '0') + (int) (dmsp.lat_minutes / 10);                tmp2 = (char) tmpi2;            } else {                tmp2 = '0';            }        } else if (latitude < 0.0000) {            tmpi = (int) ((double) dmsp.lat_degrees / 15.0 - 0.999);            tmpi = 71 - Math.abs(tmpi);            if (tmpi < 65) {                tmpi = 65;            }            /* DKS changed from abs to fabs */            for (i = 0; i * 15 < (int) (Math.abs((latitude - 0.9999))); i++)                ;            /* DKS changed from abs to fabs */            tmpi1 = i * 15 - (int) (Math.abs((latitude - 0.9999)));            if ((tmpi1 >= 8) && (tmpi1 < 13)) {                tmpi1 += 1;            } else if (tmpi1 >= 13) {                tmpi1 += 2;            }            if (tmpi1 > 16) {                tmpi1 = 16;            }            tmpi1 = 65 + tmpi1;            tmp1 = (char) tmpi1;            tmpi2 = ((int) '0') + (6 - (int) (dmsp.lat_minutes / 10));            tmp2 = (char) tmpi2;        }        GEOSTRING[1] = tmp;        GEOSTRING[3] = tmp1;        GEOSTRING[5] = tmp2;        String ret = new String(GEOSTRING);        if (Debug.debugging("maketocdetail")) {            Debug.output("latlon2GEOREF: lat = " + latitude + ", lon = "                    + longitude + ", GEOREF = " + ret);        }        return ret;    } /* latlong2GEOREF() */