Skip to content

Commit

Permalink
Added converters for QGis:UNitTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Aug 23, 2012
1 parent 1873866 commit 90d3ab6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/core/qgis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ] );
}
8 changes: 8 additions & 0 deletions src/core/qgis.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 90d3ab6

Please sign in to comment.