@Test public void AdjustLocationAltitude_WhenAltitudePresentNoPreferences_NothingAdjusted(){ PreferenceHelper ph = mock(PreferenceHelper.class); when(ph.shouldAdjustAltitudeFromGeoIdHeight()).thenReturn(true); Location loc = MockLocations.builder("MOCK", 12.193,19.111).withAltitude(100).build(); Location actual = Locations.getLocationWithAdjustedAltitude(loc, ph); assertThat("Location with altitude but no preference not adjusted", actual.getAltitude(), is(100d)); verify(loc, times(0)).setAltitude(anyDouble()); }
public static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph) { if(!loc.hasAltitude()){ return loc; } if(ph.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null){ String geoidheight = loc.getExtras().getString(BundleConstants.GEOIDHEIGHT); if (!Strings.isNullOrEmpty(geoidheight)) { loc.setAltitude(loc.getAltitude() - Double.parseDouble(geoidheight)); } else { loc.removeAltitude(); } } if(loc.hasAltitude() && ph.getSubtractAltitudeOffset() != 0){ loc.setAltitude(loc.getAltitude() - ph.getSubtractAltitudeOffset()); } return loc; }
Locations { public static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph) { if(!loc.hasAltitude()){ return loc; } if(ph.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null){ String geoidheight = loc.getExtras().getString(BundleConstants.GEOIDHEIGHT); if (!Strings.isNullOrEmpty(geoidheight)) { loc.setAltitude(loc.getAltitude() - Double.parseDouble(geoidheight)); } else { loc.removeAltitude(); } } if(loc.hasAltitude() && ph.getSubtractAltitudeOffset() != 0){ loc.setAltitude(loc.getAltitude() - ph.getSubtractAltitudeOffset()); } return loc; } }
Locations { public static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph) { if(!loc.hasAltitude()){ return loc; } if(ph.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null){ String geoidheight = loc.getExtras().getString(BundleConstants.GEOIDHEIGHT); if (!Strings.isNullOrEmpty(geoidheight)) { loc.setAltitude(loc.getAltitude() - Double.parseDouble(geoidheight)); } else { loc.removeAltitude(); } } if(loc.hasAltitude() && ph.getSubtractAltitudeOffset() != 0){ loc.setAltitude(loc.getAltitude() - ph.getSubtractAltitudeOffset()); } return loc; }  }
Locations { public static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph) { if(!loc.hasAltitude()){ return loc; } if(ph.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null){ String geoidheight = loc.getExtras().getString(BundleConstants.GEOIDHEIGHT); if (!Strings.isNullOrEmpty(geoidheight)) { loc.setAltitude(loc.getAltitude() - Double.parseDouble(geoidheight)); } else { loc.removeAltitude(); } } if(loc.hasAltitude() && ph.getSubtractAltitudeOffset() != 0){ loc.setAltitude(loc.getAltitude() - ph.getSubtractAltitudeOffset()); } return loc; }  static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph); static Location getLocationAdjustedForGPSWeekRollover(Location loc); }
Locations { public static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph) { if(!loc.hasAltitude()){ return loc; } if(ph.shouldAdjustAltitudeFromGeoIdHeight() && loc.getExtras() != null){ String geoidheight = loc.getExtras().getString(BundleConstants.GEOIDHEIGHT); if (!Strings.isNullOrEmpty(geoidheight)) { loc.setAltitude(loc.getAltitude() - Double.parseDouble(geoidheight)); } else { loc.removeAltitude(); } } if(loc.hasAltitude() && ph.getSubtractAltitudeOffset() != 0){ loc.setAltitude(loc.getAltitude() - ph.getSubtractAltitudeOffset()); } return loc; }  static Location getLocationWithAdjustedAltitude(Location loc, PreferenceHelper ph); static Location getLocationAdjustedForGPSWeekRollover(Location loc);  }