|
29 | 29 | class Common { |
30 | 30 | private static final Logger LOG = LoggerFactory.getLogger(Common.class); |
31 | 31 |
|
32 | | - static final int[] nc = { |
| 32 | + // TODO: Need better name and explanation. |
| 33 | + static final int[] NC = { |
33 | 34 | 1, 31, 961, 29791, 923521, 28629151, 887503681 |
34 | 35 | }; |
35 | | - static final int[] xSide = { |
| 36 | + |
| 37 | + // TODO: Need better name and explanation. |
| 38 | + static final int[] X_SIDE = { |
36 | 39 | 0, 5, 31, 168, 961, 5208, 29791, 165869, 923521, 5141947 |
37 | 40 | }; |
38 | | - static final int[] ySide = { |
| 41 | + |
| 42 | + // TODO: Need better name and explanation. |
| 43 | + static final int[] Y_SIDE = { |
39 | 44 | 0, 6, 31, 176, 961, 5456, 29791, 165869, 923521, 5141947 |
40 | 45 | }; |
41 | | - private static final int[] xDivider19 = { |
| 46 | + |
| 47 | + // TODO: Need better name and explanation. |
| 48 | + private static final int[] X_DIVIDER_19 = { |
42 | 49 | 360, 360, 360, 360, 360, 360, 361, 361, 361, 361, |
43 | 50 | 362, 362, 362, 363, 363, 363, 364, 364, 365, 366, |
44 | 51 | 366, 367, 367, 368, 369, 370, 370, 371, 372, 373, |
@@ -86,46 +93,48 @@ private Common() { |
86 | 93 | * @param maxY Longitude. |
87 | 94 | * @return Divider. |
88 | 95 | */ |
| 96 | + // TODO: Need better names for minY and maxY |
89 | 97 | static int xDivider(final int minY, final int maxY) { |
90 | 98 | assert minY < maxY; |
91 | 99 | if (minY >= 0) { |
92 | 100 | // maxY > minY > 0 |
93 | 101 | assert (maxY > minY) && (minY > 0); |
94 | | - return xDivider19[minY >> 19]; |
| 102 | + return X_DIVIDER_19[minY >> 19]; |
95 | 103 | } else if (maxY >= 0) { |
96 | 104 | // maxY > 0 > minY |
97 | 105 | assert (maxY > 0) && (0 > minY); |
98 | | - return xDivider19[0]; |
| 106 | + return X_DIVIDER_19[0]; |
99 | 107 | } else { |
100 | 108 | // 0 > maxY > minY |
101 | 109 | assert (0 > maxY) && (maxY > minY); |
102 | | - return xDivider19[(-maxY) >> 19]; |
| 110 | + return X_DIVIDER_19[(-maxY) >> 19]; |
103 | 111 | } |
104 | 112 | } |
105 | 113 |
|
| 114 | + // TODO: Need to explain what a codex is. |
106 | 115 | static int countCityCoordinatesForCountry(final int codex, final int territoryRecord, final int firstTerritoryRecord) { |
107 | 116 | assert codex >= 0; |
108 | 117 | assert territoryRecord >= 0; |
109 | 118 | assert firstTerritoryRecord >= 0; |
110 | | - final int i = getFirstNamelessRecord(codex, territoryRecord, firstTerritoryRecord); |
111 | | - int e = territoryRecord; |
112 | | - while (Data.getCodex(e) == codex) { |
113 | | - e++; |
| 119 | + final int firstRecord = getFirstNamelessRecord(codex, territoryRecord, firstTerritoryRecord); |
| 120 | + int record = territoryRecord; |
| 121 | + while (Data.getCodex(record) == codex) { |
| 122 | + record++; |
114 | 123 | } |
115 | | - assert i <= e; |
116 | | - return e - i; |
| 124 | + assert firstRecord <= record; |
| 125 | + return record - firstRecord; |
117 | 126 | } |
118 | 127 |
|
119 | 128 | static int getFirstNamelessRecord(final int codex, final int territoryRecord, final int firstTerritoryRecord) { |
120 | 129 | assert codex >= 0; |
121 | 130 | assert territoryRecord >= 0; |
122 | 131 | assert firstTerritoryRecord >= 0; |
123 | | - int i = territoryRecord; |
124 | | - while ((i >= firstTerritoryRecord) && Data.isNameless(i) && (Data.getCodex(i) == codex)) { |
125 | | - i--; |
| 132 | + int record = territoryRecord; |
| 133 | + while ((record >= firstTerritoryRecord) && Data.isNameless(record) && (Data.getCodex(record) == codex)) { |
| 134 | + record--; |
126 | 135 | } |
127 | | - i++; |
128 | | - assert i <= territoryRecord; |
129 | | - return i; |
| 136 | + record++; |
| 137 | + assert record <= territoryRecord; |
| 138 | + return record; |
130 | 139 | } |
131 | 140 | } |
0 commit comments