Changeset 10250 in josm for trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
- Timestamp:
- 2016-05-18T17:44:31+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
r10242 r10250 103 103 public void loadGridShiftFile(InputStream in, boolean loadAccuracy) throws IOException { 104 104 byte[] b8 = new byte[8]; 105 boolean bigEndian = true;106 105 fromEllipsoid = ""; 107 106 toEllipsoid = ""; … … 111 110 if (!"NUM_OREC".equals(overviewHeaderCountId)) 112 111 throw new IllegalArgumentException("Input file is not an NTv2 grid shift file"); 112 boolean bigEndian; 113 113 readBytes(in, b8); 114 114 overviewHeaderCount = NTV2Util.getIntBE(b8, 0); … … 204 204 */ 205 205 public boolean gridShiftForward(NTV2GridShift gs) { 206 // Try the last sub grid first, big chance the coord is still within it 207 NTV2SubGrid subGrid = lastSubGrid.getSubGridForCoord(gs.getLonPositiveWestSeconds(), gs.getLatSeconds()); 206 NTV2SubGrid subGrid = null; 207 if (lastSubGrid != null) { 208 // Try the last sub grid first, big chance the coord is still within it 209 subGrid = lastSubGrid.getSubGridForCoord(gs.getLonPositiveWestSeconds(), gs.getLatSeconds()); 210 } 208 211 if (subGrid == null) { 209 subGrid = getSubGrid( gs.getLonPositiveWestSeconds(), gs.getLatSeconds());210 } 211 if (subGrid == null) 212 subGrid = getSubGrid(topLevelSubGrid, gs.getLonPositiveWestSeconds(), gs.getLatSeconds()); 213 } 214 if (subGrid == null) { 212 215 return false; 213 else {216 } else { 214 217 subGrid.interpolateGridShift(gs); 215 218 gs.setSubGridName(subGrid.getSubGridName()); … … 251 254 252 255 /** 253 * Find the finest SubGrid containing the coordinate, specified 254 * in Positive West Seconds 255 * 256 * Find the finest SubGrid containing the coordinate, specified in Positive West Seconds 257 * @param topLevelSubGrid top level subgrid 256 258 * @param lon Longitude in Positive West Seconds 257 259 * @param lat Latitude in Seconds 258 260 * @return The SubGrid found or null 259 261 */ 260 private NTV2SubGrid getSubGrid(double lon, double lat) {262 private static NTV2SubGrid getSubGrid(NTV2SubGrid[] topLevelSubGrid, double lon, double lat) { 261 263 NTV2SubGrid sub = null; 262 264 for (int i = 0; i < topLevelSubGrid.length; i++) {
Note:
See TracChangeset
for help on using the changeset viewer.