Skip to content
Permalink
Browse files

Added converters for QGis:UNitTypes

  • Loading branch information
homann committed Aug 23, 2012
1 parent 1873866 commit 90d3ab6f2db780d534485f85fd0ae355bdac6ab1
Showing with 38 additions and 0 deletions.
  1. +30 −0 src/core/qgis.cpp
  2. +8 −0 src/core/qgis.h
@@ -67,5 +67,35 @@ const char* QGis::qgisFeatureTypes[] =
"WKBMultiPolygon"
};


const double QGis::DEFAULT_IDENTIFY_RADIUS = 0.5;

// description strings for units
// Order must match enum indices
const char* QGis::qgisUnitTypes[] =
{
"meters",
"feet",
"degrees",
"<unknown>",
"degrees",
"degrees",
"degrees"
};

QGis::UnitType QGis::fromString( QString unitTxt, QGis::UnitType defaultType )
{
for ( int i = 0; i < sizeof( qgisUnitTypes ); i++ )
{
if ( unitTxt == qgisUnitTypes[ i ] )
{
return static_cast<UnitType>( i );
}
}
return defaultType;
}

QString QGis::toString( QGis::UnitType unit )
{
return QString( qgisUnitTypes[ static_cast<int>( unit ) ] );
}
@@ -95,6 +95,9 @@ class CORE_EXPORT QGis
DegreesMinutesSeconds = 2, // was 4
DegreesDecimalMinutes = 2, // was 5
};
// Converters for the above type
static QString toString( QGis::UnitType unit );
static UnitType fromString( QString unitTxt, QGis::UnitType defaultType = UnknownUnit );

//! User defined event types
enum UserEvent
@@ -109,6 +112,11 @@ class CORE_EXPORT QGis
};

static const double DEFAULT_IDENTIFY_RADIUS;

private:
// String representation of unit types (set in qgis.cpp)
static const char *qgisUnitTypes[];

};

// hack to workaround warnings when casting void pointers

0 comments on commit 90d3ab6

Please sign in to comment.
You can’t perform that action at this time.