(Tokenizer st, String type)
| 91 | } |
| 92 | |
| 93 | private long |
| 94 | parsePosition(Tokenizer st, String type) throws IOException { |
| 95 | boolean isLatitude = type.equals("latitude"); |
| 96 | int deg = 0, min = 0; |
| 97 | double sec = 0; |
| 98 | long value; |
| 99 | String s; |
| 100 | |
| 101 | deg = st.getUInt16(); |
| 102 | if (deg > 180 || (deg > 90 && isLatitude)) |
| 103 | throw st.exception("Invalid LOC " + type + " degrees"); |
| 104 | |
| 105 | s = st.getString(); |
| 106 | try { |
| 107 | min = Integer.parseInt(s); |
| 108 | if (min < 0 || min > 59) |
| 109 | throw st.exception("Invalid LOC " + type + " minutes"); |
| 110 | s = st.getString(); |
| 111 | sec = parseFixedPoint(s); |
| 112 | if (sec < 0 || sec >= 60) |
| 113 | throw st.exception("Invalid LOC " + type + " seconds"); |
| 114 | s = st.getString(); |
| 115 | } catch (NumberFormatException e) { |
| 116 | } |
| 117 | |
| 118 | if (s.length() != 1) |
| 119 | throw st.exception("Invalid LOC " + type); |
| 120 | |
| 121 | value = (long) (1000 * (sec + 60L * (min + 60L * deg))); |
| 122 | |
| 123 | char c = Character.toUpperCase(s.charAt(0)); |
| 124 | if ((isLatitude && c == 'S') || (!isLatitude && c == 'W')) |
| 125 | value = -value; |
| 126 | else if ((isLatitude && c != 'N') || (!isLatitude && c != 'E')) |
| 127 | throw st.exception("Invalid LOC " + type); |
| 128 | |
| 129 | value += (1L << 31); |
| 130 | |
| 131 | return value; |
| 132 | } |
| 133 | |
| 134 | private long |
| 135 | parseDouble(Tokenizer st, String type, boolean required, long min, long max, |
no test coverage detected