Skip to content

Commit 5d42734

Browse files
committedMar 16, 2013
Removed old vector layer API (select(), nextFeature(), featureAtId())
1 parent 6361d19 commit 5d42734

File tree

3 files changed

+0
-356
lines changed

3 files changed

+0
-356
lines changed
 

‎python/core/qgsvectorlayer.sip

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,6 @@ class QgsVectorLayer : QgsMapLayer
8989

9090
public:
9191

92-
QgsVectorLayer* __iter__();
93-
%MethodCode
94-
sipRes = sipCpp;
95-
%End
96-
97-
SIP_PYOBJECT __next__();
98-
%MethodCode
99-
QgsFeature* f = new QgsFeature;
100-
if (sipCpp->nextFeature(*f))
101-
sipRes = sipConvertFromInstance(f, sipClass_QgsFeature, Py_None);
102-
else
103-
{
104-
delete f;
105-
PyErr_SetString(PyExc_StopIteration,"");
106-
}
107-
%End
108-
10992
enum EditorLayout
11093
{
11194
GeneratedLayout,
@@ -382,34 +365,11 @@ class QgsVectorLayer : QgsMapLayer
382365
*/
383366
virtual QString subsetString();
384367

385-
/**
386-
* Select features with or without attributes in a given window.
387-
* @param fetchAttributes indizes of attributes to fetch
388-
* @param rect window (QgsRectangle() for all)
389-
* @param fetchGeometry fetch features with geometry
390-
* @param useIntersect fetch only features that actually intersect the window (not just the bounding box)
391-
*/
392-
void select( QList<int> fetchAttributes,
393-
QgsRectangle rect = QgsRectangle(),
394-
bool fetchGeometry = true,
395-
bool useIntersect = false ) /Deprecated/;
396-
397368
/**
398369
* Query the provider for features specified in request.
399370
*/
400371
QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
401372

402-
/**
403-
* fetch a feature (after select)
404-
* @param feature buffer to read the feature into
405-
* @return true, if a feature was fetched, false, if there are no more features
406-
*/
407-
bool nextFeature( QgsFeature& feature ) /Deprecated/;
408-
409-
/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
410-
@return true in case of success*/
411-
bool featureAtId( QgsFeatureId featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true ) /Deprecated/;
412-
413373
/** Adds a feature
414374
@param f feature to add
415375
@param alsoUpdateExtent If True, will also go to the effort of e.g. updating the extents.

‎src/core/qgsvectorlayer.cpp

Lines changed: 0 additions & 280 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ QgsVectorLayer::~QgsVectorLayer()
181181
{
182182
QgsDebugMsg( "entered." );
183183

184-
if ( !mLayerIterator.isClosed() )
185-
mLayerIterator.close();
186-
187184
emit layerDeleted();
188185

189186
mValid = false;
@@ -1667,15 +1664,6 @@ bool QgsVectorLayer::setSubsetString( QString subset )
16671664
return res;
16681665
}
16691666

1670-
#if 0
1671-
void QgsVectorLayer::addJoinedAttributes( QgsFeature& f, bool all )
1672-
{
1673-
if ( all || ( mFetchAttributes.size() > 0 && mJoinBuffer->containsFetchJoins() ) )
1674-
{
1675-
mJoinBuffer->updateFeatureAttributes( f, f.attributes().count(), all );
1676-
}
1677-
}
1678-
#endif
16791667

16801668
QgsFeatureIterator QgsVectorLayer::getFeatures( const QgsFeatureRequest& request )
16811669
{
@@ -1685,274 +1673,6 @@ QgsFeatureIterator QgsVectorLayer::getFeatures( const QgsFeatureRequest& request
16851673
return QgsFeatureIterator( new QgsVectorLayerFeatureIterator( this, request ) );
16861674
}
16871675

1688-
void QgsVectorLayer::select( QgsAttributeList attributes, QgsRectangle rect, bool fetchGeometries, bool useIntersect )
1689-
{
1690-
QgsFeatureRequest request;
1691-
if ( !rect.isEmpty() )
1692-
request.setFilterRect( rect );
1693-
if ( !fetchGeometries )
1694-
request.setFlags( QgsFeatureRequest::NoGeometry );
1695-
if ( useIntersect )
1696-
request.setFlags( request.flags() | QgsFeatureRequest::ExactIntersect );
1697-
if ( attributes != pendingAllAttributesList() )
1698-
request.setSubsetOfAttributes( attributes );
1699-
1700-
if ( !mLayerIterator.isClosed() )
1701-
mLayerIterator.close();
1702-
1703-
mLayerIterator = getFeatures( request );
1704-
}
1705-
1706-
bool QgsVectorLayer::nextFeature( QgsFeature &f )
1707-
{
1708-
return mLayerIterator.nextFeature( f );
1709-
1710-
#if 0
1711-
if ( !mFetching )
1712-
return false;
1713-
1714-
if ( mEditBuffer )
1715-
{
1716-
if ( !mFetchRect.isEmpty() )
1717-
{
1718-
// check if changed geometries are in rectangle
1719-
for ( ; mFetchChangedGeomIt != mEditBuffer->mChangedGeometries.end(); mFetchChangedGeomIt++ )
1720-
{
1721-
QgsFeatureId fid = mFetchChangedGeomIt.key();
1722-
1723-
if ( mFetchConsidered.contains( fid ) )
1724-
// skip deleted features
1725-
continue;
1726-
1727-
mFetchConsidered << fid;
1728-
1729-
if ( !mFetchChangedGeomIt->intersects( mFetchRect ) )
1730-
// skip changed geometries not in rectangle and don't check again
1731-
continue;
1732-
1733-
f.setFeatureId( fid );
1734-
f.setValid( true );
1735-
1736-
if ( mFetchGeometry )
1737-
f.setGeometry( mFetchChangedGeomIt.value() );
1738-
1739-
if ( mFetchAttributes.size() > 0 )
1740-
{
1741-
if ( fid < 0 )
1742-
{
1743-
// fid<0 => in mAddedFeatures
1744-
bool found = false;
1745-
1746-
for ( QgsFeatureList::iterator it = mEditBuffer->mAddedFeatures.begin(); it != mEditBuffer->mAddedFeatures.end(); it++ )
1747-
{
1748-
if ( fid == it->id() )
1749-
{
1750-
found = true;
1751-
f.setAttributes( it->attributes() );
1752-
// no need to update (always up-to-date) updateFeatureAttributes( f );
1753-
break;
1754-
}
1755-
}
1756-
1757-
if ( !found )
1758-
{
1759-
QgsDebugMsg( QString( "No attributes for the added feature %1 found" ).arg( f.id() ) );
1760-
}
1761-
}
1762-
else
1763-
{
1764-
// retrieve attributes from provider
1765-
QgsFeature tmp;
1766-
//mDataProvider->featureAtId( fid, tmp, false, mFetchProvAttributes );
1767-
QgsFeatureRequest request;
1768-
request.setFilterFid( fid ).setSubsetOfAttributes( mFetchProvAttributes );
1769-
QgsFeatureIterator fi = mDataProvider->getFeatures( request );
1770-
if ( fi.nextFeature( tmp ) )
1771-
{
1772-
if ( mEditBuffer )
1773-
mEditBuffer->updateChangedAttributes( tmp );
1774-
f.setAttributes( tmp.attributes() );
1775-
}
1776-
}
1777-
}
1778-
1779-
addJoinedAttributes( f );
1780-
1781-
// return complete feature
1782-
mFetchChangedGeomIt++;
1783-
return true;
1784-
}
1785-
1786-
// no more changed geometries
1787-
}
1788-
1789-
for ( ; mFetchAddedFeaturesIt != mEditBuffer->mAddedFeatures.end(); mFetchAddedFeaturesIt++ )
1790-
{
1791-
QgsFeatureId fid = mFetchAddedFeaturesIt->id();
1792-
1793-
if ( mFetchConsidered.contains( fid ) )
1794-
// must have changed geometry outside rectangle
1795-
continue;
1796-
1797-
if ( !mFetchRect.isEmpty() &&
1798-
mFetchAddedFeaturesIt->geometry() &&
1799-
!mFetchAddedFeaturesIt->geometry()->intersects( mFetchRect ) )
1800-
// skip added features not in rectangle
1801-
continue;
1802-
1803-
f.setFeatureId( fid );
1804-
f.setValid( true );
1805-
1806-
if ( mFetchGeometry )
1807-
f.setGeometry( *mFetchAddedFeaturesIt->geometry() );
1808-
1809-
if ( mFetchAttributes.size() > 0 )
1810-
{
1811-
f.setAttributes( mFetchAddedFeaturesIt->attributes() );
1812-
// no need to do this (always up-to-date) updateFeatureAttributes( f );
1813-
}
1814-
1815-
addJoinedAttributes( f );
1816-
1817-
mFetchAddedFeaturesIt++;
1818-
return true;
1819-
}
1820-
1821-
// no more added features
1822-
}
1823-
1824-
while ( mProviderIterator.nextFeature( f ) )
1825-
{
1826-
if ( mFetchConsidered.contains( f.id() ) )
1827-
{
1828-
continue;
1829-
}
1830-
if ( mFetchAttributes.size() > 0 )
1831-
{
1832-
if ( mEditBuffer )
1833-
mEditBuffer->updateChangedAttributes( f ); //check changed attributes
1834-
addJoinedAttributes( f ); // check joined attributes
1835-
}
1836-
if ( mEditBuffer && mFetchGeometry )
1837-
{
1838-
mEditBuffer->updateFeatureGeometry( f );
1839-
}
1840-
1841-
return true;
1842-
}
1843-
1844-
mFetching = false;
1845-
return false;
1846-
#endif
1847-
}
1848-
1849-
bool QgsVectorLayer::featureAtId( QgsFeatureId featureId, QgsFeature& f, bool fetchGeometries, bool fetchAttributes )
1850-
{
1851-
QgsFeatureRequest request;
1852-
request.setFilterFid( featureId );
1853-
if ( !fetchGeometries )
1854-
request.setFlags( QgsFeatureRequest::NoGeometry );
1855-
if ( !fetchAttributes )
1856-
request.setSubsetOfAttributes( QgsAttributeList() );
1857-
1858-
QgsFeatureIterator fi = getFeatures( request );
1859-
return fi.nextFeature( f );
1860-
1861-
#if 0
1862-
if ( !mDataProvider )
1863-
return false;
1864-
1865-
if ( mEditBuffer && mEditBuffer->mDeletedFeatureIds.contains( featureId ) )
1866-
return false;
1867-
1868-
if ( fetchGeometries && mEditBuffer->mChangedGeometries.contains( featureId ) )
1869-
{
1870-
f.setFeatureId( featureId );
1871-
f.setValid( true );
1872-
f.setGeometry( mEditBuffer->mChangedGeometries[featureId] );
1873-
1874-
if ( fetchAttributes )
1875-
{
1876-
if ( featureId < 0 && mEditBuffer )
1877-
{
1878-
// featureId<0 => in mAddedFeatures
1879-
bool found = false;
1880-
1881-
for ( QgsFeatureList::iterator it = mEditBuffer->mAddedFeatures.begin(); it != mEditBuffer->mAddedFeatures.end(); it++ )
1882-
{
1883-
if ( featureId != it->id() )
1884-
{
1885-
found = true;
1886-
f.setAttributes( it->attributes() );
1887-
break;
1888-
}
1889-
}
1890-
1891-
if ( !found )
1892-
{
1893-
QgsDebugMsg( QString( "No attributes for the added feature %1 found" ).arg( f.id() ) );
1894-
}
1895-
}
1896-
else
1897-
{
1898-
// retrieve attributes from provider
1899-
QgsFeature tmp;
1900-
//mDataProvider->featureAtId( featureId, tmp, false, mDataProvider->attributeIndexes() );
1901-
QgsFeatureRequest request;
1902-
request.setFilterFid( featureId ).setFlags( QgsFeatureRequest::NoGeometry );
1903-
QgsFeatureIterator fi = mDataProvider->getFeatures( request );
1904-
if ( fi.nextFeature( tmp ) )
1905-
{
1906-
f.setAttributes( tmp.attributes() );
1907-
if ( mEditBuffer )
1908-
mEditBuffer->updateChangedAttributes( f );
1909-
}
1910-
}
1911-
addJoinedAttributes( f, true );
1912-
}
1913-
return true;
1914-
}
1915-
1916-
//added features
1917-
if ( mEditBuffer )
1918-
{
1919-
for ( QgsFeatureList::iterator iter = mEditBuffer->mAddedFeatures.begin(); iter != mEditBuffer->mAddedFeatures.end(); ++iter )
1920-
{
1921-
if ( iter->id() == featureId )
1922-
{
1923-
f.setFeatureId( iter->id() );
1924-
f.setValid( true );
1925-
if ( fetchGeometries )
1926-
f.setGeometry( *iter->geometry() );
1927-
1928-
if ( fetchAttributes )
1929-
f.setAttributes( iter->attributes() );
1930-
1931-
return true;
1932-
}
1933-
}
1934-
}
1935-
1936-
// regular features
1937-
QgsFeatureRequest request;
1938-
request.setFilterFid( featureId );
1939-
if ( !fetchGeometries )
1940-
request.setFlags( QgsFeatureRequest::NoGeometry );
1941-
if ( !fetchAttributes )
1942-
request.setSubsetOfAttributes( QgsAttributeList() );
1943-
1944-
QgsFeatureIterator fi = mDataProvider->getFeatures( request );
1945-
if ( fi.nextFeature( f ) )
1946-
{
1947-
if ( mEditBuffer )
1948-
mEditBuffer->updateChangedAttributes( f );
1949-
addJoinedAttributes( f, true );
1950-
return true;
1951-
}
1952-
1953-
return false;
1954-
#endif
1955-
}
19561676

19571677
bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )
19581678
{

‎src/core/qgsvectorlayer.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -437,28 +437,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
437437
*/
438438
virtual QString subsetString();
439439

440-
/**
441-
* Select features with or without attributes in a given window.
442-
* @param fetchAttributes indizes of attributes to fetch
443-
* @param rect window (QgsRectangle() for all)
444-
* @param fetchGeometry fetch features with geometry
445-
* @param useIntersect fetch only features that actually intersect the window (not just the bounding box)
446-
*/
447-
Q_DECL_DEPRECATED void select( QgsAttributeList fetchAttributes,
448-
QgsRectangle rect = QgsRectangle(),
449-
bool fetchGeometry = true,
450-
bool useIntersect = false );
451-
/**
452-
* fetch a feature (after select)
453-
* @param feature buffer to read the feature into
454-
* @return true, if a feature was fetched, false, if there are no more features
455-
*/
456-
Q_DECL_DEPRECATED bool nextFeature( QgsFeature& feature );
457-
458-
/**Gets the feature at the given feature id. Considers the changed, added, deleted and permanent features
459-
@return true in case of success*/
460-
Q_DECL_DEPRECATED bool featureAtId( QgsFeatureId featureId, QgsFeature &f, bool fetchGeometries = true, bool fetchAttributes = true );
461-
462440
/**
463441
* Query the provider for features specified in request.
464442
*/
@@ -1088,20 +1066,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
10881066
//annotation form for this layer
10891067
QString mAnnotationForm;
10901068

1091-
QgsFeatureIterator mLayerIterator; // temporary: to support old API
1092-
1093-
#if 0
1094-
bool mFetching;
1095-
QgsRectangle mFetchRect;
1096-
QgsAttributeList mFetchAttributes;
1097-
QgsAttributeList mFetchProvAttributes;
1098-
bool mFetchGeometry;
1099-
1100-
QSet<QgsFeatureId> mFetchConsidered;
1101-
QgsGeometryMap::iterator mFetchChangedGeomIt;
1102-
QgsFeatureList::iterator mFetchAddedFeaturesIt;
1103-
#endif
1104-
11051069
//! cache for some vector layer data - currently only geometries for faster editing
11061070
QgsVectorLayerCache* mCache;
11071071

0 commit comments

Comments
 (0)
Please sign in to comment.