QueryIndexHelper { public static TemporalConstraintsSet clipIndexedTemporalConstraints( final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final TimeDescriptors timeDescriptors, final TemporalConstraintsSet constraintsSet) { if ((timeDescriptors.getEndRange() != null) && (timeDescriptors.getStartRange() != null)) { final String ename = timeDescriptors.getEndRange().getLocalName(); final String sname = timeDescriptors.getStartRange().getLocalName(); if (constraintsSet.hasConstraintsForRange(sname, ename)) { final TemporalRange statsStartRange = getStatsRange(statsMap, timeDescriptors.getStartRange()); final TemporalRange statsEndRange = getStatsRange(statsMap, timeDescriptors.getEndRange()); final TemporalRange fullRange = new TemporalRange(statsStartRange.getStartTime(), statsEndRange.getEndTime()); final TemporalConstraints constraints = constraintsSet.getConstraintsForRange(sname, ename); constraints.replaceWithIntersections( new TemporalConstraints(fullRange, constraints.getName())); constraintsSet.removeAllConstraintsExcept(constraints.getName()); return constraintsSet; } } else if ((timeDescriptors.getTime() != null) && constraintsSet.hasConstraintsFor(timeDescriptors.getTime().getLocalName())) { final String name = timeDescriptors.getTime().getLocalName(); final TimeRangeDataStatistics stats = ((TimeRangeDataStatistics) statsMap.get( VectorStatisticsQueryBuilder.newBuilder().factory().timeRange().fieldName( name).build().getId())); final TemporalConstraints constraints = constraintsSet.getConstraintsFor(name); if (stats != null) { constraints.replaceWithIntersections( new TemporalConstraints(stats.asTemporalRange(), name)); } constraintsSet.removeAllConstraintsExcept(name); return constraintsSet; } return constraintsSet; }  static TemporalConstraintsSet clipIndexedTemporalConstraints(
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap,
      final TimeDescriptors timeDescriptors,
      final TemporalConstraintsSet constraintsSet); static Geometry clipIndexedBBOXConstraints(
      final SimpleFeatureType featureType,
      final Geometry bbox,
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap); static ConstraintSet getTimeConstraintsFromIndex(
      final TimeDescriptors timeDescriptors,
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> stats); static ConstraintSet getBBOXIndexConstraintsFromIndex(
      final SimpleFeatureType featureType,
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap); static ConstraintsByClass composeTimeConstraints(
      final SimpleFeatureType featureType,
      final TimeDescriptors timeDescriptors,
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap,
      final TemporalConstraintsSet timeBoundsSet); static ConstraintsByClass composeTimeBoundedConstraints(
      final SimpleFeatureType featureType,
      final TimeDescriptors timeDescriptors,
      final TemporalConstraintsSet timeBoundsSet); static GeoConstraintsWrapper composeGeometricConstraints(
      final SimpleFeatureType featureType,
      final Geometry jtsBounds); static ConstraintsByClass composeConstraints(
      final SimpleFeatureType featureType,
      final TimeDescriptors timeDescriptors,
      final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap,
      final Geometry jtsBounds,
      final TemporalConstraintsSet timeBoundsSet);  }
@Test public void testGetTemporalConstraintsForSingleClippedRange() throws ParseException { final Date stime = DateUtilities.parseISO("2005-05-14T20:32:56Z"); final Date etime = DateUtilities.parseISO("2005-05-18T20:32:56Z"); final Date stime1 = DateUtilities.parseISO("2005-05-18T20:32:56Z"); final Date etime1 = DateUtilities.parseISO("2005-05-19T20:32:56Z"); final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap = new HashMap<>(); final FeatureTimeRangeStatistics whenStats = new FeatureTimeRangeStatistics("when"); statsMap.put( VectorStatisticsQueryBuilder.newBuilder().factory().timeRange().fieldName( "when").build().getId(), whenStats); final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet(); constraintsSet.getConstraintsFor("when").add(new TemporalRange(stime, etime)); final SimpleFeature notIntersectSingle1 = createSingleTimeFeature(startTime); whenStats.entryIngested(notIntersectSingle1); final SimpleFeature notIntersectSingle = createSingleTimeFeature(endTime); whenStats.entryIngested(notIntersectSingle); final TemporalConstraintsSet resultConstraintsSet = QueryIndexHelper.clipIndexedTemporalConstraints( statsMap, singleTimeDescriptors, constraintsSet); final TemporalConstraints constraints = resultConstraintsSet.getConstraintsFor("when"); assertEquals(1, constraints.getRanges().size()); assertEquals(startTime, constraints.getStartRange().getStartTime()); assertEquals(etime, constraints.getStartRange().getEndTime()); final TemporalConstraintsSet constraintsSet1 = new TemporalConstraintsSet(); constraintsSet1.getConstraintsFor("when").add(new TemporalRange(stime1, etime1)); final TemporalConstraintsSet resultConstraintsSet1 = QueryIndexHelper.clipIndexedTemporalConstraints( statsMap, singleTimeDescriptors, constraintsSet1); final TemporalConstraints constraints1 = resultConstraintsSet1.getConstraintsFor("when"); assertEquals(1, constraints1.getRanges().size()); assertEquals(stime1, constraints1.getStartRange().getStartTime()); assertEquals(etime1, constraints1.getStartRange().getEndTime()); }
@Test public void testGetTemporalConstraintsForRangeClippedFullRange() throws ParseException { final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap = new HashMap<>(); final FeatureTimeRangeStatistics startStats = new FeatureTimeRangeStatistics("start"); statsMap.put( VectorStatisticsQueryBuilder.newBuilder().factory().timeRange().fieldName( "start").build().getId(), startStats); final FeatureTimeRangeStatistics endStats = new FeatureTimeRangeStatistics("end"); statsMap.put( VectorStatisticsQueryBuilder.newBuilder().factory().timeRange().fieldName( "end").build().getId(), endStats); final Date statsStart1 = DateUtilities.parseISO("2005-05-18T20:32:56Z"); final Date statsStart2 = DateUtilities.parseISO("2005-05-20T20:32:56Z"); final Date statsEnd1 = DateUtilities.parseISO("2005-05-21T20:32:56Z"); final Date statsEnd2 = DateUtilities.parseISO("2005-05-24T20:32:56Z"); final SimpleFeature firstRangFeature = createFeature(statsStart1, statsEnd1); startStats.entryIngested(firstRangFeature); endStats.entryIngested(firstRangFeature); final SimpleFeature secondRangFeature = createFeature(statsStart2, statsEnd2); startStats.entryIngested(secondRangFeature); endStats.entryIngested(secondRangFeature); final Date stime = DateUtilities.parseISO("2005-05-18T20:32:56Z"); final Date etime = DateUtilities.parseISO("2005-05-19T20:32:56Z"); final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet(); constraintsSet.getConstraintsForRange("start", "end").add( new TemporalRange(new Date(0), etime)); final TemporalConstraintsSet resultConstraintsSet = QueryIndexHelper.clipIndexedTemporalConstraints( statsMap, rangeTimeDescriptors, constraintsSet); final TemporalConstraints constraints = resultConstraintsSet.getConstraintsForRange("start", "end"); assertEquals(1, constraints.getRanges().size()); assertEquals(stime, constraints.getStartRange().getStartTime()); assertEquals(etime, constraints.getStartRange().getEndTime()); }