Skip to content
Permalink
Browse files

Add Distance*, Area*, Angle* prefixes to QgsUnitTypes enum values

  • Loading branch information
nyalldawson committed Jul 25, 2016
1 parent 510f428 commit f6b09eaee142516eccd65578eac5e698ed825829
Showing with 921 additions and 904 deletions.
  1. +19 −2 doc/api_break.dox
  2. +1 −1 python/core/qgsscalecalculator.sip
  3. +32 −32 python/core/qgsunittypes.sip
  4. +1 −1 python/core/qgsvectorfilewriter.sip
  5. +1 −1 python/core/symbology-ng/qgssymbollayerv2.sip
  6. +1 −1 python/core/symbology-ng/qgssymbolv2.sip
  7. +2 −2 src/analysis/vector/qgstransectsample.cpp
  8. +2 −2 src/app/qgisapp.cpp
  9. +4 −4 src/app/qgsdecorationgrid.cpp
  10. +5 −5 src/app/qgsdecorationscalebar.cpp
  11. +1 −1 src/app/qgsdisplayangle.cpp
  12. +1 −1 src/app/qgsmaptooloffsetpointsymbol.cpp
  13. +29 −29 src/app/qgsmeasuredialog.cpp
  14. +25 −25 src/app/qgsoptions.cpp
  15. +24 −24 src/app/qgsprojectproperties.cpp
  16. +4 −4 src/core/composer/qgscomposerscalebar.cpp
  17. +4 −4 src/core/dxf/qgsdxfexport.cpp
  18. +9 −9 src/core/qgscoordinatereferencesystem.cpp
  19. +1 −1 src/core/qgscoordinatereferencesystem_p.h
  20. +40 −40 src/core/qgsdistancearea.cpp
  21. +2 −2 src/core/qgsexpressionprivate.h
  22. +1 −1 src/core/qgsmapsettings.cpp
  23. +2 −2 src/core/qgspallabeling.cpp
  24. +2 −2 src/core/qgsproject.cpp
  25. +4 −4 src/core/qgsscalecalculator.cpp
  26. +1 −1 src/core/qgsscalecalculator.h
  27. +384 −384 src/core/qgsunittypes.cpp
  28. +25 −25 src/core/qgsunittypes.h
  29. +2 −2 src/core/qgsvectorfilewriter.cpp
  30. +1 −1 src/core/qgsvectorfilewriter.h
  31. +2 −2 src/core/qgsvectorlayereditutils.cpp
  32. +3 −3 src/core/qgsxmlutils.cpp
  33. +1 −1 src/core/symbology-ng/qgsellipsesymbollayerv2.cpp
  34. +6 −6 src/core/symbology-ng/qgsfillsymbollayerv2.cpp
  35. +2 −2 src/core/symbology-ng/qgslinesymbollayerv2.cpp
  36. +2 −2 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  37. +1 −1 src/core/symbology-ng/qgssymbollayerv2.cpp
  38. +2 −2 src/core/symbology-ng/qgssymbollayerv2.h
  39. +4 −4 src/core/symbology-ng/qgssymbollayerv2utils.cpp
  40. +4 −4 src/core/symbology-ng/qgssymbolv2.cpp
  41. +1 −1 src/core/symbology-ng/qgssymbolv2.h
  42. +1 −1 src/core/symbology-ng/qgsvectorfieldsymbollayer.cpp
  43. +3 −3 src/gui/qgsunitselectionwidget.cpp
  44. +1 −1 src/gui/qgsunitselectionwidget.h
  45. +3 −3 src/plugins/coordinate_capture/coordinatecapture.cpp
  46. +1 −1 src/plugins/grass/qgsgrassnewmapset.cpp
  47. +2 −2 src/plugins/grass/qgsgrassregion.cpp
  48. +1 −1 src/providers/arcgisrest/qgsamsprovider.cpp
  49. +3 −3 src/providers/wcs/qgswcsprovider.cpp
  50. +2 −2 src/providers/wfs/qgswfsshareddata.cpp
  51. +2 −2 src/providers/wms/qgswmscapabilities.cpp
  52. +3 −3 src/providers/wms/qgswmsprovider.cpp
  53. +1 −1 src/server/qgsmaprenderer.cpp
  54. +1 −1 src/server/qgswmsserver.cpp
  55. +4 −4 tests/src/app/testqgsattributetable.cpp
  56. +4 −4 tests/src/app/testqgsfieldcalculator.cpp
  57. +7 −7 tests/src/app/testqgsmaptoolidentifyaction.cpp
  58. +4 −4 tests/src/app/testqgsmeasuretool.cpp
  59. +1 −1 tests/src/core/testqgsatlascomposition.cpp
  60. +1 −1 tests/src/core/testqgscomposerdd.cpp
  61. +1 −1 tests/src/core/testqgscomposition.cpp
  62. +4 −4 tests/src/core/testqgscoordinatereferencesystem.cpp
  63. +14 −14 tests/src/core/testqgsdistancearea.cpp
  64. +15 −15 tests/src/core/testqgsexpression.cpp
  65. +12 −12 tests/src/core/testqgsproject.cpp
  66. +1 −1 tests/src/python/test_qgsatlascomposition.py
  67. +47 −47 tests/src/python/test_qgsdistancearea.py
  68. +1 −1 tests/src/python/test_qgssymbolv2.py
  69. +119 −119 tests/src/python/test_qgsunittypes.py
  70. +4 −4 tests/src/python/test_qgsvectorlayer.py
