Package mil.nga.giat.geowave.index.dimension.bin

Examples of mil.nga.giat.geowave.index.dimension.bin.TemporalBinningStrategy


   *            an enumeration of temporal units (DAY, MONTH, or YEAR)
   */
  public TimeDefinition(
      final Unit unit ) {
    super(
        new TemporalBinningStrategy(
            unit));

  }
View Full Code Here


                      // so tests are all entirely
                      // reproducible
    startCal.setTimeInMillis(time);
    final Calendar endCal = Calendar.getInstance();
    endCal.setTimeInMillis(time);
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        unit);
    binStrategy.setToEpoch(startCal);
    binStrategy.setToEpoch(endCal);
    endCal.add(
        unit.toCalendarEnum(),
        binCount);
    return binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        (double) endCal.getTimeInMillis() - 1));
  }
View Full Code Here

    startCal.setTimeInMillis(time);
    final Calendar endCal = Calendar.getInstance();
    // theoretically should get 3 bins back the first and last not having
    // full extent and the middle one being full extent
    endCal.setTimeInMillis(time + (TemporalBinningStrategy.MILLIS_PER_DAY * 2));
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.DAY);

    BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        endCal.getTimeInMillis()));
    Assert.assertEquals(
        3,
        ranges.length);

    Assert.assertTrue(!ranges[0].isFullExtent());

    Assert.assertTrue(ranges[1].isFullExtent());

    Assert.assertTrue(!ranges[2].isFullExtent());

    final Calendar startCalOnEpoch = Calendar.getInstance();

    startCalOnEpoch.setTimeInMillis(time);
    binStrategy.setToEpoch(startCalOnEpoch);

    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCalOnEpoch.getTimeInMillis(),
        endCal.getTimeInMillis()));
    Assert.assertEquals(
        3,
        ranges.length);
    // now the first element should be full extent
    Assert.assertTrue(ranges[0].isFullExtent());

    Assert.assertTrue(ranges[1].isFullExtent());

    Assert.assertTrue(!ranges[2].isFullExtent());

    final Calendar endCalOnMax = Calendar.getInstance();
    // theoretically should get 3 bins back the first and last not having
    // full extent and the middle one being full extent
    endCalOnMax.setTimeInMillis(time + (TemporalBinningStrategy.MILLIS_PER_DAY * 3));
    binStrategy.setToEpoch(endCalOnMax);
    endCalOnMax.add(
        Calendar.MILLISECOND,
        -1);
    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        endCalOnMax.getTimeInMillis()));
    Assert.assertEquals(
        3,
        ranges.length);
View Full Code Here

    final long time = 6758493029128L;
    startCal.setTimeInMillis(time);
    startCal.set(
        Calendar.MONTH,
        0);// make sure its a month after one with 31 days
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.MONTH);
    binStrategy.setToEpoch(startCal);
    final Calendar endCal = Calendar.getInstance();
    endCal.setTimeInMillis(time);
    endCal.set(
        Calendar.MONTH,
        0);// make sure its a month after one with 31 days
    binStrategy.setToEpoch(endCal);
    final BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis() - 1,
        endCal.getTimeInMillis()));

    Assert.assertEquals(
        2,
        ranges.length);

    // the first range should be the max possible value and both the min and
    // max of the range should be equal
    Assert.assertTrue(ranges[0].getNormalizedMax() == binStrategy.getBinMax());
    Assert.assertTrue(ranges[0].getNormalizedMin() == ranges[0].getNormalizedMax());

    // the second range should be the min possible value and both the min
    // and max of the range should be equal
    Assert.assertTrue(ranges[1].getNormalizedMin() == binStrategy.getBinMin());
    Assert.assertTrue(ranges[0].getNormalizedMax() == ranges[0].getNormalizedMin());
  }
View Full Code Here

  }

  @Test
  public void testStartAndEndEqual() {
    final long time = 123987564019283L;
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.YEAR);
    final BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        time,
        time));

    Assert.assertEquals(
        1,
View Full Code Here

    endCal.set(
        Calendar.DAY_OF_MONTH,
        1);
    // test the day boundaries first - going from feb28 to march 1 should
    // give 2 bins
    TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.DAY);
    BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        endCal.getTimeInMillis()));

    Assert.assertEquals(
        2,
        ranges.length);

    // now test the month boundaries - adding a day to feb28 for the end
    // time should give 2 bins
    binStrategy = new TemporalBinningStrategy(
        Unit.MONTH);
    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY)));

    Assert.assertEquals(
        2,
View Full Code Here

    endCal.set(
        Calendar.DAY_OF_MONTH,
        1);
    // test the day boundaries first - going from feb28 to march 1 should
    // give 3 bins
    TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.DAY);
    BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        endCal.getTimeInMillis()));

    Assert.assertEquals(
        3,
        ranges.length);

    // now test the month boundaries - adding a day to feb28 for the end
    // time should give 1 bin, adding 2 days should give 2 bins
    binStrategy = new TemporalBinningStrategy(
        Unit.MONTH);
    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY)));

    Assert.assertEquals(
        1,
        ranges.length);
    // add 2 days and now we should end up with 2 bins
    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY * 2)));

    Assert.assertEquals(
        2,
 
View Full Code Here

  }

  @Test
  public void testNonLeapYear() {
    final long time = 75470203439504394L;
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.YEAR);
    final Calendar startCal = Calendar.getInstance();
    startCal.setTimeInMillis(time);
    startCal.set(
        Calendar.YEAR,
        2015);
    binStrategy.setToEpoch(startCal);
    // if we add 365 days to this we should get 2 year bins
    final BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY * 365)));
    Assert.assertEquals(
        2,
        ranges.length);
 
View Full Code Here

  }

  @Test
  public void testLeapYear() {
    final long time = 94823024856598633L;
    final TemporalBinningStrategy binStrategy = new TemporalBinningStrategy(
        Unit.YEAR);
    final Calendar startCal = Calendar.getInstance();
    startCal.setTimeInMillis(time);
    startCal.set(
        Calendar.YEAR,
        2016);
    binStrategy.setToEpoch(startCal);
    // if we add 365 days to this we should get 1 year bin
    BinRange[] ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY * 365)));
    Assert.assertEquals(
        1,
        ranges.length);
    // if we add 366 days to this we should get 2 year bins, and the second
    // bin should be the epoch
    ranges = binStrategy.getNormalizedRanges(new NumericRange(
        startCal.getTimeInMillis(),
        startCal.getTimeInMillis() + (TemporalBinningStrategy.MILLIS_PER_DAY * 366)));
    Assert.assertEquals(
        2,
        ranges.length);

    // the second bin should just contain the epoch
    Assert.assertTrue(ranges[1].getNormalizedMin() == ranges[1].getNormalizedMax());
    Assert.assertTrue(ranges[1].getNormalizedMin() == binStrategy.getBinMin());
  }
View Full Code Here

TOP

Related Classes of mil.nga.giat.geowave.index.dimension.bin.TemporalBinningStrategy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.