Search in sources :

Example 1 with ConstraintSet

use of org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet in project geowave by locationtech.

the class ChooseLocalityPreservingQueryStrategyTest method createConstraints.

private ConstraintsByClass createConstraints(final double lat, final double lon, final double time) {
    final ConstraintSet cs1 = new ConstraintSet();
    cs1.addConstraint(LatitudeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0, lat), true));
    cs1.addConstraint(LongitudeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0, lon), true));
    final ConstraintSet cs2a = new ConstraintSet();
    cs2a.addConstraint(TimeDefinition.class, new ConstraintData(new ConstrainedIndexValue(0, time), true));
    return new ConstraintsByClass(Arrays.asList(cs2a)).merge(Collections.singletonList(cs1));
}
Also used : ConstraintData(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData) ConstraintsByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)

Example 2 with ConstraintSet

use of org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet 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 ConstraintSet

use of org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet in project geowave by locationtech.

the class GeometryUtils method basicGeoConstraintsWrapperFromGeometry.

/**
 * This utility method will convert a JTS geometry to contraints that can be used in a GeoWave
 * query.
 *
 * @return Constraints as a mapping of NumericData objects representing ranges for a latitude
 *         dimension and a longitude dimension
 */
public static GeoConstraintsWrapper basicGeoConstraintsWrapperFromGeometry(final Geometry geometry) {
    final List<ConstraintSet> set = new LinkedList<>();
    final boolean geometryConstraintsExactMatch = constructListOfConstraintSetsFromGeometry(geometry, set, true);
    return new GeoConstraintsWrapper(new ConstraintsByClass(set), geometryConstraintsExactMatch, geometry);
}
Also used : ConstraintsByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet) LinkedList(java.util.LinkedList)

Example 4 with ConstraintSet

use of org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet in project geowave by locationtech.

the class GeometryUtils method basicConstraintSetFromEnvelope.

/**
 * This utility method will convert a JTS envelope to contraints that can be used in a GeoWave
 * query.
 *
 * @return Constraints as a mapping of NumericData objects representing ranges for a latitude
 *         dimension and a longitude dimension
 */
public static ConstraintSet basicConstraintSetFromEnvelope(final Envelope env) {
    // Create a NumericRange object using the x axis
    final NumericRange rangeLongitude = new NumericRange(env.getMinX(), env.getMaxX());
    // Create a NumericRange object using the y axis
    final NumericRange rangeLatitude = new NumericRange(env.getMinY(), env.getMaxY());
    final Map<Class<? extends NumericDimensionDefinition>, ConstraintData> constraintsPerDimension = new HashMap<>();
    // Create and return a new IndexRange array with an x and y axis
    // range
    final ConstraintData xRange = new ConstraintData(rangeLongitude, false);
    final ConstraintData yRange = new ConstraintData(rangeLatitude, false);
    constraintsPerDimension.put(CustomCRSUnboundedSpatialDimensionX.class, xRange);
    constraintsPerDimension.put(CustomCRSUnboundedSpatialDimensionY.class, yRange);
    constraintsPerDimension.put(CustomCRSBoundedSpatialDimensionX.class, xRange);
    constraintsPerDimension.put(CustomCRSBoundedSpatialDimensionY.class, yRange);
    constraintsPerDimension.put(LongitudeDefinition.class, xRange);
    constraintsPerDimension.put(LatitudeDefinition.class, yRange);
    return new ConstraintSet(constraintsPerDimension);
}
Also used : NumericRange(org.locationtech.geowave.core.index.numeric.NumericRange) ConstraintData(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData) HashMap(java.util.HashMap) NumericDimensionDefinition(org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition) ConstraintsByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)

Example 5 with ConstraintSet

use of org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet in project geowave by locationtech.

the class GeometryUtils method basicConstraintsFromPoint.

/**
 * This utility method will convert a JTS envelope to that can be used in a GeoWave query.
 *
 * @return Constraints as a mapping of NumericData objects representing ranges for a latitude
 *         dimension and a longitude dimension
 */
public static ConstraintSet basicConstraintsFromPoint(final double latitudeDegrees, final double longitudeDegrees) {
    // Create a NumericData object using the x axis
    final NumericData latitude = new NumericValue(latitudeDegrees);
    // Create a NumericData object using the y axis
    final NumericData longitude = new NumericValue(longitudeDegrees);
    final Map<Class<? extends NumericDimensionDefinition>, ConstraintData> constraintsPerDimension = new HashMap<>();
    // Create and return a new IndexRange array with an x and y axis
    // range
    constraintsPerDimension.put(LongitudeDefinition.class, new ConstraintData(longitude, false));
    constraintsPerDimension.put(LatitudeDefinition.class, new ConstraintData(latitude, false));
    return new ConstraintSet(constraintsPerDimension);
}
Also used : ConstraintData(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData) HashMap(java.util.HashMap) NumericDimensionDefinition(org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition) MultiDimensionalNumericData(org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData) NumericData(org.locationtech.geowave.core.index.numeric.NumericData) ConstraintsByClass(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass) NumericValue(org.locationtech.geowave.core.index.numeric.NumericValue) ConstraintSet(org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)

Aggregations

ConstraintSet (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintSet)10 ConstraintsByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintsByClass)9 ConstraintData (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass.ConstraintData)8 HashMap (java.util.HashMap)4 NumericData (org.locationtech.geowave.core.index.numeric.NumericData)4 Index (org.locationtech.geowave.core.store.api.Index)4 BasicQueryByClass (org.locationtech.geowave.core.store.query.constraints.BasicQueryByClass)4 Test (org.junit.Test)3 BasicNumericDataset (org.locationtech.geowave.core.index.numeric.BasicNumericDataset)3 MultiDimensionalNumericData (org.locationtech.geowave.core.index.numeric.MultiDimensionalNumericData)3 ArrayList (java.util.ArrayList)2 NumericDimensionDefinition (org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition)2 NumericRange (org.locationtech.geowave.core.index.numeric.NumericRange)2 NumericValue (org.locationtech.geowave.core.index.numeric.NumericValue)2 CommonIndexedPersistenceEncoding (org.locationtech.geowave.core.store.data.CommonIndexedPersistenceEncoding)2 NumericDimensionField (org.locationtech.geowave.core.store.dimension.NumericDimensionField)2 BasicIndexModel (org.locationtech.geowave.core.store.index.BasicIndexModel)2 CustomNameIndex (org.locationtech.geowave.core.store.index.CustomNameIndex)2 IndexImpl (org.locationtech.geowave.core.store.index.IndexImpl)2 QueryFilter (org.locationtech.geowave.core.store.query.filter.QueryFilter)2