@@ -54,8 +54,8 @@ qgsPermissiveToInt()</li>
with the general Degrees unit</li>
<li>The distance unit types QGis::UnitType (including QGis::Meters, QGis::Feet, QGis::Degrees, QGis::NauticalMiles,
QGis::Kilometers, QGis::Yards, QGis::Miles and QGis::UnknownUnit have been moved to QgsUnitTypes::DistanceUnit.
Additionally, UnknownUnit was renamed to UnknownDistanceUnit. All methods which accepted QGis::UnitType parameters
have been updated to take QgsUnitTypes::DistanceUnit instead.</li>
Some of these unit types have also been renamed - see the notes on QgsUnitTypes below. All methods which accepted
QGis::UnitType parameters have been updated to take QgsUnitTypes::DistanceUnit instead.</li>
<li>The unit handling methods toLiteral, fromLiteral, tr, fromTr, fromUnitToUnitFactor have been removed. Their
corresponding counterparts in QgsUnitTypes should be used instead.</li>
</ul>
@@ -468,6 +468,23 @@ parameters or QgsSymbolV2::OutputUnitList parameters now take QgsUnitTypes::Rend
use QgsTreeWidgetItemObject which is an upgraded version of the original QgsTreeWidgetItem</li>
</ul>

\subsection qgis_api_break_3_0_QgsUnitTypes QgsUnitTypes

<ul>
<li>All distance enumeration values were renamed to have a "Distance" prefix, including
Meters (to DistanceMeters), Kilometers (to DistanceKilometers), Feet (to DistanceFeet),
NauticalMiles (to DistanceNauticalMiles), Yards (to DistanceYards), Miles (to DistanceMiles),
Degrees (to DistanceDegrees) and UnknownDistanceUnit to DistanceUnknownUnit</li>
<li>All area enumeration values were renamed to have a "Area" prefix, including
SquareMeters (to AreaSquareMeters), SquareKilometers (to AreaSquareKilometers), SquareFeet (to AreaSquareFeet),
SquareYards (to AreaSquareYards), SquareMiles (to AreaSquareMiles), Hectares (to AreaHectares),
Acres (to AreaAcres), SquareNauticalMiles (to AreaSquareNauticalMiles), SquareDegrees (to AreaSquareDegrees)
and UnknownAreaUnit to AreaUnknownUnit</li>
<li>All angle enumeration values were renamed to have a "Angle" prefix, including
Radians (to AngleRadians), Gon (to AngleGon), MinutesOfArc (to AngleMinutesOfArc),
SecondsOfArc (to AngleSecondsOfArc), Turn (to AngleTurn) and UnknownAngleUnit to AngleUnknownUnit</li>
</ul>

\subsection qgis_api_break_3_0_QgsVectorLayer QgsVectorLayer

<ul>
@@ -16,7 +16,7 @@ class QgsScaleCalculator
* @param mapUnits Units of the data on the map
*/
QgsScaleCalculator( double dpi = 0,
QgsUnitTypes::DistanceUnit mapUnits = QgsUnitTypes::Meters );
QgsUnitTypes::DistanceUnit mapUnits = QgsUnitTypes::DistanceMeters );

