@@ -181,9 +181,6 @@ QgsVectorLayer::~QgsVectorLayer()
181
181
{
182
182
QgsDebugMsg ( " entered." );
183
183
184
- if ( !mLayerIterator .isClosed () )
185
- mLayerIterator .close ();
186
-
187
184
emit layerDeleted ();
188
185
189
186
mValid = false ;
@@ -1667,15 +1664,6 @@ bool QgsVectorLayer::setSubsetString( QString subset )
1667
1664
return res;
1668
1665
}
1669
1666
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
1679
1667
1680
1668
QgsFeatureIterator QgsVectorLayer::getFeatures ( const QgsFeatureRequest& request )
1681
1669
{
@@ -1685,274 +1673,6 @@ QgsFeatureIterator QgsVectorLayer::getFeatures( const QgsFeatureRequest& request
1685
1673
return QgsFeatureIterator ( new QgsVectorLayerFeatureIterator ( this , request ) );
1686
1674
}
1687
1675
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
- }
1956
1676
1957
1677
bool QgsVectorLayer::addFeature ( QgsFeature& f, bool alsoUpdateExtent )
1958
1678
{
0 commit comments