use of org.locationtech.geowave.core.store.query.constraints.Constraints in project geowave by locationtech.
the class QueryIndexHelperTest method testComposeSubsetConstraints.
@Test
public void testComposeSubsetConstraints() throws ParseException {
final TestStatisticsCache statsCache = new TestStatisticsCache();
final TimeRangeStatistic startStats = new TimeRangeStatistic("type", "start");
final TimeRangeValue startValue = startStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "start", startValue);
final TimeRangeStatistic endStats = new TimeRangeStatistic("type", "end");
final TimeRangeValue endValue = endStats.createEmpty();
statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "end", endValue);
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);
FeatureDataAdapter adapter = new FeatureDataAdapter(firstRangFeature.getFeatureType());
startValue.entryIngested(adapter, firstRangFeature);
endValue.entryIngested(adapter, firstRangFeature);
final SimpleFeature secondRangFeature = createFeature(statsStart2, statsEnd2);
startValue.entryIngested(adapter, secondRangFeature);
endValue.entryIngested(adapter, 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(stime, etime));
final Constraints constraints = QueryIndexHelper.composeTimeBoundedConstraints(rangeType, rangeTimeDescriptors, constraintsSet);
final List<MultiDimensionalNumericData> nd = constraints.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd.isEmpty());
final BoundingBoxStatistic geoStats = new BoundingBoxStatistic("type", "geometry");
final BoundingBoxValue geoValue = geoStats.createEmpty();
statsCache.putFieldStatistic(BoundingBoxStatistic.STATS_TYPE, "geometry", geoValue);
final SimpleFeature firstFeature = createGeoFeature(factory.createPoint(new Coordinate(22.25, 42.25)));
geoValue.entryIngested(adapter, firstFeature);
final SimpleFeature secondFeature = createGeoFeature(factory.createPoint(new Coordinate(27.25, 41.25)));
geoValue.entryIngested(adapter, secondFeature);
final Constraints constraints1 = QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, null, constraintsSet);
final List<MultiDimensionalNumericData> nd1 = constraints1.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd1.isEmpty());
/*
* assertEquals( stime.getTime(), (long) nd1.get( 0).getDataPerDimension()[2].getMin());
* assertEquals( etime.getTime(), (long) nd1.get( 0).getDataPerDimension()[2].getMax());
*/
final TemporalConstraintsSet constraintsSet2 = new TemporalConstraintsSet();
constraintsSet2.getConstraintsForRange("start", "end").add(new TemporalRange(statsStart1, statsEnd2));
final Constraints constraints2 = QueryIndexHelper.composeTimeBoundedConstraints(rangeType, rangeTimeDescriptors, constraintsSet2);
final List<MultiDimensionalNumericData> nd2 = constraints2.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
assertTrue(nd2.isEmpty());
}
use of org.locationtech.geowave.core.store.query.constraints.Constraints in project geowave by locationtech.
the class GeometryUtilsTest method testConstraintGeneration.
@Test
public void testConstraintGeneration() {
final GeometryFactory gf = new GeometryFactory();
final Geometry multiPolygon = gf.createMultiPolygon(new Polygon[] { gf.createPolygon(new Coordinate[] { new Coordinate(20.0, 30), new Coordinate(20, 40), new Coordinate(10, 40), new Coordinate(10, 30), new Coordinate(20, 30) }), gf.createPolygon(new Coordinate[] { new Coordinate(-9, -2), new Coordinate(-9, -1), new Coordinate(-8, -1), new Coordinate(-8, -2), new Coordinate(-9, -2) }) });
final Constraints constraints = GeometryUtils.basicConstraintsFromGeometry(multiPolygon);
final List<MultiDimensionalNumericData> results = constraints.getIndexConstraints(new IndexImpl(new ExampleNumericIndexStrategy(), null));
assertEquals(2, results.size());
assertTrue(Arrays.equals(new Double[] { 10d, 30d }, results.get(0).getMinValuesPerDimension()));
assertTrue(Arrays.equals(new Double[] { 20d, 40d }, results.get(0).getMaxValuesPerDimension()));
assertTrue(Arrays.equals(new Double[] { -9d, -2d }, results.get(1).getMinValuesPerDimension()));
assertTrue(Arrays.equals(new Double[] { -8d, -1d }, results.get(1).getMaxValuesPerDimension()));
}
Aggregations