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:
87 case Qgis::DistanceUnit::Degrees:
90 case Qgis::DistanceUnit::Unknown:
91 return Qgis::DistanceUnitType::Unknown;
93 return Qgis::DistanceUnitType::Unknown;
100 case Qgis::AreaUnit::SquareMeters:
101 case Qgis::AreaUnit::SquareKilometers:
102 case Qgis::AreaUnit::SquareFeet:
103 case Qgis::AreaUnit::SquareYards:
104 case Qgis::AreaUnit::SquareMiles:
105 case Qgis::AreaUnit::Hectares:
106 case Qgis::AreaUnit::Acres:
107 case Qgis::AreaUnit::SquareNauticalMiles:
108 case Qgis::AreaUnit::SquareCentimeters:
109 case Qgis::AreaUnit::SquareMillimeters:
112 case Qgis::AreaUnit::SquareDegrees:
115 case Qgis::AreaUnit::Unknown:
116 return Qgis::DistanceUnitType::Unknown;
119 return Qgis::DistanceUnitType::Unknown;
126 case Qgis::DistanceUnit::Meters:
127 return QStringLiteral(
"meters" );
129 case Qgis::DistanceUnit::Kilometers:
130 return QStringLiteral(
"km" );
132 case Qgis::DistanceUnit::Feet:
133 return QStringLiteral(
"feet" );
135 case Qgis::DistanceUnit::Yards:
136 return QStringLiteral(
"yd" );
138 case Qgis::DistanceUnit::Miles:
139 return QStringLiteral(
"mi" );
141 case Qgis::DistanceUnit::Degrees:
142 return QStringLiteral(
"degrees" );
144 case Qgis::DistanceUnit::Unknown:
145 return QStringLiteral(
"<unknown>" );
147 case Qgis::DistanceUnit::NauticalMiles:
148 return QStringLiteral(
"nautical miles" );
150 case Qgis::DistanceUnit::Centimeters:
151 return QStringLiteral(
"cm" );
153 case Qgis::DistanceUnit::Millimeters:
154 return QStringLiteral(
"mm" );
167 const QString normalized =
string.trimmed().toLower();
172 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Meters ) )
173 return Qgis::DistanceUnit::Meters;
174 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Feet ) )
175 return Qgis::DistanceUnit::Feet;
176 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Degrees ) )
177 return Qgis::DistanceUnit::Degrees;
178 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::NauticalMiles ) )
179 return Qgis::DistanceUnit::NauticalMiles;
180 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Kilometers ) )
181 return Qgis::DistanceUnit::Kilometers;
182 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Yards ) )
183 return Qgis::DistanceUnit::Yards;
184 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Miles ) )
185 return Qgis::DistanceUnit::Miles;
186 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Centimeters ) )
187 return Qgis::DistanceUnit::Centimeters;
188 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Millimeters ) )
189 return Qgis::DistanceUnit::Millimeters;
190 if ( normalized ==
encodeUnit( Qgis::DistanceUnit::Unknown ) )
191 return Qgis::DistanceUnit::Unknown;
196 return Qgis::DistanceUnit::Unknown;
203 case Qgis::DistanceUnit::Meters:
204 return QObject::tr(
"meters",
"distance" );
206 case Qgis::DistanceUnit::Kilometers:
207 return QObject::tr(
"kilometers",
"distance" );
209 case Qgis::DistanceUnit::Feet:
210 return QObject::tr(
"feet",
"distance" );
212 case Qgis::DistanceUnit::Yards:
213 return QObject::tr(
"yards",
"distance" );
215 case Qgis::DistanceUnit::Miles:
216 return QObject::tr(
"miles",
"distance" );
218 case Qgis::DistanceUnit::Degrees:
219 return QObject::tr(
"degrees",
"distance" );
221 case Qgis::DistanceUnit::Centimeters:
222 return QObject::tr(
"centimeters",
"distance" );
224 case Qgis::DistanceUnit::Millimeters:
225 return QObject::tr(
"millimeters",
"distance" );
227 case Qgis::DistanceUnit::Unknown:
228 return QObject::tr(
"<unknown>",
"distance" );
230 case Qgis::DistanceUnit::NauticalMiles:
231 return QObject::tr(
"nautical miles",
"distance" );
240 case Qgis::RenderUnit::Millimeters:
241 return QObject::tr(
"mm",
"render" );
243 case Qgis::RenderUnit::MapUnits:
244 return QObject::tr(
"map units",
"render" );
246 case Qgis::RenderUnit::Pixels:
247 return QObject::tr(
"px",
"render" );
249 case Qgis::RenderUnit::Percentage:
250 return QObject::tr(
"%",
"render" );
252 case Qgis::RenderUnit::Points:
253 return QObject::tr(
"pt",
"render" );
255 case Qgis::RenderUnit::Inches:
256 return QObject::tr(
"in",
"render" );
258 case Qgis::RenderUnit::Unknown:
259 return QObject::tr(
"unknown",
"render" );
261 case Qgis::RenderUnit::MetersInMapUnits:
262 return QObject::tr(
"m",
"render" );
273 case Qgis::DistanceUnit::Meters:
274 return QObject::tr(
"m",
"distance" );
276 case Qgis::DistanceUnit::Kilometers:
277 return QObject::tr(
"km",
"distance" );
279 case Qgis::DistanceUnit::Feet:
280 return QObject::tr(
"ft",
"distance" );
282 case Qgis::DistanceUnit::Yards:
283 return QObject::tr(
"yd",
"distance" );
285 case Qgis::DistanceUnit::Miles:
286 return QObject::tr(
"mi",
"distance" );
288 case Qgis::DistanceUnit::Degrees:
289 return QObject::tr(
"deg",
"distance" );
291 case Qgis::DistanceUnit::Centimeters:
292 return QObject::tr(
"cm",
"distance" );
294 case Qgis::DistanceUnit::Millimeters:
295 return QObject::tr(
"mm",
"distance" );
297 case Qgis::DistanceUnit::Unknown:
300 case Qgis::DistanceUnit::NauticalMiles:
301 return QObject::tr(
"NM",
"distance" );
314 const QString normalized =
string.trimmed().toLower();
319 if ( normalized ==
toString( Qgis::DistanceUnit::Meters ) )
320 return Qgis::DistanceUnit::Meters;
321 if ( normalized ==
toString( Qgis::DistanceUnit::Kilometers ) )
322 return Qgis::DistanceUnit::Kilometers;
323 if ( normalized ==
toString( Qgis::DistanceUnit::Feet ) )
324 return Qgis::DistanceUnit::Feet;
325 if ( normalized ==
toString( Qgis::DistanceUnit::Yards ) )
326 return Qgis::DistanceUnit::Yards;
327 if ( normalized ==
toString( Qgis::DistanceUnit::Miles ) )
328 return Qgis::DistanceUnit::Miles;
329 if ( normalized ==
toString( Qgis::DistanceUnit::Degrees ) )
330 return Qgis::DistanceUnit::Degrees;
331 if ( normalized ==
toString( Qgis::DistanceUnit::Centimeters ) )
332 return Qgis::DistanceUnit::Centimeters;
333 if ( normalized ==
toString( Qgis::DistanceUnit::Millimeters ) )
334 return Qgis::DistanceUnit::Millimeters;
335 if ( normalized ==
toString( Qgis::DistanceUnit::NauticalMiles ) )
336 return Qgis::DistanceUnit::NauticalMiles;
337 if ( normalized ==
toString( Qgis::DistanceUnit::Unknown ) )
338 return Qgis::DistanceUnit::Unknown;
343 return Qgis::DistanceUnit::Unknown;
354#define DEGREE_TO_METER 111319.49079327358
355#define FEET_TO_METER 0.3048
356#define NMILE_TO_METER 1852.0
357#define KILOMETERS_TO_METER 1000.0
358#define CENTIMETERS_TO_METER 0.01
359#define MILLIMETERS_TO_METER 0.001
360#define YARDS_TO_METER 0.9144
361#define YARDS_TO_FEET 3.0
362#define MILES_TO_METER 1609.344
367 case Qgis::DistanceUnit::Meters:
371 case Qgis::DistanceUnit::Meters:
373 case Qgis::DistanceUnit::Kilometers:
375 case Qgis::DistanceUnit::Millimeters:
377 case Qgis::DistanceUnit::Centimeters:
379 case Qgis::DistanceUnit::Feet:
381 case Qgis::DistanceUnit::Yards:
383 case Qgis::DistanceUnit::Miles:
385 case Qgis::DistanceUnit::Degrees:
387 case Qgis::DistanceUnit::NauticalMiles:
389 case Qgis::DistanceUnit::Unknown:
395 case Qgis::DistanceUnit::Kilometers:
399 case Qgis::DistanceUnit::Meters:
401 case Qgis::DistanceUnit::Kilometers:
403 case Qgis::DistanceUnit::Centimeters:
405 case Qgis::DistanceUnit::Millimeters:
407 case Qgis::DistanceUnit::Feet:
409 case Qgis::DistanceUnit::Yards:
411 case Qgis::DistanceUnit::Miles:
413 case Qgis::DistanceUnit::Degrees:
415 case Qgis::DistanceUnit::NauticalMiles:
417 case Qgis::DistanceUnit::Unknown:
423 case Qgis::DistanceUnit::Feet:
427 case Qgis::DistanceUnit::Meters:
429 case Qgis::DistanceUnit::Kilometers:
431 case Qgis::DistanceUnit::Centimeters:
433 case Qgis::DistanceUnit::Millimeters:
435 case Qgis::DistanceUnit::Feet:
437 case Qgis::DistanceUnit::Yards:
439 case Qgis::DistanceUnit::Miles:
441 case Qgis::DistanceUnit::Degrees:
443 case Qgis::DistanceUnit::NauticalMiles:
445 case Qgis::DistanceUnit::Unknown:
451 case Qgis::DistanceUnit::Yards:
455 case Qgis::DistanceUnit::Meters:
457 case Qgis::DistanceUnit::Kilometers:
459 case Qgis::DistanceUnit::Centimeters:
461 case Qgis::DistanceUnit::Millimeters:
463 case Qgis::DistanceUnit::Feet:
465 case Qgis::DistanceUnit::Yards:
467 case Qgis::DistanceUnit::Miles:
469 case Qgis::DistanceUnit::Degrees:
471 case Qgis::DistanceUnit::NauticalMiles:
473 case Qgis::DistanceUnit::Unknown:
479 case Qgis::DistanceUnit::Miles:
483 case Qgis::DistanceUnit::Meters:
485 case Qgis::DistanceUnit::Kilometers:
487 case Qgis::DistanceUnit::Centimeters:
489 case Qgis::DistanceUnit::Millimeters:
491 case Qgis::DistanceUnit::Feet:
493 case Qgis::DistanceUnit::Yards:
495 case Qgis::DistanceUnit::Miles:
497 case Qgis::DistanceUnit::Degrees:
499 case Qgis::DistanceUnit::NauticalMiles:
501 case Qgis::DistanceUnit::Unknown:
507 case Qgis::DistanceUnit::Degrees:
511 case Qgis::DistanceUnit::Meters:
513 case Qgis::DistanceUnit::Kilometers:
515 case Qgis::DistanceUnit::Centimeters:
517 case Qgis::DistanceUnit::Millimeters:
519 case Qgis::DistanceUnit::Feet:
521 case Qgis::DistanceUnit::Yards:
523 case Qgis::DistanceUnit::Miles:
525 case Qgis::DistanceUnit::Degrees:
527 case Qgis::DistanceUnit::NauticalMiles:
529 case Qgis::DistanceUnit::Unknown:
535 case Qgis::DistanceUnit::NauticalMiles:
539 case Qgis::DistanceUnit::Meters:
541 case Qgis::DistanceUnit::Kilometers:
543 case Qgis::DistanceUnit::Centimeters:
545 case Qgis::DistanceUnit::Millimeters:
547 case Qgis::DistanceUnit::Feet:
549 case Qgis::DistanceUnit::Yards:
551 case Qgis::DistanceUnit::Miles:
553 case Qgis::DistanceUnit::Degrees:
555 case Qgis::DistanceUnit::NauticalMiles:
557 case Qgis::DistanceUnit::Unknown:
563 case Qgis::DistanceUnit::Centimeters:
567 case Qgis::DistanceUnit::Meters:
569 case Qgis::DistanceUnit::Kilometers:
571 case Qgis::DistanceUnit::Centimeters:
573 case Qgis::DistanceUnit::Millimeters:
575 case Qgis::DistanceUnit::Feet:
577 case Qgis::DistanceUnit::Yards:
579 case Qgis::DistanceUnit::Miles:
581 case Qgis::DistanceUnit::Degrees:
583 case Qgis::DistanceUnit::NauticalMiles:
585 case Qgis::DistanceUnit::Unknown:
591 case Qgis::DistanceUnit::Millimeters:
595 case Qgis::DistanceUnit::Meters:
597 case Qgis::DistanceUnit::Kilometers:
599 case Qgis::DistanceUnit::Centimeters:
601 case Qgis::DistanceUnit::Millimeters:
603 case Qgis::DistanceUnit::Feet:
605 case Qgis::DistanceUnit::Yards:
607 case Qgis::DistanceUnit::Miles:
609 case Qgis::DistanceUnit::Degrees:
611 case Qgis::DistanceUnit::NauticalMiles:
613 case Qgis::DistanceUnit::Unknown:
619 case Qgis::DistanceUnit::Unknown:
629 case Qgis::AreaUnit::SquareMeters:
630 return QStringLiteral(
"m2" );
631 case Qgis::AreaUnit::SquareKilometers:
632 return QStringLiteral(
"km2" );
633 case Qgis::AreaUnit::SquareFeet:
634 return QStringLiteral(
"ft2" );
635 case Qgis::AreaUnit::SquareYards:
636 return QStringLiteral(
"y2" );
637 case Qgis::AreaUnit::SquareMiles:
638 return QStringLiteral(
"mi2" );
639 case Qgis::AreaUnit::Hectares:
640 return QStringLiteral(
"ha" );
641 case Qgis::AreaUnit::Acres:
642 return QStringLiteral(
"ac" );
643 case Qgis::AreaUnit::SquareNauticalMiles:
644 return QStringLiteral(
"nm2" );
645 case Qgis::AreaUnit::SquareDegrees:
646 return QStringLiteral(
"deg2" );
647 case Qgis::AreaUnit::SquareCentimeters:
648 return QStringLiteral(
"cm2" );
649 case Qgis::AreaUnit::SquareMillimeters:
650 return QStringLiteral(
"mm2" );
651 case Qgis::AreaUnit::Unknown:
652 return QStringLiteral(
"<unknown>" );
659 const QString normalized =
string.trimmed().toLower();
664 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMeters ) )
665 return Qgis::AreaUnit::SquareMeters;
666 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareKilometers ) )
667 return Qgis::AreaUnit::SquareKilometers;
668 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareFeet ) )
669 return Qgis::AreaUnit::SquareFeet;
670 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareYards ) )
671 return Qgis::AreaUnit::SquareYards;
672 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMiles ) )
673 return Qgis::AreaUnit::SquareMiles;
674 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Hectares ) )
675 return Qgis::AreaUnit::Hectares;
676 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Acres ) )
677 return Qgis::AreaUnit::Acres;
678 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareNauticalMiles ) )
679 return Qgis::AreaUnit::SquareNauticalMiles;
680 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareDegrees ) )
681 return Qgis::AreaUnit::SquareDegrees;
682 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareCentimeters ) )
683 return Qgis::AreaUnit::SquareCentimeters;
684 if ( normalized ==
encodeUnit( Qgis::AreaUnit::SquareMillimeters ) )
685 return Qgis::AreaUnit::SquareMillimeters;
686 if ( normalized ==
encodeUnit( Qgis::AreaUnit::Unknown ) )
687 return Qgis::AreaUnit::Unknown;
692 return Qgis::AreaUnit::Unknown;
699 case Qgis::AreaUnit::SquareMeters:
700 return QObject::tr(
"square meters",
"area" );
701 case Qgis::AreaUnit::SquareKilometers:
702 return QObject::tr(
"square kilometers",
"area" );
703 case Qgis::AreaUnit::SquareFeet:
704 return QObject::tr(
"square feet",
"area" );
705 case Qgis::AreaUnit::SquareYards:
706 return QObject::tr(
"square yards",
"area" );
707 case Qgis::AreaUnit::SquareMiles:
708 return QObject::tr(
"square miles",
"area" );
709 case Qgis::AreaUnit::Hectares:
710 return QObject::tr(
"hectares",
"area" );
711 case Qgis::AreaUnit::Acres:
712 return QObject::tr(
"acres",
"area" );
713 case Qgis::AreaUnit::SquareNauticalMiles:
714 return QObject::tr(
"square nautical miles",
"area" );
715 case Qgis::AreaUnit::SquareDegrees:
716 return QObject::tr(
"square degrees",
"area" );
717 case Qgis::AreaUnit::SquareMillimeters:
718 return QObject::tr(
"square millimeters",
"area" );
719 case Qgis::AreaUnit::SquareCentimeters:
720 return QObject::tr(
"square centimeters",
"area" );
721 case Qgis::AreaUnit::Unknown:
722 return QObject::tr(
"<unknown>",
"area" );
731 case Qgis::AreaUnit::SquareMeters:
732 return QObject::tr(
"m²",
"area" );
733 case Qgis::AreaUnit::SquareKilometers:
734 return QObject::tr(
"km²",
"area" );
735 case Qgis::AreaUnit::SquareFeet:
736 return QObject::tr(
"ft²",
"area" );
737 case Qgis::AreaUnit::SquareYards:
738 return QObject::tr(
"yd²",
"area" );
739 case Qgis::AreaUnit::SquareMiles:
740 return QObject::tr(
"mi²",
"area" );
741 case Qgis::AreaUnit::Hectares:
742 return QObject::tr(
"ha",
"area" );
743 case Qgis::AreaUnit::Acres:
744 return QObject::tr(
"ac",
"area" );
745 case Qgis::AreaUnit::SquareNauticalMiles:
746 return QObject::tr(
"NM²",
"area" );
747 case Qgis::AreaUnit::SquareDegrees:
748 return QObject::tr(
"deg²",
"area" );
749 case Qgis::AreaUnit::SquareCentimeters:
750 return QObject::tr(
"cm²",
"area" );
751 case Qgis::AreaUnit::SquareMillimeters:
752 return QObject::tr(
"mm²",
"area" );
753 case Qgis::AreaUnit::Unknown:
761 const QString normalized =
string.trimmed().toLower();
766 if ( normalized ==
toString( Qgis::AreaUnit::SquareMeters ) )
767 return Qgis::AreaUnit::SquareMeters;
768 if ( normalized ==
toString( Qgis::AreaUnit::SquareKilometers ) )
769 return Qgis::AreaUnit::SquareKilometers;
770 if ( normalized ==
toString( Qgis::AreaUnit::SquareFeet ) )
771 return Qgis::AreaUnit::SquareFeet;
772 if ( normalized ==
toString( Qgis::AreaUnit::SquareYards ) )
773 return Qgis::AreaUnit::SquareYards;
774 if ( normalized ==
toString( Qgis::AreaUnit::SquareMiles ) )
775 return Qgis::AreaUnit::SquareMiles;
776 if ( normalized ==
toString( Qgis::AreaUnit::Hectares ) )
777 return Qgis::AreaUnit::Hectares;
778 if ( normalized ==
toString( Qgis::AreaUnit::Acres ) )
779 return Qgis::AreaUnit::Acres;
780 if ( normalized ==
toString( Qgis::AreaUnit::SquareNauticalMiles ) )
781 return Qgis::AreaUnit::SquareNauticalMiles;
782 if ( normalized ==
toString( Qgis::AreaUnit::SquareDegrees ) )
783 return Qgis::AreaUnit::SquareDegrees;
784 if ( normalized ==
toString( Qgis::AreaUnit::SquareMillimeters ) )
785 return Qgis::AreaUnit::SquareMillimeters;
786 if ( normalized ==
toString( Qgis::AreaUnit::SquareCentimeters ) )
787 return Qgis::AreaUnit::SquareCentimeters;
788 if ( normalized ==
toString( Qgis::AreaUnit::Unknown ) )
789 return Qgis::AreaUnit::Unknown;
793 return Qgis::AreaUnit::Unknown;
798#define KM2_TO_M2 1000000.0
799#define CM2_TO_M2 0.0001
800#define MM2_TO_M2 0.000001
801#define FT2_TO_M2 0.09290304
802#define YD2_TO_M2 0.83612736
803#define MI2_TO_M2 2589988.110336
804#define HA_TO_M2 10000.0
805#define AC_TO_FT2 43560.0
806#define DEG2_TO_M2 12392029030.5
807#define NM2_TO_M2 3429904.0
812 case Qgis::AreaUnit::SquareMeters:
816 case Qgis::AreaUnit::SquareMeters:
818 case Qgis::AreaUnit::SquareKilometers:
820 case Qgis::AreaUnit::SquareFeet:
822 case Qgis::AreaUnit::SquareYards:
824 case Qgis::AreaUnit::SquareMiles:
826 case Qgis::AreaUnit::Hectares:
828 case Qgis::AreaUnit::Acres:
830 case Qgis::AreaUnit::SquareNauticalMiles:
832 case Qgis::AreaUnit::SquareDegrees:
834 case Qgis::AreaUnit::SquareCentimeters:
836 case Qgis::AreaUnit::SquareMillimeters:
838 case Qgis::AreaUnit::Unknown:
844 case Qgis::AreaUnit::SquareKilometers:
848 case Qgis::AreaUnit::SquareMeters:
850 case Qgis::AreaUnit::SquareKilometers:
852 case Qgis::AreaUnit::SquareFeet:
854 case Qgis::AreaUnit::SquareYards:
856 case Qgis::AreaUnit::SquareMiles:
858 case Qgis::AreaUnit::Hectares:
860 case Qgis::AreaUnit::Acres:
862 case Qgis::AreaUnit::SquareNauticalMiles:
864 case Qgis::AreaUnit::SquareDegrees:
866 case Qgis::AreaUnit::SquareCentimeters:
868 case Qgis::AreaUnit::SquareMillimeters:
870 case Qgis::AreaUnit::Unknown:
876 case Qgis::AreaUnit::SquareFeet:
880 case Qgis::AreaUnit::SquareMeters:
882 case Qgis::AreaUnit::SquareKilometers:
884 case Qgis::AreaUnit::SquareFeet:
886 case Qgis::AreaUnit::SquareYards:
888 case Qgis::AreaUnit::SquareMiles:
890 case Qgis::AreaUnit::Hectares:
892 case Qgis::AreaUnit::Acres:
894 case Qgis::AreaUnit::SquareNauticalMiles:
896 case Qgis::AreaUnit::SquareDegrees:
898 case Qgis::AreaUnit::SquareCentimeters:
900 case Qgis::AreaUnit::SquareMillimeters:
902 case Qgis::AreaUnit::Unknown:
909 case Qgis::AreaUnit::SquareYards:
913 case Qgis::AreaUnit::SquareMeters:
915 case Qgis::AreaUnit::SquareKilometers:
917 case Qgis::AreaUnit::SquareFeet:
919 case Qgis::AreaUnit::SquareYards:
921 case Qgis::AreaUnit::SquareMiles:
923 case Qgis::AreaUnit::Hectares:
925 case Qgis::AreaUnit::Acres:
927 case Qgis::AreaUnit::SquareNauticalMiles:
929 case Qgis::AreaUnit::SquareDegrees:
931 case Qgis::AreaUnit::SquareCentimeters:
933 case Qgis::AreaUnit::SquareMillimeters:
935 case Qgis::AreaUnit::Unknown:
941 case Qgis::AreaUnit::SquareMiles:
945 case Qgis::AreaUnit::SquareMeters:
947 case Qgis::AreaUnit::SquareKilometers:
949 case Qgis::AreaUnit::SquareFeet:
951 case Qgis::AreaUnit::SquareYards:
953 case Qgis::AreaUnit::SquareMiles:
955 case Qgis::AreaUnit::Hectares:
957 case Qgis::AreaUnit::Acres:
959 case Qgis::AreaUnit::SquareNauticalMiles:
961 case Qgis::AreaUnit::SquareDegrees:
963 case Qgis::AreaUnit::SquareCentimeters:
965 case Qgis::AreaUnit::SquareMillimeters:
967 case Qgis::AreaUnit::Unknown:
974 case Qgis::AreaUnit::Hectares:
978 case Qgis::AreaUnit::SquareMeters:
980 case Qgis::AreaUnit::SquareKilometers:
982 case Qgis::AreaUnit::SquareFeet:
984 case Qgis::AreaUnit::SquareYards:
986 case Qgis::AreaUnit::SquareMiles:
988 case Qgis::AreaUnit::Hectares:
990 case Qgis::AreaUnit::Acres:
992 case Qgis::AreaUnit::SquareNauticalMiles:
994 case Qgis::AreaUnit::SquareDegrees:
996 case Qgis::AreaUnit::SquareCentimeters:
998 case Qgis::AreaUnit::SquareMillimeters:
1000 case Qgis::AreaUnit::Unknown:
1007 case Qgis::AreaUnit::Acres:
1011 case Qgis::AreaUnit::SquareMeters:
1013 case Qgis::AreaUnit::SquareKilometers:
1015 case Qgis::AreaUnit::SquareFeet:
1017 case Qgis::AreaUnit::SquareYards:
1019 case Qgis::AreaUnit::SquareMiles:
1021 case Qgis::AreaUnit::Hectares:
1023 case Qgis::AreaUnit::Acres:
1025 case Qgis::AreaUnit::SquareNauticalMiles:
1027 case Qgis::AreaUnit::SquareDegrees:
1029 case Qgis::AreaUnit::SquareCentimeters:
1031 case Qgis::AreaUnit::SquareMillimeters:
1033 case Qgis::AreaUnit::Unknown:
1040 case Qgis::AreaUnit::SquareNauticalMiles:
1044 case Qgis::AreaUnit::SquareMeters:
1046 case Qgis::AreaUnit::SquareKilometers:
1048 case Qgis::AreaUnit::SquareFeet:
1050 case Qgis::AreaUnit::SquareYards:
1052 case Qgis::AreaUnit::SquareMiles:
1054 case Qgis::AreaUnit::Hectares:
1056 case Qgis::AreaUnit::Acres:
1058 case Qgis::AreaUnit::SquareNauticalMiles:
1060 case Qgis::AreaUnit::SquareDegrees:
1062 case Qgis::AreaUnit::SquareCentimeters:
1064 case Qgis::AreaUnit::SquareMillimeters:
1066 case Qgis::AreaUnit::Unknown:
1073 case Qgis::AreaUnit::SquareDegrees:
1077 case Qgis::AreaUnit::SquareMeters:
1079 case Qgis::AreaUnit::SquareKilometers:
1081 case Qgis::AreaUnit::SquareFeet:
1083 case Qgis::AreaUnit::SquareYards:
1085 case Qgis::AreaUnit::SquareMiles:
1087 case Qgis::AreaUnit::Hectares:
1089 case Qgis::AreaUnit::Acres:
1091 case Qgis::AreaUnit::SquareNauticalMiles:
1093 case Qgis::AreaUnit::SquareDegrees:
1095 case Qgis::AreaUnit::SquareCentimeters:
1097 case Qgis::AreaUnit::SquareMillimeters:
1099 case Qgis::AreaUnit::Unknown:
1106 case Qgis::AreaUnit::SquareMillimeters:
1110 case Qgis::AreaUnit::SquareMeters:
1112 case Qgis::AreaUnit::SquareKilometers:
1114 case Qgis::AreaUnit::SquareFeet:
1116 case Qgis::AreaUnit::SquareYards:
1118 case Qgis::AreaUnit::SquareMiles:
1120 case Qgis::AreaUnit::Hectares:
1122 case Qgis::AreaUnit::Acres:
1124 case Qgis::AreaUnit::SquareNauticalMiles:
1126 case Qgis::AreaUnit::SquareDegrees:
1128 case Qgis::AreaUnit::SquareCentimeters:
1130 case Qgis::AreaUnit::SquareMillimeters:
1132 case Qgis::AreaUnit::Unknown:
1138 case Qgis::AreaUnit::SquareCentimeters:
1142 case Qgis::AreaUnit::SquareMeters:
1144 case Qgis::AreaUnit::SquareKilometers:
1146 case Qgis::AreaUnit::SquareFeet:
1148 case Qgis::AreaUnit::SquareYards:
1150 case Qgis::AreaUnit::SquareMiles:
1152 case Qgis::AreaUnit::Hectares:
1154 case Qgis::AreaUnit::Acres:
1156 case Qgis::AreaUnit::SquareNauticalMiles:
1158 case Qgis::AreaUnit::SquareDegrees:
1160 case Qgis::AreaUnit::SquareCentimeters:
1162 case Qgis::AreaUnit::SquareMillimeters:
1164 case Qgis::AreaUnit::Unknown:
1170 case Qgis::AreaUnit::Unknown:
1178 switch ( distanceUnit )
1180 case Qgis::DistanceUnit::Meters:
1181 return Qgis::AreaUnit::SquareMeters;
1183 case Qgis::DistanceUnit::Kilometers:
1184 return Qgis::AreaUnit::SquareKilometers;
1186 case Qgis::DistanceUnit::Centimeters:
1187 return Qgis::AreaUnit::SquareCentimeters;
1189 case Qgis::DistanceUnit::Millimeters:
1190 return Qgis::AreaUnit::SquareMillimeters;
1192 case Qgis::DistanceUnit::Feet:
1193 return Qgis::AreaUnit::SquareFeet;
1195 case Qgis::DistanceUnit::Yards:
1196 return Qgis::AreaUnit::SquareYards;
1198 case Qgis::DistanceUnit::Miles:
1199 return Qgis::AreaUnit::SquareMiles;
1201 case Qgis::DistanceUnit::Degrees:
1202 return Qgis::AreaUnit::SquareDegrees;
1204 case Qgis::DistanceUnit::Unknown:
1205 return Qgis::AreaUnit::Unknown;
1207 case Qgis::DistanceUnit::NauticalMiles:
1208 return Qgis::AreaUnit::SquareNauticalMiles;
1211 return Qgis::AreaUnit::Unknown;
1218 case Qgis::AreaUnit::SquareMeters:
1219 case Qgis::AreaUnit::Hectares:
1220 return Qgis::DistanceUnit::Meters;
1222 case Qgis::AreaUnit::SquareKilometers:
1223 return Qgis::DistanceUnit::Kilometers;
1225 case Qgis::AreaUnit::SquareCentimeters:
1226 return Qgis::DistanceUnit::Centimeters;
1228 case Qgis::AreaUnit::SquareMillimeters:
1229 return Qgis::DistanceUnit::Millimeters;
1231 case Qgis::AreaUnit::SquareFeet:
1232 return Qgis::DistanceUnit::Feet;
1234 case Qgis::AreaUnit::SquareYards:
1235 case Qgis::AreaUnit::Acres:
1236 return Qgis::DistanceUnit::Yards;
1238 case Qgis::AreaUnit::SquareMiles:
1239 return Qgis::DistanceUnit::Miles;
1241 case Qgis::AreaUnit::SquareDegrees:
1242 return Qgis::DistanceUnit::Degrees;
1244 case Qgis::AreaUnit::Unknown:
1245 return Qgis::DistanceUnit::Unknown;
1247 case Qgis::AreaUnit::SquareNauticalMiles:
1248 return Qgis::DistanceUnit::NauticalMiles;
1251 return Qgis::DistanceUnit::Unknown;
1258 case Qgis::TemporalUnit::Seconds:
1259 return QStringLiteral(
"s" );
1260 case Qgis::TemporalUnit::Milliseconds:
1261 return QStringLiteral(
"ms" );
1262 case Qgis::TemporalUnit::Minutes:
1263 return QStringLiteral(
"min" );
1264 case Qgis::TemporalUnit::Hours:
1265 return QStringLiteral(
"h" );
1266 case Qgis::TemporalUnit::Days:
1267 return QStringLiteral(
"d" );
1268 case Qgis::TemporalUnit::Weeks:
1269 return QStringLiteral(
"wk" );
1270 case Qgis::TemporalUnit::Months:
1271 return QStringLiteral(
"mon" );
1272 case Qgis::TemporalUnit::Years:
1273 return QStringLiteral(
"y" );
1274 case Qgis::TemporalUnit::Decades:
1275 return QStringLiteral(
"dec" );
1276 case Qgis::TemporalUnit::Centuries:
1277 return QStringLiteral(
"c" );
1278 case Qgis::TemporalUnit::IrregularStep:
1279 return QStringLiteral(
"xxx" );
1280 case Qgis::TemporalUnit::Unknown:
1281 return QStringLiteral(
"<unknown>" );
1288 const QString normalized =
string.trimmed().toLower();
1293 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Seconds ) )
1294 return Qgis::TemporalUnit::Seconds;
1295 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Milliseconds ) )
1296 return Qgis::TemporalUnit::Milliseconds;
1297 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Minutes ) )
1298 return Qgis::TemporalUnit::Minutes;
1299 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Hours ) )
1300 return Qgis::TemporalUnit::Hours;
1301 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Days ) )
1302 return Qgis::TemporalUnit::Days;
1303 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Weeks ) )
1304 return Qgis::TemporalUnit::Weeks;
1305 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Months ) )
1306 return Qgis::TemporalUnit::Months;
1307 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Years ) )
1308 return Qgis::TemporalUnit::Years;
1309 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Decades ) )
1310 return Qgis::TemporalUnit::Decades;
1311 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Centuries ) )
1312 return Qgis::TemporalUnit::Centuries;
1313 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::IrregularStep ) )
1314 return Qgis::TemporalUnit::IrregularStep;
1315 if ( normalized ==
encodeUnit( Qgis::TemporalUnit::Unknown ) )
1316 return Qgis::TemporalUnit::Unknown;
1321 return Qgis::TemporalUnit::Unknown;
1328 case Qgis::TemporalUnit::Seconds:
1329 return QObject::tr(
"seconds",
"temporal" );
1330 case Qgis::TemporalUnit::Milliseconds:
1331 return QObject::tr(
"milliseconds",
"temporal" );
1332 case Qgis::TemporalUnit::Minutes:
1333 return QObject::tr(
"minutes",
"temporal" );
1334 case Qgis::TemporalUnit::Hours:
1335 return QObject::tr(
"hours",
"temporal" );
1336 case Qgis::TemporalUnit::Days:
1337 return QObject::tr(
"days",
"temporal" );
1338 case Qgis::TemporalUnit::Weeks:
1339 return QObject::tr(
"weeks",
"temporal" );
1340 case Qgis::TemporalUnit::Months:
1341 return QObject::tr(
"months",
"temporal" );
1342 case Qgis::TemporalUnit::Years:
1343 return QObject::tr(
"years",
"temporal" );
1344 case Qgis::TemporalUnit::Decades:
1345 return QObject::tr(
"decades",
"temporal" );
1346 case Qgis::TemporalUnit::Centuries:
1347 return QObject::tr(
"centuries",
"temporal" );
1348 case Qgis::TemporalUnit::IrregularStep:
1349 return QObject::tr(
"steps",
"temporal" );
1350 case Qgis::TemporalUnit::Unknown:
1351 return QObject::tr(
"<unknown>",
"temporal" );
1360 case Qgis::TemporalUnit::Seconds:
1361 return QObject::tr(
"s",
"temporal" );
1362 case Qgis::TemporalUnit::Milliseconds:
1363 return QObject::tr(
"ms",
"temporal" );
1364 case Qgis::TemporalUnit::Minutes:
1365 return QObject::tr(
"min",
"temporal" );
1366 case Qgis::TemporalUnit::Hours:
1367 return QObject::tr(
"h",
"temporal" );
1368 case Qgis::TemporalUnit::Days:
1369 return QObject::tr(
"d",
"temporal" );
1370 case Qgis::TemporalUnit::Weeks:
1371 return QObject::tr(
"wk",
"temporal" );
1372 case Qgis::TemporalUnit::Months:
1373 return QObject::tr(
"mon",
"temporal" );
1374 case Qgis::TemporalUnit::Years:
1375 return QObject::tr(
"y",
"temporal" );
1376 case Qgis::TemporalUnit::Decades:
1377 return QObject::tr(
"dec",
"temporal" );
1378 case Qgis::TemporalUnit::Centuries:
1379 return QObject::tr(
"cen",
"temporal" );
1380 case Qgis::TemporalUnit::IrregularStep:
1381 return QObject::tr(
"steps",
"temporal" );
1382 case Qgis::TemporalUnit::Unknown:
1383 return QObject::tr(
"<unknown>",
"temporal" );
1390 const QString normalized =
string.trimmed().toLower();
1395 if ( normalized ==
toString( Qgis::TemporalUnit::Seconds ) )
1396 return Qgis::TemporalUnit::Seconds;
1397 if ( normalized ==
toString( Qgis::TemporalUnit::Milliseconds ) )
1398 return Qgis::TemporalUnit::Milliseconds;
1399 if ( normalized ==
toString( Qgis::TemporalUnit::Minutes ) )
1400 return Qgis::TemporalUnit::Minutes;
1401 if ( normalized ==
toString( Qgis::TemporalUnit::Hours ) )
1402 return Qgis::TemporalUnit::Hours;
1403 if ( normalized ==
toString( Qgis::TemporalUnit::Days ) )
1404 return Qgis::TemporalUnit::Days;
1405 if ( normalized ==
toString( Qgis::TemporalUnit::Weeks ) )
1406 return Qgis::TemporalUnit::Weeks;
1407 if ( normalized ==
toString( Qgis::TemporalUnit::Months ) )
1408 return Qgis::TemporalUnit::Months;
1409 if ( normalized ==
toString( Qgis::TemporalUnit::Years ) )
1410 return Qgis::TemporalUnit::Years;
1411 if ( normalized ==
toString( Qgis::TemporalUnit::Decades ) )
1412 return Qgis::TemporalUnit::Decades;
1413 if ( normalized ==
toString( Qgis::TemporalUnit::Centuries ) )
1414 return Qgis::TemporalUnit::Centuries;
1415 if ( normalized ==
toString( Qgis::TemporalUnit::IrregularStep ) )
1416 return Qgis::TemporalUnit::IrregularStep;
1417 if ( normalized ==
toString( Qgis::TemporalUnit::Unknown ) )
1418 return Qgis::TemporalUnit::Unknown;
1423 return Qgis::TemporalUnit::Unknown;
1430 case Qgis::TemporalUnit::Seconds:
1434 case Qgis::TemporalUnit::Seconds:
1436 case Qgis::TemporalUnit::Milliseconds:
1438 case Qgis::TemporalUnit::Minutes:
1440 case Qgis::TemporalUnit::Hours:
1442 case Qgis::TemporalUnit::Days:
1444 case Qgis::TemporalUnit::Weeks:
1445 return 1 / 604800.0;
1446 case Qgis::TemporalUnit::Months:
1447 return 1 / 2592000.0;
1448 case Qgis::TemporalUnit::Years:
1449 return 1 / 31557600.0;
1450 case Qgis::TemporalUnit::Decades:
1451 return 1 / 315576000.0;
1452 case Qgis::TemporalUnit::Centuries:
1453 return 1 / 3155760000.0;
1454 case Qgis::TemporalUnit::Unknown:
1455 case Qgis::TemporalUnit::IrregularStep:
1460 case Qgis::TemporalUnit::Milliseconds:
1464 case Qgis::TemporalUnit::Seconds:
1466 case Qgis::TemporalUnit::Milliseconds:
1468 case Qgis::TemporalUnit::Minutes:
1470 case Qgis::TemporalUnit::Hours:
1471 return 1 / 3600000.0;
1472 case Qgis::TemporalUnit::Days:
1473 return 1 / 86400000.0;
1474 case Qgis::TemporalUnit::Weeks:
1475 return 1 / 60480000.0;
1476 case Qgis::TemporalUnit::Months:
1477 return 1 / 259200000.0;
1478 case Qgis::TemporalUnit::Years:
1479 return 1 / 3155760000.0;
1480 case Qgis::TemporalUnit::Decades:
1481 return 1 / 31557600000.0;
1482 case Qgis::TemporalUnit::Centuries:
1483 return 1 / 315576000000.0;
1484 case Qgis::TemporalUnit::Unknown:
1485 case Qgis::TemporalUnit::IrregularStep:
1490 case Qgis::TemporalUnit::Minutes:
1494 case Qgis::TemporalUnit::Seconds:
1496 case Qgis::TemporalUnit::Milliseconds:
1498 case Qgis::TemporalUnit::Minutes:
1500 case Qgis::TemporalUnit::Hours:
1502 case Qgis::TemporalUnit::Days:
1504 case Qgis::TemporalUnit::Weeks:
1506 case Qgis::TemporalUnit::Months:
1508 case Qgis::TemporalUnit::Years:
1509 return 1 / 525960.0;
1510 case Qgis::TemporalUnit::Decades:
1511 return 1 / 5259600.0;
1512 case Qgis::TemporalUnit::Centuries:
1513 return 1 / 52596000.0;
1514 case Qgis::TemporalUnit::Unknown:
1515 case Qgis::TemporalUnit::IrregularStep:
1520 case Qgis::TemporalUnit::Hours:
1524 case Qgis::TemporalUnit::Seconds:
1526 case Qgis::TemporalUnit::Milliseconds:
1528 case Qgis::TemporalUnit::Minutes:
1530 case Qgis::TemporalUnit::Hours:
1532 case Qgis::TemporalUnit::Days:
1534 case Qgis::TemporalUnit::Weeks:
1536 case Qgis::TemporalUnit::Months:
1538 case Qgis::TemporalUnit::Years:
1540 case Qgis::TemporalUnit::Decades:
1542 case Qgis::TemporalUnit::Centuries:
1543 return 1 / 876600.0;
1544 case Qgis::TemporalUnit::Unknown:
1545 case Qgis::TemporalUnit::IrregularStep:
1550 case Qgis::TemporalUnit::Days:
1554 case Qgis::TemporalUnit::Seconds:
1556 case Qgis::TemporalUnit::Milliseconds:
1558 case Qgis::TemporalUnit::Minutes:
1560 case Qgis::TemporalUnit::Hours:
1562 case Qgis::TemporalUnit::Days:
1564 case Qgis::TemporalUnit::Weeks:
1566 case Qgis::TemporalUnit::Months:
1568 case Qgis::TemporalUnit::Years:
1570 case Qgis::TemporalUnit::Decades:
1572 case Qgis::TemporalUnit::Centuries:
1574 case Qgis::TemporalUnit::Unknown:
1575 case Qgis::TemporalUnit::IrregularStep:
1580 case Qgis::TemporalUnit::Weeks:
1584 case Qgis::TemporalUnit::Seconds:
1586 case Qgis::TemporalUnit::Milliseconds:
1588 case Qgis::TemporalUnit::Minutes:
1590 case Qgis::TemporalUnit::Hours:
1592 case Qgis::TemporalUnit::Days:
1594 case Qgis::TemporalUnit::Weeks:
1596 case Qgis::TemporalUnit::Months:
1598 case Qgis::TemporalUnit::Years:
1600 case Qgis::TemporalUnit::Decades:
1602 case Qgis::TemporalUnit::Centuries:
1604 case Qgis::TemporalUnit::Unknown:
1605 case Qgis::TemporalUnit::IrregularStep:
1610 case Qgis::TemporalUnit::Months:
1614 case Qgis::TemporalUnit::Seconds:
1616 case Qgis::TemporalUnit::Milliseconds:
1617 return 2592000000.0;
1618 case Qgis::TemporalUnit::Minutes:
1620 case Qgis::TemporalUnit::Hours:
1622 case Qgis::TemporalUnit::Days:
1624 case Qgis::TemporalUnit::Weeks:
1626 case Qgis::TemporalUnit::Months:
1628 case Qgis::TemporalUnit::Years:
1630 case Qgis::TemporalUnit::Decades:
1632 case Qgis::TemporalUnit::Centuries:
1633 return 30 / 36525.0;
1634 case Qgis::TemporalUnit::Unknown:
1635 case Qgis::TemporalUnit::IrregularStep:
1640 case Qgis::TemporalUnit::Years:
1644 case Qgis::TemporalUnit::Seconds:
1646 case Qgis::TemporalUnit::Milliseconds:
1647 return 31557600000.0;
1648 case Qgis::TemporalUnit::Minutes:
1650 case Qgis::TemporalUnit::Hours:
1652 case Qgis::TemporalUnit::Days:
1654 case Qgis::TemporalUnit::Weeks:
1655 return 365.25 / 7.0;
1656 case Qgis::TemporalUnit::Months:
1657 return 365.25 / 30.0;
1658 case Qgis::TemporalUnit::Years:
1660 case Qgis::TemporalUnit::Decades:
1662 case Qgis::TemporalUnit::Centuries:
1664 case Qgis::TemporalUnit::Unknown:
1665 case Qgis::TemporalUnit::IrregularStep:
1670 case Qgis::TemporalUnit::Decades:
1674 case Qgis::TemporalUnit::Seconds:
1676 case Qgis::TemporalUnit::Milliseconds:
1677 return 315576000000.0;
1678 case Qgis::TemporalUnit::Minutes:
1680 case Qgis::TemporalUnit::Hours:
1682 case Qgis::TemporalUnit::Days:
1684 case Qgis::TemporalUnit::Weeks:
1685 return 3652.5 / 7.0;
1686 case Qgis::TemporalUnit::Months:
1687 return 3652.5 / 30.0;
1688 case Qgis::TemporalUnit::Years:
1690 case Qgis::TemporalUnit::Decades:
1692 case Qgis::TemporalUnit::Centuries:
1694 case Qgis::TemporalUnit::Unknown:
1695 case Qgis::TemporalUnit::IrregularStep:
1701 case Qgis::TemporalUnit::Centuries:
1705 case Qgis::TemporalUnit::Seconds:
1706 return 3155760000.0;
1707 case Qgis::TemporalUnit::Milliseconds:
1708 return 3155760000000.0;
1709 case Qgis::TemporalUnit::Minutes:
1711 case Qgis::TemporalUnit::Hours:
1713 case Qgis::TemporalUnit::Days:
1715 case Qgis::TemporalUnit::Weeks:
1717 case Qgis::TemporalUnit::Months:
1718 return 36525 / 30.0;
1719 case Qgis::TemporalUnit::Years:
1721 case Qgis::TemporalUnit::Decades:
1723 case Qgis::TemporalUnit::Centuries:
1725 case Qgis::TemporalUnit::Unknown:
1726 case Qgis::TemporalUnit::IrregularStep:
1732 case Qgis::TemporalUnit::Unknown:
1733 case Qgis::TemporalUnit::IrregularStep:
1743 const QString normalized =
string.trimmed().toLower();
1748 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicMeters ) )
1749 return Qgis::VolumeUnit::CubicMeters;
1750 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicFeet ) )
1751 return Qgis::VolumeUnit::CubicFeet;
1752 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicYards ) )
1753 return Qgis::VolumeUnit::CubicYards;
1754 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Barrel ) )
1755 return Qgis::VolumeUnit::Barrel;
1756 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicDecimeter ) )
1757 return Qgis::VolumeUnit::CubicDecimeter;
1758 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Liters ) )
1759 return Qgis::VolumeUnit::Liters;
1760 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::GallonUS ) )
1761 return Qgis::VolumeUnit::GallonUS;
1762 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicInch ) )
1763 return Qgis::VolumeUnit::CubicInch;
1764 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicCentimeter ) )
1765 return Qgis::VolumeUnit::CubicCentimeter;
1766 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::CubicDegrees ) )
1767 return Qgis::VolumeUnit::CubicDegrees;
1768 if ( normalized ==
encodeUnit( Qgis::VolumeUnit::Unknown ) )
1769 return Qgis::VolumeUnit::Unknown;
1774 return Qgis::VolumeUnit::Unknown;
1781 case Qgis::VolumeUnit::CubicMeters:
1782 return QObject::tr(
"cubic meters",
"volume" );
1783 case Qgis::VolumeUnit::CubicFeet:
1784 return QObject::tr(
"cubic feet",
"volume" );
1785 case Qgis::VolumeUnit::CubicYards:
1786 return QObject::tr(
"cubic yards",
"volume" );
1787 case Qgis::VolumeUnit::Barrel:
1788 return QObject::tr(
"barrels",
"volume" );
1789 case Qgis::VolumeUnit::CubicDecimeter:
1790 return QObject::tr(
"cubic decimeters",
"volume" );
1791 case Qgis::VolumeUnit::Liters:
1792 return QObject::tr(
"liters",
"volume" );
1793 case Qgis::VolumeUnit::GallonUS:
1794 return QObject::tr(
"gallons",
"volume" );
1795 case Qgis::VolumeUnit::CubicInch:
1796 return QObject::tr(
"cubic inches",
"volume" );
1797 case Qgis::VolumeUnit::CubicCentimeter:
1798 return QObject::tr(
"cubic centimeters",
"volume" );
1799 case Qgis::VolumeUnit::CubicDegrees:
1800 return QObject::tr(
"cubic degrees",
"volume" );
1801 case Qgis::VolumeUnit::Unknown:
1802 return QObject::tr(
"<unknown>",
"volume" );
1811 case Qgis::VolumeUnit::CubicMeters:
1812 return QObject::tr(
"m³",
"volume" );
1813 case Qgis::VolumeUnit::CubicFeet:
1814 return QObject::tr(
"ft³",
"volume" );
1815 case Qgis::VolumeUnit::CubicYards:
1816 return QObject::tr(
"yds³",
"volume" );
1817 case Qgis::VolumeUnit::Barrel:
1818 return QObject::tr(
"bbl",
"volume" );
1819 case Qgis::VolumeUnit::CubicDecimeter:
1820 return QObject::tr(
"dm³",
"volume" );
1821 case Qgis::VolumeUnit::Liters:
1822 return QObject::tr(
"l",
"volume" );
1823 case Qgis::VolumeUnit::GallonUS:
1824 return QObject::tr(
"gal",
"volume" );
1825 case Qgis::VolumeUnit::CubicInch:
1826 return QObject::tr(
"in³",
"volume" );
1827 case Qgis::VolumeUnit::CubicCentimeter:
1828 return QObject::tr(
"cm³",
"volume" );
1829 case Qgis::VolumeUnit::CubicDegrees:
1830 return QObject::tr(
"deg³",
"volume" );
1831 case Qgis::VolumeUnit::Unknown:
1832 return QObject::tr(
"<unknown>",
"volume" );
1840 const QString normalized =
string.trimmed().toLower();
1845 if ( normalized ==
toString( Qgis::VolumeUnit::CubicMeters ) )
1846 return Qgis::VolumeUnit::CubicMeters;
1847 if ( normalized ==
toString( Qgis::VolumeUnit::CubicFeet ) )
1848 return Qgis::VolumeUnit::CubicFeet;
1849 if ( normalized ==
toString( Qgis::VolumeUnit::CubicYards ) )
1850 return Qgis::VolumeUnit::CubicYards;
1851 if ( normalized ==
toString( Qgis::VolumeUnit::Barrel ) )
1852 return Qgis::VolumeUnit::Barrel;
1853 if ( normalized ==
toString( Qgis::VolumeUnit::CubicDecimeter ) )
1854 return Qgis::VolumeUnit::CubicDecimeter;
1855 if ( normalized ==
toString( Qgis::VolumeUnit::Liters ) )
1856 return Qgis::VolumeUnit::Liters;
1857 if ( normalized ==
toString( Qgis::VolumeUnit::GallonUS ) )
1858 return Qgis::VolumeUnit::GallonUS;
1859 if ( normalized ==
toString( Qgis::VolumeUnit::CubicInch ) )
1860 return Qgis::VolumeUnit::CubicInch;
1861 if ( normalized ==
toString( Qgis::VolumeUnit::CubicCentimeter ) )
1862 return Qgis::VolumeUnit::CubicCentimeter;
1863 if ( normalized ==
toString( Qgis::VolumeUnit::CubicDegrees ) )
1864 return Qgis::VolumeUnit::CubicDegrees;
1865 if ( normalized ==
toString( Qgis::VolumeUnit::Unknown ) )
1866 return Qgis::VolumeUnit::Unknown;
1871 return Qgis::VolumeUnit::Unknown;
1874#define DEG2_TO_M3 1379474361572186.2
1879 case Qgis::VolumeUnit::CubicMeters:
1883 case Qgis::VolumeUnit::CubicMeters:
1885 case Qgis::VolumeUnit::CubicFeet:
1886 return 35.314666572222;
1887 case Qgis::VolumeUnit::CubicYards:
1888 return 1.307950613786;
1889 case Qgis::VolumeUnit::Barrel:
1890 return 6.2898107438466;
1891 case Qgis::VolumeUnit::CubicDecimeter:
1893 case Qgis::VolumeUnit::Liters:
1895 case Qgis::VolumeUnit::GallonUS:
1896 return 264.17205124156;
1897 case Qgis::VolumeUnit::CubicInch:
1898 return 61023.7438368;
1899 case Qgis::VolumeUnit::CubicCentimeter:
1901 case Qgis::VolumeUnit::CubicDegrees:
1903 case Qgis::VolumeUnit::Unknown:
1908 case Qgis::VolumeUnit::CubicFeet:
1912 case Qgis::VolumeUnit::CubicMeters:
1913 return 0.028316846592;
1914 case Qgis::VolumeUnit::CubicFeet:
1916 case Qgis::VolumeUnit::CubicYards:
1918 case Qgis::VolumeUnit::Barrel:
1920 case Qgis::VolumeUnit::CubicDecimeter:
1922 case Qgis::VolumeUnit::Liters:
1924 case Qgis::VolumeUnit::GallonUS:
1926 case Qgis::VolumeUnit::CubicInch:
1927 return 1728.000629765;
1928 case Qgis::VolumeUnit::CubicCentimeter:
1930 case Qgis::VolumeUnit::CubicDegrees:
1932 case Qgis::VolumeUnit::Unknown:
1937 case Qgis::VolumeUnit::CubicYards:
1941 case Qgis::VolumeUnit::CubicMeters:
1943 case Qgis::VolumeUnit::CubicFeet:
1944 return 26.999998234;
1945 case Qgis::VolumeUnit::CubicYards:
1947 case Qgis::VolumeUnit::Barrel:
1949 case Qgis::VolumeUnit::CubicDecimeter:
1951 case Qgis::VolumeUnit::Liters:
1953 case Qgis::VolumeUnit::GallonUS:
1954 return 201.974025549;
1955 case Qgis::VolumeUnit::CubicInch:
1956 return 46656.013952472;
1957 case Qgis::VolumeUnit::CubicCentimeter:
1959 case Qgis::VolumeUnit::CubicDegrees:
1961 case Qgis::VolumeUnit::Unknown:
1966 case Qgis::VolumeUnit::Barrel:
1970 case Qgis::VolumeUnit::CubicMeters:
1972 case Qgis::VolumeUnit::CubicFeet:
1974 case Qgis::VolumeUnit::CubicYards:
1976 case Qgis::VolumeUnit::Barrel:
1978 case Qgis::VolumeUnit::CubicDecimeter:
1980 case Qgis::VolumeUnit::Liters:
1982 case Qgis::VolumeUnit::GallonUS:
1983 return 41.999998943;
1984 case Qgis::VolumeUnit::CubicInch:
1985 return 9702.002677722;
1986 case Qgis::VolumeUnit::CubicCentimeter:
1988 case Qgis::VolumeUnit::CubicDegrees:
1990 case Qgis::VolumeUnit::Unknown:
1995 case Qgis::VolumeUnit::CubicDecimeter:
1996 case Qgis::VolumeUnit::Liters:
2000 case Qgis::VolumeUnit::CubicMeters:
2002 case Qgis::VolumeUnit::CubicFeet:
2004 case Qgis::VolumeUnit::CubicYards:
2006 case Qgis::VolumeUnit::Barrel:
2008 case Qgis::VolumeUnit::CubicDecimeter:
2009 case Qgis::VolumeUnit::Liters:
2011 case Qgis::VolumeUnit::GallonUS:
2013 case Qgis::VolumeUnit::CubicInch:
2014 return 61.023758990;
2015 case Qgis::VolumeUnit::CubicCentimeter:
2017 case Qgis::VolumeUnit::CubicDegrees:
2019 case Qgis::VolumeUnit::Unknown:
2024 case Qgis::VolumeUnit::GallonUS:
2028 case Qgis::VolumeUnit::CubicMeters:
2030 case Qgis::VolumeUnit::CubicFeet:
2032 case Qgis::VolumeUnit::CubicYards:
2034 case Qgis::VolumeUnit::Barrel:
2036 case Qgis::VolumeUnit::CubicDecimeter:
2037 case Qgis::VolumeUnit::Liters:
2039 case Qgis::VolumeUnit::GallonUS:
2041 case Qgis::VolumeUnit::CubicInch:
2042 return 231.000069567;
2043 case Qgis::VolumeUnit::CubicCentimeter:
2045 case Qgis::VolumeUnit::CubicDegrees:
2047 case Qgis::VolumeUnit::Unknown:
2052 case Qgis::VolumeUnit::CubicInch:
2056 case Qgis::VolumeUnit::CubicMeters:
2058 case Qgis::VolumeUnit::CubicFeet:
2060 case Qgis::VolumeUnit::CubicYards:
2062 case Qgis::VolumeUnit::Barrel:
2064 case Qgis::VolumeUnit::CubicDecimeter:
2065 case Qgis::VolumeUnit::Liters:
2067 case Qgis::VolumeUnit::GallonUS:
2069 case Qgis::VolumeUnit::CubicInch:
2071 case Qgis::VolumeUnit::CubicCentimeter:
2072 return 16.387060000;
2073 case Qgis::VolumeUnit::CubicDegrees:
2075 case Qgis::VolumeUnit::Unknown:
2080 case Qgis::VolumeUnit::CubicCentimeter:
2084 case Qgis::VolumeUnit::CubicMeters:
2086 case Qgis::VolumeUnit::CubicFeet:
2088 case Qgis::VolumeUnit::CubicYards:
2090 case Qgis::VolumeUnit::Barrel:
2092 case Qgis::VolumeUnit::CubicDecimeter:
2093 case Qgis::VolumeUnit::Liters:
2095 case Qgis::VolumeUnit::GallonUS:
2096 return 0.000264172 ;
2097 case Qgis::VolumeUnit::CubicInch:
2099 case Qgis::VolumeUnit::CubicCentimeter:
2101 case Qgis::VolumeUnit::CubicDegrees:
2103 case Qgis::VolumeUnit::Unknown:
2108 case Qgis::VolumeUnit::CubicDegrees:
2109 if ( toUnit == Qgis::VolumeUnit::Unknown || toUnit == Qgis::VolumeUnit::CubicDegrees )
2114 case Qgis::VolumeUnit::Unknown:
2124 switch ( distanceUnit )
2126 case Qgis::DistanceUnit::Meters:
2127 return Qgis::VolumeUnit::CubicMeters;
2129 case Qgis::DistanceUnit::Kilometers:
2130 return Qgis::VolumeUnit::CubicMeters;
2132 case Qgis::DistanceUnit::Centimeters:
2133 return Qgis::VolumeUnit::CubicCentimeter;
2135 case Qgis::DistanceUnit::Millimeters:
2136 return Qgis::VolumeUnit::CubicCentimeter;
2138 case Qgis::DistanceUnit::Feet:
2139 return Qgis::VolumeUnit::CubicFeet;
2141 case Qgis::DistanceUnit::Yards:
2142 return Qgis::VolumeUnit::CubicYards;
2144 case Qgis::DistanceUnit::Miles:
2145 return Qgis::VolumeUnit::CubicFeet;
2147 case Qgis::DistanceUnit::Degrees:
2148 return Qgis::VolumeUnit::CubicDegrees;
2150 case Qgis::DistanceUnit::Unknown:
2151 return Qgis::VolumeUnit::Unknown;
2153 case Qgis::DistanceUnit::NauticalMiles:
2154 return Qgis::VolumeUnit::CubicFeet;
2157 return Qgis::VolumeUnit::Unknown;
2162 switch ( volumeUnit )
2164 case Qgis::VolumeUnit::CubicMeters:
2165 return Qgis::DistanceUnit::Meters;
2166 case Qgis::VolumeUnit::CubicFeet:
2167 return Qgis::DistanceUnit::Feet;
2168 case Qgis::VolumeUnit::CubicYards:
2169 return Qgis::DistanceUnit::Yards;
2170 case Qgis::VolumeUnit::Barrel:
2171 return Qgis::DistanceUnit::Feet;
2172 case Qgis::VolumeUnit::CubicDecimeter:
2173 return Qgis::DistanceUnit::Centimeters;
2174 case Qgis::VolumeUnit::Liters:
2175 return Qgis::DistanceUnit::Meters;
2176 case Qgis::VolumeUnit::GallonUS:
2177 return Qgis::DistanceUnit::Feet;
2178 case Qgis::VolumeUnit::CubicInch:
2179 return Qgis::DistanceUnit::Feet;
2180 case Qgis::VolumeUnit::CubicCentimeter:
2181 return Qgis::DistanceUnit::Centimeters;
2182 case Qgis::VolumeUnit::CubicDegrees:
2183 return Qgis::DistanceUnit::Degrees;
2184 case Qgis::VolumeUnit::Unknown:
2185 return Qgis::DistanceUnit::Unknown;
2187 return Qgis::DistanceUnit::Unknown;
2194 case Qgis::VolumeUnit::CubicMeters:
2195 case Qgis::VolumeUnit::CubicFeet:
2196 case Qgis::VolumeUnit::CubicYards:
2197 case Qgis::VolumeUnit::Barrel:
2198 case Qgis::VolumeUnit::CubicDecimeter:
2199 case Qgis::VolumeUnit::Liters:
2200 case Qgis::VolumeUnit::GallonUS:
2201 case Qgis::VolumeUnit::CubicInch:
2202 case Qgis::VolumeUnit::CubicCentimeter:
2204 case Qgis::VolumeUnit::CubicDegrees:
2206 case Qgis::VolumeUnit::Unknown:
2207 return Qgis::DistanceUnitType::Unknown;
2209 return Qgis::DistanceUnitType::Unknown;
2216 case Qgis::VolumeUnit::CubicMeters:
2217 return QStringLiteral(
"m3" );
2218 case Qgis::VolumeUnit::CubicFeet:
2219 return QStringLiteral(
"ft3" );
2220 case Qgis::VolumeUnit::CubicYards:
2221 return QStringLiteral(
"yd3" );
2222 case Qgis::VolumeUnit::Barrel:
2223 return QStringLiteral(
"bbl" );
2224 case Qgis::VolumeUnit::CubicDecimeter:
2225 return QStringLiteral(
"dm3" );
2226 case Qgis::VolumeUnit::Liters:
2227 return QStringLiteral(
"l" );
2228 case Qgis::VolumeUnit::GallonUS:
2229 return QStringLiteral(
"gal" );
2230 case Qgis::VolumeUnit::CubicInch:
2231 return QStringLiteral(
"in3" );
2232 case Qgis::VolumeUnit::CubicCentimeter:
2233 return QStringLiteral(
"cm3" );
2234 case Qgis::VolumeUnit::CubicDegrees:
2235 return QStringLiteral(
"deg3" );
2236 case Qgis::VolumeUnit::Unknown:
2237 return QStringLiteral(
"<unknown>" );
2246 case Qgis::AngleUnit::Degrees:
2247 return QStringLiteral(
"degrees" );
2248 case Qgis::AngleUnit::Radians:
2249 return QStringLiteral(
"radians" );
2250 case Qgis::AngleUnit::Gon:
2251 return QStringLiteral(
"gon" );
2252 case Qgis::AngleUnit::MinutesOfArc:
2253 return QStringLiteral(
"moa" );
2254 case Qgis::AngleUnit::SecondsOfArc:
2255 return QStringLiteral(
"soa" );
2256 case Qgis::AngleUnit::Turn:
2257 return QStringLiteral(
"tr" );
2258 case Qgis::AngleUnit::MilliradiansSI:
2259 return QStringLiteral(
"milliradians" );
2260 case Qgis::AngleUnit::MilNATO:
2261 return QStringLiteral(
"mil" );
2262 case Qgis::AngleUnit::Unknown:
2263 return QStringLiteral(
"<unknown>" );
2270 const QString normalized =
string.trimmed().toLower();
2275 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Degrees ) )
2276 return Qgis::AngleUnit::Degrees;
2277 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Radians ) )
2278 return Qgis::AngleUnit::Radians;
2279 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Gon ) )
2280 return Qgis::AngleUnit::Gon;
2281 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MinutesOfArc ) )
2282 return Qgis::AngleUnit::MinutesOfArc;
2283 if ( normalized ==
encodeUnit( Qgis::AngleUnit::SecondsOfArc ) )
2284 return Qgis::AngleUnit::SecondsOfArc;
2285 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Turn ) )
2286 return Qgis::AngleUnit::Turn;
2287 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MilliradiansSI ) )
2288 return Qgis::AngleUnit::MilliradiansSI;
2289 if ( normalized ==
encodeUnit( Qgis::AngleUnit::MilNATO ) )
2290 return Qgis::AngleUnit::MilNATO;
2291 if ( normalized ==
encodeUnit( Qgis::AngleUnit::Unknown ) )
2292 return Qgis::AngleUnit::Unknown;
2296 return Qgis::AngleUnit::Unknown;
2303 case Qgis::AngleUnit::Degrees:
2304 return QObject::tr(
"degrees",
"angle" );
2305 case Qgis::AngleUnit::Radians:
2306 return QObject::tr(
"radians",
"angle" );
2307 case Qgis::AngleUnit::Gon:
2308 return QObject::tr(
"gon",
"angle" );
2309 case Qgis::AngleUnit::MinutesOfArc:
2310 return QObject::tr(
"minutes of arc",
"angle" );
2311 case Qgis::AngleUnit::SecondsOfArc:
2312 return QObject::tr(
"seconds of arc",
"angle" );
2313 case Qgis::AngleUnit::Turn:
2314 return QObject::tr(
"turns",
"angle" );
2315 case Qgis::AngleUnit::MilliradiansSI:
2316 return QObject::tr(
"milliradians",
"angle" );
2317 case Qgis::AngleUnit::MilNATO:
2318 return QObject::tr(
"mil",
"angle" );
2319 case Qgis::AngleUnit::Unknown:
2320 return QObject::tr(
"<unknown>",
"angle" );
2330 case Qgis::AngleUnit::Degrees:
2334 case Qgis::AngleUnit::Degrees:
2336 case Qgis::AngleUnit::Radians:
2337 return M_PI / 180.0;
2338 case Qgis::AngleUnit::Gon:
2339 return 400.0 / 360.0;
2340 case Qgis::AngleUnit::MinutesOfArc:
2342 case Qgis::AngleUnit::SecondsOfArc:
2344 case Qgis::AngleUnit::Turn:
2346 case Qgis::AngleUnit::MilliradiansSI:
2347 return M_PI / 180.0 * 1000;
2348 case Qgis::AngleUnit::MilNATO:
2349 return 3200.0 / 180;
2350 case Qgis::AngleUnit::Unknown:
2355 case Qgis::AngleUnit::Radians:
2359 case Qgis::AngleUnit::Degrees:
2360 return 180.0 / M_PI;
2361 case Qgis::AngleUnit::Radians:
2363 case Qgis::AngleUnit::Gon:
2364 return 200.0 / M_PI;
2365 case Qgis::AngleUnit::MinutesOfArc:
2366 return 60 * 180.0 / M_PI;
2367 case Qgis::AngleUnit::SecondsOfArc:
2368 return 3600 * 180.0 / M_PI;
2369 case Qgis::AngleUnit::Turn:
2371 case Qgis::AngleUnit::MilliradiansSI:
2373 case Qgis::AngleUnit::MilNATO:
2374 return 3200.0 / M_PI;
2375 case Qgis::AngleUnit::Unknown:
2380 case Qgis::AngleUnit::Gon:
2384 case Qgis::AngleUnit::Degrees:
2385 return 360.0 / 400.0;
2386 case Qgis::AngleUnit::Radians:
2387 return M_PI / 200.0;
2388 case Qgis::AngleUnit::Gon:
2390 case Qgis::AngleUnit::MinutesOfArc:
2391 return 60 * 360.0 / 400.0;
2392 case Qgis::AngleUnit::SecondsOfArc:
2393 return 3600 * 360.0 / 400.0;
2394 case Qgis::AngleUnit::Turn:
2396 case Qgis::AngleUnit::MilliradiansSI:
2397 return M_PI / 200.0 * 1000;
2398 case Qgis::AngleUnit::MilNATO:
2399 return 3200.0 / 200.0;
2400 case Qgis::AngleUnit::Unknown:
2405 case Qgis::AngleUnit::MinutesOfArc:
2409 case Qgis::AngleUnit::Degrees:
2411 case Qgis::AngleUnit::Radians:
2412 return M_PI / 180.0 / 60.0;
2413 case Qgis::AngleUnit::Gon:
2414 return 400.0 / 360.0 / 60.0;
2415 case Qgis::AngleUnit::MinutesOfArc:
2417 case Qgis::AngleUnit::SecondsOfArc:
2419 case Qgis::AngleUnit::Turn:
2420 return 1.0 / 360.0 / 60.0;
2421 case Qgis::AngleUnit::MilliradiansSI:
2422 return M_PI / 180.0 / 60.0 * 1000;
2423 case Qgis::AngleUnit::MilNATO:
2424 return 3200.0 / 180.0 / 60.0;
2425 case Qgis::AngleUnit::Unknown:
2430 case Qgis::AngleUnit::SecondsOfArc:
2434 case Qgis::AngleUnit::Degrees:
2436 case Qgis::AngleUnit::Radians:
2437 return M_PI / 180.0 / 3600.0;
2438 case Qgis::AngleUnit::Gon:
2439 return 400.0 / 360.0 / 3600.0;
2440 case Qgis::AngleUnit::MinutesOfArc:
2442 case Qgis::AngleUnit::SecondsOfArc:
2444 case Qgis::AngleUnit::Turn:
2445 return 1.0 / 360.0 / 3600.0;
2446 case Qgis::AngleUnit::MilliradiansSI:
2447 return M_PI / 180.0 / 3600.0 * 1000;
2448 case Qgis::AngleUnit::MilNATO:
2449 return 3200.0 / 180.0 / 3600.0;
2450 case Qgis::AngleUnit::Unknown:
2455 case Qgis::AngleUnit::Turn:
2459 case Qgis::AngleUnit::Degrees:
2461 case Qgis::AngleUnit::Radians:
2463 case Qgis::AngleUnit::Gon:
2465 case Qgis::AngleUnit::MinutesOfArc:
2466 return 360.0 * 60.0;
2467 case Qgis::AngleUnit::SecondsOfArc:
2468 return 360.0 * 3600.0;
2469 case Qgis::AngleUnit::Turn:
2471 case Qgis::AngleUnit::MilliradiansSI:
2472 return 2 * M_PI * 1000;
2473 case Qgis::AngleUnit::MilNATO:
2475 case Qgis::AngleUnit::Unknown:
2480 case Qgis::AngleUnit::MilliradiansSI:
2484 case Qgis::AngleUnit::Degrees:
2485 return 180.0 / M_PI / 1000;
2486 case Qgis::AngleUnit::Radians:
2488 case Qgis::AngleUnit::Gon:
2489 return 200.0 / M_PI / 1000;
2490 case Qgis::AngleUnit::MinutesOfArc:
2491 return 180.0 * 60.0 / M_PI / 1000;
2492 case Qgis::AngleUnit::SecondsOfArc:
2493 return 180.0 * 3600.0 / M_PI / 1000;
2494 case Qgis::AngleUnit::Turn:
2495 return M_PI / 2 / 1000;
2496 case Qgis::AngleUnit::MilliradiansSI:
2498 case Qgis::AngleUnit::MilNATO:
2499 return 3200.0 / 1000.0 / M_PI;
2500 case Qgis::AngleUnit::Unknown:
2506 case Qgis::AngleUnit::MilNATO:
2510 case Qgis::AngleUnit::Degrees:
2511 return 180.0 / 3200;
2512 case Qgis::AngleUnit::Radians:
2514 case Qgis::AngleUnit::Gon:
2515 return 200.0 / 3200;
2516 case Qgis::AngleUnit::MinutesOfArc:
2517 return 60 * 180.0 / 3200;
2518 case Qgis::AngleUnit::SecondsOfArc:
2519 return 3600.0 * 180 / 3200;
2520 case Qgis::AngleUnit::Turn:
2521 return 1.0 / ( 2 * 32000 );
2522 case Qgis::AngleUnit::MilliradiansSI:
2523 return 1000.0 * M_PI / 3200.0;
2524 case Qgis::AngleUnit::MilNATO:
2526 case Qgis::AngleUnit::Unknown:
2532 case Qgis::AngleUnit::Unknown:
2541 int decimalPlaces = 2;
2545 case Qgis::AngleUnit::Degrees:
2546 unitLabel = QObject::tr(
"°",
"angle" );
2549 case Qgis::AngleUnit::Radians:
2550 unitLabel = QObject::tr(
" rad",
"angle" );
2553 case Qgis::AngleUnit::Gon:
2554 unitLabel = QObject::tr(
" gon",
"angle" );
2557 case Qgis::AngleUnit::MinutesOfArc:
2558 unitLabel = QObject::tr(
"′",
"angle minutes" );
2561 case Qgis::AngleUnit::SecondsOfArc:
2562 unitLabel = QObject::tr(
"″",
"angle seconds" );
2565 case Qgis::AngleUnit::Turn:
2566 unitLabel = QObject::tr(
" tr",
"angle turn" );
2569 case Qgis::AngleUnit::MilliradiansSI:
2570 unitLabel = QObject::tr(
" millirad",
"angular mil SI" );
2573 case Qgis::AngleUnit::MilNATO:
2574 unitLabel = QObject::tr(
" mil",
"angular mil NATO" );
2577 case Qgis::AngleUnit::Unknown:
2581 if ( decimals >= 0 )
2582 decimalPlaces = decimals;
2584 return QStringLiteral(
"%L1%2" ).arg(
angle, 0,
'f', decimalPlaces ).arg( unitLabel );
2593 case Qgis::DistanceUnit::Meters:
2597 result.
unit = Qgis::DistanceUnit::Meters;
2599 else if ( std::fabs( distance ) > 1000.0 )
2602 result.
unit = Qgis::DistanceUnit::Kilometers;
2604 else if ( std::fabs( distance ) < 0.01 )
2607 result.
unit = Qgis::DistanceUnit::Millimeters;
2609 else if ( std::fabs( distance ) < 0.1 )
2613 result.
unit = Qgis::DistanceUnit::Centimeters;
2618 result.
unit = Qgis::DistanceUnit::Meters;
2622 case Qgis::DistanceUnit::Kilometers:
2623 if ( keepBaseUnit || std::fabs( distance ) >= 1.0 )
2626 result.
unit = Qgis::DistanceUnit::Kilometers;
2631 result.
unit = Qgis::DistanceUnit::Meters;
2635 case Qgis::DistanceUnit::Feet:
2636 if ( std::fabs( distance ) <= 5280.0 || keepBaseUnit )
2639 result.
unit = Qgis::DistanceUnit::Feet;
2644 result.
unit = Qgis::DistanceUnit::Miles;
2648 case Qgis::DistanceUnit::Yards:
2649 if ( std::fabs( distance ) <= 1760.0 || keepBaseUnit )
2652 result.
unit = Qgis::DistanceUnit::Yards;
2657 result.
unit = Qgis::DistanceUnit::Miles;
2661 case Qgis::DistanceUnit::Miles:
2662 if ( std::fabs( distance ) >= 1.0 || keepBaseUnit )
2665 result.
unit = Qgis::DistanceUnit::Miles;
2670 result.
unit = Qgis::DistanceUnit::Feet;
2674 case Qgis::DistanceUnit::NauticalMiles:
2676 result.
unit = Qgis::DistanceUnit::NauticalMiles;
2679 case Qgis::DistanceUnit::Degrees:
2681 result.
unit = Qgis::DistanceUnit::Degrees;
2684 case Qgis::DistanceUnit::Unknown:
2686 result.
unit = Qgis::DistanceUnit::Unknown;
2701 result.
value = -1.0;
2702 result.
unit = Qgis::AreaUnit::Unknown;
2705 if ( unit == Qgis::AreaUnit::SquareMillimeters )
2710 result.
unit = Qgis::AreaUnit::SquareMillimeters;
2715 unit = Qgis::AreaUnit::SquareMeters;
2718 else if ( unit == Qgis::AreaUnit::SquareCentimeters )
2723 result.
unit = Qgis::AreaUnit::SquareCentimeters;
2728 unit = Qgis::AreaUnit::SquareMeters;
2734 case Qgis::AreaUnit::SquareCentimeters:
2737 case Qgis::AreaUnit::SquareMillimeters:
2740 case Qgis::AreaUnit::SquareMeters:
2745 result.
unit = Qgis::AreaUnit::SquareMeters;
2750 result.
unit = Qgis::AreaUnit::SquareKilometers;
2755 result.
unit = Qgis::AreaUnit::Hectares;
2760 result.
unit = Qgis::AreaUnit::SquareMeters;
2765 case Qgis::AreaUnit::SquareKilometers:
2768 result.
unit = Qgis::AreaUnit::SquareKilometers;
2772 case Qgis::AreaUnit::SquareFeet:
2777 result.
unit = Qgis::AreaUnit::SquareFeet;
2782 result.
unit = Qgis::AreaUnit::SquareMiles;
2787 result.
unit = Qgis::AreaUnit::SquareFeet;
2792 case Qgis::AreaUnit::SquareYards:
2797 result.
unit = Qgis::AreaUnit::SquareYards;
2802 result.
unit = Qgis::AreaUnit::SquareMiles;
2807 result.
unit = Qgis::AreaUnit::SquareYards;
2812 case Qgis::AreaUnit::SquareMiles:
2815 result.
unit = Qgis::AreaUnit::SquareMiles;
2819 case Qgis::AreaUnit::Hectares:
2824 result.
unit = Qgis::AreaUnit::Hectares;
2829 result.
unit = Qgis::AreaUnit::SquareKilometers;
2834 result.
unit = Qgis::AreaUnit::Hectares;
2839 case Qgis::AreaUnit::Acres:
2844 result.
unit = Qgis::AreaUnit::Acres;
2849 result.
unit = Qgis::AreaUnit::SquareMiles;
2854 result.
unit = Qgis::AreaUnit::Acres;
2859 case Qgis::AreaUnit::SquareNauticalMiles:
2862 result.
unit = Qgis::AreaUnit::SquareNauticalMiles;
2866 case Qgis::AreaUnit::SquareDegrees:
2869 result.
unit = Qgis::AreaUnit::SquareDegrees;
2873 case Qgis::AreaUnit::Unknown:
2876 result.
unit = Qgis::AreaUnit::Unknown;
2890 if ( dist.
unit != Qgis::DistanceUnit::Unknown )
2896 return QStringLiteral(
"%L1%2" ).arg( distance, 0,
'e', decimals ).arg( unitText );
2900 return QStringLiteral(
"%L1%2" ).arg( dist.
value, 0,
'f', decimals ).arg( unitText );
2910 if ( areaValue.
unit != Qgis::AreaUnit::Unknown )
2916 return QStringLiteral(
"%L1%2" ).arg( area, 0,
'e', decimals ).arg( unitText );
2920 return QStringLiteral(
"%L1%2" ).arg( areaValue.
value, 0,
'f', decimals ).arg( unitText );
2928 case Qgis::RenderUnit::Millimeters:
2929 return QStringLiteral(
"MM" );
2930 case Qgis::RenderUnit::MetersInMapUnits:
2931 return QStringLiteral(
"RenderMetersInMapUnits" );
2932 case Qgis::RenderUnit::MapUnits:
2933 return QStringLiteral(
"MapUnit" );
2934 case Qgis::RenderUnit::Pixels:
2935 return QStringLiteral(
"Pixel" );
2936 case Qgis::RenderUnit::Percentage:
2937 return QStringLiteral(
"Percentage" );
2938 case Qgis::RenderUnit::Points:
2939 return QStringLiteral(
"Point" );
2940 case Qgis::RenderUnit::Inches:
2941 return QStringLiteral(
"Inch" );
2942 case Qgis::RenderUnit::Unknown:
2950 const QString normalized =
string.trimmed().toLower();
2955 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Millimeters ).toLower() )
2956 return Qgis::RenderUnit::Millimeters;
2957 if ( normalized ==
encodeUnit( Qgis::RenderUnit::MetersInMapUnits ).toLower() )
2958 return Qgis::RenderUnit::MetersInMapUnits;
2959 if ( normalized == QLatin1String(
"meters" ) )
2960 return Qgis::RenderUnit::MetersInMapUnits;
2961 if ( normalized ==
encodeUnit( Qgis::RenderUnit::MapUnits ).toLower() )
2962 return Qgis::RenderUnit::MapUnits;
2963 if ( normalized == QLatin1String(
"mapunits" ) )
2964 return Qgis::RenderUnit::MapUnits;
2965 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Pixels ).toLower() )
2966 return Qgis::RenderUnit::Pixels;
2967 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Percentage ).toLower() )
2968 return Qgis::RenderUnit::Percentage;
2969 if ( normalized == QLatin1String(
"percent" ) )
2970 return Qgis::RenderUnit::Percentage;
2971 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Points ).toLower() )
2972 return Qgis::RenderUnit::Points;
2973 if ( normalized == QLatin1String(
"points" ) )
2974 return Qgis::RenderUnit::Points;
2975 if ( normalized ==
encodeUnit( Qgis::RenderUnit::Inches ).toLower() )
2976 return Qgis::RenderUnit::Inches;
2982 return Qgis::RenderUnit::Millimeters;
2989 case Qgis::RenderUnit::Millimeters:
2990 return QObject::tr(
"millimeters",
"render" );
2992 case Qgis::RenderUnit::MetersInMapUnits:
2993 return QObject::tr(
"meters at scale",
"render" );
2995 case Qgis::RenderUnit::MapUnits:
2996 return QObject::tr(
"map units",
"render" );
2998 case Qgis::RenderUnit::Pixels:
2999 return QObject::tr(
"pixels",
"render" );
3001 case Qgis::RenderUnit::Percentage:
3002 return QObject::tr(
"percent",
"render" );
3004 case Qgis::RenderUnit::Points:
3005 return QObject::tr(
"points",
"render" );
3007 case Qgis::RenderUnit::Inches:
3008 return QObject::tr(
"inches",
"render" );
3010 case Qgis::RenderUnit::Unknown:
3011 return QObject::tr(
"<unknown>",
"render" );
3023 case Qgis::LayoutUnit::Centimeters:
3024 return QStringLiteral(
"cm" );
3025 case Qgis::LayoutUnit::Meters:
3026 return QStringLiteral(
"m" );
3027 case Qgis::LayoutUnit::Inches:
3028 return QStringLiteral(
"in" );
3029 case Qgis::LayoutUnit::Feet:
3030 return QStringLiteral(
"ft" );
3031 case Qgis::LayoutUnit::Points:
3032 return QStringLiteral(
"pt" );
3033 case Qgis::LayoutUnit::Picas:
3034 return QStringLiteral(
"pi" );
3035 case Qgis::LayoutUnit::Pixels:
3036 return QStringLiteral(
"px" );
3037 case Qgis::LayoutUnit::Millimeters:
3038 return QStringLiteral(
"mm" );
3045 const QString normalized =
string.trimmed().toLower();
3050 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Millimeters ).toLower() )
3051 return Qgis::LayoutUnit::Millimeters;
3052 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Centimeters ).toLower() )
3053 return Qgis::LayoutUnit::Centimeters;
3054 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Meters ).toLower() )
3055 return Qgis::LayoutUnit::Meters;
3056 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Inches ).toLower() )
3057 return Qgis::LayoutUnit::Inches;
3058 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Feet ).toLower() )
3059 return Qgis::LayoutUnit::Feet;
3060 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Points ).toLower() )
3061 return Qgis::LayoutUnit::Points;
3062 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Picas ).toLower() )
3063 return Qgis::LayoutUnit::Picas;
3064 if ( normalized ==
encodeUnit( Qgis::LayoutUnit::Pixels ).toLower() )
3065 return Qgis::LayoutUnit::Pixels;
3071 return Qgis::LayoutUnit::Millimeters;
3078 case Qgis::LayoutUnit::Pixels:
3079 return Qgis::LayoutUnitType::ScreenUnits;
3080 case Qgis::LayoutUnit::Millimeters:
3081 case Qgis::LayoutUnit::Centimeters:
3082 case Qgis::LayoutUnit::Meters:
3083 case Qgis::LayoutUnit::Inches:
3084 case Qgis::LayoutUnit::Feet:
3085 case Qgis::LayoutUnit::Points:
3086 case Qgis::LayoutUnit::Picas:
3087 return Qgis::LayoutUnitType::PaperUnits;
3091 return Qgis::LayoutUnitType::PaperUnits;
3098 case Qgis::LayoutUnit::Pixels:
3099 return QObject::tr(
"px" );
3100 case Qgis::LayoutUnit::Millimeters:
3101 return QObject::tr(
"mm" );
3102 case Qgis::LayoutUnit::Centimeters:
3103 return QObject::tr(
"cm" );
3104 case Qgis::LayoutUnit::Meters:
3105 return QObject::tr(
"m" );
3106 case Qgis::LayoutUnit::Inches:
3107 return QObject::tr(
"in",
"unit inch" );
3108 case Qgis::LayoutUnit::Feet:
3109 return QObject::tr(
"ft" );
3110 case Qgis::LayoutUnit::Points:
3111 return QObject::tr(
"pt" );
3112 case Qgis::LayoutUnit::Picas:
3113 return QObject::tr(
"pica" );
3122 case Qgis::LayoutUnit::Pixels:
3123 return QObject::tr(
"pixels" );
3124 case Qgis::LayoutUnit::Millimeters:
3125 return QObject::tr(
"millimeters" );
3126 case Qgis::LayoutUnit::Centimeters:
3127 return QObject::tr(
"centimeters" );
3128 case Qgis::LayoutUnit::Meters:
3129 return QObject::tr(
"meters" );
3130 case Qgis::LayoutUnit::Inches:
3131 return QObject::tr(
"inches" );
3132 case Qgis::LayoutUnit::Feet:
3133 return QObject::tr(
"feet" );
3134 case Qgis::LayoutUnit::Points:
3135 return QObject::tr(
"points" );
3136 case Qgis::LayoutUnit::Picas:
3137 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.
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.