/**
* Set the dpi to be used in scale calculations
@@ -15,65 +15,65 @@ class QgsUnitTypes
//! Units of distance
enum DistanceUnit
{
Meters, /*!< meters */
Kilometers, /*!< kilometers */
Feet, /*!< imperial feet */
NauticalMiles, /*!< nautical miles */
Yards, /*!< imperial yards */
Miles, /*!< terrestial miles */
Degrees, /*!< degrees, for planar geographic CRS distance measurements */
UnknownDistanceUnit, /*!< unknown distance unit */
DistanceMeters, /*!< meters */
DistanceKilometers, /*!< kilometers */
DistanceFeet, /*!< imperial feet */
DistanceNauticalMiles, /*!< nautical miles */
DistanceYards, /*!< imperial yards */
DistanceMiles, /*!< terrestial miles */
DistanceDegrees, /*!< degrees, for planar geographic CRS distance measurements */
DistanceUnknownUnit, /*!< unknown distance unit */
};

/** Types of distance units
*/
enum DistanceUnitType
{
Standard, /*!< unit is a standard measurement unit */
Geographic, /*!< unit is a geographic (eg degree based) unit */
UnknownType, /*!< unknown unit type */
Standard, /*!< unit is a standard measurement unit */
Geographic, /*!< unit is a geographic (eg degree based) unit */
UnknownType, /*!< unknown unit type */
};

//! Units of area
enum AreaUnit
{
SquareMeters, /*!< square meters */
SquareKilometers, /*!< square kilometers */
SquareFeet, /*!< square feet */
SquareYards, /*!< square yards */
SquareMiles, /*!< square miles */
Hectares, /*!< hectares */
Acres, /*!< acres */
SquareNauticalMiles, /*!< square nautical miles */
SquareDegrees, /*!< square degrees, for planar geographic CRS area measurements */
UnknownAreaUnit, /*!< unknown areal unit */
AreaSquareMeters, /*!< square meters */
AreaSquareKilometers, /*!< square kilometers */
AreaSquareFeet, /*!< square feet */
AreaSquareYards, /*!< square yards */
AreaSquareMiles, /*!< square miles */
AreaHectares, /*!< hectares */
AreaAcres, /*!< acres */
AreaSquareNauticalMiles, /*!< square nautical miles */
AreaSquareDegrees, /*!< square degrees, for planar geographic CRS area measurements */
AreaUnknownUnit, /*!< unknown areal unit */
};

//! Units of angles
enum AngleUnit
{
AngleDegrees = 0, /*!< degrees */
Radians, /*!< square kilometers */
Gon, /*!< gon/gradian */
MinutesOfArc, /*!< minutes of arc */
SecondsOfArc, /*!< seconds of arc */
Turn, /*!< turn/revolutions */
UnknownAngleUnit, /*!< unknown angle unit */
AngleDegrees, /*!< degrees */
AngleRadians, /*!< square kilometers */
AngleGon, /*!< gon/gradian */
AngleMinutesOfArc, /*!< minutes of arc */
AngleSecondsOfArc, /*!< seconds of arc */
AngleTurn, /*!< turn/revolutions */
AngleUnknownUnit, /*!< unknown angle unit */
};

//! List of render units
typedef QList<QgsUnitTypes::RenderUnit> RenderUnitList;

//! Rendering size units
enum RenderUnit
{
RenderMillimeters, //!< millimeters
RenderMapUnits, //!< map units
RenderPixels, //!< pixels
RenderPercentage, //!< percentage of another measurement (eg canvas size, feature size)
UnknownRenderUnit, //!< mixed or unknown units
RenderUnknownUnit, //!< mixed or unknown units
};

//! List of render units
typedef QList<QgsUnitTypes::RenderUnit> RenderUnitList;

/** Returns the type for a distance unit.
*/
static DistanceUnitType unitType( QgsUnitTypes::DistanceUnit unit );
@@ -271,7 +271,7 @@ class QgsVectorFileWriter
QString errorMessage();

/** Add feature to the currently opened data source */
bool addFeature( QgsFeature& feature, QgsFeatureRendererV2* renderer = 0, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::Meters );
bool addFeature( QgsFeature& feature, QgsFeatureRendererV2* renderer = 0, QgsUnitTypes::DistanceUnit outputUnit = QgsUnitTypes::DistanceMeters );

