bool ossimTilingPoly::next(ossimRefPtr<ossimMapProjection>& resultProjection, ossimIrect& resultingBounds, ossimString& resultingName) { bool result = true; if(theTileId < theTotalTiles) { ostringstream idString; ossim_int64 tileId = theTileId + 1; if (tileId < static_cast<ossim_int64>(m_features.size())) { idString << m_features[tileId].m_fid; resultingName = theTileNameMask; resultingName = resultingName.substitute("%f%", idString.str().c_str()); } result = nextFeature(); resultingBounds = m_exteriorCut->getRectangle(); resultProjection = theMapProjection; ++theTileId; } else { result = false; } return result; }
bool QgsVectorDataProvider::featureAtId( int featureId, QgsFeature& feature, bool fetchGeometry, QgsAttributeList fetchAttributes ) { select( fetchAttributes, QgsRectangle(), fetchGeometry ); while ( nextFeature( feature ) ) { if ( feature.id() == featureId ) return true; } return false; }
bool QgsSqlAnywhereFeatureIterator::nextFeature( QgsFeature& feature ) { if ( mClosed ) return false; feature.setValid( false ); if ( !P->isValid() ) { SaDebugMsg( "Read attempt on an invalid SQL Anywhere data source" ); return false; } if ( mStmt == NULL || !mStmt->isValid() ) { SaDebugMsg( "nextFeature() called with invalid cursor()" ); return false; } return nextFeature( feature, mStmt ); }
void QgsVectorDataProvider::uniqueValues( int index, QList<QVariant> &values, int limit ) { QgsFeature f; QgsAttributeList keys; keys.append( index ); select( keys, QgsRectangle(), false ); QSet<QString> set; values.clear(); while ( nextFeature( f ) ) { if ( !set.contains( f.attributeMap()[index].toString() ) ) { values.append( f.attributeMap()[index] ); set.insert( f.attributeMap()[index].toString() ); } if ( limit >= 0 && values.size() >= limit ) break; } }
void QgsAbstractFeatureIterator::setupOrderBy( const QList<QgsFeatureRequest::OrderByClause>& orderBys ) { // Let the provider try using an efficient order by strategy first if ( !orderBys.isEmpty() && !prepareOrderBy( orderBys ) ) { // No success from the provider // Prepare the expressions QList<QgsFeatureRequest::OrderByClause> preparedOrderBys( orderBys ); QList<QgsFeatureRequest::OrderByClause>::iterator orderByIt( preparedOrderBys.begin() ); QgsExpressionContext* expressionContext( mRequest.expressionContext() ); do { orderByIt->expression().prepare( expressionContext ); } while ( ++orderByIt != preparedOrderBys.end() ); // Fetch all features QgsIndexedFeature indexedFeature; indexedFeature.mIndexes.resize( preparedOrderBys.size() ); while ( nextFeature( indexedFeature.mFeature ) ) { expressionContext->setFeature( indexedFeature.mFeature ); int i = 0; Q_FOREACH ( const QgsFeatureRequest::OrderByClause& orderBy, preparedOrderBys ) { indexedFeature.mIndexes.replace( i++, orderBy.expression().evaluate( expressionContext ) ); } // We need all features, to ignore the limit for this pre-fetch // keep the fetched count at 0. mFetchedCount = 0; mCachedFeatures.append( indexedFeature ); }
void QgsVectorDataProvider::fillMinMaxCache() { if ( !mCacheMinMaxDirty ) return; const QgsFieldMap& flds = fields(); for ( QgsFieldMap::const_iterator it = flds.begin(); it != flds.end(); ++it ) { if ( it->type() == QVariant::Int ) { mCacheMinValues[it.key()] = QVariant( INT_MAX ); mCacheMaxValues[it.key()] = QVariant( INT_MIN ); } else if ( it->type() == QVariant::Double ) { mCacheMinValues[it.key()] = QVariant( DBL_MAX ); mCacheMaxValues[it.key()] = QVariant( -DBL_MAX ); } else { mCacheMinValues[it.key()] = QVariant(); mCacheMaxValues[it.key()] = QVariant(); } } QgsFeature f; QgsAttributeList keys = mCacheMinValues.keys(); select( keys, QgsRectangle(), false ); while ( nextFeature( f ) ) { QgsAttributeMap attrMap = f.attributeMap(); for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it ) { const QVariant& varValue = attrMap[*it]; if ( flds[*it].type() == QVariant::Int ) { int value = varValue.toInt(); if ( value < mCacheMinValues[*it].toInt() ) mCacheMinValues[*it] = value; if ( value > mCacheMaxValues[*it].toInt() ) mCacheMaxValues[*it] = value; } else if ( flds[*it].type() == QVariant::Double ) { double value = varValue.toDouble(); if ( value < mCacheMinValues[*it].toDouble() ) mCacheMinValues[*it] = value; if ( value > mCacheMaxValues[*it].toDouble() ) mCacheMaxValues[*it] = value; } else { QString value = varValue.toString(); if ( mCacheMinValues[*it].isNull() || value < mCacheMinValues[*it].toString() ) { mCacheMinValues[*it] = value; } if ( mCacheMaxValues[*it].isNull() || value > mCacheMaxValues[*it].toString() ) { mCacheMaxValues[*it] = value; } } } } mCacheMinMaxDirty = false; }