Ticket #20167: NTV2GridShiftFile.patch
| File NTV2GridShiftFile.patch, 3.3 KB (added by , 5 years ago) |
|---|
-
src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
164 164 /** 165 165 * Create a tree of Sub Grids by adding each Sub Grid to its parent (where 166 166 * it has one), and returning an array of the top level Sub Grids 167 * @param subGrid an array of all Sub Grids167 * @param subGrids an array of all Sub Grids 168 168 * @return an array of top level Sub Grids with lower level Sub Grids set. 169 169 */ 170 private static NTV2SubGrid[] createSubGridTree(NTV2SubGrid... subGrid ) {170 private static NTV2SubGrid[] createSubGridTree(NTV2SubGrid... subGrids) { 171 171 int topLevelCount = 0; 172 172 Map<String, List<NTV2SubGrid>> subGridMap = new HashMap<>(); 173 for ( int i = 0; i < subGrid.length; i++) {174 if ("NONE".equalsIgnoreCase(subGrid [i].getParentSubGridName())) {173 for (NTV2SubGrid subGrid : subGrids) { 174 if ("NONE".equalsIgnoreCase(subGrid.getParentSubGridName())) { 175 175 topLevelCount++; 176 176 } 177 subGridMap.put(subGrid [i].getSubGridName(), new ArrayList<NTV2SubGrid>());177 subGridMap.put(subGrid.getSubGridName(), new ArrayList<>()); 178 178 } 179 179 NTV2SubGrid[] topLevelSubGrid = new NTV2SubGrid[topLevelCount]; 180 180 topLevelCount = 0; 181 for ( int i = 0; i < subGrid.length; i++) {182 if ("NONE".equalsIgnoreCase(subGrid [i].getParentSubGridName())) {183 topLevelSubGrid[topLevelCount++] = subGrid [i];181 for (NTV2SubGrid subGrid : subGrids) { 182 if ("NONE".equalsIgnoreCase(subGrid.getParentSubGridName())) { 183 topLevelSubGrid[topLevelCount++] = subGrid; 184 184 } else { 185 List<NTV2SubGrid> parent = subGridMap.get(subGrid [i].getParentSubGridName());186 parent.add(subGrid [i]);185 List<NTV2SubGrid> parent = subGridMap.get(subGrid.getParentSubGridName()); 186 parent.add(subGrid); 187 187 } 188 188 } 189 189 NTV2SubGrid[] nullArray = new NTV2SubGrid[0]; 190 for ( int i = 0; i < subGrid.length; i++) {191 List<NTV2SubGrid> subSubGrids = subGridMap.get(subGrid [i].getSubGridName());190 for (NTV2SubGrid subGrid : subGrids) { 191 List<NTV2SubGrid> subSubGrids = subGridMap.get(subGrid.getSubGridName()); 192 192 if (!subSubGrids.isEmpty()) { 193 193 NTV2SubGrid[] subGridArray = subSubGrids.toArray(nullArray); 194 subGrid [i].setSubGridArray(subGridArray);194 subGrid.setSubGridArray(subGridArray); 195 195 } 196 196 } 197 197 return topLevelSubGrid; … … 262 262 */ 263 263 private static NTV2SubGrid getSubGrid(NTV2SubGrid[] topLevelSubGrid, double lon, double lat) { 264 264 NTV2SubGrid sub = null; 265 for ( int i = 0; i < topLevelSubGrid.length; i++) {266 sub = topLevel SubGrid[i].getSubGridForCoord(lon, lat);265 for (NTV2SubGrid topLevel : topLevelSubGrid) { 266 sub = topLevel.getSubGridForCoord(lon, lat); 267 267 if (sub != null) { 268 268 break; 269 269 }
