20 #include "qgsversion.h" 22 #include <QCoreApplication> 28 #include "qgsconfig.h" 50 const QString
GEOPROJ4 = QStringLiteral(
"+proj=longlat +datum=WGS84 +no_defs" );
54 " DATUM[\"WGS_1984\", " 55 " SPHEROID[\"WGS 84\",6378137,298.257223563, " 56 " AUTHORITY[\"EPSG\",7030]], " 57 " TOWGS84[0,0,0,0,0,0,0], " 58 " AUTHORITY[\"EPSG\",6326]], " 59 " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",8901]], " 60 " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",9108]], " 61 " AXIS[\"Lat\",NORTH], " 62 " AXIS[\"Long\",EAST], " 63 " AUTHORITY[\"EPSG\",4326]]";
66 "1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000," 67 "1:10000,1:5000,1:2500,1:1000,1:500";
71 const QString
GEO_NONE = QStringLiteral(
"NONE" );
94 const double Qgis::UI_SCALE_FACTOR = 1;
100 string.remove( QLocale::system().groupSeparator() );
101 return QLocale::system().toDouble(
string, &ok );
107 string.remove( QLocale::system().groupSeparator() );
108 return QLocale::system().toInt(
string, &ok );
113 if ( size == 0 ||
long( size ) < 0 )
115 QgsDebugMsg( QString(
"Negative or zero size %1." ).arg( size ) );
118 void *p = malloc( size );
121 QgsDebugMsg( QString(
"Allocation of %1 bytes failed." ).arg( size ) );
128 if ( nmemb == 0 ||
long( nmemb ) < 0 || size == 0 ||
long( size ) < 0 )
130 QgsDebugMsg( QString(
"Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
136 memset( p, 0, nmemb * size );
149 if ( !lhs.isValid() )
150 return rhs.isValid();
151 else if ( lhs.isNull() )
152 return rhs.isValid() && !rhs.isNull();
153 else if ( !rhs.isValid() || rhs.isNull() )
156 switch ( lhs.type() )
159 return lhs.toInt() < rhs.toInt();
161 return lhs.toUInt() < rhs.toUInt();
162 case QVariant::LongLong:
163 return lhs.toLongLong() < rhs.toLongLong();
164 case QVariant::ULongLong:
165 return lhs.toULongLong() < rhs.toULongLong();
166 case QVariant::Double:
167 return lhs.toDouble() < rhs.toDouble();
169 return lhs.toChar() < rhs.toChar();
171 return lhs.toDate() < rhs.toDate();
173 return lhs.toTime() < rhs.toTime();
174 case QVariant::DateTime:
175 return lhs.toDateTime() < rhs.toDateTime();
177 return lhs.toBool() < rhs.toBool();
181 const QList<QVariant> &lhsl = lhs.toList();
182 const QList<QVariant> &rhsl = rhs.toList();
184 int i, n = std::min( lhsl.size(), rhsl.size() );
185 for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() && lhsl[i].isNull() == rhsl[i].isNull() && lhsl[i] == rhsl[i]; i++ )
189 return lhsl.size() < rhsl.size();
194 case QVariant::StringList:
196 const QStringList &lhsl = lhs.toStringList();
197 const QStringList &rhsl = rhs.toStringList();
199 int i, n = std::min( lhsl.size(), rhsl.size() );
200 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
204 return lhsl.size() < rhsl.size();
206 return lhsl[i] < rhsl[i];
210 return QString::localeAwareCompare( lhs.toString(), rhs.toString() ) < 0;
221 if ( path.startsWith( QLatin1String(
"/vsizip/" ), Qt::CaseInsensitive ) ||
222 path.endsWith( QLatin1String(
".zip" ), Qt::CaseInsensitive ) )
223 return QStringLiteral(
"/vsizip/" );
224 else if ( path.startsWith( QLatin1String(
"/vsitar/" ), Qt::CaseInsensitive ) ||
225 path.endsWith( QLatin1String(
".tar" ), Qt::CaseInsensitive ) ||
226 path.endsWith( QLatin1String(
".tar.gz" ), Qt::CaseInsensitive ) ||
227 path.endsWith( QLatin1String(
".tgz" ), Qt::CaseInsensitive ) )
228 return QStringLiteral(
"/vsitar/" );
229 else if ( path.startsWith( QLatin1String(
"/vsigzip/" ), Qt::CaseInsensitive ) ||
230 path.endsWith( QLatin1String(
".gz" ), Qt::CaseInsensitive ) )
231 return QStringLiteral(
"/vsigzip/" );
233 return QLatin1String(
"" );
236 uint
qHash(
const QVariant &variant )
238 if ( !variant.isValid() || variant.isNull() )
239 return std::numeric_limits<uint>::max();
241 switch ( variant.type() )
244 return qHash( variant.toInt() );
246 return qHash( variant.toUInt() );
248 return qHash( variant.toBool() );
249 case QVariant::Double:
250 return qHash( variant.toDouble() );
251 case QVariant::LongLong:
252 return qHash( variant.toLongLong() );
253 case QVariant::ULongLong:
254 return qHash( variant.toULongLong() );
255 case QVariant::String:
256 return qHash( variant.toString() );
258 return qHash( variant.toChar() );
261 #if QT_VERSION >= 0x050600 262 return qHash( variant.toList() );
265 QVariantList list = variant.toList();
266 if ( list.isEmpty() )
269 return qHash( list.at( 0 ) );
272 case QVariant::StringList:
273 #if QT_VERSION >= 0x050600 274 return qHash( variant.toStringList() );
277 QStringList list = variant.toStringList();
278 if ( list.isEmpty() )
281 return qHash( list.at( 0 ) );
284 case QVariant::ByteArray:
285 return qHash( variant.toByteArray() );
287 return qHash( variant.toDate() );
289 return qHash( variant.toTime() );
290 case QVariant::DateTime:
291 return qHash( variant.toDateTime() );
293 case QVariant::Locale:
294 case QVariant::RegExp:
295 return qHash( variant.toString() );
300 return std::numeric_limits<uint>::max();
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.
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.
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.