Package nav.util.string

Examples of nav.util.string.StringUtil


     * @since 1.0
     */
    public String toStringDegMin() {
        String str = "";
        String quad = "";
        StringUtil su = new StringUtil();
        switch (coordinate) {
            case LAT:
                if (decCoordinate >= 0) {
                    quad = "N";
                } else {
                    quad = "S";
                }
                str = su.padNumZero(Math.abs(deg), 2);
                str += "\u00b0" + su.padNumZero(Math.abs(minsDecMins), 2, MINPRECISION) + "'" + quad;
                break;
            case LNG:
                if (decCoordinate >= 0) {
                    quad = "E";
                } else {
                    quad = "W";
                }
                str = su.padNumZero(Math.abs(deg), 3);
                str += "\u00b0" + su.padNumZero(Math.abs(minsDecMins), 2, MINPRECISION) + "'" + quad;
        }
        return str;
    }
View Full Code Here


     *
     * @return              The coordinate in decimal format.
     * @since 1.0
     */
    public String toStringDec() {
        StringUtil u = new StringUtil();
        switch (coordinate) {
            case LAT:
                return u.padNumZero(decCoordinate, 2, DEGPRECISION);
            case LNG:
                return u.padNumZero(decCoordinate, 3, DEGPRECISION);
        }
        return "error";
    }
View Full Code Here

     * @return heading      The target's heading.
     * @since 1.0
     */
    public String decodeHdg(int input) {
        String output = "";
        StringUtil u = new StringUtil();

        if (input == 511) {
            output = "n/a";
        } else {
            output = String.valueOf(u.padNumZero(input, 3));
        }

        return output;
    }
View Full Code Here

        int hoursNow = cal.get(Calendar.HOUR_OF_DAY);
        int minsNow = cal.get(Calendar.MINUTE);
        int secsNow = cal.get(Calendar.SECOND);

        StringUtil su = new StringUtil();

        /* AIS seconds - assumes 'current' minute... due network &
         * processing delays, it may in fact be the previous minute
         * as we're not GPS hardware time synchronised...
         */
        int aisSecs = Integer.parseInt(input, 2);

        switch (aisSecs) {
            case 60:
                timestampStr = "Not Available";
                break;
            case 61:
                timestampStr = "EPFS manual";
                break;
            case 62:
                timestampStr = "EPFS DR";
                break;
            case 63:
                timestampStr = "EPFS U/S";
                break;
            default:
                /* Do a simple check to see if it was 'probably' the previous
                 * minute... if so, correct the display time. NOTE: the PC
                 * system clock needs to be pretty close to UTC (within 1-2s)
                 * for this to work - clock synchronisation is needed regularly!
                 */
                if ((minsNow * 60) + secsNow + CLOCK_JITTER < (minsNow * 60) + aisSecs) {
                    switch (minsNow) {
                        case 0:
                            minsNow = 59;
                            switch (hoursNow) {
                                case 0:
                                    hoursNow = 23;
                                    break;
                                default:
                                    hoursNow -= 1;
                            }
                            break;
                        default:
                            minsNow -= 1;
                    }
                }
                // Set the calendar time to the AIS message received time - in UTC
                cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH),
                        cal.get(Calendar.DAY_OF_MONTH), hoursNow, minsNow, aisSecs);
                //Store this as the last update time
                timestamp = cal.getTimeInMillis();

                Calendar newCal = Calendar.getInstance();

                // Current system time in UTC
                newCal.add(
                        Calendar.MILLISECOND,
                        -newCal.get(Calendar.DST_OFFSET)
                        - newCal.get(Calendar.ZONE_OFFSET));

                // build a string representation of the message time...
                timestampStr = String.valueOf(su.padNumZero(hoursNow, 2))
                        + ":" + String.valueOf(su.padNumZero(minsNow, 2))
                        + ":" + String.valueOf(su.padNumZero(aisSecs, 2));
        }
    }
View Full Code Here

        // Repeat Indicator (6-8)
        super.setRepeatIndicator(Integer.parseInt(data.substring(6, 8), 2));

        // MMSI (9-38)
        StringUtil su = new StringUtil();
        super.setMmsi(su.padNumZero(Integer.parseInt(data.substring(8, 38), 2), 9));

        // UTC Year ()38-52
        year = Integer.parseInt(data.substring(38, 52), 2);

        // UTC Month (52-56)
        month = Integer.parseInt(data.substring(52, 56), 2);

        // UTC Day (56-61)
        day = Integer.parseInt(data.substring(56, 61), 2);

        // UTC Hour (61-66)
        hour = Integer.parseInt(data.substring(61, 66), 2);

        // UTC Minute (66-72)
        minute = Integer.parseInt(data.substring(66, 72), 2);

        // UTC second (72-78)
        second = Integer.parseInt(data.substring(72, 78), 2);

        // Set the time stamp based on above number...
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day, hour, minute, second);
        super.setTimestamp(cal.getTimeInMillis());
        super.setTimestampStr(su.padNumZero(hour, 2) + ":"
                + su.padNumZero(minute, 2) + ":"
                + su.padNumZero(second, 2));

        // Position Accuracy (78-79)
        super.decodePosAccuracy(data.substring(78, 79));

        // Longitude (79-107) //Latitude (107-134)
