@@ -127,7 +127,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
127
127
setCoordinateSystem ();
128
128
129
129
QSettings settings;
130
- if ( settings.value ( " /qgis/use_symbology_ng" , false ).toBool () && geometryType () != QGis::NoGeometry )
130
+ if ( settings.value ( " /qgis/use_symbology_ng" , false ).toBool () && hasGeometryType () )
131
131
{
132
132
// using symbology-ng!
133
133
setUsingRendererV2 ( true );
@@ -142,7 +142,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
142
142
}
143
143
144
144
// if the default style failed to load or was disabled use some very basic defaults
145
- if ( !defaultLoadedFlag && geometryType () != QGis::NoGeometry )
145
+ if ( !defaultLoadedFlag && hasGeometryType () )
146
146
{
147
147
// add single symbol renderer
148
148
if ( mUsingRendererV2 )
@@ -240,7 +240,7 @@ QString QgsVectorLayer::providerType() const
240
240
*/
241
241
void QgsVectorLayer::setDisplayField ( QString fldName )
242
242
{
243
- if ( geometryType () == QGis::NoGeometry )
243
+ if ( ! hasGeometryType () )
244
244
return ;
245
245
246
246
// If fldName is provided, use it as the display field, otherwise
@@ -320,7 +320,7 @@ void QgsVectorLayer::setDisplayField( QString fldName )
320
320
// This method will probably be removed again in the near future!
321
321
void QgsVectorLayer::drawLabels ( QgsRenderContext& rendererContext )
322
322
{
323
- if ( geometryType () == QGis::NoGeometry )
323
+ if ( ! hasGeometryType () )
324
324
return ;
325
325
326
326
QgsDebugMsg ( " Starting draw of labels" );
@@ -711,7 +711,7 @@ unsigned char *QgsVectorLayer::drawPolygon( unsigned char *feature, QgsRenderCon
711
711
712
712
void QgsVectorLayer::drawRendererV2 ( QgsRenderContext& rendererContext, bool labeling )
713
713
{
714
- if ( geometryType () == QGis::NoGeometry )
714
+ if ( ! hasGeometryType () )
715
715
return ;
716
716
717
717
QSettings settings;
@@ -776,7 +776,7 @@ void QgsVectorLayer::drawRendererV2( QgsRenderContext& rendererContext, bool lab
776
776
777
777
void QgsVectorLayer::drawRendererV2Levels ( QgsRenderContext& rendererContext, bool labeling )
778
778
{
779
- if ( geometryType () == QGis::NoGeometry )
779
+ if ( ! hasGeometryType () )
780
780
return ;
781
781
782
782
QHash< QgsSymbolV2*, QList<QgsFeature> > features; // key = symbol, value = array of features
@@ -916,7 +916,7 @@ void QgsVectorLayer::reload()
916
916
917
917
bool QgsVectorLayer::draw ( QgsRenderContext& rendererContext )
918
918
{
919
- if ( geometryType () == QGis::NoGeometry )
919
+ if ( ! hasGeometryType () )
920
920
return true ;
921
921
922
922
// set update threshold before each draw to make sure the current setting is picked up
@@ -1293,7 +1293,7 @@ const QgsRenderer* QgsVectorLayer::renderer() const
1293
1293
1294
1294
void QgsVectorLayer::setRenderer ( QgsRenderer * r )
1295
1295
{
1296
- if ( geometryType () == QGis::NoGeometry )
1296
+ if ( ! hasGeometryType () )
1297
1297
return ;
1298
1298
1299
1299
if ( r != mRenderer )
@@ -1354,6 +1354,12 @@ QGis::GeometryType QgsVectorLayer::geometryType() const
1354
1354
return QGis::UnknownGeometry;
1355
1355
}
1356
1356
1357
+ bool QgsVectorLayer::hasGeometryType () const
1358
+ {
1359
+ QGis::GeometryType t = geometryType ();
1360
+ return ( t != QGis::NoGeometry && t != QGis::UnknownGeometry );
1361
+ }
1362
+
1357
1363
QGis::WkbType QgsVectorLayer::wkbType () const
1358
1364
{
1359
1365
return ( QGis::WkbType )( mWkbType );
@@ -1422,7 +1428,7 @@ long QgsVectorLayer::updateFeatureCount() const
1422
1428
1423
1429
void QgsVectorLayer::updateExtents ()
1424
1430
{
1425
- if ( geometryType () == QGis::NoGeometry )
1431
+ if ( ! hasGeometryType () )
1426
1432
return ;
1427
1433
1428
1434
mLayerExtent .setMinimal ();
@@ -1921,7 +1927,7 @@ bool QgsVectorLayer::addFeature( QgsFeature& f, bool alsoUpdateExtent )
1921
1927
1922
1928
bool QgsVectorLayer::insertVertex ( double x, double y, int atFeatureId, int beforeVertex )
1923
1929
{
1924
- if ( geometryType () == QGis::NoGeometry )
1930
+ if ( ! hasGeometryType () )
1925
1931
return false ;
1926
1932
1927
1933
if ( !mEditable )
@@ -1960,7 +1966,7 @@ bool QgsVectorLayer::insertVertex( double x, double y, int atFeatureId, int befo
1960
1966
1961
1967
bool QgsVectorLayer::moveVertex ( double x, double y, int atFeatureId, int atVertex )
1962
1968
{
1963
- if ( geometryType () == QGis::NoGeometry )
1969
+ if ( ! hasGeometryType () )
1964
1970
return false ;
1965
1971
1966
1972
if ( !mEditable )
@@ -2000,7 +2006,7 @@ bool QgsVectorLayer::moveVertex( double x, double y, int atFeatureId, int atVert
2000
2006
2001
2007
bool QgsVectorLayer::deleteVertex ( int atFeatureId, int atVertex )
2002
2008
{
2003
- if ( geometryType () == QGis::NoGeometry )
2009
+ if ( ! hasGeometryType () )
2004
2010
return false ;
2005
2011
2006
2012
if ( !mEditable )
@@ -2074,7 +2080,7 @@ bool QgsVectorLayer::deleteSelectedFeatures()
2074
2080
2075
2081
int QgsVectorLayer::addRing ( const QList<QgsPoint>& ring )
2076
2082
{
2077
- if ( geometryType () == QGis::NoGeometry )
2083
+ if ( ! hasGeometryType () )
2078
2084
return 5 ;
2079
2085
2080
2086
int addRingReturnCode = 5 ; // default: return code for 'ring not inserted'
@@ -2111,7 +2117,7 @@ int QgsVectorLayer::addRing( const QList<QgsPoint>& ring )
2111
2117
2112
2118
int QgsVectorLayer::addIsland ( const QList<QgsPoint>& ring )
2113
2119
{
2114
- if ( geometryType () == QGis::NoGeometry )
2120
+ if ( ! hasGeometryType () )
2115
2121
return 6 ;
2116
2122
2117
2123
// number of selected features must be 1
@@ -2188,7 +2194,7 @@ int QgsVectorLayer::addIsland( const QList<QgsPoint>& ring )
2188
2194
2189
2195
int QgsVectorLayer::translateFeature ( int featureId, double dx, double dy )
2190
2196
{
2191
- if ( geometryType () == QGis::NoGeometry )
2197
+ if ( ! hasGeometryType () )
2192
2198
return 1 ;
2193
2199
2194
2200
// look if geometry of selected feature already contains geometry changes
@@ -2246,7 +2252,7 @@ int QgsVectorLayer::translateFeature( int featureId, double dx, double dy )
2246
2252
2247
2253
int QgsVectorLayer::splitFeatures ( const QList<QgsPoint>& splitLine, bool topologicalEditing )
2248
2254
{
2249
- if ( geometryType () == QGis::NoGeometry )
2255
+ if ( ! hasGeometryType () )
2250
2256
return 4 ;
2251
2257
2252
2258
QgsFeatureList newFeatures; // store all the newly created features
@@ -2358,7 +2364,7 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
2358
2364
2359
2365
int QgsVectorLayer::removePolygonIntersections ( QgsGeometry* geom )
2360
2366
{
2361
- if ( geometryType () == QGis::NoGeometry )
2367
+ if ( ! hasGeometryType () )
2362
2368
return 1 ;
2363
2369
2364
2370
int returnValue = 0 ;
@@ -2393,7 +2399,7 @@ int QgsVectorLayer::removePolygonIntersections( QgsGeometry* geom )
2393
2399
2394
2400
int QgsVectorLayer::addTopologicalPoints ( QgsGeometry* geom )
2395
2401
{
2396
- if ( geometryType () == QGis::NoGeometry )
2402
+ if ( ! hasGeometryType () )
2397
2403
return 1 ;
2398
2404
2399
2405
if ( !geom )
@@ -2500,7 +2506,7 @@ int QgsVectorLayer::addTopologicalPoints( QgsGeometry* geom )
2500
2506
2501
2507
int QgsVectorLayer::addTopologicalPoints ( const QgsPoint& p )
2502
2508
{
2503
- if ( geometryType () == QGis::NoGeometry )
2509
+ if ( ! hasGeometryType () )
2504
2510
return 1 ;
2505
2511
2506
2512
QMultiMap<double , QgsSnappingResult> snapResults; // results from the snapper object
@@ -2825,7 +2831,7 @@ bool QgsVectorLayer::writeXml( QDomNode & layer_node,
2825
2831
2826
2832
bool QgsVectorLayer::readSymbology ( const QDomNode& node, QString& errorMessage )
2827
2833
{
2828
- if ( geometryType () != QGis::NoGeometry )
2834
+ if ( hasGeometryType () )
2829
2835
{
2830
2836
// try renderer v2 first
2831
2837
QDomElement rendererElement = node.firstChildElement ( RENDERER_TAG_NAME );
@@ -3020,7 +3026,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
3020
3026
{
3021
3027
QDomElement mapLayerNode = node.toElement ();
3022
3028
3023
- if ( geometryType () != QGis::NoGeometry )
3029
+ if ( hasGeometryType () )
3024
3030
{
3025
3031
if ( mUsingRendererV2 )
3026
3032
{
@@ -3198,7 +3204,7 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
3198
3204
3199
3205
bool QgsVectorLayer::changeGeometry ( int fid, QgsGeometry* geom )
3200
3206
{
3201
- if ( !mEditable || !mDataProvider || geometryType () == QGis::NoGeometry )
3207
+ if ( !mEditable || !mDataProvider || ! hasGeometryType () )
3202
3208
{
3203
3209
return false ;
3204
3210
}
@@ -3831,7 +3837,7 @@ bool QgsVectorLayer::addFeatures( QgsFeatureList features, bool makeSelected )
3831
3837
3832
3838
bool QgsVectorLayer::copySymbologySettings ( const QgsMapLayer& other )
3833
3839
{
3834
- if ( geometryType () == QGis::NoGeometry )
3840
+ if ( ! hasGeometryType () )
3835
3841
return false ;
3836
3842
3837
3843
const QgsVectorLayer* vl = qobject_cast<const QgsVectorLayer *>( &other );
@@ -3899,7 +3905,7 @@ bool QgsVectorLayer::hasCompatibleSymbology( const QgsMapLayer& other ) const
3899
3905
3900
3906
bool QgsVectorLayer::snapPoint ( QgsPoint& point, double tolerance )
3901
3907
{
3902
- if ( geometryType () == QGis::NoGeometry )
3908
+ if ( ! hasGeometryType () )
3903
3909
return false ;
3904
3910
3905
3911
QMultiMap<double , QgsSnappingResult> snapResults;
@@ -3926,7 +3932,7 @@ int QgsVectorLayer::snapWithContext( const QgsPoint& startPoint, double snapping
3926
3932
QMultiMap<double , QgsSnappingResult>& snappingResults,
3927
3933
QgsSnapper::SnappingType snap_to )
3928
3934
{
3929
- if ( geometryType () == QGis::NoGeometry )
3935
+ if ( ! hasGeometryType () )
3930
3936
return 1 ;
3931
3937
3932
3938
if ( snappingTolerance <= 0 || !mDataProvider )
@@ -4033,7 +4039,7 @@ void QgsVectorLayer::snapToGeometry( const QgsPoint& startPoint, int featureId,
4033
4039
4034
4040
int QgsVectorLayer::insertSegmentVerticesForSnap ( const QList<QgsSnappingResult>& snapResults )
4035
4041
{
4036
- if ( geometryType () == QGis::NoGeometry )
4042
+ if ( ! hasGeometryType () )
4037
4043
return 1 ;
4038
4044
4039
4045
int returnval = 0 ;
@@ -4262,7 +4268,7 @@ void QgsVectorLayer::setCoordinateSystem()
4262
4268
// we only nee to do that if the srs is not alreay valid
4263
4269
if ( !mCRS ->isValid () )
4264
4270
{
4265
- if ( geometryType () != QGis::NoGeometry )
4271
+ if ( hasGeometryType () )
4266
4272
{
4267
4273
mCRS ->setValidationHint ( tr ( " Specify CRS for layer %1" ).arg ( name () ) );
4268
4274
mCRS ->validate ();
@@ -4456,7 +4462,7 @@ QgsFeatureRendererV2* QgsVectorLayer::rendererV2()
4456
4462
}
4457
4463
void QgsVectorLayer::setRendererV2 ( QgsFeatureRendererV2* r )
4458
4464
{
4459
- if ( geometryType () == QGis::NoGeometry )
4465
+ if ( ! hasGeometryType () )
4460
4466
return ;
4461
4467
4462
4468
delete mRendererV2 ;
@@ -4468,7 +4474,7 @@ bool QgsVectorLayer::isUsingRendererV2()
4468
4474
}
4469
4475
void QgsVectorLayer::setUsingRendererV2 ( bool usingRendererV2 )
4470
4476
{
4471
- if ( geometryType () == QGis::NoGeometry )
4477
+ if ( ! hasGeometryType () )
4472
4478
return ;
4473
4479
4474
4480
mUsingRendererV2 = usingRendererV2;
0 commit comments