@Test public void testNormalizeDateLineCrossingEast() { final double minRange = 150; final double maxRange = 200; final int expectedBinCount = 2; final BinRange[] expectedBinRanges = new BinRange[] {new BinRange(-180, -160), new BinRange(150, 180)}; final BinRange[] binRange = getNormalizedRanges(minRange, maxRange); Assert.assertEquals(expectedBinCount, binRange.length); for (int i = 0; i < binRange.length; i++) { Assert.assertEquals( expectedBinRanges[i].getNormalizedMin(), binRange[i].getNormalizedMin(), DELTA); Assert.assertEquals( expectedBinRanges[i].getNormalizedMax(), binRange[i].getNormalizedMax(), DELTA); } }
@Override public BinRange[] getNormalizedRanges(final NumericData range) { if (range == null) { return new BinRange[0]; } if (FloatCompareUtils.checkDoublesEqual(range.getMin(), range.getMax())) { return super.getNormalizedRanges(range); } final double normalizedMin = getNormalizedLongitude(range.getMin()); final double normalizedMax = getNormalizedLongitude(range.getMax()); if ((normalizedMax < normalizedMin) && !((FloatCompareUtils.checkDoublesEqual(normalizedMax, -1) && (FloatCompareUtils.checkDoublesEqual(normalizedMin, 0))))) { return new BinRange[] {new BinRange(-180, normalizedMax), new BinRange(normalizedMin, 180)}; } return new BinRange[] {new BinRange(normalizedMin, normalizedMax)}; }
LongitudeDefinition extends BasicDimensionDefinition { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if (range == null) { return new BinRange[0]; } if (FloatCompareUtils.checkDoublesEqual(range.getMin(), range.getMax())) { return super.getNormalizedRanges(range); } final double normalizedMin = getNormalizedLongitude(range.getMin()); final double normalizedMax = getNormalizedLongitude(range.getMax()); if ((normalizedMax < normalizedMin) && !((FloatCompareUtils.checkDoublesEqual(normalizedMax, -1) && (FloatCompareUtils.checkDoublesEqual(normalizedMin, 0))))) { return new BinRange[] {new BinRange(-180, normalizedMax), new BinRange(normalizedMin, 180)}; } return new BinRange[] {new BinRange(normalizedMin, normalizedMax)}; } }
LongitudeDefinition extends BasicDimensionDefinition { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if (range == null) { return new BinRange[0]; } if (FloatCompareUtils.checkDoublesEqual(range.getMin(), range.getMax())) { return super.getNormalizedRanges(range); } final double normalizedMin = getNormalizedLongitude(range.getMin()); final double normalizedMax = getNormalizedLongitude(range.getMax()); if ((normalizedMax < normalizedMin) && !((FloatCompareUtils.checkDoublesEqual(normalizedMax, -1) && (FloatCompareUtils.checkDoublesEqual(normalizedMin, 0))))) { return new BinRange[] {new BinRange(-180, normalizedMax), new BinRange(normalizedMin, 180)}; } return new BinRange[] {new BinRange(normalizedMin, normalizedMax)}; } LongitudeDefinition(); }
LongitudeDefinition extends BasicDimensionDefinition { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if (range == null) { return new BinRange[0]; } if (FloatCompareUtils.checkDoublesEqual(range.getMin(), range.getMax())) { return super.getNormalizedRanges(range); } final double normalizedMin = getNormalizedLongitude(range.getMin()); final double normalizedMax = getNormalizedLongitude(range.getMax()); if ((normalizedMax < normalizedMin) && !((FloatCompareUtils.checkDoublesEqual(normalizedMax, -1) && (FloatCompareUtils.checkDoublesEqual(normalizedMin, 0))))) { return new BinRange[] {new BinRange(-180, normalizedMax), new BinRange(normalizedMin, 180)}; } return new BinRange[] {new BinRange(normalizedMin, normalizedMax)}; } LongitudeDefinition(); @Override BinRange[] getNormalizedRanges(final NumericData range); static double getNormalizedLongitude(final double lon); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes); }
LongitudeDefinition extends BasicDimensionDefinition { @Override public BinRange[] getNormalizedRanges(final NumericData range) { if (range == null) { return new BinRange[0]; } if (FloatCompareUtils.checkDoublesEqual(range.getMin(), range.getMax())) { return super.getNormalizedRanges(range); } final double normalizedMin = getNormalizedLongitude(range.getMin()); final double normalizedMax = getNormalizedLongitude(range.getMax()); if ((normalizedMax < normalizedMin) && !((FloatCompareUtils.checkDoublesEqual(normalizedMax, -1) && (FloatCompareUtils.checkDoublesEqual(normalizedMin, 0))))) { return new BinRange[] {new BinRange(-180, normalizedMax), new BinRange(normalizedMin, 180)}; } return new BinRange[] {new BinRange(normalizedMin, normalizedMax)}; } LongitudeDefinition(); @Override BinRange[] getNormalizedRanges(final NumericData range); static double getNormalizedLongitude(final double lon); @Override byte[] toBinary(); @Override void fromBinary(final byte[] bytes);  }