20 #include "qgsversion.h"
22 #include <QCoreApplication>
28 #include "qgsconfig.h"
50 #if GDAL_VERSION_NUM >= 1800
53 const QString GEOPROJ4 =
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
58 " DATUM[\"WGS_1984\", "
59 " SPHEROID[\"WGS 84\",6378137,298.257223563, "
60 " AUTHORITY[\"EPSG\",7030]], "
61 " TOWGS84[0,0,0,0,0,0,0], "
62 " AUTHORITY[\"EPSG\",6326]], "
63 " PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",8901]], "
64 " UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",9108]], "
65 " AXIS[\"Lat\",NORTH], "
66 " AXIS[\"Long\",EAST], "
67 " AUTHORITY[\"EPSG\",4326]]";
70 "1:1000000,1:500000,1:250000,1:100000,1:50000,1:25000,"
71 "1:10000,1:5000,1:2500,1:1000,1:500";
91 const char* QGis::qgisUnitTypes[] =
93 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"meters" ),
94 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"feet" ),
95 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
96 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"<unknown>" ),
97 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
98 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
99 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"degrees" ),
100 QT_TRANSLATE_NOOP(
"QGis::UnitType",
"nautical miles" )
155 for (
unsigned int i = 0; i < (
sizeof( qgisUnitTypes ) /
sizeof( qgisUnitTypes[0] ) ); i++ )
157 if ( literal == qgisUnitTypes[ i ] )
167 return QString( qgisUnitTypes[ static_cast<int>( unit )] );
177 for (
unsigned int i = 0; i < (
sizeof( qgisUnitTypes ) /
sizeof( qgisUnitTypes[0] ) ); i++ )
179 if ( literal ==
QGis::tr( static_cast<UnitType>( i ) ) )
189 #define DEGREE_TO_METER 111319.49079327358
190 #define FEET_TO_METER 0.3048
191 #define NMILE_TO_METER 1852.0
255 if ( size == 0 ||
long( size ) < 0 )
260 void *p = malloc( size );
270 if ( nmemb == 0 ||
long( nmemb ) < 0 || size == 0 ||
long( size ) < 0 )
272 QgsDebugMsg(
QString(
"Negative or zero nmemb %1 or size %2." ).arg( nmemb ).arg( size ) );
278 memset( p, 0, nmemb * size );
290 switch ( lhs.
type() )
296 case QVariant::LongLong:
298 case QVariant::ULongLong:
300 case QVariant::Double:
308 case QVariant::DateTime:
322 if ( path.
startsWith(
"/vsizip/", Qt::CaseInsensitive ) ||
323 path.
endsWith(
".zip", Qt::CaseInsensitive ) )
325 else if ( path.
startsWith(
"/vsitar/", Qt::CaseInsensitive ) ||
326 path.
endsWith(
".tar", Qt::CaseInsensitive ) ||
327 path.
endsWith(
".tar.gz", Qt::CaseInsensitive ) ||
328 path.
endsWith(
".tgz", Qt::CaseInsensitive ) )
330 else if ( path.
startsWith(
"/vsigzip/", Qt::CaseInsensitive ) ||
331 path.
endsWith(
".gz", Qt::CaseInsensitive ) )
402 case Point:
return "Point";
403 case Line:
return "Line";
404 case Polygon:
return "Polygon";
407 default:
return "Invalid type";
430 default:
return "invalid wkbtype";
static const char * QGIS_VERSION
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 bool isMultiType(Type type)
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...
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 Type multiType(Type type)
UnitType
Map units that qgis supports.
QDateTime toDateTime() const
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 to old WKB type.
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
static const double DEFAULT_IDENTIFY_RADIUS
Old search radius in % of canvas width.
WkbType
Used for symbology operations.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
qulonglong toULongLong(bool *ok) const
static Type singleType(Type type)
double toDouble(const QString &s, bool *ok) const
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
const QString GEO_NONE
Constant that holds the string representation for "No ellips/No CRS".
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type to new WKB type.
static Type flatType(Type type)
uint toUInt(bool *ok) const
static bool hasM(Type type)
Tests whether a WKB type contains m values.
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
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
static WkbType singleType(WkbType type)
Map multi to single type.
const QString GEOWKT
Wkt string that represents a geographic coord sys.
static const double DEFAULT_SEARCH_RADIUS_MM
Identify search radius in mm.
static const char * QGIS_RELEASE_NAME
static const char * featureType(WkbType type)
description strings for feature types
static 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
static bool isSingleType(Type type)
static UnitType fromTr(const QString &literal, QGis::UnitType defaultType=UnknownUnit)
Provides type value from translated version.
QString qgsVsiPrefix(const QString &path)
QString translate(const char *context, const char *sourceText, const char *disambiguation, Encoding encoding)
static 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
double toDouble(bool *ok) const
static 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 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 const int QGIS_VERSION_INT
static double DEFAULT_HIGHLIGHT_MIN_WIDTH_MM
Default highlight line/outline minimum width in mm.