Search in sources :

Example 1 with Constraints

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());
}
Also used : BoundingBoxStatistic(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) BoundingBoxValue(org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Constraints(org.locationtech.geowave.core.store.query.constraints.Constraints) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) Coordinate(org.locationtech.jts.geom.Coordinate) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TimeRangeStatistic(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic) TimeRangeValue(org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue) FeatureDataAdapter(org.locationtech.geowave.adapter.vector.FeatureDataAdapter) Test(org.junit.Test)

Example 2 with Constraints

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()));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Constraints(org.locationtech.geowave.core.store.query.constraints.Constraints) Coordinate(org.locationtech.jts.geom.Coordinate) IndexImpl(org.locationtech.geowave.core.store.index.IndexImpl) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)2 Constraints (org.locationtech.geowave.core.store.query.constraints.Constraints)2 Coordinate (org.locationtech.jts.geom.Coordinate)2 Date (java.util.Date)1 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)1 TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)1 TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)1 TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)1 BoundingBoxStatistic (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic)1 BoundingBoxValue (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue)1 TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)1 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)1 IndexImpl (org.locationtech.geowave.core.store.index.IndexImpl)1 Geometry (org.locationtech.jts.geom.Geometry)1 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)1 SimpleFeature (org.opengis.feature.simple.SimpleFeature)1