30 case Qgis::UnitType::Distance:
31 return QStringLiteral(
"distance" );
33 case Qgis::UnitType::Area:
34 return QStringLiteral(
"area" );
36 case Qgis::UnitType::Volume:
37 return QStringLiteral(
"volume" );
39 case Qgis::UnitType::Temporal:
40 return QStringLiteral(
"temporal" );
42 case Qgis::UnitType::Unknown:
43 return QStringLiteral(
"<unknown>" );
51 const QString normalized =
string.trimmed().toLower();
57 return Qgis::UnitType::Distance;
59 return Qgis::UnitType::Area;
61 return Qgis::UnitType::Volume;
63 return Qgis::UnitType::Temporal;
65 return Qgis::UnitType::Unknown;
70 return Qgis::UnitType::Unknown;
77 case Qgis::DistanceUnit::Meters:
78 case Qgis::DistanceUnit::Feet:
79 case Qgis::DistanceUnit::NauticalMiles:
80 case Qgis::DistanceUnit::Yards:
81 case Qgis::DistanceUnit::Miles:
82 case Qgis::DistanceUnit::Kilometers:
83 case Qgis::DistanceUnit::Centimeters:
84 case Qgis::DistanceUnit::Millimeters:
88 case Qgis::DistanceUnit::Degrees:
91 case Qgis::DistanceUnit::Unknown:
92 return Qgis::DistanceUnitType::Unknown;
94 return Qgis::DistanceUnitType::Unknown;
101 case Qgis::AreaUnit::SquareMeters:
102 case Qgis::AreaUnit::SquareKilometers:
103 case Qgis::AreaUnit::SquareFeet:
104 case Qgis::AreaUnit::SquareYards:
105 case Qgis::AreaUnit::SquareMiles:
106 case Qgis::AreaUnit::Hectares:
107 case Qgis::AreaUnit::Acres:
108 case Qgis::AreaUnit::SquareNauticalMiles:
109 case Qgis::AreaUnit::SquareCentimeters:
110 case Qgis::AreaUnit::SquareMillimeters:
114 case Qgis::AreaUnit::SquareDegrees:
117 case Qgis::AreaUnit::Unknown:
118 return Qgis::DistanceUnitType::Unknown;
121 return Qgis::DistanceUnitType::Unknown;
128 case Qgis::DistanceUnit::Meters:
129 return QStringLiteral(
"meters" );
131 case Qgis::DistanceUnit::Kilometers:
132 return QStringLiteral(
"km" );
134 case Qgis::DistanceUnit::Feet:
135 return QStringLiteral(
"feet" );
137 case Qgis::DistanceUnit::Yards:
138 return QStringLiteral(
"yd" );
140 case Qgis::DistanceUnit::Miles:
141 return QStringLiteral(
"mi" );
143 case Qgis::DistanceUnit::Degrees:
144 return QStringLiteral(
"degrees" );
146 case Qgis::DistanceUnit::Unknown:
147 return QStringLiteral(
"<unknown>" );
149 case Qgis::DistanceUnit::NauticalMiles:
150 return QStringLiteral(
"nautical miles" );
152 case Qgis::DistanceUnit::Centimeters:
153 return QStringLiteral(
"cm" );
155 case Qgis::DistanceUnit::Millimeters:
156 return QStringLiteral(
"mm" );
159 return QStringLiteral(
"in" );
172 const QString normalized =
string.trimmed().toLower();
177 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Meters ) )
178 return Qgis::DistanceUnit::Meters;
179 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Feet ) )
180 return Qgis::DistanceUnit::Feet;
181 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Degrees ) )
182 return Qgis::DistanceUnit::Degrees;
183 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::NauticalMiles ) )
184 return Qgis::DistanceUnit::NauticalMiles;
185 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Kilometers ) )
186 return Qgis::DistanceUnit::Kilometers;
187 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Yards ) )
188 return Qgis::DistanceUnit::Yards;
189 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Miles ) )
190 return Qgis::DistanceUnit::Miles;
191 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Centimeters ) )
192 return Qgis::DistanceUnit::Centimeters;
193 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Millimeters ) )
194 return Qgis::DistanceUnit::Millimeters;
197 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Unknown ) )
198 return Qgis::DistanceUnit::Unknown;
203 return Qgis::DistanceUnit::Unknown;
210 case Qgis::DistanceUnit::Meters:
211 return QObject::tr(
"meters",
"distance" );
213 case Qgis::DistanceUnit::Kilometers:
214 return QObject::tr(
"kilometers",
"distance" );
216 case Qgis::DistanceUnit::Feet:
217 return QObject::tr(
"feet",
"distance" );
219 case Qgis::DistanceUnit::Yards:
220 return QObject::tr(
"yards",
"distance" );
222 case Qgis::DistanceUnit::Miles:
223 return QObject::tr(
"miles",
"distance" );
225 case Qgis::DistanceUnit::Degrees:
226 return QObject::tr(
"degrees",
"distance" );
228 case Qgis::DistanceUnit::Centimeters:
229 return QObject::tr(
"centimeters",
"distance" );
231 case Qgis::DistanceUnit::Millimeters:
232 return QObject::tr(
"millimeters",
"distance" );
235 return QObject::tr(
"inches",
"distance" );
237 case Qgis::DistanceUnit::Unknown:
238 return QObject::tr(
"<unknown>",
"distance" );
240 case Qgis::DistanceUnit::NauticalMiles:
241 return QObject::tr(
"nautical miles",
"distance" );
250 case Qgis::RenderUnit::Millimeters:
251 return QObject::tr(
"mm",
"render" );
253 case Qgis::RenderUnit::MapUnits:
254 return QObject::tr(
"map units",
"render" );
256 case Qgis::RenderUnit::Pixels:
257 return QObject::tr(
"px",
"render" );
259 case Qgis::RenderUnit::Percentage:
260 return QObject::tr(
"%",
"render" );
262 case Qgis::RenderUnit::Points:
263 return QObject::tr(
"pt",
"render" );
265 case Qgis::RenderUnit::Inches:
266 return QObject::tr(
"in",
"render" );
268 case Qgis::RenderUnit::Unknown:
269 return QObject::tr(
"unknown",
"render" );
271 case Qgis::RenderUnit::MetersInMapUnits:
272 return QObject::tr(
"m",
"render" );
283 case Qgis::DistanceUnit::Meters:
284 return QObject::tr(
"m",
"distance" );
286 case Qgis::DistanceUnit::Kilometers:
287 return QObject::tr(
"km",
"distance" );
289 case Qgis::DistanceUnit::Feet:
290 return QObject::tr(
"ft",
"distance" );
292 case Qgis::DistanceUnit::Yards:
293 return QObject::tr(
"yd",
"distance" );
295 case Qgis::DistanceUnit::Miles:
296 return QObject::tr(
"mi",
"distance" );
298 case Qgis::DistanceUnit::Degrees:
299 return QObject::tr(
"deg",
"distance" );
301 case Qgis::DistanceUnit::Centimeters:
302 return QObject::tr(
"cm",
"distance" );
304 case Qgis::DistanceUnit::Millimeters:
305 return QObject::tr(
"mm",
"distance" );
308 return QObject::tr(
"in",
"distance" );
310 case Qgis::DistanceUnit::Unknown:
313 case Qgis::DistanceUnit::NauticalMiles:
314 return QObject::tr(
"NM",
"distance" );
327 const QString normalized =
string.trimmed().toLower();
332 if ( normalized ==
toString( Qgis::DistanceUnit::Meters ) )
333 return Qgis::DistanceUnit::Meters;
334 if ( normalized ==
toString( Qgis::DistanceUnit::Kilometers ) )
335 return Qgis::DistanceUnit::Kilometers;
336 if ( normalized ==
toString( Qgis::DistanceUnit::Feet ) )
337 return Qgis::DistanceUnit::Feet;
338 if ( normalized ==
toString( Qgis::DistanceUnit::Yards ) )
339 return Qgis::DistanceUnit::Yards;
340 if ( normalized ==
toString( Qgis::DistanceUnit::Miles ) )
341 return Qgis::DistanceUnit::Miles;
342 if ( normalized ==
toString( Qgis::DistanceUnit::Degrees ) )
343 return Qgis::DistanceUnit::Degrees;
344 if ( normalized ==
toString( Qgis::DistanceUnit::Centimeters ) )
345 return Qgis::DistanceUnit::Centimeters;
346 if ( normalized ==
toString( Qgis::DistanceUnit::Millimeters ) )
347 return Qgis::DistanceUnit::Millimeters;
348 if ( normalized ==
toString( Qgis::DistanceUnit::NauticalMiles ) )
349 return Qgis::DistanceUnit::NauticalMiles;
352 if ( normalized ==
toString( Qgis::DistanceUnit::Unknown ) )
353 return Qgis::DistanceUnit::Unknown;
358 return Qgis::DistanceUnit::Unknown;
369#define DEGREE_TO_METER 111319.49079327358
370#define FEET_TO_METER 0.3048
371#define NMILE_TO_METER 1852.0
372#define KILOMETERS_TO_METER 1000.0
373#define CENTIMETERS_TO_METER 0.01
374#define MILLIMETERS_TO_METER 0.001
375#define INCHES_TO_METER 0.0254
376#define FEET_TO_INCHES 12
377#define YARDS_TO_METER 0.9144
378#define YARDS_TO_FEET 3.0
379#define MILES_TO_METER 1609.344
384 case Qgis::DistanceUnit::Meters:
388 case Qgis::DistanceUnit::Meters:
390 case Qgis::DistanceUnit::Kilometers:
392 case Qgis::DistanceUnit::Millimeters:
394 case Qgis::DistanceUnit::Centimeters:
398 case Qgis::DistanceUnit::Feet:
400 case Qgis::DistanceUnit::Yards:
402 case Qgis::DistanceUnit::Miles:
404 case Qgis::DistanceUnit::Degrees:
406 case Qgis::DistanceUnit::NauticalMiles:
408 case Qgis::DistanceUnit::Unknown:
414 case Qgis::DistanceUnit::Kilometers:
418 case Qgis::DistanceUnit::Meters:
420 case Qgis::DistanceUnit::Kilometers:
422 case Qgis::DistanceUnit::Centimeters:
424 case Qgis::DistanceUnit::Millimeters:
428 case Qgis::DistanceUnit::Feet:
430 case Qgis::DistanceUnit::Yards:
432 case Qgis::DistanceUnit::Miles:
434 case Qgis::DistanceUnit::Degrees:
436 case Qgis::DistanceUnit::NauticalMiles:
438 case Qgis::DistanceUnit::Unknown:
444 case Qgis::DistanceUnit::Feet:
448 case Qgis::DistanceUnit::Meters:
450 case Qgis::DistanceUnit::Kilometers:
452 case Qgis::DistanceUnit::Centimeters:
454 case Qgis::DistanceUnit::Millimeters:
458 case Qgis::DistanceUnit::Feet:
460 case Qgis::DistanceUnit::Yards:
462 case Qgis::DistanceUnit::Miles:
464 case Qgis::DistanceUnit::Degrees:
466 case Qgis::DistanceUnit::NauticalMiles:
468 case Qgis::DistanceUnit::Unknown:
474 case Qgis::DistanceUnit::Yards:
478 case Qgis::DistanceUnit::Meters:
480 case Qgis::DistanceUnit::Kilometers:
482 case Qgis::DistanceUnit::Centimeters:
484 case Qgis::DistanceUnit::Millimeters:
486 case Qgis::DistanceUnit::Feet:
490 case Qgis::DistanceUnit::Yards:
492 case Qgis::DistanceUnit::Miles:
494 case Qgis::DistanceUnit::Degrees:
496 case Qgis::DistanceUnit::NauticalMiles:
498 case Qgis::DistanceUnit::Unknown:
504 case Qgis::DistanceUnit::Miles:
508 case Qgis::DistanceUnit::Meters:
510 case Qgis::DistanceUnit::Kilometers:
512 case Qgis::DistanceUnit::Centimeters:
514 case Qgis::DistanceUnit::Millimeters:
516 case Qgis::DistanceUnit::Feet:
520 case Qgis::DistanceUnit::Yards:
522 case Qgis::DistanceUnit::Miles:
524 case Qgis::DistanceUnit::Degrees:
526 case Qgis::DistanceUnit::NauticalMiles:
528 case Qgis::DistanceUnit::Unknown:
534 case Qgis::DistanceUnit::Degrees:
538 case Qgis::DistanceUnit::Meters:
540 case Qgis::DistanceUnit::Kilometers:
542 case Qgis::DistanceUnit::Centimeters:
544 case Qgis::DistanceUnit::Millimeters:
546 case Qgis::DistanceUnit::Feet:
550 case Qgis::DistanceUnit::Yards:
552 case Qgis::DistanceUnit::Miles:
554 case Qgis::DistanceUnit::Degrees:
556 case Qgis::DistanceUnit::NauticalMiles:
558 case Qgis::DistanceUnit::Unknown:
564 case Qgis::DistanceUnit::NauticalMiles:
568 case Qgis::DistanceUnit::Meters:
570 case Qgis::DistanceUnit::Kilometers:
572 case Qgis::DistanceUnit::Centimeters:
574 case Qgis::DistanceUnit::Millimeters:
576 case Qgis::DistanceUnit::Feet:
580 case Qgis::DistanceUnit::Yards:
582 case Qgis::DistanceUnit::Miles:
584 case Qgis::DistanceUnit::Degrees:
586 case Qgis::DistanceUnit::NauticalMiles:
588 case Qgis::DistanceUnit::Unknown:
594 case Qgis::DistanceUnit::Centimeters:
598 case Qgis::DistanceUnit::Meters:
600 case Qgis::DistanceUnit::Kilometers:
602 case Qgis::DistanceUnit::Centimeters:
604 case Qgis::DistanceUnit::Millimeters:
606 case Qgis::DistanceUnit::Feet:
608 case Qgis::DistanceUnit::Yards:
612 case Qgis::DistanceUnit::Miles:
614 case Qgis::DistanceUnit::Degrees:
616 case Qgis::DistanceUnit::NauticalMiles:
618 case Qgis::DistanceUnit::Unknown:
624 case Qgis::DistanceUnit::Millimeters:
628 case Qgis::DistanceUnit::Meters:
630 case Qgis::DistanceUnit::Kilometers:
632 case Qgis::DistanceUnit::Centimeters:
634 case Qgis::DistanceUnit::Millimeters:
636 case Qgis::DistanceUnit::Feet:
638 case Qgis::DistanceUnit::Yards:
642 case Qgis::DistanceUnit::Miles:
644 case Qgis::DistanceUnit::Degrees:
646 case Qgis::DistanceUnit::NauticalMiles:
648 case Qgis::DistanceUnit::Unknown:
659 case Qgis::DistanceUnit::Meters:
661 case Qgis::DistanceUnit::Kilometers:
663 case Qgis::DistanceUnit::Centimeters:
665 case Qgis::DistanceUnit::Millimeters:
667 case Qgis::DistanceUnit::Feet:
671 case Qgis::DistanceUnit::Yards:
673 case Qgis::DistanceUnit::Miles:
675 case Qgis::DistanceUnit::Degrees:
677 case Qgis::DistanceUnit::NauticalMiles:
679 case Qgis::DistanceUnit::Unknown:
685 case Qgis::DistanceUnit::Unknown:
695 case Qgis::AreaUnit::SquareMeters:
696 return QStringLiteral(
"m2" );
697 case Qgis::AreaUnit::SquareKilometers:
698 return QStringLiteral(
"km2" );
699 case Qgis::AreaUnit::SquareFeet:
700 return QStringLiteral(
"ft2" );
701 case Qgis::AreaUnit::SquareYards:
702 return QStringLiteral(
"y2" );
703 case Qgis::AreaUnit::SquareMiles:
704 return QStringLiteral(
"mi2" );
705 case Qgis::AreaUnit::Hectares:
706 return QStringLiteral(
"ha" );
707 case Qgis::AreaUnit::Acres:
708 return QStringLiteral(
"ac" );
709 case Qgis::AreaUnit::SquareNauticalMiles:
710 return QStringLiteral(
"nm2" );
711 case Qgis::AreaUnit::SquareDegrees:
712 return QStringLiteral(
"deg2" );
713 case Qgis::AreaUnit::SquareCentimeters:
714 return QStringLiteral(
"cm2" );
715 case Qgis::AreaUnit::SquareMillimeters:
716 return QStringLiteral(
"mm2" );
718 return QStringLiteral(
"in2" );
719 case Qgis::AreaUnit::Unknown:
720 return QStringLiteral(
"<unknown>" );
727 const QString normalized =
string.trimmed().toLower();
732 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMeters ) )
733 return Qgis::AreaUnit::SquareMeters;
734 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareKilometers ) )
735 return Qgis::AreaUnit::SquareKilometers;
736 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareFeet ) )
737 return Qgis::AreaUnit::SquareFeet;
738 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareYards ) )
739 return Qgis::AreaUnit::SquareYards;
740 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMiles ) )
741 return Qgis::AreaUnit::SquareMiles;
742 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Hectares ) )
743 return Qgis::AreaUnit::Hectares;
744 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Acres ) )
745 return Qgis::AreaUnit::Acres;
746 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareNauticalMiles ) )
747 return Qgis::AreaUnit::SquareNauticalMiles;
748 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareDegrees ) )
749 return Qgis::AreaUnit::SquareDegrees;
750 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareCentimeters ) )
751 return Qgis::AreaUnit::SquareCentimeters;
752 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMillimeters ) )
753 return Qgis::AreaUnit::SquareMillimeters;
756 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Unknown ) )
757 return Qgis::AreaUnit::Unknown;
762 return Qgis::AreaUnit::Unknown;
769 case Qgis::AreaUnit::SquareMeters:
770 return QObject::tr(
"square meters",
"area" );
771 case Qgis::AreaUnit::SquareKilometers:
772 return QObject::tr(
"square kilometers",
"area" );
773 case Qgis::AreaUnit::SquareFeet:
774 return QObject::tr(
"square feet",
"area" );
775 case Qgis::AreaUnit::SquareYards:
776 return QObject::tr(
"square yards",
"area" );
777 case Qgis::AreaUnit::SquareMiles:
778 return QObject::tr(
"square miles",
"area" );
779 case Qgis::AreaUnit::Hectares:
780 return QObject::tr(
"hectares",
"area" );
781 case Qgis::AreaUnit::Acres:
782 return QObject::tr(
"acres",
"area" );
783 case Qgis::AreaUnit::SquareNauticalMiles:
784 return QObject::tr(
"square nautical miles",
"area" );
785 case Qgis::AreaUnit::SquareDegrees:
786 return QObject::tr(
"square degrees",
"area" );
787 case Qgis::AreaUnit::SquareMillimeters:
788 return QObject::tr(
"square millimeters",
"area" );
789 case Qgis::AreaUnit::SquareCentimeters:
790 return QObject::tr(
"square centimeters",
"area" );
792 return QObject::tr(
"square inches",
"area" );
793 case Qgis::AreaUnit::Unknown:
794 return QObject::tr(
"<unknown>",
"area" );
803 case Qgis::AreaUnit::SquareMeters:
804 return QObject::tr(
"m²",
"area" );
805 case Qgis::AreaUnit::SquareKilometers:
806 return QObject::tr(
"km²",
"area" );
807 case Qgis::AreaUnit::SquareFeet:
808 return QObject::tr(
"ft²",
"area" );
809 case Qgis::AreaUnit::SquareYards:
810 return QObject::tr(
"yd²",
"area" );
811 case Qgis::AreaUnit::SquareMiles:
812 return QObject::tr(
"mi²",
"area" );
813 case Qgis::AreaUnit::Hectares:
814 return QObject::tr(
"ha",
"area" );
815 case Qgis::AreaUnit::Acres:
816 return QObject::tr(
"ac",
"area" );
817 case Qgis::AreaUnit::SquareNauticalMiles:
818 return QObject::tr(
"NM²",
"area" );
819 case Qgis::AreaUnit::SquareDegrees:
820 return QObject::tr(
"deg²",
"area" );
821 case Qgis::AreaUnit::SquareCentimeters:
822 return QObject::tr(
"cm²",
"area" );
823 case Qgis::AreaUnit::SquareMillimeters:
824 return QObject::tr(
"mm²",
"area" );
826 return QObject::tr(
"in²",
"area" );
827 case Qgis::AreaUnit::Unknown:
835 const QString normalized =
string.trimmed().toLower();
840 if ( normalized ==
toString( Qgis::AreaUnit::SquareMeters ) )
841 return Qgis::AreaUnit::SquareMeters;
842 if ( normalized ==
toString( Qgis::AreaUnit::SquareKilometers ) )
843 return Qgis::AreaUnit::SquareKilometers;
844 if ( normalized ==
toString( Qgis::AreaUnit::SquareFeet ) )
845 return Qgis::AreaUnit::SquareFeet;
846 if ( normalized ==
toString( Qgis::AreaUnit::SquareYards ) )
847 return Qgis::AreaUnit::SquareYards;
848 if ( normalized ==
toString( Qgis::AreaUnit::SquareMiles ) )
849 return Qgis::AreaUnit::SquareMiles;
850 if ( normalized ==
toString( Qgis::AreaUnit::Hectares ) )
851 return Qgis::AreaUnit::Hectares;
852 if ( normalized ==
toString( Qgis::AreaUnit::Acres ) )
853 return Qgis::AreaUnit::Acres;
854 if ( normalized ==
toString( Qgis::AreaUnit::SquareNauticalMiles ) )
855 return Qgis::AreaUnit::SquareNauticalMiles;
856 if ( normalized ==
toString( Qgis::AreaUnit::SquareDegrees ) )
857 return Qgis::AreaUnit::SquareDegrees;
858 if ( normalized ==
toString( Qgis::AreaUnit::SquareMillimeters ) )
859 return Qgis::AreaUnit::SquareMillimeters;
860 if ( normalized ==
toString( Qgis::AreaUnit::SquareCentimeters ) )
861 return Qgis::AreaUnit::SquareCentimeters;
864 if ( normalized ==
toString( Qgis::AreaUnit::Unknown ) )
865 return Qgis::AreaUnit::Unknown;
869 return Qgis::AreaUnit::Unknown;
874#define KM2_TO_M2 1000000.0
875#define CM2_TO_M2 0.0001
876#define MM2_TO_M2 0.000001
877#define FT2_TO_M2 0.09290304
878#define IN2_TO_M2 0.00064516
879#define YD2_TO_M2 0.83612736
880#define MI2_TO_M2 2589988.110336
881#define HA_TO_M2 10000.0
882#define AC_TO_FT2 43560.0
883#define DEG2_TO_M2 12392029030.5
884#define NM2_TO_M2 3429904.0
889 case Qgis::AreaUnit::SquareMeters:
893 case Qgis::AreaUnit::SquareMeters:
895 case Qgis::AreaUnit::SquareKilometers:
897 case Qgis::AreaUnit::SquareFeet:
899 case Qgis::AreaUnit::SquareYards:
901 case Qgis::AreaUnit::SquareMiles:
903 case Qgis::AreaUnit::Hectares:
905 case Qgis::AreaUnit::Acres:
907 case Qgis::AreaUnit::SquareNauticalMiles:
909 case Qgis::AreaUnit::SquareDegrees:
911 case Qgis::AreaUnit::SquareCentimeters:
913 case Qgis::AreaUnit::SquareMillimeters:
917 case Qgis::AreaUnit::Unknown:
923 case Qgis::AreaUnit::SquareKilometers:
927 case Qgis::AreaUnit::SquareMeters:
929 case Qgis::AreaUnit::SquareKilometers:
931 case Qgis::AreaUnit::SquareFeet:
933 case Qgis::AreaUnit::SquareYards:
935 case Qgis::AreaUnit::SquareMiles:
937 case Qgis::AreaUnit::Hectares:
939 case Qgis::AreaUnit::Acres:
941 case Qgis::AreaUnit::SquareNauticalMiles:
943 case Qgis::AreaUnit::SquareDegrees:
945 case Qgis::AreaUnit::SquareCentimeters:
947 case Qgis::AreaUnit::SquareMillimeters:
951 case Qgis::AreaUnit::Unknown:
957 case Qgis::AreaUnit::SquareFeet:
961 case Qgis::AreaUnit::SquareMeters:
963 case Qgis::AreaUnit::SquareKilometers:
965 case Qgis::AreaUnit::SquareFeet:
967 case Qgis::AreaUnit::SquareYards:
969 case Qgis::AreaUnit::SquareMiles:
971 case Qgis::AreaUnit::Hectares:
973 case Qgis::AreaUnit::Acres:
975 case Qgis::AreaUnit::SquareNauticalMiles:
977 case Qgis::AreaUnit::SquareDegrees:
979 case Qgis::AreaUnit::SquareCentimeters:
981 case Qgis::AreaUnit::SquareMillimeters:
985 case Qgis::AreaUnit::Unknown:
992 case Qgis::AreaUnit::SquareYards:
996 case Qgis::AreaUnit::SquareMeters:
998 case Qgis::AreaUnit::SquareKilometers:
1000 case Qgis::AreaUnit::SquareFeet:
1002 case Qgis::AreaUnit::SquareYards:
1004 case Qgis::AreaUnit::SquareMiles:
1006 case Qgis::AreaUnit::Hectares:
1008 case Qgis::AreaUnit::Acres:
1010 case Qgis::AreaUnit::SquareNauticalMiles:
1012 case Qgis::AreaUnit::SquareDegrees:
1014 case Qgis::AreaUnit::SquareCentimeters:
1016 case Qgis::AreaUnit::SquareMillimeters:
1020 case Qgis::AreaUnit::Unknown:
1026 case Qgis::AreaUnit::SquareMiles:
1030 case Qgis::AreaUnit::SquareMeters:
1032 case Qgis::AreaUnit::SquareKilometers:
1034 case Qgis::AreaUnit::SquareFeet:
1036 case Qgis::AreaUnit::SquareYards:
1038 case Qgis::AreaUnit::SquareMiles:
1040 case Qgis::AreaUnit::Hectares:
1042 case Qgis::AreaUnit::Acres:
1044 case Qgis::AreaUnit::SquareNauticalMiles:
1046 case Qgis::AreaUnit::SquareDegrees:
1048 case Qgis::AreaUnit::SquareCentimeters:
1050 case Qgis::AreaUnit::SquareMillimeters:
1054 case Qgis::AreaUnit::Unknown:
1061 case Qgis::AreaUnit::Hectares:
1065 case Qgis::AreaUnit::SquareMeters:
1067 case Qgis::AreaUnit::SquareKilometers:
1069 case Qgis::AreaUnit::SquareFeet:
1071 case Qgis::AreaUnit::SquareYards:
1073 case Qgis::AreaUnit::SquareMiles:
1075 case Qgis::AreaUnit::Hectares:
1077 case Qgis::AreaUnit::Acres:
1079 case Qgis::AreaUnit::SquareNauticalMiles:
1081 case Qgis::AreaUnit::SquareDegrees:
1083 case Qgis::AreaUnit::SquareCentimeters:
1085 case Qgis::AreaUnit::SquareMillimeters:
1089 case Qgis::AreaUnit::Unknown:
1096 case Qgis::AreaUnit::Acres:
1100 case Qgis::AreaUnit::SquareMeters:
1102 case Qgis::AreaUnit::SquareKilometers:
1104 case Qgis::AreaUnit::SquareFeet:
1106 case Qgis::AreaUnit::SquareYards:
1108 case Qgis::AreaUnit::SquareMiles:
1110 case Qgis::AreaUnit::Hectares:
1112 case Qgis::AreaUnit::Acres:
1114 case Qgis::AreaUnit::SquareNauticalMiles:
1116 case Qgis::AreaUnit::SquareDegrees:
1118 case Qgis::AreaUnit::SquareCentimeters:
1120 case Qgis::AreaUnit::SquareMillimeters:
1124 case Qgis::AreaUnit::Unknown:
1131 case Qgis::AreaUnit::SquareNauticalMiles:
1135 case Qgis::AreaUnit::SquareMeters:
1137 case Qgis::AreaUnit::SquareKilometers:
1139 case Qgis::AreaUnit::SquareFeet:
1141 case Qgis::AreaUnit::SquareYards:
1143 case Qgis::AreaUnit::SquareMiles:
1145 case Qgis::AreaUnit::Hectares:
1147 case Qgis::AreaUnit::Acres:
1149 case Qgis::AreaUnit::SquareNauticalMiles:
1151 case Qgis::AreaUnit::SquareDegrees:
1153 case Qgis::AreaUnit::SquareCentimeters:
1155 case Qgis::AreaUnit::SquareMillimeters:
1159 case Qgis::AreaUnit::Unknown:
1166 case Qgis::AreaUnit::SquareDegrees:
1170 case Qgis::AreaUnit::SquareMeters:
1172 case Qgis::AreaUnit::SquareKilometers:
1174 case Qgis::AreaUnit::SquareFeet:
1176 case Qgis::AreaUnit::SquareYards:
1178 case Qgis::AreaUnit::SquareMiles:
1180 case Qgis::AreaUnit::Hectares:
1182 case Qgis::AreaUnit::Acres:
1184 case Qgis::AreaUnit::SquareNauticalMiles:
1186 case Qgis::AreaUnit::SquareDegrees:
1188 case Qgis::AreaUnit::SquareCentimeters:
1190 case Qgis::AreaUnit::SquareMillimeters:
1194 case Qgis::AreaUnit::Unknown:
1201 case Qgis::AreaUnit::SquareMillimeters:
1205 case Qgis::AreaUnit::SquareMeters:
1207 case Qgis::AreaUnit::SquareKilometers:
1209 case Qgis::AreaUnit::SquareFeet:
1211 case Qgis::AreaUnit::SquareYards:
1213 case Qgis::AreaUnit::SquareMiles:
1215 case Qgis::AreaUnit::Hectares:
1217 case Qgis::AreaUnit::Acres:
1219 case Qgis::AreaUnit::SquareNauticalMiles:
1221 case Qgis::AreaUnit::SquareDegrees:
1223 case Qgis::AreaUnit::SquareCentimeters:
1225 case Qgis::AreaUnit::SquareMillimeters:
1229 case Qgis::AreaUnit::Unknown:
1235 case Qgis::AreaUnit::SquareCentimeters:
1239 case Qgis::AreaUnit::SquareMeters:
1241 case Qgis::AreaUnit::SquareKilometers:
1243 case Qgis::AreaUnit::SquareFeet:
1245 case Qgis::AreaUnit::SquareYards:
1247 case Qgis::AreaUnit::SquareMiles:
1249 case Qgis::AreaUnit::Hectares:
1251 case Qgis::AreaUnit::Acres:
1253 case Qgis::AreaUnit::SquareNauticalMiles:
1255 case Qgis::AreaUnit::SquareDegrees:
1257 case Qgis::AreaUnit::SquareCentimeters:
1259 case Qgis::AreaUnit::SquareMillimeters:
1263 case Qgis::AreaUnit::Unknown:
1273 case Qgis::AreaUnit::SquareMeters:
1275 case Qgis::AreaUnit::SquareKilometers:
1277 case Qgis::AreaUnit::SquareFeet:
1279 case Qgis::AreaUnit::SquareYards:
1281 case Qgis::AreaUnit::SquareMiles:
1283 case Qgis::AreaUnit::Hectares:
1285 case Qgis::AreaUnit::Acres:
1287 case Qgis::AreaUnit::SquareNauticalMiles:
1289 case Qgis::AreaUnit::SquareDegrees:
1291 case Qgis::AreaUnit::SquareCentimeters:
1293 case Qgis::AreaUnit::SquareMillimeters:
1297 case Qgis::AreaUnit::Unknown:
1303 case Qgis::AreaUnit::Unknown:
1311 switch ( distanceUnit )
1313 case Qgis::DistanceUnit::Meters:
1314 return Qgis::AreaUnit::SquareMeters;
1316 case Qgis::DistanceUnit::Kilometers:
1317 return Qgis::AreaUnit::SquareKilometers;
1319 case Qgis::DistanceUnit::Centimeters:
1320 return Qgis::AreaUnit::SquareCentimeters;
1322 case Qgis::DistanceUnit::Millimeters:
1323 return Qgis::AreaUnit::SquareMillimeters;
1325 case Qgis::DistanceUnit::Feet:
1326 return Qgis::AreaUnit::SquareFeet;
1328 case Qgis::DistanceUnit::Yards:
1329 return Qgis::AreaUnit::SquareYards;
1331 case Qgis::DistanceUnit::Miles:
1332 return Qgis::AreaUnit::SquareMiles;
1334 case Qgis::DistanceUnit::Degrees:
1335 return Qgis::AreaUnit::SquareDegrees;
1337 case Qgis::DistanceUnit::Unknown:
1338 return Qgis::AreaUnit::Unknown;
1340 case Qgis::DistanceUnit::NauticalMiles:
1341 return Qgis::AreaUnit::SquareNauticalMiles;
1347 return Qgis::AreaUnit::Unknown;
1354 case Qgis::AreaUnit::SquareMeters:
1355 case Qgis::AreaUnit::Hectares:
1356 return Qgis::DistanceUnit::Meters;
1358 case Qgis::AreaUnit::SquareKilometers:
1359 return Qgis::DistanceUnit::Kilometers;
1361 case Qgis::AreaUnit::SquareCentimeters:
1362 return Qgis::DistanceUnit::Centimeters;
1364 case Qgis::AreaUnit::SquareMillimeters:
1365 return Qgis::DistanceUnit::Millimeters;
1367 case Qgis::AreaUnit::SquareFeet:
1368 return Qgis::DistanceUnit::Feet;
1370 case Qgis::AreaUnit::SquareYards:
1371 case Qgis::AreaUnit::Acres:
1372 return Qgis::DistanceUnit::Yards;
1374 case Qgis::AreaUnit::SquareMiles:
1375 return Qgis::DistanceUnit::Miles;
1377 case Qgis::AreaUnit::SquareDegrees:
1378 return Qgis::DistanceUnit::Degrees;
1380 case Qgis::AreaUnit::Unknown:
1381 return Qgis::DistanceUnit::Unknown;
1383 case Qgis::AreaUnit::SquareNauticalMiles:
1384 return Qgis::DistanceUnit::NauticalMiles;
1390 return Qgis::DistanceUnit::Unknown;
1397 case Qgis::TemporalUnit::Seconds:
1398 return QStringLiteral(
"s" );
1399 case Qgis::TemporalUnit::Milliseconds:
1400 return QStringLiteral(
"ms" );
1401 case Qgis::TemporalUnit::Minutes:
1402 return QStringLiteral(
"min" );
1403 case Qgis::TemporalUnit::Hours:
1404 return QStringLiteral(
"h" );
1405 case Qgis::TemporalUnit::Days:
1406 return QStringLiteral(
"d" );
1407 case Qgis::TemporalUnit::Weeks:
1408 return QStringLiteral(
"wk" );
1409 case Qgis::TemporalUnit::Months:
1410 return QStringLiteral(
"mon" );
1411 case Qgis::TemporalUnit::Years:
1412 return QStringLiteral(
"y" );
1413 case Qgis::TemporalUnit::Decades:
1414 return QStringLiteral(
"dec" );
1415 case Qgis::TemporalUnit::Centuries:
1416 return QStringLiteral(
"c" );
1417 case Qgis::TemporalUnit::IrregularStep:
1418 return QStringLiteral(
"xxx" );
1419 case Qgis::TemporalUnit::Unknown:
1420 return QStringLiteral(
"<unknown>" );
1427 const QString normalized =
string.trimmed().toLower();
1432 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Seconds ) )
1433 return Qgis::TemporalUnit::Seconds;
1434 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Milliseconds ) )
1435 return Qgis::TemporalUnit::Milliseconds;
1436 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Minutes ) )
1437 return Qgis::TemporalUnit::Minutes;
1438 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Hours ) )
1439 return Qgis::TemporalUnit::Hours;
1440 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Days ) )
1441 return Qgis::TemporalUnit::Days;
1442 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Weeks ) )
1443 return Qgis::TemporalUnit::Weeks;
1444 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Months ) )
1445 return Qgis::TemporalUnit::Months;
1446 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Years ) )
1447 return Qgis::TemporalUnit::Years;
1448 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Decades ) )
1449 return Qgis::TemporalUnit::Decades;
1450 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Centuries ) )
1451 return Qgis::TemporalUnit::Centuries;
1452 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::IrregularStep ) )
1453 return Qgis::TemporalUnit::IrregularStep;
1454 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Unknown ) )
1455 return Qgis::TemporalUnit::Unknown;
1460 return Qgis::TemporalUnit::Unknown;
1467 case Qgis::TemporalUnit::Seconds:
1468 return QObject::tr(
"seconds",
"temporal" );
1469 case Qgis::TemporalUnit::Milliseconds:
1470 return QObject::tr(
"milliseconds",
"temporal" );
1471 case Qgis::TemporalUnit::Minutes:
1472 return QObject::tr(
"minutes",
"temporal" );
1473 case Qgis::TemporalUnit::Hours:
1474 return QObject::tr(
"hours",
"temporal" );
1475 case Qgis::TemporalUnit::Days:
1476 return QObject::tr(
"days",
"temporal" );
1477 case Qgis::TemporalUnit::Weeks:
1478 return QObject::tr(
"weeks",
"temporal" );
1479 case Qgis::TemporalUnit::Months:
1480 return QObject::tr(
"months",
"temporal" );
1481 case Qgis::TemporalUnit::Years:
1482 return QObject::tr(
"years",
"temporal" );
1483 case Qgis::TemporalUnit::Decades:
1484 return QObject::tr(
"decades",
"temporal" );
1485 case Qgis::TemporalUnit::Centuries:
1486 return QObject::tr(
"centuries",
"temporal" );
1487 case Qgis::TemporalUnit::IrregularStep:
1488 return QObject::tr(
"steps",
"temporal" );
1489 case Qgis::TemporalUnit::Unknown:
1490 return QObject::tr(
"<unknown>",
"temporal" );
1499 case Qgis::TemporalUnit::Seconds:
1500 return QObject::tr(
"s",
"temporal" );
1501 case Qgis::TemporalUnit::Milliseconds:
1502 return QObject::tr(
"ms",
"temporal" );
1503 case Qgis::TemporalUnit::Minutes:
1504 return QObject::tr(
"min",
"temporal" );
1505 case Qgis::TemporalUnit::Hours:
1506 return QObject::tr(
"h",
"temporal" );
1507 case Qgis::TemporalUnit::Days:
1508 return QObject::tr(
"d",
"temporal" );
1509 case Qgis::TemporalUnit::Weeks:
1510 return QObject::tr(
"wk",
"temporal" );
1511 case Qgis::TemporalUnit::Months:
1512 return QObject::tr(
"mon",
"temporal" );
1513 case Qgis::TemporalUnit::Years:
1514 return QObject::tr(
"y",
"temporal" );
1515 case Qgis::TemporalUnit::Decades:
1516 return QObject::tr(
"dec",
"temporal" );
1517 case Qgis::TemporalUnit::Centuries:
1518 return QObject::tr(
"cen",
"temporal" );
1519 case Qgis::TemporalUnit::IrregularStep:
1520 return QObject::tr(
"steps",
"temporal" );
1521 case Qgis::TemporalUnit::Unknown:
1522 return QObject::tr(
"<unknown>",
"temporal" );
1529 const QString normalized =
string.trimmed().toLower();
1534 if ( normalized ==
toString( Qgis::TemporalUnit::Seconds ) )
1535 return Qgis::TemporalUnit::Seconds;
1536 if ( normalized ==
toString( Qgis::TemporalUnit::Milliseconds ) )
1537 return Qgis::TemporalUnit::Milliseconds;
1538 if ( normalized ==
toString( Qgis::TemporalUnit::Minutes ) )
1539 return Qgis::TemporalUnit::Minutes;
1540 if ( normalized ==
toString( Qgis::TemporalUnit::Hours ) )
1541 return Qgis::TemporalUnit::Hours;
1542 if ( normalized ==
toString( Qgis::TemporalUnit::Days ) )
1543 return Qgis::TemporalUnit::Days;
1544 if ( normalized ==
toString( Qgis::TemporalUnit::Weeks ) )
1545 return Qgis::TemporalUnit::Weeks;
1546 if ( normalized ==
toString( Qgis::TemporalUnit::Months ) )
1547 return Qgis::TemporalUnit::Months;
1548 if ( normalized ==
toString( Qgis::TemporalUnit::Years ) )
1549 return Qgis::TemporalUnit::Years;
1550 if ( normalized ==
toString( Qgis::TemporalUnit::Decades ) )
1551 return Qgis::TemporalUnit::Decades;
1552 if ( normalized ==
toString( Qgis::TemporalUnit::Centuries ) )
1553 return Qgis::TemporalUnit::Centuries;
1554 if ( normalized ==
toString( Qgis::TemporalUnit::IrregularStep ) )
1555 return Qgis::TemporalUnit::IrregularStep;
1556 if ( normalized ==
toString( Qgis::TemporalUnit::Unknown ) )
1557 return Qgis::TemporalUnit::Unknown;
1562 return Qgis::TemporalUnit::Unknown;
1569 case Qgis::TemporalUnit::Seconds:
1573 case Qgis::TemporalUnit::Seconds:
1575 case Qgis::TemporalUnit::Milliseconds:
1577 case Qgis::TemporalUnit::Minutes:
1579 case Qgis::TemporalUnit::Hours:
1581 case Qgis::TemporalUnit::Days:
1583 case Qgis::TemporalUnit::Weeks:
1584 return 1 / 604800.0;
1585 case Qgis::TemporalUnit::Months:
1586 return 1 / 2592000.0;
1587 case Qgis::TemporalUnit::Years:
1588 return 1 / 31557600.0;
1589 case Qgis::TemporalUnit::Decades:
1590 return 1 / 315576000.0;
1591 case Qgis::TemporalUnit::Centuries:
1592 return 1 / 3155760000.0;
1593 case Qgis::TemporalUnit::Unknown:
1594 case Qgis::TemporalUnit::IrregularStep:
1599 case Qgis::TemporalUnit::Milliseconds:
1603 case Qgis::TemporalUnit::Seconds:
1605 case Qgis::TemporalUnit::Milliseconds:
1607 case Qgis::TemporalUnit::Minutes:
1609 case Qgis::TemporalUnit::Hours:
1610 return 1 / 3600000.0;
1611 case Qgis::TemporalUnit::Days:
1612 return 1 / 86400000.0;
1613 case Qgis::TemporalUnit::Weeks:
1614 return 1 / 60480000.0;
1615 case Qgis::TemporalUnit::Months:
1616 return 1 / 259200000.0;
1617 case Qgis::TemporalUnit::Years:
1618 return 1 / 3155760000.0;
1619 case Qgis::TemporalUnit::Decades:
1620 return 1 / 31557600000.0;
1621 case Qgis::TemporalUnit::Centuries:
1622 return 1 / 315576000000.0;
1623 case Qgis::TemporalUnit::Unknown:
1624 case Qgis::TemporalUnit::IrregularStep:
1629 case Qgis::TemporalUnit::Minutes:
1633 case Qgis::TemporalUnit::Seconds:
1635 case Qgis::TemporalUnit::Milliseconds:
1637 case Qgis::TemporalUnit::Minutes:
1639 case Qgis::TemporalUnit::Hours:
1641 case Qgis::TemporalUnit::Days:
1643 case Qgis::TemporalUnit::Weeks:
1645 case Qgis::TemporalUnit::Months:
1647 case Qgis::TemporalUnit::Years:
1648 return 1 / 525960.0;
1649 case Qgis::TemporalUnit::Decades:
1650 return 1 / 5259600.0;
1651 case Qgis::TemporalUnit::Centuries:
1652 return 1 / 52596000.0;
1653 case Qgis::TemporalUnit::Unknown:
1654 case Qgis::TemporalUnit::IrregularStep:
1659 case Qgis::TemporalUnit::Hours:
1663 case Qgis::TemporalUnit::Seconds:
1665 case Qgis::TemporalUnit::Milliseconds:
1667 case Qgis::TemporalUnit::Minutes:
1669 case Qgis::TemporalUnit::Hours:
1671 case Qgis::TemporalUnit::Days:
1673 case Qgis::TemporalUnit::Weeks:
1675 case Qgis::TemporalUnit::Months:
1677 case Qgis::TemporalUnit::Years:
1679 case Qgis::TemporalUnit::Decades:
1681 case Qgis::TemporalUnit::Centuries:
1682 return 1 / 876600.0;
1683 case Qgis::TemporalUnit::Unknown:
1684 case Qgis::TemporalUnit::IrregularStep:
1689 case Qgis::TemporalUnit::Days:
1693 case Qgis::TemporalUnit::Seconds:
1695 case Qgis::TemporalUnit::Milliseconds:
1697 case Qgis::TemporalUnit::Minutes:
1699 case Qgis::TemporalUnit::Hours:
1701 case Qgis::TemporalUnit::Days:
1703 case Qgis::TemporalUnit::Weeks:
1705 case Qgis::TemporalUnit::Months:
1707 case Qgis::TemporalUnit::Years:
1709 case Qgis::TemporalUnit::Decades:
1711 case Qgis::TemporalUnit::Centuries:
1713 case Qgis::TemporalUnit::Unknown:
1714 case Qgis::TemporalUnit::IrregularStep:
1719 case Qgis::TemporalUnit::Weeks:
1723 case Qgis::TemporalUnit::Seconds:
1725 case Qgis::TemporalUnit::Milliseconds:
1727 case Qgis::TemporalUnit::Minutes:
1729 case Qgis::TemporalUnit::Hours:
1731 case Qgis::TemporalUnit::Days:
1733 case Qgis::TemporalUnit::Weeks:
1735 case Qgis::TemporalUnit::Months:
1737 case Qgis::TemporalUnit::Years:
1739 case Qgis::TemporalUnit::Decades:
1741 case Qgis::TemporalUnit::Centuries:
1743 case Qgis::TemporalUnit::Unknown:
1744 case Qgis::TemporalUnit::IrregularStep:
1749 case Qgis::TemporalUnit::Months:
1753 case Qgis::TemporalUnit::Seconds:
1755 case Qgis::TemporalUnit::Milliseconds:
1756 return 2592000000.0;
1757 case Qgis::TemporalUnit::Minutes:
1759 case Qgis::TemporalUnit::Hours:
1761 case Qgis::TemporalUnit::Days:
1763 case Qgis::TemporalUnit::Weeks:
1765 case Qgis::TemporalUnit::Months:
1767 case Qgis::TemporalUnit::Years:
1769 case Qgis::TemporalUnit::Decades:
1771 case Qgis::TemporalUnit::Centuries:
1772 return 30 / 36525.0;
1773 case Qgis::TemporalUnit::Unknown:
1774 case Qgis::TemporalUnit::IrregularStep:
1779 case Qgis::TemporalUnit::Years:
1783 case Qgis::TemporalUnit::Seconds:
1785 case Qgis::TemporalUnit::Milliseconds:
1786 return 31557600000.0;
1787 case Qgis::TemporalUnit::Minutes:
1789 case Qgis::TemporalUnit::Hours:
1791 case Qgis::TemporalUnit::Days:
1793 case Qgis::TemporalUnit::Weeks:
1794 return 365.25 / 7.0;
1795 case Qgis::TemporalUnit::Months:
1796 return 365.25 / 30.0;
1797 case Qgis::TemporalUnit::Years:
1799 case Qgis::TemporalUnit::Decades:
1801 case Qgis::TemporalUnit::Centuries:
1803 case Qgis::TemporalUnit::Unknown:
1804 case Qgis::TemporalUnit::IrregularStep:
1809 case Qgis::TemporalUnit::Decades:
1813 case Qgis::TemporalUnit::Seconds:
1815 case Qgis::TemporalUnit::Milliseconds:
1816 return 315576000000.0;
1817 case Qgis::TemporalUnit::Minutes:
1819 case Qgis::TemporalUnit::Hours:
1821 case Qgis::TemporalUnit::Days:
1823 case Qgis::TemporalUnit::Weeks:
1824 return 3652.5 / 7.0;
1825 case Qgis::TemporalUnit::Months:
1826 return 3652.5 / 30.0;
1827 case Qgis::TemporalUnit::Years:
1829 case Qgis::TemporalUnit::Decades:
1831 case Qgis::TemporalUnit::Centuries:
1833 case Qgis::TemporalUnit::Unknown:
1834 case Qgis::TemporalUnit::IrregularStep:
1840 case Qgis::TemporalUnit::Centuries:
1844 case Qgis::TemporalUnit::Seconds:
1845 return 3155760000.0;
1846 case Qgis::TemporalUnit::Milliseconds:
1847 return 3155760000000.0;
1848 case Qgis::TemporalUnit::Minutes:
1850 case Qgis::TemporalUnit::Hours:
1852 case Qgis::TemporalUnit::Days:
1854 case Qgis::TemporalUnit::Weeks:
1856 case Qgis::TemporalUnit::Months:
1857 return 36525 / 30.0;
1858 case Qgis::TemporalUnit::Years:
1860 case Qgis::TemporalUnit::Decades:
1862 case Qgis::TemporalUnit::Centuries:
1864 case Qgis::TemporalUnit::Unknown:
1865 case Qgis::TemporalUnit::IrregularStep:
1871 case Qgis::TemporalUnit::Unknown:
1872 case Qgis::TemporalUnit::IrregularStep:
1882 const QString normalized =
string.trimmed().toLower();
1887 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicMeters ) )
1888 return Qgis::VolumeUnit::CubicMeters;
1889 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicFeet ) )
1890 return Qgis::VolumeUnit::CubicFeet;
1891 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicYards ) )
1892 return Qgis::VolumeUnit::CubicYards;
1893 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Barrel ) )
1894 return Qgis::VolumeUnit::Barrel;
1895 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicDecimeter ) )
1896 return Qgis::VolumeUnit::CubicDecimeter;
1897 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Liters ) )
1898 return Qgis::VolumeUnit::Liters;
1899 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::GallonUS ) )
1900 return Qgis::VolumeUnit::GallonUS;
1901 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicInch ) )
1902 return Qgis::VolumeUnit::CubicInch;
1903 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicCentimeter ) )
1904 return Qgis::VolumeUnit::CubicCentimeter;
1905 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicDegrees ) )
1906 return Qgis::VolumeUnit::CubicDegrees;
1907 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Unknown ) )
1908 return Qgis::VolumeUnit::Unknown;
1913 return Qgis::VolumeUnit::Unknown;
1920 case Qgis::VolumeUnit::CubicMeters:
1921 return QObject::tr(
"cubic meters",
"volume" );
1922 case Qgis::VolumeUnit::CubicFeet:
1923 return QObject::tr(
"cubic feet",
"volume" );
1924 case Qgis::VolumeUnit::CubicYards:
1925 return QObject::tr(
"cubic yards",
"volume" );
1926 case Qgis::VolumeUnit::Barrel:
1927 return QObject::tr(
"barrels",
"volume" );
1928 case Qgis::VolumeUnit::CubicDecimeter:
1929 return QObject::tr(
"cubic decimeters",
"volume" );
1930 case Qgis::VolumeUnit::Liters:
1931 return QObject::tr(
"liters",
"volume" );
1932 case Qgis::VolumeUnit::GallonUS:
1933 return QObject::tr(
"gallons",
"volume" );
1934 case Qgis::VolumeUnit::CubicInch:
1935 return QObject::tr(
"cubic inches",
"volume" );
1936 case Qgis::VolumeUnit::CubicCentimeter:
1937 return QObject::tr(
"cubic centimeters",
"volume" );
1938 case Qgis::VolumeUnit::CubicDegrees:
1939 return QObject::tr(
"cubic degrees",
"volume" );
1940 case Qgis::VolumeUnit::Unknown:
1941 return QObject::tr(
"<unknown>",
"volume" );
1950 case Qgis::VolumeUnit::CubicMeters:
1951 return QObject::tr(
"m³",
"volume" );
1952 case Qgis::VolumeUnit::CubicFeet:
1953 return QObject::tr(
"ft³",
"volume" );
1954 case Qgis::VolumeUnit::CubicYards:
1955 return QObject::tr(
"yds³",
"volume" );
1956 case Qgis::VolumeUnit::Barrel:
1957 return QObject::tr(
"bbl",
"volume" );
1958 case Qgis::VolumeUnit::CubicDecimeter:
1959 return QObject::tr(
"dm³",
"volume" );
1960 case Qgis::VolumeUnit::Liters:
1961 return QObject::tr(
"l",
"volume" );
1962 case Qgis::VolumeUnit::GallonUS:
1963 return QObject::tr(
"gal",
"volume" );
1964 case Qgis::VolumeUnit::CubicInch:
1965 return QObject::tr(
"in³",
"volume" );
1966 case Qgis::VolumeUnit::CubicCentimeter:
1967 return QObject::tr(
"cm³",
"volume" );
1968 case Qgis::VolumeUnit::CubicDegrees:
1969 return QObject::tr(
"deg³",
"volume" );
1970 case Qgis::VolumeUnit::Unknown:
1971 return QObject::tr(
"<unknown>",
"volume" );
1979 const QString normalized =
string.trimmed().toLower();
1984 if ( normalized ==
toString( Qgis::VolumeUnit::CubicMeters ) )
1985 return Qgis::VolumeUnit::CubicMeters;
1986 if ( normalized ==
toString( Qgis::VolumeUnit::CubicFeet ) )
1987 return Qgis::VolumeUnit::CubicFeet;
1988 if ( normalized ==
toString( Qgis::VolumeUnit::CubicYards ) )
1989 return Qgis::VolumeUnit::CubicYards;
1990 if ( normalized ==
toString( Qgis::VolumeUnit::Barrel ) )
1991 return Qgis::VolumeUnit::Barrel;
1992 if ( normalized ==
toString( Qgis::VolumeUnit::CubicDecimeter ) )
1993 return Qgis::VolumeUnit::CubicDecimeter;
1994 if ( normalized ==
toString( Qgis::VolumeUnit::Liters ) )
1995 return Qgis::VolumeUnit::Liters;
1996 if ( normalized ==
toString( Qgis::VolumeUnit::GallonUS ) )
1997 return Qgis::VolumeUnit::GallonUS;
1998 if ( normalized ==
toString( Qgis::VolumeUnit::CubicInch ) )
1999 return Qgis::VolumeUnit::CubicInch;
2000 if ( normalized ==
toString( Qgis::VolumeUnit::CubicCentimeter ) )
2001 return Qgis::VolumeUnit::CubicCentimeter;
2002 if ( normalized ==
toString( Qgis::VolumeUnit::CubicDegrees ) )
2003 return Qgis::VolumeUnit::CubicDegrees;
2004 if ( normalized ==
toString( Qgis::VolumeUnit::Unknown ) )
2005 return Qgis::VolumeUnit::Unknown;
2010 return Qgis::VolumeUnit::Unknown;
2013#define DEG2_TO_M3 1379474361572186.2
2018 case Qgis::VolumeUnit::CubicMeters:
2022 case Qgis::VolumeUnit::CubicMeters:
2024 case Qgis::VolumeUnit::CubicFeet:
2025 return 35.314666572222;
2026 case Qgis::VolumeUnit::CubicYards:
2027 return 1.307950613786;
2028 case Qgis::VolumeUnit::Barrel:
2029 return 6.2898107438466;
2030 case Qgis::VolumeUnit::CubicDecimeter:
2032 case Qgis::VolumeUnit::Liters:
2034 case Qgis::VolumeUnit::GallonUS:
2035 return 264.17205124156;
2036 case Qgis::VolumeUnit::CubicInch:
2037 return 61023.7438368;
2038 case Qgis::VolumeUnit::CubicCentimeter:
2040 case Qgis::VolumeUnit::CubicDegrees:
2042 case Qgis::VolumeUnit::Unknown:
2047 case Qgis::VolumeUnit::CubicFeet:
2051 case Qgis::VolumeUnit::CubicMeters:
2052 return 0.028316846592;
2053 case Qgis::VolumeUnit::CubicFeet:
2055 case Qgis::VolumeUnit::CubicYards:
2057 case Qgis::VolumeUnit::Barrel:
2059 case Qgis::VolumeUnit::CubicDecimeter:
2061 case Qgis::VolumeUnit::Liters:
2063 case Qgis::VolumeUnit::GallonUS:
2065 case Qgis::VolumeUnit::CubicInch:
2066 return 1728.000629765;
2067 case Qgis::VolumeUnit::CubicCentimeter:
2069 case Qgis::VolumeUnit::CubicDegrees:
2071 case Qgis::VolumeUnit::Unknown:
2076 case Qgis::VolumeUnit::CubicYards:
2080 case Qgis::VolumeUnit::CubicMeters:
2082 case Qgis::VolumeUnit::CubicFeet:
2083 return 26.999998234;
2084 case Qgis::VolumeUnit::CubicYards:
2086 case Qgis::VolumeUnit::Barrel:
2088 case Qgis::VolumeUnit::CubicDecimeter:
2090 case Qgis::VolumeUnit::Liters:
2092 case Qgis::VolumeUnit::GallonUS:
2093 return 201.974025549;
2094 case Qgis::VolumeUnit::CubicInch:
2095 return 46656.013952472;
2096 case Qgis::VolumeUnit::CubicCentimeter:
2098 case Qgis::VolumeUnit::CubicDegrees:
2100 case Qgis::VolumeUnit::Unknown:
2105 case Qgis::VolumeUnit::Barrel:
2109 case Qgis::VolumeUnit::CubicMeters:
2111 case Qgis::VolumeUnit::CubicFeet:
2113 case Qgis::VolumeUnit::CubicYards:
2115 case Qgis::VolumeUnit::Barrel:
2117 case Qgis::VolumeUnit::CubicDecimeter:
2119 case Qgis::VolumeUnit::Liters:
2121 case Qgis::VolumeUnit::GallonUS:
2122 return 41.999998943;
2123 case Qgis::VolumeUnit::CubicInch:
2124 return 9702.002677722;
2125 case Qgis::VolumeUnit::CubicCentimeter:
2127 case Qgis::VolumeUnit::CubicDegrees:
2129 case Qgis::VolumeUnit::Unknown:
2134 case Qgis::VolumeUnit::CubicDecimeter:
2135 case Qgis::VolumeUnit::Liters:
2139 case Qgis::VolumeUnit::CubicMeters:
2141 case Qgis::VolumeUnit::CubicFeet:
2143 case Qgis::VolumeUnit::CubicYards:
2145 case Qgis::VolumeUnit::Barrel:
2147 case Qgis::VolumeUnit::CubicDecimeter:
2148 case Qgis::VolumeUnit::Liters:
2150 case Qgis::VolumeUnit::GallonUS:
2152 case Qgis::VolumeUnit::CubicInch:
2153 return 61.023758990;
2154 case Qgis::VolumeUnit::CubicCentimeter:
2156 case Qgis::VolumeUnit::CubicDegrees:
2158 case Qgis::VolumeUnit::Unknown:
2163 case Qgis::VolumeUnit::GallonUS:
2167 case Qgis::VolumeUnit::CubicMeters:
2169 case Qgis::VolumeUnit::CubicFeet:
2171 case Qgis::VolumeUnit::CubicYards:
2173 case Qgis::VolumeUnit::Barrel:
2175 case Qgis::VolumeUnit::CubicDecimeter:
2176 case Qgis::VolumeUnit::Liters:
2178 case Qgis::VolumeUnit::GallonUS:
2180 case Qgis::VolumeUnit::CubicInch:
2181 return 231.000069567;
2182 case Qgis::VolumeUnit::CubicCentimeter:
2184 case Qgis::VolumeUnit::CubicDegrees:
2186 case Qgis::VolumeUnit::Unknown:
2191 case Qgis::VolumeUnit::CubicInch:
2195 case Qgis::VolumeUnit::CubicMeters:
2197 case Qgis::VolumeUnit::CubicFeet:
2199 case Qgis::VolumeUnit::CubicYards:
2201 case Qgis::VolumeUnit::Barrel:
2203 case Qgis::VolumeUnit::CubicDecimeter:
2204 case Qgis::VolumeUnit::Liters:
2206 case Qgis::VolumeUnit::GallonUS:
2208 case Qgis::VolumeUnit::CubicInch:
2210 case Qgis::VolumeUnit::CubicCentimeter:
2211 return 16.387060000;
2212 case Qgis::VolumeUnit::CubicDegrees:
2214 case Qgis::VolumeUnit::Unknown:
2219 case Qgis::VolumeUnit::CubicCentimeter:
2223 case Qgis::VolumeUnit::CubicMeters:
2225 case Qgis::VolumeUnit::CubicFeet:
2227 case Qgis::VolumeUnit::CubicYards:
2229 case Qgis::VolumeUnit::Barrel:
2231 case Qgis::VolumeUnit::CubicDecimeter:
2232 case Qgis::VolumeUnit::Liters:
2234 case Qgis::VolumeUnit::GallonUS:
2235 return 0.000264172 ;
2236 case Qgis::VolumeUnit::CubicInch:
2238 case Qgis::VolumeUnit::CubicCentimeter:
2240 case Qgis::VolumeUnit::CubicDegrees:
2242 case Qgis::VolumeUnit::Unknown:
2247 case Qgis::VolumeUnit::CubicDegrees:
2248 if ( toUnit == Qgis::VolumeUnit::Unknown || toUnit == Qgis::VolumeUnit::CubicDegrees )
2253 case Qgis::VolumeUnit::Unknown:
2263 switch ( distanceUnit )
2265 case Qgis::DistanceUnit::Meters:
2266 return Qgis::VolumeUnit::CubicMeters;
2268 case Qgis::DistanceUnit::Kilometers:
2269 return Qgis::VolumeUnit::CubicMeters;
2271 case Qgis::DistanceUnit::Centimeters:
2272 return Qgis::VolumeUnit::CubicCentimeter;
2274 case Qgis::DistanceUnit::Millimeters:
2275 return Qgis::VolumeUnit::CubicCentimeter;
2277 case Qgis::DistanceUnit::Feet:
2278 return Qgis::VolumeUnit::CubicFeet;
2280 case Qgis::DistanceUnit::Yards:
2281 return Qgis::VolumeUnit::CubicYards;
2283 case Qgis::DistanceUnit::Miles:
2284 return Qgis::VolumeUnit::CubicFeet;
2286 case Qgis::DistanceUnit::Degrees:
2287 return Qgis::VolumeUnit::CubicDegrees;
2289 case Qgis::DistanceUnit::Unknown:
2290 return Qgis::VolumeUnit::Unknown;
2292 case Qgis::DistanceUnit::NauticalMiles:
2293 return Qgis::VolumeUnit::CubicFeet;
2296 return Qgis::VolumeUnit::CubicInch;
2299 return Qgis::VolumeUnit::Unknown;
2304 switch ( volumeUnit )
2306 case Qgis::VolumeUnit::CubicMeters:
2307 return Qgis::DistanceUnit::Meters;
2308 case Qgis::VolumeUnit::CubicFeet:
2309 return Qgis::DistanceUnit::Feet;
2310 case Qgis::VolumeUnit::CubicYards:
2311 return Qgis::DistanceUnit::Yards;
2312 case Qgis::VolumeUnit::Barrel:
2313 return Qgis::DistanceUnit::Feet;
2314 case Qgis::VolumeUnit::CubicDecimeter:
2315 return Qgis::DistanceUnit::Centimeters;
2316 case Qgis::VolumeUnit::Liters:
2317 return Qgis::DistanceUnit::Meters;
2318 case Qgis::VolumeUnit::GallonUS:
2319 return Qgis::DistanceUnit::Feet;
2320 case Qgis::VolumeUnit::CubicInch:
2322 case Qgis::VolumeUnit::CubicCentimeter:
2323 return Qgis::DistanceUnit::Centimeters;
2324 case Qgis::VolumeUnit::CubicDegrees:
2325 return Qgis::DistanceUnit::Degrees;
2326 case Qgis::VolumeUnit::Unknown:
2327 return Qgis::DistanceUnit::Unknown;
2329 return Qgis::DistanceUnit::Unknown;
2336 case Qgis::VolumeUnit::CubicMeters:
2337 case Qgis::VolumeUnit::CubicFeet:
2338 case Qgis::VolumeUnit::CubicYards:
2339 case Qgis::VolumeUnit::Barrel:
2340 case Qgis::VolumeUnit::CubicDecimeter:
2341 case Qgis::VolumeUnit::Liters:
2342 case Qgis::VolumeUnit::GallonUS:
2343 case Qgis::VolumeUnit::CubicInch:
2344 case Qgis::VolumeUnit::CubicCentimeter:
2346 case Qgis::VolumeUnit::CubicDegrees:
2348 case Qgis::VolumeUnit::Unknown:
2349 return Qgis::DistanceUnitType::Unknown;
2351 return Qgis::DistanceUnitType::Unknown;
2358 case Qgis::VolumeUnit::CubicMeters:
2359 return QStringLiteral(
"m3" );
2360 case Qgis::VolumeUnit::CubicFeet:
2361 return QStringLiteral(
"ft3" );
2362 case Qgis::VolumeUnit::CubicYards:
2363 return QStringLiteral(
"yd3" );
2364 case Qgis::VolumeUnit::Barrel:
2365 return QStringLiteral(
"bbl" );
2366 case Qgis::VolumeUnit::CubicDecimeter:
2367 return QStringLiteral(
"dm3" );
2368 case Qgis::VolumeUnit::Liters:
2369 return QStringLiteral(
"l" );
2370 case Qgis::VolumeUnit::GallonUS:
2371 return QStringLiteral(
"gal" );
2372 case Qgis::VolumeUnit::CubicInch:
2373 return QStringLiteral(
"in3" );
2374 case Qgis::VolumeUnit::CubicCentimeter:
2375 return QStringLiteral(
"cm3" );
2376 case Qgis::VolumeUnit::CubicDegrees:
2377 return QStringLiteral(
"deg3" );
2378 case Qgis::VolumeUnit::Unknown:
2379 return QStringLiteral(
"<unknown>" );
2388 case Qgis::AngleUnit::Degrees:
2389 return QStringLiteral(
"degrees" );
2390 case Qgis::AngleUnit::Radians:
2391 return QStringLiteral(
"radians" );
2392 case Qgis::AngleUnit::Gon:
2393 return QStringLiteral(
"gon" );
2394 case Qgis::AngleUnit::MinutesOfArc:
2395 return QStringLiteral(
"moa" );
2396 case Qgis::AngleUnit::SecondsOfArc:
2397 return QStringLiteral(
"soa" );
2398 case Qgis::AngleUnit::Turn:
2399 return QStringLiteral(
"tr" );
2400 case Qgis::AngleUnit::MilliradiansSI:
2401 return QStringLiteral(
"milliradians" );
2402 case Qgis::AngleUnit::MilNATO:
2403 return QStringLiteral(
"mil" );
2404 case Qgis::AngleUnit::Unknown:
2405 return QStringLiteral(
"<unknown>" );
2412 const QString normalized =
string.trimmed().toLower();
2417 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Degrees ) )
2418 return Qgis::AngleUnit::Degrees;
2419 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Radians ) )
2420 return Qgis::AngleUnit::Radians;
2421 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Gon ) )
2422 return Qgis::AngleUnit::Gon;
2423 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MinutesOfArc ) )
2424 return Qgis::AngleUnit::MinutesOfArc;
2425 if ( normalized ==
encodeUnit( Qgis::AngleUnit::SecondsOfArc ) )
2426 return Qgis::AngleUnit::SecondsOfArc;
2427 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Turn ) )
2428 return Qgis::AngleUnit::Turn;
2429 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MilliradiansSI ) )
2430 return Qgis::AngleUnit::MilliradiansSI;
2431 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MilNATO ) )
2432 return Qgis::AngleUnit::MilNATO;
2433 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Unknown ) )
2434 return Qgis::AngleUnit::Unknown;
2438 return Qgis::AngleUnit::Unknown;
2445 case Qgis::AngleUnit::Degrees:
2446 return QObject::tr(
"degrees",
"angle" );
2447 case Qgis::AngleUnit::Radians:
2448 return QObject::tr(
"radians",
"angle" );
2449 case Qgis::AngleUnit::Gon:
2450 return QObject::tr(
"gon",
"angle" );
2451 case Qgis::AngleUnit::MinutesOfArc:
2452 return QObject::tr(
"minutes of arc",
"angle" );
2453 case Qgis::AngleUnit::SecondsOfArc:
2454 return QObject::tr(
"seconds of arc",
"angle" );
2455 case Qgis::AngleUnit::Turn:
2456 return QObject::tr(
"turns",
"angle" );
2457 case Qgis::AngleUnit::MilliradiansSI:
2458 return QObject::tr(
"milliradians",
"angle" );
2459 case Qgis::AngleUnit::MilNATO:
2460 return QObject::tr(
"mil",
"angle" );
2461 case Qgis::AngleUnit::Unknown:
2462 return QObject::tr(
"<unknown>",
"angle" );
2472 case Qgis::AngleUnit::Degrees:
2476 case Qgis::AngleUnit::Degrees:
2478 case Qgis::AngleUnit::Radians:
2479 return M_PI / 180.0;
2480 case Qgis::AngleUnit::Gon:
2481 return 400.0 / 360.0;
2482 case Qgis::AngleUnit::MinutesOfArc:
2484 case Qgis::AngleUnit::SecondsOfArc:
2486 case Qgis::AngleUnit::Turn:
2488 case Qgis::AngleUnit::MilliradiansSI:
2489 return M_PI / 180.0 * 1000;
2490 case Qgis::AngleUnit::MilNATO:
2491 return 3200.0 / 180;
2492 case Qgis::AngleUnit::Unknown:
2497 case Qgis::AngleUnit::Radians:
2501 case Qgis::AngleUnit::Degrees:
2502 return 180.0 / M_PI;
2503 case Qgis::AngleUnit::Radians:
2505 case Qgis::AngleUnit::Gon:
2506 return 200.0 / M_PI;
2507 case Qgis::AngleUnit::MinutesOfArc:
2508 return 60 * 180.0 / M_PI;
2509 case Qgis::AngleUnit::SecondsOfArc:
2510 return 3600 * 180.0 / M_PI;
2511 case Qgis::AngleUnit::Turn:
2513 case Qgis::AngleUnit::MilliradiansSI:
2515 case Qgis::AngleUnit::MilNATO:
2516 return 3200.0 / M_PI;
2517 case Qgis::AngleUnit::Unknown:
2522 case Qgis::AngleUnit::Gon:
2526 case Qgis::AngleUnit::Degrees:
2527 return 360.0 / 400.0;
2528 case Qgis::AngleUnit::Radians:
2529 return M_PI / 200.0;
2530 case Qgis::AngleUnit::Gon:
2532 case Qgis::AngleUnit::MinutesOfArc:
2533 return 60 * 360.0 / 400.0;
2534 case Qgis::AngleUnit::SecondsOfArc:
2535 return 3600 * 360.0 / 400.0;
2536 case Qgis::AngleUnit::Turn:
2538 case Qgis::AngleUnit::MilliradiansSI:
2539 return M_PI / 200.0 * 1000;
2540 case Qgis::AngleUnit::MilNATO:
2541 return 3200.0 / 200.0;
2542 case Qgis::AngleUnit::Unknown:
2547 case Qgis::AngleUnit::MinutesOfArc:
2551 case Qgis::AngleUnit::Degrees:
2553 case Qgis::AngleUnit::Radians:
2554 return M_PI / 180.0 / 60.0;
2555 case Qgis::AngleUnit::Gon:
2556 return 400.0 / 360.0 / 60.0;
2557 case Qgis::AngleUnit::MinutesOfArc:
2559 case Qgis::AngleUnit::SecondsOfArc:
2561 case Qgis::AngleUnit::Turn:
2562 return 1.0 / 360.0 / 60.0;
2563 case Qgis::AngleUnit::MilliradiansSI:
2564 return M_PI / 180.0 / 60.0 * 1000;
2565 case Qgis::AngleUnit::MilNATO:
2566 return 3200.0 / 180.0 / 60.0;
2567 case Qgis::AngleUnit::Unknown:
2572 case Qgis::AngleUnit::SecondsOfArc:
2576 case Qgis::AngleUnit::Degrees:
2578 case Qgis::AngleUnit::Radians:
2579 return M_PI / 180.0 / 3600.0;
2580 case Qgis::AngleUnit::Gon:
2581 return 400.0 / 360.0 / 3600.0;
2582 case Qgis::AngleUnit::MinutesOfArc:
2584 case Qgis::AngleUnit::SecondsOfArc:
2586 case Qgis::AngleUnit::Turn:
2587 return 1.0 / 360.0 / 3600.0;
2588 case Qgis::AngleUnit::MilliradiansSI:
2589 return M_PI / 180.0 / 3600.0 * 1000;
2590 case Qgis::AngleUnit::MilNATO:
2591 return 3200.0 / 180.0 / 3600.0;
2592 case Qgis::AngleUnit::Unknown:
2597 case Qgis::AngleUnit::Turn:
2601 case Qgis::AngleUnit::Degrees:
2603 case Qgis::AngleUnit::Radians:
2605 case Qgis::AngleUnit::Gon:
2607 case Qgis::AngleUnit::MinutesOfArc:
2608 return 360.0 * 60.0;
2609 case Qgis::AngleUnit::SecondsOfArc:
2610 return 360.0 * 3600.0;
2611 case Qgis::AngleUnit::Turn:
2613 case Qgis::AngleUnit::MilliradiansSI:
2614 return 2 * M_PI * 1000;
2615 case Qgis::AngleUnit::MilNATO:
2617 case Qgis::AngleUnit::Unknown:
2622 case Qgis::AngleUnit::MilliradiansSI:
2626 case Qgis::AngleUnit::Degrees:
2627 return 180.0 / M_PI / 1000;
2628 case Qgis::AngleUnit::Radians:
2630 case Qgis::AngleUnit::Gon:
2631 return 200.0 / M_PI / 1000;
2632 case Qgis::AngleUnit::MinutesOfArc:
2633 return 180.0 * 60.0 / M_PI / 1000;
2634 case Qgis::AngleUnit::SecondsOfArc:
2635 return 180.0 * 3600.0 / M_PI / 1000;
2636 case Qgis::AngleUnit::Turn:
2637 return M_PI / 2 / 1000;
2638 case Qgis::AngleUnit::MilliradiansSI:
2640 case Qgis::AngleUnit::MilNATO:
2641 return 3200.0 / 1000.0 / M_PI;
2642 case Qgis::AngleUnit::Unknown:
2648 case Qgis::AngleUnit::MilNATO:
2652 case Qgis::AngleUnit::Degrees:
2653 return 180.0 / 3200;
2654 case Qgis::AngleUnit::Radians:
2656 case Qgis::AngleUnit::Gon:
2657 return 200.0 / 3200;
2658 case Qgis::AngleUnit::MinutesOfArc:
2659 return 60 * 180.0 / 3200;
2660 case Qgis::AngleUnit::SecondsOfArc:
2661 return 3600.0 * 180 / 3200;
2662 case Qgis::AngleUnit::Turn:
2663 return 1.0 / ( 2 * 32000 );
2664 case Qgis::AngleUnit::MilliradiansSI:
2665 return 1000.0 * M_PI / 3200.0;
2666 case Qgis::AngleUnit::MilNATO:
2668 case Qgis::AngleUnit::Unknown:
2674 case Qgis::AngleUnit::Unknown:
2683 int decimalPlaces = 2;
2687 case Qgis::AngleUnit::Degrees:
2688 unitLabel = QObject::tr(
"°",
"angle" );
2691 case Qgis::AngleUnit::Radians:
2692 unitLabel = QObject::tr(
" rad",
"angle" );
2695 case Qgis::AngleUnit::Gon:
2696 unitLabel = QObject::tr(
" gon",
"angle" );
2699 case Qgis::AngleUnit::MinutesOfArc:
2700 unitLabel = QObject::tr(
"′",
"angle minutes" );
2703 case Qgis::AngleUnit::SecondsOfArc:
2704 unitLabel = QObject::tr(
"″",
"angle seconds" );
2707 case Qgis::AngleUnit::Turn:
2708 unitLabel = QObject::tr(
" tr",
"angle turn" );
2711 case Qgis::AngleUnit::MilliradiansSI:
2712 unitLabel = QObject::tr(
" millirad",
"angular mil SI" );
2715 case Qgis::AngleUnit::MilNATO:
2716 unitLabel = QObject::tr(
" mil",
"angular mil NATO" );
2719 case Qgis::AngleUnit::Unknown:
2723 if ( decimals >= 0 )
2724 decimalPlaces = decimals;
2726 return QStringLiteral(
"%L1%2" ).arg(
angle, 0,
'f', decimalPlaces ).arg( unitLabel );
2735 case Qgis::DistanceUnit::Meters:
2739 result.
unit = Qgis::DistanceUnit::Meters;
2741 else if ( std::fabs( distance ) > 1000.0 )
2744 result.
unit = Qgis::DistanceUnit::Kilometers;
2746 else if ( std::fabs( distance ) < 0.01 )
2749 result.
unit = Qgis::DistanceUnit::Millimeters;
2751 else if ( std::fabs( distance ) < 0.1 )
2755 result.
unit = Qgis::DistanceUnit::Centimeters;
2760 result.
unit = Qgis::DistanceUnit::Meters;
2764 case Qgis::DistanceUnit::Kilometers:
2765 if ( keepBaseUnit || std::fabs( distance ) >= 1.0 )
2768 result.
unit = Qgis::DistanceUnit::Kilometers;
2773 result.
unit = Qgis::DistanceUnit::Meters;
2777 case Qgis::DistanceUnit::Feet:
2778 if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit )
2781 result.
unit = Qgis::DistanceUnit::Feet;
2786 result.
unit = Qgis::DistanceUnit::Miles;
2790 case Qgis::DistanceUnit::Yards:
2791 if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit )
2794 result.
unit = Qgis::DistanceUnit::Yards;
2799 result.
unit = Qgis::DistanceUnit::Miles;
2803 case Qgis::DistanceUnit::Miles:
2804 if ( std::fabs( distance ) >= 1.0 || keepBaseUnit )
2807 result.
unit = Qgis::DistanceUnit::Miles;
2812 result.
unit = Qgis::DistanceUnit::Feet;
2816 case Qgis::DistanceUnit::NauticalMiles:
2818 result.
unit = Qgis::DistanceUnit::NauticalMiles;
2821 case Qgis::DistanceUnit::Degrees:
2823 result.
unit = Qgis::DistanceUnit::Degrees;
2826 case Qgis::DistanceUnit::Unknown:
2828 result.
unit = Qgis::DistanceUnit::Unknown;
2843 result.
value = -1.0;
2844 result.
unit = Qgis::AreaUnit::Unknown;
2847 if ( unit == Qgis::AreaUnit::SquareMillimeters )
2852 result.
unit = Qgis::AreaUnit::SquareMillimeters;
2857 unit = Qgis::AreaUnit::SquareMeters;
2860 else if ( unit == Qgis::AreaUnit::SquareCentimeters )
2865 result.
unit = Qgis::AreaUnit::SquareCentimeters;
2870 unit = Qgis::AreaUnit::SquareMeters;
2876 case Qgis::AreaUnit::SquareCentimeters:
2879 case Qgis::AreaUnit::SquareMillimeters:
2882 case Qgis::AreaUnit::SquareMeters:
2887 result.
unit = Qgis::AreaUnit::SquareMeters;
2892 result.
unit = Qgis::AreaUnit::SquareKilometers;
2897 result.
unit = Qgis::AreaUnit::Hectares;
2902 result.
unit = Qgis::AreaUnit::SquareMeters;
2907 case Qgis::AreaUnit::SquareKilometers:
2910 result.
unit = Qgis::AreaUnit::SquareKilometers;
2921 case Qgis::AreaUnit::SquareFeet:
2926 result.
unit = Qgis::AreaUnit::SquareFeet;
2931 result.
unit = Qgis::AreaUnit::SquareMiles;
2936 result.
unit = Qgis::AreaUnit::SquareFeet;
2941 case Qgis::AreaUnit::SquareYards:
2946 result.
unit = Qgis::AreaUnit::SquareYards;
2951 result.
unit = Qgis::AreaUnit::SquareMiles;
2956 result.
unit = Qgis::AreaUnit::SquareYards;
2961 case Qgis::AreaUnit::SquareMiles:
2964 result.
unit = Qgis::AreaUnit::SquareMiles;
2968 case Qgis::AreaUnit::Hectares:
2973 result.
unit = Qgis::AreaUnit::Hectares;
2978 result.
unit = Qgis::AreaUnit::SquareKilometers;
2983 result.
unit = Qgis::AreaUnit::Hectares;
2988 case Qgis::AreaUnit::Acres:
2993 result.
unit = Qgis::AreaUnit::Acres;
2998 result.
unit = Qgis::AreaUnit::SquareMiles;
3003 result.
unit = Qgis::AreaUnit::Acres;
3008 case Qgis::AreaUnit::SquareNauticalMiles:
3011 result.
unit = Qgis::AreaUnit::SquareNauticalMiles;
3015 case Qgis::AreaUnit::SquareDegrees:
3018 result.
unit = Qgis::AreaUnit::SquareDegrees;
3022 case Qgis::AreaUnit::Unknown:
3025 result.
unit = Qgis::AreaUnit::Unknown;
3039 if ( dist.
unit != Qgis::DistanceUnit::Unknown )
3045 return QStringLiteral(
"%L1%2" ).arg( distance, 0,
'e', decimals ).arg( unitText );
3049 return QStringLiteral(
"%L1%2" ).arg( dist.
value, 0,
'f', decimals ).arg( unitText );
3059 if ( areaValue.
unit != Qgis::AreaUnit::Unknown )
3065 return QStringLiteral(
"%L1%2" ).arg( area, 0,
'e', decimals ).arg( unitText );
3069 return QStringLiteral(
"%L1%2" ).arg( areaValue.
value, 0,
'f', decimals ).arg( unitText );
3077 case Qgis::RenderUnit::Millimeters:
3078 return QStringLiteral(
"MM" );
3079 case Qgis::RenderUnit::MetersInMapUnits:
3080 return QStringLiteral(
"RenderMetersInMapUnits" );
3081 case Qgis::RenderUnit::MapUnits:
3082 return QStringLiteral(
"MapUnit" );
3083 case Qgis::RenderUnit::Pixels:
3084 return QStringLiteral(
"Pixel" );
3085 case Qgis::RenderUnit::Percentage:
3086 return QStringLiteral(
"Percentage" );
3087 case Qgis::RenderUnit::Points:
3088 return QStringLiteral(
"Point" );
3089 case Qgis::RenderUnit::Inches:
3090 return QStringLiteral(
"Inch" );
3091 case Qgis::RenderUnit::Unknown:
3099 const QString normalized =
string.trimmed().toLower();
3104 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Millimeters ).toLower() )
3105 return Qgis::RenderUnit::Millimeters;
3106 if ( normalized ==
encodeUnit( Qgis::RenderUnit::MetersInMapUnits ).toLower() )
3107 return Qgis::RenderUnit::MetersInMapUnits;
3108 if ( normalized == QLatin1String(
"meters" ) )
3109 return Qgis::RenderUnit::MetersInMapUnits;
3110 if ( normalized ==
encodeUnit( Qgis::RenderUnit::MapUnits ).toLower() )
3111 return Qgis::RenderUnit::MapUnits;
3112 if ( normalized == QLatin1String(
"mapunits" ) )
3113 return Qgis::RenderUnit::MapUnits;
3114 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Pixels ).toLower() )
3115 return Qgis::RenderUnit::Pixels;
3116 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Percentage ).toLower() )
3117 return Qgis::RenderUnit::Percentage;
3118 if ( normalized == QLatin1String(
"percent" ) )
3119 return Qgis::RenderUnit::Percentage;
3120 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Points ).toLower() )
3121 return Qgis::RenderUnit::Points;
3122 if ( normalized == QLatin1String(
"points" ) )
3123 return Qgis::RenderUnit::Points;
3124 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Inches ).toLower() )
3125 return Qgis::RenderUnit::Inches;
3131 return Qgis::RenderUnit::Millimeters;
3138 case Qgis::RenderUnit::Millimeters:
3139 return QObject::tr(
"millimeters",
"render" );
3141 case Qgis::RenderUnit::MetersInMapUnits:
3142 return QObject::tr(
"meters at scale",
"render" );
3144 case Qgis::RenderUnit::MapUnits:
3145 return QObject::tr(
"map units",
"render" );
3147 case Qgis::RenderUnit::Pixels:
3148 return QObject::tr(
"pixels",
"render" );
3150 case Qgis::RenderUnit::Percentage:
3151 return QObject::tr(
"percent",
"render" );
3153 case Qgis::RenderUnit::Points:
3154 return QObject::tr(
"points",
"render" );
3156 case Qgis::RenderUnit::Inches:
3157 return QObject::tr(
"inches",
"render" );
3159 case Qgis::RenderUnit::Unknown:
3160 return QObject::tr(
"<unknown>",
"render" );
3172 case Qgis::LayoutUnit::Centimeters:
3173 return QStringLiteral(
"cm" );
3174 case Qgis::LayoutUnit::Meters:
3175 return QStringLiteral(
"m" );
3176 case Qgis::LayoutUnit::Inches:
3177 return QStringLiteral(
"in" );
3178 case Qgis::LayoutUnit::Feet:
3179 return QStringLiteral(
"ft" );
3180 case Qgis::LayoutUnit::Points:
3181 return QStringLiteral(
"pt" );
3182 case Qgis::LayoutUnit::Picas:
3183 return QStringLiteral(
"pi" );
3184 case Qgis::LayoutUnit::Pixels:
3185 return QStringLiteral(
"px" );
3186 case Qgis::LayoutUnit::Millimeters:
3187 return QStringLiteral(
"mm" );
3194 const QString normalized =
string.trimmed().toLower();
3199 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Millimeters ).toLower() )
3200 return Qgis::LayoutUnit::Millimeters;
3201 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Centimeters ).toLower() )
3202 return Qgis::LayoutUnit::Centimeters;
3203 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Meters ).toLower() )
3204 return Qgis::LayoutUnit::Meters;
3205 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Inches ).toLower() )
3206 return Qgis::LayoutUnit::Inches;
3207 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Feet ).toLower() )
3208 return Qgis::LayoutUnit::Feet;
3209 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Points ).toLower() )
3210 return Qgis::LayoutUnit::Points;
3211 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Picas ).toLower() )
3212 return Qgis::LayoutUnit::Picas;
3213 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Pixels ).toLower() )
3214 return Qgis::LayoutUnit::Pixels;
3220 return Qgis::LayoutUnit::Millimeters;
3227 case Qgis::LayoutUnit::Pixels:
3228 return Qgis::LayoutUnitType::ScreenUnits;
3229 case Qgis::LayoutUnit::Millimeters:
3230 case Qgis::LayoutUnit::Centimeters:
3231 case Qgis::LayoutUnit::Meters:
3232 case Qgis::LayoutUnit::Inches:
3233 case Qgis::LayoutUnit::Feet:
3234 case Qgis::LayoutUnit::Points:
3235 case Qgis::LayoutUnit::Picas:
3236 return Qgis::LayoutUnitType::PaperUnits;
3240 return Qgis::LayoutUnitType::PaperUnits;
3247 case Qgis::LayoutUnit::Pixels:
3248 return QObject::tr(
"px" );
3249 case Qgis::LayoutUnit::Millimeters:
3250 return QObject::tr(
"mm" );
3251 case Qgis::LayoutUnit::Centimeters:
3252 return QObject::tr(
"cm" );
3253 case Qgis::LayoutUnit::Meters:
3254 return QObject::tr(
"m" );
3255 case Qgis::LayoutUnit::Inches:
3256 return QObject::tr(
"in",
"unit inch" );
3257 case Qgis::LayoutUnit::Feet:
3258 return QObject::tr(
"ft" );
3259 case Qgis::LayoutUnit::Points:
3260 return QObject::tr(
"pt" );
3261 case Qgis::LayoutUnit::Picas:
3262 return QObject::tr(
"pica" );
3271 case Qgis::LayoutUnit::Pixels:
3272 return QObject::tr(
"pixels" );
3273 case Qgis::LayoutUnit::Millimeters:
3274 return QObject::tr(
"millimeters" );
3275 case Qgis::LayoutUnit::Centimeters:
3276 return QObject::tr(
"centimeters" );
3277 case Qgis::LayoutUnit::Meters:
3278 return QObject::tr(
"meters" );
3279 case Qgis::LayoutUnit::Inches:
3280 return QObject::tr(
"inches" );
3281 case Qgis::LayoutUnit::Feet:
3282 return QObject::tr(
"feet" );
3283 case Qgis::LayoutUnit::Points:
3284 return QObject::tr(
"points" );
3285 case Qgis::LayoutUnit::Picas:
3286 return QObject::tr(
"picas" );
DistanceUnitType
Types of distance units.
@ Geographic
Unit is a geographic (e.g., degree based) unit.
@ Standard
Unit is a standard measurement unit.
LayoutUnit
Layout measurement units.
AngleUnit
Units of angles.
DistanceUnit
Units of distance.
@ Inches
Inches (since QGIS 3.32)
@ SquareInches
Square inches (since QGIS 3.32)
TemporalUnit
Temporal units.
RenderUnit
Rendering size units.
LayoutUnitType
Types of layout units.
VolumeUnit
Units of volume.
static Q_INVOKABLE Qgis::VolumeUnit decodeVolumeUnit(const QString &string, bool *ok=nullptr)
Decodes a volume unit from a string.
static Q_INVOKABLE Qgis::DistanceUnit stringToDistanceUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to a distance unit.
static Q_INVOKABLE QgsUnitTypes::AreaValue scaledArea(double area, Qgis::AreaUnit unit, int decimals, bool keepBaseUnit=false)
Will convert an area with a given unit to an area value which is nice to display.
static Q_INVOKABLE QgsUnitTypes::DistanceValue scaledDistance(double distance, Qgis::DistanceUnit unit, int decimals, bool keepBaseUnit=false)
Will convert a distance with a given unit to a distance value which is nice to display.
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
static Q_INVOKABLE QString formatArea(double area, int decimals, Qgis::AreaUnit unit, bool keepBaseUnit=false)
Returns an area formatted as a friendly string.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::VolumeUnit stringToVolumeUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to a volume unit.
static Q_INVOKABLE QString formatDistance(double distance, int decimals, Qgis::DistanceUnit unit, bool keepBaseUnit=false)
Returns an distance formatted as a friendly string.
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
static Q_INVOKABLE Qgis::DistanceUnitType unitType(Qgis::DistanceUnit unit)
Returns the type for a distance unit.
static Q_INVOKABLE Qgis::UnitType decodeUnitType(const QString &string, bool *ok=nullptr)
Decodes a unit type from a string.
static Q_INVOKABLE Qgis::AreaUnit decodeAreaUnit(const QString &string, bool *ok=nullptr)
Decodes an areal unit from a string.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE Qgis::TemporalUnit stringToTemporalUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to a temporal unit.
static Q_INVOKABLE Qgis::LayoutUnit decodeLayoutUnit(const QString &string, bool *ok=nullptr)
Decodes a layout unit from a string.
static Q_INVOKABLE Qgis::AreaUnit stringToAreaUnit(const QString &string, bool *ok=nullptr)
Converts a translated string to an areal unit.
static Q_INVOKABLE Qgis::AreaUnit distanceToAreaUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
static Q_INVOKABLE Qgis::TemporalUnit decodeTemporalUnit(const QString &string, bool *ok=nullptr)
Decodes a temporal unit from a string.
static Q_INVOKABLE Qgis::AngleUnit decodeAngleUnit(const QString &string, bool *ok=nullptr)
Decodes an angular unit from a string.
static Q_INVOKABLE Qgis::DistanceUnit areaToDistanceUnit(Qgis::AreaUnit areaUnit)
Converts an area unit to its corresponding distance unit, e.g., square meters to meters.
static Q_INVOKABLE Qgis::DistanceUnit volumeToDistanceUnit(Qgis::VolumeUnit volumeUnit)
Converts a volume unit to its corresponding distance unit, e.g., cubic meters to meters.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QString encodeUnitType(Qgis::UnitType type)
Encodes a unit type to a string.
static Q_INVOKABLE QString formatAngle(double angle, int decimals, Qgis::AngleUnit unit)
Returns an angle formatted as a friendly string.
static Q_INVOKABLE Qgis::VolumeUnit distanceToVolumeUnit(Qgis::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding volume unit, e.g., meters to cubic meters.
static Q_INVOKABLE Qgis::DistanceUnit decodeDistanceUnit(const QString &string, bool *ok=nullptr)
Decodes a distance unit from a string.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
#define MILLIMETERS_TO_METER
#define CENTIMETERS_TO_METER
#define KILOMETERS_TO_METER
A combination of area value and unit.
double value
The value part of the distance.
Qgis::AreaUnit unit
The value part of the distance.
A combination of distance value and unit.
double value
The value part of the distance.
Qgis::DistanceUnit unit
The value part of the distance.