20 #include "qgsversion.h" 22 #include <QCoreApplication> 28 #include "qgsconfig.h" 51 const QString
GEOPROJ4 = QStringLiteral(
"+proj=longlat +datum=WGS84 +no_defs" );
55 " DATUM[\"WGS_1984\", " 56 " SPHEROID[\"WGS 84\",6378137,298.257223563, " 57 " AUTHORITY[\"EPSG\",\"7030\"]], " 58 " TOWGS84[0,0,0,0,0,0,0], " 59 " AUTHORITY[\"EPSG\",\"6326\"]], " 60 " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]], " 61 " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]], " 62 " AXIS[\"Lat\",NORTH], " 63 " AXIS[\"Long\",EAST], " 64 " AUTHORITY[\"EPSG\",\"4326\"]]";
67 "1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000," 68 "1:10000,1:5000,1:2500,1:1000,1:500";
72 const QString
GEO_NONE = QStringLiteral(
"NONE" );
95 const double Qgis::UI_SCALE_FACTOR = 1;
101 string.remove( QLocale().groupSeparator() );
102 return QLocale().toDouble(
string, &ok );
108 string.remove( QLocale().groupSeparator() );
109 return QLocale().toInt(
string, &ok );
115 string.remove( QLocale().groupSeparator() );
116 return QLocale().toLongLong(
string, &ok );
121 if ( size == 0 ||
long( size ) < 0 )
123 QgsDebugMsg( QStringLiteral(
"Negative or zero size %1." ).arg( size ) );
126 void *p = malloc( size );
129 QgsDebugMsg( QStringLiteral(
"Allocation of %1 bytes failed." ).arg( size ) );
136 if ( nmemb == 0 ||
long( nmemb ) < 0 || size == 0 ||
long( size ) < 0 )
138 QgsDebugMsg( QStringLiteral(
"Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
144 memset( p, 0, nmemb * size );
157 if ( !lhs.isValid() )
158 return rhs.isValid();
159 else if ( lhs.isNull() )
160 return rhs.isValid() && !rhs.isNull();
161 else if ( !rhs.isValid() || rhs.isNull() )
164 switch ( lhs.type() )
167 return lhs.toInt() < rhs.toInt();
169 return lhs.toUInt() < rhs.toUInt();
170 case QVariant::LongLong:
171 return lhs.toLongLong() < rhs.toLongLong();
172 case QVariant::ULongLong:
173 return lhs.toULongLong() < rhs.toULongLong();
174 case QVariant::Double:
175 return lhs.toDouble() < rhs.toDouble();
177 return lhs.toChar() < rhs.toChar();
179 return lhs.toDate() < rhs.toDate();
181 return lhs.toTime() < rhs.toTime();
182 case QVariant::DateTime:
183 return lhs.toDateTime() < rhs.toDateTime();
185 return lhs.toBool() < rhs.toBool();
189 const QList<QVariant> &lhsl = lhs.toList();
190 const QList<QVariant> &rhsl = rhs.toList();
192 int i, n = std::min( lhsl.size(), rhsl.size() );
193 for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() &&
qgsVariantEqual( lhsl[i], rhsl[i] ); i++ )
197 return lhsl.size() < rhsl.size();
202 case QVariant::StringList:
204 const QStringList &lhsl = lhs.toStringList();
205 const QStringList &rhsl = rhs.toStringList();
207 int i, n = std::min( lhsl.size(), rhsl.size() );
208 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
212 return lhsl.size() < rhsl.size();
214 return lhsl[i] < rhsl[i];
218 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
229 if ( path.startsWith( QLatin1String(
"/vsizip/" ), Qt::CaseInsensitive ) )
230 return QStringLiteral(
"/vsizip/" );
231 else if ( path.endsWith( QLatin1String(
".shp.zip" ), Qt::CaseInsensitive ) )
234 if ( GDALIdentifyDriver( path.toUtf8().constData(), nullptr ) )
236 return QStringLiteral(
"/vsizip/" );
238 else if ( path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) )
239 return QStringLiteral(
"/vsizip/" );
240 else if ( path.startsWith( QLatin1String(
"/vsitar/" ), Qt::CaseInsensitive ) ||
241 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) ||
242 path.endsWith( QLatin1String(
".tar.gz" ), Qt::CaseInsensitive ) ||
243 path.endsWith( QLatin1String(
".tgz" ), Qt::CaseInsensitive ) )
244 return QStringLiteral(
"/vsitar/" );
245 else if ( path.startsWith( QLatin1String(
"/vsigzip/" ), Qt::CaseInsensitive ) ||
246 path.endsWith( QLatin1String(
".gz" ), Qt::CaseInsensitive ) )
247 return QStringLiteral(
"/vsigzip/" );
252 uint
qHash(
const QVariant &variant )
254 if ( !variant.isValid() || variant.isNull() )
255 return std::numeric_limits<uint>::max();
257 switch ( variant.type() )
260 return qHash( variant.toInt() );
262 return qHash( variant.toUInt() );
264 return qHash( variant.toBool() );
265 case QVariant::Double:
266 return qHash( variant.toDouble() );
267 case QVariant::LongLong:
268 return qHash( variant.toLongLong() );
269 case QVariant::ULongLong:
270 return qHash( variant.toULongLong() );
271 case QVariant::String:
272 return qHash( variant.toString() );
274 return qHash( variant.toChar() );
276 return qHash( variant.toList() );
277 case QVariant::StringList:
278 return qHash( variant.toStringList() );
279 case QVariant::ByteArray:
280 return qHash( variant.toByteArray() );
282 return qHash( variant.toDate() );
284 return qHash( variant.toTime() );
285 case QVariant::DateTime:
286 return qHash( variant.toDateTime() );
288 case QVariant::Locale:
289 case QVariant::RegExp:
290 return qHash( variant.toString() );
295 return std::numeric_limits<uint>::max();
300 return ( lhs.isNull() == rhs.isNull() && lhs == rhs ) || ( lhs.isNull() && rhs.isNull() && lhs.isValid() && rhs.isValid() );
static const QString QGIS_VERSION
Version string.
static const char * QGIS_DEV_VERSION
The development version.
void * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory.
static const double UI_SCALE_FACTOR
UI scaling factor.
double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
void * qgsCalloc(size_t nmemb, size_t size)
Allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the alloc...
UnitType
Type of unit of tolerance value from settings.
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
static const int QGIS_VERSION_INT
Version number used for comparing versions using the "Check QGIS Version" function.
int qgsPermissiveToInt(QString string, bool &ok)
Converts a string to an integer in a permissive way, e.g., allowing for incorrect numbers of digits b...
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
const QString GEO_NONE
Constant that holds the string representation for "No ellips/No CRS".
static const double DEFAULT_Z_COORDINATE
Default Z coordinate value for 2.5d geometry This value have to be assigned to the Z coordinate for t...
static const double DEFAULT_SNAP_TOLERANCE
Default snapping distance tolerance.
Pixels unit of tolerance.
const QString GEOPROJ4
PROJ4 string that represents a geographic coord sys.
qlonglong qgsPermissiveToLongLong(QString string, bool &ok)
Converts a string to an qlonglong in a permissive way, e.g., allowing for incorrect numbers of digits...
static const double DEFAULT_SEARCH_RADIUS_MM
Identify search radius in mm.
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
static const QgsTolerance::UnitType DEFAULT_SNAP_UNITS
Default snapping distance units.
const QString GEOWKT
Wkt string that represents a geographic coord sys.
uint qHash(const QVariant &variant)
Hash for QVariant.
static const float DEFAULT_MAPTOPIXEL_THRESHOLD
Default threshold between map coordinates and device coordinates for map2pixel simplification.
static const QString QGIS_RELEASE_NAME
Release name.
const QString PROJECT_SCALES
QString qgsVsiPrefix(const QString &path)
static const double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/stroke minimum width in mm.
bool qgsVariantEqual(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether they are equal, two NULL values are always treated a...
static const double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
void qgsFree(void *ptr)
Frees the memory space pointed to by ptr.
static const double SCALE_PRECISION
Fudge factor used to compare two scales.