20 #include "qgsversion.h" 22 #include <QCoreApplication> 28 #include "qgsconfig.h" 51 #if GDAL_VERSION_NUM >= 1800 54 const QString GEOPROJ4 =
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
59 " DATUM[\"WGS_1984\", " 60 " SPHEROID[\"WGS 84\",6378137,298.257223563, " 61 " AUTHORITY[\"EPSG\",7030]], " 62 " TOWGS84[0,0,0,0,0,0,0], " 63 " AUTHORITY[\"EPSG\",6326]], " 64 " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",8901]], " 65 " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",9108]], " 66 " AXIS[\"Lat\",NORTH], " 67 " AXIS[\"Long\",EAST], " 68 " AUTHORITY[\"EPSG\",4326]]";
71 "1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000," 72 "1:10000,1:5000,1:2500,1:1000,1:500";
94 const char* QGis::qgisUnitTypes[] =
96 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"meters" ),
97 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"feet" ),
98 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
99 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"<unknown>" ),
100 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
101 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
102 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
103 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"nautical miles" )
195 return ok ? unit : defaultType;
212 return ok ? unit : defaultType;
236 if ( size == 0 ||
long( size ) < 0 )
241 void *p = malloc( size );
251 if ( nmemb == 0 ||
long( nmemb ) < 0 || size == 0 ||
long( size ) < 0 )
253 QgsDebugMsg(
QString(
"Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
259 memset( p, 0, nmemb * size );
279 switch ( lhs.
type() )
285 case QVariant::LongLong:
287 case QVariant::ULongLong:
289 case QVariant::Double:
297 case QVariant::DateTime:
307 int i, n = qMin( lhsl.
size(), rhsl.
size() );
308 for ( i = 0; i < n && lhsl[i].type() == rhsl[i].type() && lhsl[i].isNull() == rhsl[i].isNull() && lhsl[i] == rhsl[i]; i++ )
317 case QVariant::StringList:
322 int i, n = qMin( lhsl.
size(), rhsl.
size() );
323 for ( i = 0; i < n && lhsl[i] == rhsl[i]; i++ )
329 return lhsl[i] < rhsl[i];
344 if ( path.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) ||
345 path.
endsWith(
".zip", Qt::CaseInsensitive ) )
347 else if ( path.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) ||
348 path.
endsWith(
".tar", Qt::CaseInsensitive ) ||
349 path.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
350 path.
endsWith(
".tgz", Qt::CaseInsensitive ) )
352 else if ( path.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) ||
353 path.
endsWith(
".gz", Qt::CaseInsensitive ) )
452 return "Unknown geometry";
454 return "No geometry";
456 return "Invalid type";
470 return "WKBLineString";
474 return "WKBMultiPoint";
476 return "WKBMultiLineString";
478 return "WKBMultiPolygon";
480 return "WKBNoGeometry";
482 return "WKBPoint25D";
484 return "WKBLineString25D";
486 return "WKBPolygon25D";
488 return "WKBMultiPoint25D";
490 return "WKBMultiLineString25D";
492 return "WKBMultiPolygon25D";
494 return "invalid wkbtype";
static WkbType flatType(WkbType type)
Map 2d+ to 2d type.
qlonglong toLongLong(bool *ok) const
static double DEFAULT_HIGHLIGHT_BUFFER_MM
Default highlight buffer in mm.
static const QColor DEFAULT_HIGHLIGHT_COLOR
Default highlight color.
static int permissiveToInt(QString string, bool &ok)
Converts a string to an integer in a permissive way, eg allowing for incorrect numbers of digits betw...
static bool isSingleType(Type type)
Returns true if the WKB type is a single type.
void * qgsMalloc(size_t size)
Allocates size bytes and returns a pointer to the allocated memory.
int localeAwareCompare(const QString &other) const
static int wkbDimensions(WkbType type)
static bool hasM(Type type)
Tests whether a WKB type contains m values.
QList< QVariant > toList() const
QDateTime toDateTime() const
static Type multiType(Type type)
Returns the multi type for a WKB type.
static QGis::UnitType decodeDistanceUnit(const QString &string, bool *ok=0)
Decodes a distance unit from a string.
static double permissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, eg allowing for incorrect numbers of digits betwee...
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...
static QGis::WkbType fromNewWkbType(QgsWKBTypes::Type type)
Converts from new (post 2.10) WKB type (OGC) to old WKB type.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
WkbType
Used for symbology operations.
static Q_DECL_DEPRECATED const double DEFAULT_IDENTIFY_RADIUS
Old search radius in % of canvas width.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
qulonglong toULongLong(bool *ok) const
double toDouble(const QString &s, bool *ok) const
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 QString encodeUnit(QGis::UnitType unit)
Encodes a distance unit to a string.
static QString toString(QGis::UnitType unit)
Returns a translated string representing a distance unit.
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type (OGR) to new WKB type.
static QGis::UnitType stringToDistanceUnit(const QString &string, bool *ok=0)
Converts a translated string to a distance unit.
QString fromUtf8(const char *str, int size)
uint toUInt(bool *ok) const
int toInt(bool *ok) const
const QString GEOPROJ4
PROJ4 string that represents a geographic coord sys.
static const char * QGIS_DEV_VERSION
static bool isSingleType(WkbType type)
Return if type is a single type.
static const float DEFAULT_MAPTOPIXEL_THRESHOLD
Default threshold between map coordinates and device coordinates for map2pixel simplification.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
static QString QGIS_VERSION
static WkbType singleType(WkbType type)
Map multi to single type.
const QString GEOWKT
Wkt string that represents a geographic coord sys.
static double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified distance units.
static const double DEFAULT_SEARCH_RADIUS_MM
Identify search radius in mm.
static const char * featureType(WkbType type)
description strings for feature types
static Q_DECL_DEPRECATED QString tr(QGis::UnitType unit)
Provides translated version of the type value.
static WkbType multiType(WkbType type)
Map single to multitype type.
const QString PROJECT_SCALES
QStringList toStringList() const
static Q_DECL_DEPRECATED UnitType fromTr(const QString &literal, QGis::UnitType defaultType=UnknownUnit)
Provides type value from translated version.
QString qgsVsiPrefix(const QString &path)
static Q_DECL_DEPRECATED double fromUnitToUnitFactor(QGis::UnitType fromUnit, QGis::UnitType toUnit)
Returns the conversion factor between the specified units.
int toInt(const QString &s, bool *ok, int base) const
UnitType
Map units that qgis supports.
static Type flatType(Type type)
Returns the flat type for a WKB type.
double toDouble(bool *ok) const
static Q_DECL_DEPRECATED QString toLiteral(QGis::UnitType unit)
Provides the canonical name of the type value.
static bool isMultiType(WkbType type)
Return if type is a multi type.
static Q_DECL_DEPRECATED UnitType fromLiteral(const QString &literal, QGis::UnitType defaultType=UnknownUnit)
Converts from the canonical name to the type value.
void qgsFree(void *ptr)
Frees the memory space pointed to by ptr.
static QString QGIS_RELEASE_NAME
static double SCALE_PRECISION
Fudge factor used to compare two scales.
static const int QGIS_VERSION_INT
static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/outline minimum width in mm.
static Type singleType(Type type)
Returns the single type for a WKB type.