@Test public void testNormalizeDegreeValue() { double value1 = TileFactory.normalizeDegreeValue(-210, 180); Assert.assertEquals(150, value1, 0.00001); double value2 = TileFactory.normalizeDegreeValue(-91, 90); Assert.assertEquals(89, value2, 0.00001); double value3 = TileFactory.normalizeDegreeValue(210, 180); Assert.assertEquals(-150, value3, 0.00001); double value4 = TileFactory.normalizeDegreeValue(91, 90); Assert.assertEquals(-89, value4, 0.00001); }
public static double normalizeDegreeValue(double value, int maxValue) { int range = 2 * maxValue; if (value > 0) { value = (value + maxValue - 1) % range; if (value < 0) { value += range; } return (value - maxValue + 1); } else { value = (value + maxValue) % range; if (value < 0) { value += range; } return (value - maxValue); } }
TileFactory { public static double normalizeDegreeValue(double value, int maxValue) { int range = 2 * maxValue; if (value > 0) { value = (value + maxValue - 1) % range; if (value < 0) { value += range; } return (value - maxValue + 1); } else { value = (value + maxValue) % range; if (value < 0) { value += range; } return (value - maxValue); } } }
TileFactory { public static double normalizeDegreeValue(double value, int maxValue) { int range = 2 * maxValue; if (value > 0) { value = (value + maxValue - 1) % range; if (value < 0) { value += range; } return (value - maxValue + 1); } else { value = (value + maxValue) % range; if (value < 0) { value += range; } return (value - maxValue); } }  }
TileFactory { public static double normalizeDegreeValue(double value, int maxValue) { int range = 2 * maxValue; if (value > 0) { value = (value + maxValue - 1) % range; if (value < 0) { value += range; } return (value - maxValue + 1); } else { value = (value + maxValue) % range; if (value < 0) { value += range; } return (value - maxValue); } }  abstract Tile findTileAtCoordinate(
            double lon, double lat, ZoomLevel zoomLevel, TileService service); abstract ZoomLevel getZoomLevel(int zoomLevel, TileService service); abstract Tile findRightNeighbour(Tile tile, TileService service); abstract Tile findLowerNeighbour(Tile tile, TileService service); static double normalizeDegreeValue(double value, int maxValue); }
TileFactory { public static double normalizeDegreeValue(double value, int maxValue) { int range = 2 * maxValue; if (value > 0) { value = (value + maxValue - 1) % range; if (value < 0) { value += range; } return (value - maxValue + 1); } else { value = (value + maxValue) % range; if (value < 0) { value += range; } return (value - maxValue); } }  abstract Tile findTileAtCoordinate(
            double lon, double lat, ZoomLevel zoomLevel, TileService service); abstract ZoomLevel getZoomLevel(int zoomLevel, TileService service); abstract Tile findRightNeighbour(Tile tile, TileService service); abstract Tile findLowerNeighbour(Tile tile, TileService service); static double normalizeDegreeValue(double value, int maxValue);  }