View Full Code Here

  int day = Integer.parseInt(input.substring(0,5),2);
  input = input.substring(5);
  int hour = Integer.parseInt(input.substring(0,5),2);
  input = input.substring(5);
  int min = Integer.parseInt(input.substring(0,6),2);
  StringUtil su = new StringUtil();
  eta = su.padNumZero(hour,2) + ":" + su.padNumZero(min, 2) + " on " + su.padNumZero(day,2) + " " + strMonth;
    }
View Full Code Here

     * @param aisROT        ROT as transmitted by the AIS message.
     * @return              Decoded ROT.
     * @since 1.0
     */
    private String decodeROT(int aisROT) {
        StringUtil u = new StringUtil();
        if (aisROT == 0) {
            return "           ";
        }

        if (aisROT == 127) {
            return ">>S >5�/30s";
        }

        if (aisROT == -127) {
            return "<<P >5�/30s";
        }

        if (aisROT == 128) {
            return "  no data  ";
        }

        if (aisROT > 0 && aisROT < 127) {
            long tiROT = Math.round((aisROT / 4.733) * (aisROT / 4.733));
            return (">>S " + u.padNum(tiROT, 3) + "�/60s");
        }

        if (aisROT < 0 && aisROT > -127) {
            aisROT = -aisROT;
            long tiROT = Math.round((aisROT / 4.733) * (aisROT / 4.733));
            return ("<<P " + u.padNum(tiROT, 3) + "�/60s");
        }

        return aisROT + "   ??   ";
    }
View Full Code Here

     * @param aisROT        ROT as transmitted by the AIS message.
     * @return              Decoded ROT.
     * @since 1.0
     */
    private String decodeROT(int aisROT) {
        StringUtil u = new StringUtil();

        if (aisROT == 0) {
            return "           ";
        }

        if (aisROT == 127) {
            return ">>S >5∞/30s";
        }

        if (aisROT == -127) {
            return "<<P >5∞/30s";
        }

        if (aisROT == 128) {
            return "  no data  ";
        }

        if (aisROT > 0 && aisROT < 127) {
            long tiROT = Math.round((aisROT / 4.733) * (aisROT / 4.733));
            return (">>S " + u.padNum(tiROT, 3) + "∞/60s");
        }

        if (aisROT < 0 && aisROT > -127) {
            aisROT = -aisROT;
            long tiROT = Math.round((aisROT / 4.733) * (aisROT / 4.733));
            return ("<<P " + u.padNum(tiROT, 3) + "∞/60s");
        }

        return aisROT + "   ??   ";
    }
View Full Code Here

  // Repeat Indicator (7-8)
  super.setRepeatIndicator(Integer.parseInt(data.substring(6,8),2));

  // MMSI (9-38)
  StringUtil su = new StringUtil();
  super.setMmsi(su.padNumZero(Integer.parseInt(data.substring(8,38), 2),9));

  // Altitude (38-50)
  decodeAlt(data.substring(42,50));

  // Speed Over Ground (50-60)
View Full Code Here

  super.decodeTimeStamp(data.substring(128,134));
    }

    @Override
    public String print(){
        StringUtil u = new StringUtil();
  String outStr = "";
  outStr += "TYPE: " + super.getMsgType() + "\n";
  outStr += " UTC: " + super.getUtcTimeStampStr() + "\n";
  outStr += "  RI: " + super.getRepeatIndicator() + "\n";
  outStr += "MMSI: " + super.getMMSI() + "\n";
  outStr += " SOG: " + u.padNum(speed,2,1) + "\n";
  outStr += "PACC: " + super.getPosAccuracy() + "\n";
  outStr += " LAT: " + super.getPosition().toStringDegMinLat() + "\n";
  outStr += " LNG: " + super.getPosition().toStringDegMinLng() + "\n";
  outStr += " COG: " + u.padNum(course,3,1) + "∞";
  return outStr;
    }
View Full Code Here

TOP

Related Classes of nav.util.string.StringUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.