//! @note not available in python bindings
// QMap<int, int> attrIdxToOgrIdx();
@@ -155,7 +155,7 @@ class QgsSymbolLayerV2
* symbol layer subclasses will interpret this in different ways, eg a marker symbol
* layer may use it to specify the units for the marker size, while a line symbol
* layer may use it to specify the units for the line width.
* @returns output unit, or UnknownRenderUnit if the symbol layer contains mixed units
* @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol layer contains mixed units
* @see setOutputUnit()
*/
virtual QgsUnitTypes::RenderUnit outputUnit() const;
@@ -143,7 +143,7 @@ class QgsSymbolV2
* symbol layer definitions will interpret this in different ways, eg a marker symbol
* may use it to specify the units for the marker size, while a line symbol
* may use it to specify the units for the line width.
* @returns output unit, or UnknownRenderUnit if the symbol contains mixed units
* @returns output unit, or QgsUnitTypes::RenderUnknownUnit if the symbol contains mixed units
* @see setOutputUnit()
*/
QgsUnitTypes::RenderUnit outputUnit() const;
@@ -181,7 +181,7 @@ int QgsTransectSample::createSample( QProgressDialog* pd )
double minDistanceLayerUnits = minDistance;
//if minDistance is in meters and the data in degrees, we need to apply a rough conversion for the buffer distance
double bufferDist = bufferDistance( minDistance );
if ( mMinDistanceUnits == Meters && mStrataLayer->crs().mapUnits() == QgsUnitTypes::Degrees )
if ( mMinDistanceUnits == Meters && mStrataLayer->crs().mapUnits() == QgsUnitTypes::DistanceDegrees )
{
minDistanceLayerUnits = minDistance / 111319.9;
}
@@ -710,7 +710,7 @@ double QgsTransectSample::bufferDistance( double minDistanceFromAttribute ) cons
bufferDist = mBaselineBufferDistance;
}

if ( mMinDistanceUnits == Meters && mStrataLayer->crs().mapUnits() == QgsUnitTypes::Degrees )
if ( mMinDistanceUnits == Meters && mStrataLayer->crs().mapUnits() == QgsUnitTypes::DistanceDegrees )
{
bufferDist /= 111319.9;
}
@@ -4420,7 +4420,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
prj->writeEntry( "SpatialRefSys", "/ProjectCrs", srs.authid() );
prj->writeEntry( "SpatialRefSys", "/ProjectCRSID", static_cast< int >( srs.srsid() ) );
prj->setDirty( false );
if ( srs.mapUnits() != QgsUnitTypes::UnknownDistanceUnit )
if ( srs.mapUnits() != QgsUnitTypes::DistanceUnknownUnit )
{
mMapCanvas->setMapUnits( srs.mapUnits() );
}
@@ -8508,7 +8508,7 @@ void QgisApp::setProjectCrsFromLayer()
QgsCoordinateReferenceSystem crs = mLayerTreeView->currentLayer()->crs();
mMapCanvas->freeze();
mMapCanvas->setDestinationCrs( crs );
if ( crs.mapUnits() != QgsUnitTypes::UnknownDistanceUnit )
if ( crs.mapUnits() != QgsUnitTypes::DistanceUnknownUnit )
{
mMapCanvas->setMapUnits( crs.mapUnits() );
}
@@ -94,7 +94,7 @@ void QgsDecorationGrid::projectRead()

