Search in sources :

Example 1 with TemporalRange

use of org.locationtech.geowave.core.geotime.store.query.TemporalRange in project geowave by locationtech.

the class KMeansUtils method setRunnerTimeParams.

public static ScaledTemporalRange setRunnerTimeParams(final KMeansRunner runner, final DataStorePluginOptions inputDataStore, String typeName) {
    if (typeName == null) {
        // if no id provided, locate a single
        // featureadapter
        final List<String> typeNameList = FeatureDataUtils.getFeatureTypeNames(inputDataStore);
        if (typeNameList.size() == 1) {
            typeName = typeNameList.get(0);
        } else if (typeNameList.isEmpty()) {
            LOGGER.error("No feature adapters found for use with time param");
            return null;
        } else {
            LOGGER.error("Multiple feature adapters found for use with time param. Please specify one.");
            return null;
        }
    }
    final ScaledTemporalRange scaledRange = new ScaledTemporalRange();
    final String timeField = FeatureDataUtils.getTimeField(inputDataStore, typeName);
    if (timeField != null) {
        final TemporalRange timeRange = DateUtilities.getTemporalRange(inputDataStore, typeName, timeField);
        if (timeRange != null) {
            scaledRange.setTimeRange(timeRange.getStartTime(), timeRange.getEndTime());
        }
        final String geomField = FeatureDataUtils.getGeomField(inputDataStore, typeName);
        final Envelope bbox = org.locationtech.geowave.adapter.vector.util.FeatureGeometryUtils.getGeoBounds(inputDataStore, typeName, geomField);
        if (bbox != null) {
            final double xRange = bbox.getMaxX() - bbox.getMinX();
            final double yRange = bbox.getMaxY() - bbox.getMinY();
            final double valueRange = Math.min(xRange, yRange);
            scaledRange.setValueRange(0.0, valueRange);
        }
        runner.setTimeParams(timeField, scaledRange);
        return scaledRange;
    }
    LOGGER.error("Couldn't determine field to use for time param");
    return null;
}
Also used : ScaledTemporalRange(org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) ScaledTemporalRange(org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange) Envelope(org.locationtech.jts.geom.Envelope)

Example 2 with TemporalRange

use of org.locationtech.geowave.core.geotime.store.query.TemporalRange in project geowave by locationtech.

the class QueryIndexHelper method getTimeConstraintsFromIndex.

public static ConstraintSet getTimeConstraintsFromIndex(final StatisticsCache statisticsCache, final TimeDescriptors timeDescriptors) {
    if ((timeDescriptors.getEndRange() != null) || (timeDescriptors.getStartRange() != null)) {
        final TemporalRange endRange = getTimeRange(statisticsCache, timeDescriptors.getEndRange());
        final TemporalRange startRange = getTimeRange(statisticsCache, timeDescriptors.getStartRange());
        if ((endRange != null) && (startRange != null)) {
            return ExplicitSpatialTemporalQuery.createConstraints(startRange.union(endRange), true);
        } else if (endRange != null) {
            return ExplicitSpatialTemporalQuery.createConstraints(endRange, true);
        } else if (startRange != null) {
            return ExplicitSpatialTemporalQuery.createConstraints(startRange, true);
        }
    } else if (timeDescriptors.getTime() != null) {
        final TemporalRange range = getTimeRange(statisticsCache, timeDescriptors.getTime());
        if (range != null) {
            return ExplicitSpatialTemporalQuery.createConstraints(range, true);
        }
    }
    return new ConstraintSet();
}
Also used : TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)

Example 3 with TemporalRange

use of org.locationtech.geowave.core.geotime.store.query.TemporalRange in project geowave by locationtech.

the class QueryIndexHelperTest method testComposeQueryWithTimeRange.

