protected Geometry clipIndexedBBOXConstraints(final Geometry bbox) { return QueryIndexHelper.clipIndexedBBOXConstraints( getFeatureType(), bbox, transaction.getDataStatistics()); }
protected TemporalConstraintsSet clipIndexedTemporalConstraints( final TemporalConstraintsSet constraintsSet) { return QueryIndexHelper.clipIndexedTemporalConstraints( transaction.getDataStatistics(), components.getAdapter().getTimeDescriptors(), constraintsSet); }
/** * Compose a query from the set of constraints. When the provided constraints do not fulfill the * indexed dimensions, compose constraints from statistics. * * @param featureType * @param timeDescriptors * @param statsMap * @param jtsBounds * @param timeBoundsSet * @return */ public static Constraints composeConstraints( final SimpleFeatureType featureType, final TimeDescriptors timeDescriptors, final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final Geometry jtsBounds, final TemporalConstraintsSet timeBoundsSet) { final Constraints timeConstraints = composeTimeConstraints(featureType, timeDescriptors, statsMap, timeBoundsSet); final GeoConstraintsWrapper geoConstraints = composeGeometricConstraints(featureType, statsMap, jtsBounds); return timeConstraints.merge(geoConstraints.getConstraints()); } }
private BasicQuery getQuery( final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final Geometry jtsBounds, final TemporalConstraintsSet timeBounds) { final Constraints timeConstraints = QueryIndexHelper.composeTimeBoundedConstraints( components.getAdapter().getFeatureType(), components.getAdapter().getTimeDescriptors(), statsMap, timeBounds); final GeoConstraintsWrapper geoConstraints = QueryIndexHelper.composeGeometricConstraints(getFeatureType(), statsMap, jtsBounds); /** * NOTE: query to an index that requires a constraint and the constraint is missing equates to a * full table scan. @see BasicQuery */ final BasicQuery query = composeQuery(geoConstraints, timeConstraints); query.setExact(timeBounds.isExact()); return query; }
/** * Compose a time constraints. When the provided constraints do not fulfill the indexed * dimensions, compose constraints from statistics. * * @param featureType * @param timeDescriptors * @param statsMap * @param timeBoundsSet * @return */ public static Constraints composeTimeConstraints( final SimpleFeatureType featureType, final TimeDescriptors timeDescriptors, final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final TemporalConstraintsSet timeBoundsSet) { final TemporalConstraints timeBounds = TimeUtils.getTemporalConstraintsForDescriptors(timeDescriptors, timeBoundsSet); return (timeBounds != null) && !timeBounds.isEmpty() ? ExplicitSpatialTemporalQuery.createConstraints(timeBounds, false) : new Constraints(getTimeConstraintsFromIndex(timeDescriptors, statsMap)); }
/** * If composed constraints matched statistics constraints, are empty or null, then return empty * constraint set * * @param featureType * @param timeDescriptors * @param statsMap * @param timeBoundsSet * @return */ public static GeoConstraintsWrapper composeGeometricConstraints( final SimpleFeatureType featureType, final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final Geometry jtsBounds) { if (jtsBounds == null) { return new GeoConstraintsWrapper(new Constraints(), true, null); } final GeoConstraintsWrapper geoConstraints = GeometryUtils.basicGeoConstraintsWrapperFromGeometry(jtsBounds); final Constraints statsConstraints = new Constraints(getBBOXIndexConstraintsFromIndex(featureType, statsMap)); if (geoConstraints.getConstraints().matches(statsConstraints)) { return new GeoConstraintsWrapper( new Constraints(), geoConstraints.isConstraintsMatchGeometry(), jtsBounds); } return geoConstraints; }
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());
/** * If composed constraints matched statistics constraints, are empty or null, then return empty * constraint set. * * @param featureType * @param timeDescriptors * @param statsMap * @param timeBoundsSet * @return */ public static Constraints composeTimeBoundedConstraints( final SimpleFeatureType featureType, final TimeDescriptors timeDescriptors, final Map<StatisticsId, InternalDataStatistics<SimpleFeature, ?, ?>> statsMap, final TemporalConstraintsSet timeBoundsSet) { if ((timeBoundsSet == null) || timeBoundsSet.isEmpty() || !timeDescriptors.hasTime()) { return new Constraints(); } final TemporalConstraints boundsTemporalConstraints = TimeUtils.getTemporalConstraintsForDescriptors(timeDescriptors, timeBoundsSet); if (boundsTemporalConstraints.isEmpty()) { return new Constraints(); } final Constraints indexTimeConstraints = new Constraints(QueryIndexHelper.getTimeConstraintsFromIndex(timeDescriptors, statsMap)); final Constraints boundsTimeConstraints = ExplicitSpatialTemporalQuery.createConstraints(boundsTemporalConstraints, false); return (boundsTimeConstraints.matches(indexTimeConstraints)) ? new Constraints() : boundsTimeConstraints; }