/** * Retrive the extent of the Query. * * <p>This method provides access to an optimized getBounds opperation. If no optimized * opperation is available <code>null</code> will be returned. * * <p>You may still make use of getFeatures( Query ).getCount() which will return the correct * answer (even if it has to itterate through all the results to do so. * * @param query User's query * @return Extend of Query or <code>null</code> if no optimization is available * @throws IOException If a problem is encountered with source */ public ReferencedEnvelope getBounds(Query query) throws IOException { // since CRS is at most forced, we don't need to change this code try { query = makeDefinitionQuery(query, schema); } catch (IOException ex) { return null; } return source.getBounds(query); }
/** * Adjust query and forward to source. * * <p>This method provides access to an optimized getCount opperation. If no optimized * opperation is available <code>-1</code> will be returned. * * <p>You may still make use of getFeatures( Query ).getCount() which will return the correct * answer (even if it has to itterate through all the results to do so). * * @param query User's query. * @return Number of Features for Query, or -1 if no optimization is available. */ public int getCount(Query query) { try { query = makeDefinitionQuery(query, schema); } catch (IOException ex) { return -1; } try { return source.getCount(query); } catch (IOException e) { return 0; } }
Query newQuery = makeDefinitionQuery(query, schema);