@Test
public void testComposeQueryWithTimeRange() 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 BasicQueryByClass query = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), constraintsSet));
    final List<MultiDimensionalNumericData> nd = query.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
    assertEquals(stime.getTime(), nd.get(0).getDataPerDimension()[2].getMin().longValue());
    assertEquals(etime.getTime(), nd.get(0).getDataPerDimension()[2].getMax().longValue());
    final BasicQueryByClass query1 = new BasicQueryByClass(QueryIndexHelper.composeConstraints(statsCache, rangeType, rangeTimeDescriptors, factory.toGeometry(factory.createPoint(new Coordinate(27.25, 41.25)).getEnvelopeInternal()), null));
    final List<MultiDimensionalNumericData> nd1 = query1.getIndexConstraints(SPATIAL_TEMPORAL_INDEX);
    assertEquals(statsStart1.getTime(), nd1.get(0).getDataPerDimension()[2].getMin().longValue());
    assertEquals(statsEnd2.getTime(), nd1.get(0).getDataPerDimension()[2].getMax().longValue());
}
Also used : MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) Coordinate(org.locationtech.jts.geom.Coordinate) TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) 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) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) BasicQueryByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass) Test(org.junit.Test)

Example 4 with TemporalRange

use of org.locationtech.geowave.core.geotime.store.query.TemporalRange 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 5 with TemporalRange

use of org.locationtech.geowave.core.geotime.store.query.TemporalRange in project geowave by locationtech.

the class QueryIndexHelperTest method testGetTemporalConstraintsForSingleClippedRange.

@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 TestStatisticsCache statsCache = new TestStatisticsCache();
    final TimeRangeStatistic whenStats = new TimeRangeStatistic(singleType.getTypeName(), "when");
    final TimeRangeValue whenValue = whenStats.createEmpty();
    statsCache.putFieldStatistic(TimeRangeStatistic.STATS_TYPE, "when", whenValue);
    final TemporalConstraintsSet constraintsSet = new TemporalConstraintsSet();
    constraintsSet.getConstraintsFor("when").add(new TemporalRange(stime, etime));
    final FeatureDataAdapter singleDataAdapter = new FeatureDataAdapter(singleType);
    final SimpleFeature notIntersectSingle1 = createSingleTimeFeature(startTime);
    whenValue.entryIngested(singleDataAdapter, notIntersectSingle1);
    final SimpleFeature notIntersectSingle = createSingleTimeFeature(endTime);
    whenValue.entryIngested(singleDataAdapter, notIntersectSingle);
    final TemporalConstraintsSet resultConstraintsSet = QueryIndexHelper.clipIndexedTemporalConstraints(statsCache, 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(statsCache, singleTimeDescriptors, constraintsSet1);
    final TemporalConstraints constraints1 = resultConstraintsSet1.getConstraintsFor("when");
    assertEquals(1, constraints1.getRanges().size());
    assertEquals(stime1, constraints1.getStartRange().getStartTime());
    assertEquals(etime1, constraints1.getStartRange().getEndTime());
}
Also used : TemporalConstraintsSet(org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet) TemporalRange(org.locationtech.geowave.core.geotime.store.query.TemporalRange) TemporalConstraints(org.locationtech.geowave.core.geotime.store.query.TemporalConstraints) 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) Date(java.util.Date) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Test(org.junit.Test)

Aggregations

TemporalRange (org.locationtech.geowave.core.geotime.store.query.TemporalRange)31 TemporalConstraints (org.locationtech.geowave.core.geotime.store.query.TemporalConstraints)25 Date (java.util.Date)9 TemporalConstraintsSet (org.locationtech.geowave.core.geotime.store.query.TemporalConstraintsSet)6 TimeRangeStatistic (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic)6 TimeRangeValue (org.locationtech.geowave.core.geotime.store.statistics.TimeRangeStatistic.TimeRangeValue)6 Test (org.junit.Test)5 FeatureDataAdapter (org.locationtech.geowave.adapter.vector.FeatureDataAdapter)5 SimpleFeature (org.opengis.feature.simple.SimpleFeature)5 Coordinate (org.locationtech.jts.geom.Coordinate)3 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)2 Timestamp (java.sql.Timestamp)1 Calendar (java.util.Calendar)1 DefaultTransaction (org.geotools.data.DefaultTransaction)1 Transaction (org.geotools.data.Transaction)1 BaseDataStoreTest (org.locationtech.geowave.adapter.vector.BaseDataStoreTest)1 ScaledTemporalRange (org.locationtech.geowave.core.geotime.store.query.ScaledTemporalRange)1 BoundingBoxStatistic (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic)1 BoundingBoxValue (org.locationtech.geowave.core.geotime.store.statistics.BoundingBoxStatistic.BoundingBoxValue)1 InternalAdapterStore (org.locationtech.geowave.core.store.adapter.InternalAdapterStore)1