QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
providers
qgsproviderutils.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsproviderutils.cpp
3
----------------------------
4
begin : June 2021
5
copyright : (C) 2021 by Nyall Dawson
6
email : nyall dot dawson at gmail dot com
7
***************************************************************************/
8
/***************************************************************************
9
* *
10
* This program is free software; you can redistribute it and/or modify *
11
* it under the terms of the GNU General Public License as published by *
12
* the Free Software Foundation; either version 2 of the License, or *
13
* (at your option) any later version. *
14
* *
15
***************************************************************************/
16
17
#include "
qgsproviderutils.h
"
18
19
#include "
qgsprovidersublayerdetails.h
"
20
21
#include <QFileInfo>
22
#include <QString>
23
24
using namespace
Qt::StringLiterals;
25
26
bool
QgsProviderUtils::sublayerDetailsAreIncomplete
(
const
QList<QgsProviderSublayerDetails> &details,
SublayerCompletenessFlags
flags )
27
{
28
const
bool
ignoreUnknownGeometryTypes = flags &
SublayerCompletenessFlag::IgnoreUnknownGeometryType
;
29
const
bool
ignoreUnknownFeatureCount = flags &
SublayerCompletenessFlag::IgnoreUnknownFeatureCount
;
30
31
for
(
const
QgsProviderSublayerDetails
&sublayer : details )
32
{
33
switch
( sublayer.type() )
34
{
35
case
Qgis::LayerType::Vector
:
36
if
( sublayer.skippedContainerScan()
37
|| ( !ignoreUnknownGeometryTypes && sublayer.wkbType() ==
Qgis::WkbType::Unknown
)
38
|| ( !ignoreUnknownFeatureCount && ( sublayer.featureCount() ==
static_cast<
long
long
>
(
Qgis::FeatureCountState::Uncounted
) || sublayer.featureCount() ==
static_cast<
long
long
>
(
Qgis::FeatureCountState::UnknownCount
) ) ) )
39
return
true
;
40
break
;
41
42
case
Qgis::LayerType::VectorTile
:
43
case
Qgis::LayerType::Raster
:
44
if
( sublayer.skippedContainerScan() )
45
return
true
;
46
break
;
47
48
case
Qgis::LayerType::Plugin
:
49
case
Qgis::LayerType::Mesh
:
50
case
Qgis::LayerType::Annotation
:
51
case
Qgis::LayerType::PointCloud
:
52
case
Qgis::LayerType::Group
:
53
case
Qgis::LayerType::TiledScene
:
54
break
;
55
}
56
}
57
58
return
false
;
59
}
60
61
QString
QgsProviderUtils::suggestLayerNameFromFilePath
(
const
QString &path )
62
{
63
const
QFileInfo info( path );
64
// default to base name of file
65
QString name = info.completeBaseName();
66
67
// special handling for .adf files -- use directory as base name, not the unhelpful .adf file name
68
if
( info.suffix().compare(
"adf"
_L1, Qt::CaseInsensitive ) == 0 )
69
{
70
const
QString dirName = info.path();
71
name = QFileInfo( dirName ).completeBaseName();
72
}
73
// special handling for ept.json files -- use directory as base name
74
else
if
( info.fileName().compare(
"ept.json"
_L1, Qt::CaseInsensitive ) == 0 )
75
{
76
const
QString dirName = info.path();
77
name = QFileInfo( dirName ).completeBaseName();
78
}
79
80
return
name;
81
}
Qgis::LayerType::Group
@ Group
Composite group layer. Added in QGIS 3.24.
Definition
qgis.h:214
Qgis::LayerType::Plugin
@ Plugin
Plugin based layer.
Definition
qgis.h:209
Qgis::LayerType::TiledScene
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
Definition
qgis.h:215
Qgis::LayerType::Annotation
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
Definition
qgis.h:212
Qgis::LayerType::Vector
@ Vector
Vector layer.
Definition
qgis.h:207
Qgis::LayerType::VectorTile
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
Definition
qgis.h:211
Qgis::LayerType::Mesh
@ Mesh
Mesh layer. Added in QGIS 3.2.
Definition
qgis.h:210
Qgis::LayerType::Raster
@ Raster
Raster layer.
Definition
qgis.h:208
Qgis::LayerType::PointCloud
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
Definition
qgis.h:213
Qgis::WkbType::Unknown
@ Unknown
Unknown.
Definition
qgis.h:315
QgsProviderSublayerDetails
Contains details about a sub layer available from a dataset.
Definition
qgsprovidersublayerdetails.h:48
QgsProviderUtils::sublayerDetailsAreIncomplete
static bool sublayerDetailsAreIncomplete(const QList< QgsProviderSublayerDetails > &details, QgsProviderUtils::SublayerCompletenessFlags flags=QgsProviderUtils::SublayerCompletenessFlags())
Returns true if the sublayer details are incomplete, and require a more in-depth scan.
Definition
qgsproviderutils.cpp:26
QgsProviderUtils::SublayerCompletenessFlags
QFlags< SublayerCompletenessFlag > SublayerCompletenessFlags
Definition
qgsproviderutils.h:45
QgsProviderUtils::suggestLayerNameFromFilePath
static QString suggestLayerNameFromFilePath(const QString &path)
Suggests a suitable layer name given only a file path.
Definition
qgsproviderutils.cpp:61
QgsProviderUtils::SublayerCompletenessFlag::IgnoreUnknownGeometryType
@ IgnoreUnknownGeometryType
Indicates that an unknown geometry type should not be considered as incomplete.
Definition
qgsproviderutils.h:43
QgsProviderUtils::SublayerCompletenessFlag::IgnoreUnknownFeatureCount
@ IgnoreUnknownFeatureCount
Indicates that an unknown feature count should not be considered as incomplete.
Definition
qgsproviderutils.h:42
Qgis::FeatureCountState::Uncounted
@ Uncounted
Feature count not yet computed.
Definition
qgis.h:607
Qgis::FeatureCountState::UnknownCount
@ UnknownCount
Provider returned an unknown feature count.
Definition
qgis.h:608
qgsprovidersublayerdetails.h
qgsproviderutils.h
Generated on
for QGIS API Documentation by
1.17.0