mEnabled = QgsProject::instance()->readBoolEntry( mNameConfig, "/Enabled", false );
mMapUnits = static_cast< QgsUnitTypes::DistanceUnit >( QgsProject::instance()->readNumEntry( mNameConfig, "/MapUnits",
QgsUnitTypes::UnknownDistanceUnit ) );
QgsUnitTypes::DistanceUnknownUnit ) );
mGridStyle = static_cast< GridStyle >( QgsProject::instance()->readNumEntry( mNameConfig, "/Style",
QgsDecorationGrid::Line ) );
mGridIntervalX = QgsProject::instance()->readDoubleEntry( mNameConfig, "/IntervalX", 10 );
@@ -751,7 +751,7 @@ void QgsDecorationGrid::checkMapUnitsChanged()
if ( mEnabled && ( mMapUnits != mapUnits ) )
{
mEnabled = false;
mMapUnits = QgsUnitTypes::UnknownDistanceUnit; // make sure isDirty() returns true
mMapUnits = QgsUnitTypes::DistanceUnknownUnit; // make sure isDirty() returns true
if ( ! QgisApp::instance()->mapCanvas()->isFrozen() )
{
update();
@@ -763,7 +763,7 @@ bool QgsDecorationGrid::isDirty()
{
// checks if stored map units is undefined or different from canvas map units
// or if interval is 0
if ( mMapUnits == QgsUnitTypes::UnknownDistanceUnit ||
if ( mMapUnits == QgsUnitTypes::DistanceUnknownUnit ||
mMapUnits != QgisApp::instance()->mapCanvas()->mapSettings().mapUnits() ||
qgsDoubleNear( mGridIntervalX, 0.0 ) || qgsDoubleNear( mGridIntervalY, 0.0 ) )
return true;
@@ -774,7 +774,7 @@ void QgsDecorationGrid::setDirty( bool dirty )
{
if ( dirty )
{
mMapUnits = QgsUnitTypes::UnknownDistanceUnit;
mMapUnits = QgsUnitTypes::DistanceUnknownUnit;
}
else
{
@@ -135,7 +135,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
bool ok = false;
QgsUnitTypes::DistanceUnit myPreferredUnits = QgsUnitTypes::decodeDistanceUnit( settings.value( "/qgis/measure/displayunits" ).toString(), &ok );
if ( !ok )
myPreferredUnits = QgsUnitTypes::Meters;
myPreferredUnits = QgsUnitTypes::DistanceMeters;
QgsUnitTypes::DistanceUnit myMapUnits = canvas->mapUnits();

// Adjust units meter/feet/... or vice versa
@@ -175,7 +175,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
QString myScaleBarUnitLabel;
switch ( myMapUnits )
{
case QgsUnitTypes::Meters:
case QgsUnitTypes::DistanceMeters:
if ( myActualSize > 1000.0 )
{
myScaleBarUnitLabel = tr( " km" );
@@ -194,7 +194,7 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
else
myScaleBarUnitLabel = tr( " m" );
break;
case QgsUnitTypes::Feet:
case QgsUnitTypes::DistanceFeet:
if ( myActualSize > 5280.0 ) //5280 feet to the mile
{
myScaleBarUnitLabel = tr( " miles" );
@@ -224,13 +224,13 @@ void QgsDecorationScaleBar::render( QPainter * theQPainter )
myScaleBarUnitLabel = tr( " feet" );
}
break;
case QgsUnitTypes::Degrees:
case QgsUnitTypes::DistanceDegrees:
if ( myActualSize == 1.0 )
myScaleBarUnitLabel = tr( " degree" );
else
myScaleBarUnitLabel = tr( " degrees" );
break;
case QgsUnitTypes::UnknownDistanceUnit:
case QgsUnitTypes::DistanceUnknownUnit:
myScaleBarUnitLabel = tr( " unknown" );
//intentional fall-through
FALLTHROUGH;
@@ -44,5 +44,5 @@ void QgsDisplayAngle::updateUi()
QSettings settings;
QgsUnitTypes::AngleUnit unit = QgsUnitTypes::decodeAngleUnit( settings.value( "/qgis/measure/angleunits", QgsUnitTypes::encodeUnit( QgsUnitTypes::AngleDegrees ) ).toString() );
int decimals = settings.value( "/qgis/measure/decimalplaces", "3" ).toInt();
mAngleLineEdit->setText( QgsUnitTypes::formatAngle( mValue * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::Radians, unit ), decimals, unit ) );
mAngleLineEdit->setText( QgsUnitTypes::formatAngle( mValue * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::AngleRadians, unit ), decimals, unit ) );
}
@@ -244,7 +244,7 @@ QPointF QgsMapToolOffsetPointSymbol::calculateOffset( const QgsPoint& startPoint
factor = 1.0;
break;

case QgsUnitTypes::UnknownRenderUnit:
case QgsUnitTypes::RenderUnknownUnit:
case QgsUnitTypes::RenderPercentage:
//no sensible value
factor = 1.0;

0 comments on commit f6b09ea

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