QGIS API Documentation 4.3.0-Master (2b7e6c9893e)
Loading...
Searching...
No Matches
qgsvectorfieldwindbarbsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorfieldwindbarbsettings.cpp
3 ---------------------
4 begin : September 2026
5 copyright : (C) 2026 by Stefanos Natsis
6 email : uclaros at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include <QString>
19
20using namespace Qt::StringLiterals;
21
22void QgsVectorFieldWindBarbSettings::readXml( const QDomElement &elem )
23{
24 mShaftLength = elem.attribute( u"shaft-length"_s, u"10"_s ).toDouble();
25 mShaftLengthUnits = static_cast<Qgis::RenderUnit>( elem.attribute( u"shaft-length-units"_s ).toInt() );
26 mMagnitudeMultiplier = elem.attribute( u"magnitude-multiplier"_s, u"1"_s ).toDouble();
27 mMagnitudeUnits = static_cast<Qgis::WindSpeedUnit>( elem.attribute( u"magnitude-units"_s, u"0"_s ).toInt() );
28}
29
30QDomElement QgsVectorFieldWindBarbSettings::writeXml( QDomDocument &doc ) const
31{
32 QDomElement elem = doc.createElement( u"vector-windbarb-settings"_s );
33 elem.setAttribute( u"shaft-length"_s, mShaftLength );
34 elem.setAttribute( u"shaft-length-units"_s, static_cast< int >( mShaftLengthUnits ) );
35 elem.setAttribute( u"magnitude-multiplier"_s, mMagnitudeMultiplier );
36 elem.setAttribute( u"magnitude-units"_s, static_cast< int >( mMagnitudeUnits ) );
37 return elem;
38}
39
41{
42 switch ( mMagnitudeUnits )
43 {
45 return 1.0;
47 return 3600.0 / 1852.0;
49 return 1.0 / 1.852;
51 return 1.609344 / 1.852;
53 return 3600.0 / 1.852 / 5280.0 * 1.609344;
55 return mMagnitudeMultiplier;
56 }
57 return 1.0; // should not reach
58}
59
64
66{
67 return mShaftLength;
68}
69
74
76{
77 return mShaftLengthUnits;
78}
79
81{
82 mShaftLengthUnits = shaftLengthUnit;
83}
84
89
91{
92 mMagnitudeUnits = units;
93}
WindSpeedUnit
Wind speed units.
Definition qgis.h:5662
@ FeetPerSecond
Feet per second.
Definition qgis.h:5667
@ KilometersPerHour
Kilometers per hour.
Definition qgis.h:5664
@ OtherUnit
Other unit.
Definition qgis.h:5668
@ Knots
Knots (Nautical miles per hour).
Definition qgis.h:5665
@ MilesPerHour
Miles per hour.
Definition qgis.h:5666
@ MetersPerSecond
Meters per second.
Definition qgis.h:5663
RenderUnit
Rendering size units.
Definition qgis.h:5704
Qgis::WindSpeedUnit magnitudeUnits() const
Returns the units that the data are in.
double shaftLength() const
Returns the shaft length (in millimeters).
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
void setMagnitudeMultiplier(double magnitudeMultiplier)
Sets a multiplier for the magnitude to convert it to knots.
void setMagnitudeUnits(Qgis::WindSpeedUnit units)
Sets the units that the data are in.
double magnitudeMultiplier() const
Returns the multiplier for the magnitude to convert it to knots, according to the units set with setM...
void setShaftLength(double shaftLength)
Sets the shaft length (in millimeters).
Qgis::RenderUnit shaftLengthUnits() const
Returns the units for the shaft length.
void setShaftLengthUnits(Qgis::RenderUnit shaftLengthUnit)
Sets the units for the shaft length.