QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgscoordinatereferencesystemutils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgscoordinatereferencesystemutils.h
3 -------------------
4 begin : April 2022
5 copyright : (C) 202 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
19
21{
22 // crs may be a compound crs, so get just the horizontal component first
23 const QgsCoordinateReferenceSystem horizontalCrs = crs.horizontalCrs();
24 if ( !horizontalCrs.isValid() )
26
27 const QList< Qgis::CrsAxisDirection > axisList = horizontalCrs.axisOrdering();
28 if ( axisList.size() < 2 )
30
31 for ( Qgis::CrsAxisDirection axis : axisList )
32 {
33 // we're trying to map all the different possible values to just XY or YX, so excuse the coarseness!
34 switch ( axis )
35 {
46
61
80 break;
81 }
82 }
83
85}
86
88{
89 switch ( axis )
90 {
92 return QObject::tr( "N", "axis" );
94 return QObject::tr( "NNE", "axis" );
96 return QObject::tr( "SSE", "axis" );
98 return QObject::tr( "S", "axis" );
100 return QObject::tr( "SSW", "axis" );
102 return QObject::tr( "NNW", "axis" );
104 return QObject::tr( "Y", "axis" );
106 return QObject::tr( "Up", "axis" );
108 return QObject::tr( "Down", "axis" );
110 return QObject::tr( "NE", "axis" );
112 return QObject::tr( "ENE", "axis" );
114 return QObject::tr( "E", "axis" );
116 return QObject::tr( "ESE", "axis" );
118 return QObject::tr( "SE", "axis" );
120 return QObject::tr( "SW", "axis" );
122 return QObject::tr( "WSW", "axis" );
124 return QObject::tr( "W", "axis" );
126 return QObject::tr( "WNW", "axis" );
128 return QObject::tr( "NW", "axis" );
130 return QObject::tr( "X", "axis" );
132 return QObject::tr( "Disp. R", "axis" );
134 return QObject::tr( "Disp. L", "axis" );
136 return QObject::tr( "Z", "axis" );
138 return QObject::tr( "U", "axis" );
140 return QObject::tr( "D", "axis" );
142 return QObject::tr( "F", "axis" );
144 return QObject::tr( "A", "axis" );
146 return QObject::tr( "P", "axis" );
148 return QObject::tr( "STBD", "axis" );
150 return QObject::tr( "CW", "axis" );
152 return QObject::tr( "CCW", "axis" );
154 return QObject::tr( "C+", "axis" );
156 return QObject::tr( "C-", "axis" );
158 return QObject::tr( "R+", "axis" );
160 return QObject::tr( "R-", "axis" );
162 return QObject::tr( "F", "axis" );
164 return QObject::tr( "P", "axis" );
166 return QObject::tr( "T", "axis" );
168 return QObject::tr( "AF", "axis" );
170 break;
171 }
172
173 return QString();
174}
175
177{
178 switch ( type )
179 {
181 return QObject::tr( "Unknown" );
183 return QObject::tr( "Other" );
185 return QObject::tr( "Geodetic" );
187 return QObject::tr( "Geocentric" );
189 return QObject::tr( "Geographic (2D)" );
191 return QObject::tr( "Geographic (3D)" );
193 return QObject::tr( "Vertical" );
195 return QObject::tr( "Projected" );
197 return QObject::tr( "Compound" );
199 return QObject::tr( "Temporal" );
201 return QObject::tr( "Engineering" );
203 return QObject::tr( "Bound" );
205 return QObject::tr( "Derived projected" );
206 }
207 return QString();
208}
209
211{
212 if ( projection == QLatin1String( "adams_ws2" ) )
213 return QObject::tr( "Adams World in a Square II" );
214 if ( projection == QLatin1String( "aea" ) )
215 return QObject::tr( "Albers Equal Area" );
216 if ( projection == QLatin1String( "aeqd" ) )
217 return QObject::tr( "Azimuthal Equidistant" );
218 if ( projection == QLatin1String( "airy" ) )
219 return QObject::tr( "Airy" );
220 if ( projection == QLatin1String( "aitoff" ) )
221 return QObject::tr( "Aitoff" );
222 if ( projection == QLatin1String( "alsk" ) )
223 return QObject::tr( "Modified Stererographics of Alaska" );
224 if ( projection == QLatin1String( "apian" ) )
225 return QObject::tr( "Apian Globular I" );
226 if ( projection == QLatin1String( "august" ) )
227 return QObject::tr( "August Epicycloidal" );
228 if ( projection == QLatin1String( "bacon" ) )
229 return QObject::tr( "Bacon Globular" );
230 if ( projection == QLatin1String( "bipc" ) )
231 return QObject::tr( "Bipolar Conic of Western Hemisphere" );
232 if ( projection == QLatin1String( "boggs" ) )
233 return QObject::tr( "Boggs Eumorphic" );
234 if ( projection == QLatin1String( "bonne" ) )
235 return QObject::tr( "Bonne (Werner lat_1=90)" );
236 if ( projection == QLatin1String( "cass" ) )
237 return QObject::tr( "Cassini" );
238 if ( projection == QLatin1String( "cc" ) )
239 return QObject::tr( "Central Cylindrical" );
240 if ( projection == QLatin1String( "cea" ) )
241 return QObject::tr( "Equal Area Cylindrical" );
242 if ( projection == QLatin1String( "chamb" ) )
243 return QObject::tr( "Chamberlin Trimetric" );
244 if ( projection == QLatin1String( "col_urban" ) )
245 return QObject::tr( "Colombia Urban" );
246 if ( projection == QLatin1String( "collg" ) )
247 return QObject::tr( "Collignon" );
248 if ( projection == QLatin1String( "comill" ) )
249 return QObject::tr( "Compact Miller" );
250 if ( projection == QLatin1String( "crast" ) )
251 return QObject::tr( "Craster Parabolic (Putnins P4)" );
252 if ( projection == QLatin1String( "denoy" ) )
253 return QObject::tr( "Denoyer Semi-Elliptical" );
254 if ( projection == QLatin1String( "eck1" ) )
255 return QObject::tr( "Eckert I" );
256 if ( projection == QLatin1String( "eck2" ) )
257 return QObject::tr( "Eckert II" );
258 if ( projection == QLatin1String( "eck3" ) )
259 return QObject::tr( "Eckert III" );
260 if ( projection == QLatin1String( "eck4" ) )
261 return QObject::tr( "Eckert IV" );
262 if ( projection == QLatin1String( "eck5" ) )
263 return QObject::tr( "Eckert V" );
264 if ( projection == QLatin1String( "eck6" ) )
265 return QObject::tr( "Eckert VI" );
266 if ( projection == QLatin1String( "eqc" ) )
267 return QObject::tr( "Equidistant Cylindrical (Plate Carrée)" );
268 if ( projection == QLatin1String( "eqdc" ) )
269 return QObject::tr( "Equidistant Conic" );
270 if ( projection == QLatin1String( "eqearth" ) )
271 return QObject::tr( "Equal Earth" );
272 if ( projection == QLatin1String( "euler" ) )
273 return QObject::tr( "Euler" );
274 if ( projection == QLatin1String( "fahey" ) )
275 return QObject::tr( "Fahey" );
276 if ( projection == QLatin1String( "fouc" ) )
277 return QObject::tr( "Foucaut" );
278 if ( projection == QLatin1String( "fouc_s" ) )
279 return QObject::tr( "Foucaut Sinusoidal" );
280 if ( projection == QLatin1String( "gall" ) )
281 return QObject::tr( "Gall (Gall Stereographic)" );
282 if ( projection == QLatin1String( "geocent" ) )
283 return QObject::tr( "Geocentric" );
284 if ( projection == QLatin1String( "geos" ) )
285 return QObject::tr( "Geostationary Satellite View" );
286 if ( projection == QLatin1String( "gins8" ) )
287 return QObject::tr( "Ginsburg VIII (TsNIIGAiK)" );
288 if ( projection == QLatin1String( "gn_sinu" ) )
289 return QObject::tr( "General Sinusoidal Series" );
290 if ( projection == QLatin1String( "gnom" ) )
291 return QObject::tr( "Gnomonic" );
292 if ( projection == QLatin1String( "goode" ) )
293 return QObject::tr( "Goode Homolosine" );
294 if ( projection == QLatin1String( "gs48" ) )
295 return QObject::tr( "Modified Stererographics of 48 U.S." );
296 if ( projection == QLatin1String( "gs50" ) )
297 return QObject::tr( "Modified Stererographics of 50 U.S." );
298 if ( projection == QLatin1String( "hammer" ) )
299 return QObject::tr( "Hammer & Eckert-Greifendorff" );
300 if ( projection == QLatin1String( "hatano" ) )
301 return QObject::tr( "Hatano Asymmetrical Equal Area" );
302 if ( projection == QLatin1String( "igh" ) )
303 return QObject::tr( "Interrupted Goode Homolosine" );
304 if ( projection == QLatin1String( "igh_o" ) )
305 return QObject::tr( "Interrupted Goode Homolosine (Oceanic View)" );
306 if ( projection == QLatin1String( "imw_p" ) )
307 return QObject::tr( "International Map of the World Polyconic" );
308 if ( projection == QLatin1String( "kav5" ) )
309 return QObject::tr( "Kavraisky V" );
310 if ( projection == QLatin1String( "kav7" ) )
311 return QObject::tr( "Kavraisky VII" );
312 if ( projection == QLatin1String( "krovak" ) )
313 return QObject::tr( "Krovak" );
314 if ( projection == QLatin1String( "labrd" ) )
315 return QObject::tr( "Laborde" );
316 if ( projection == QLatin1String( "laea" ) )
317 return QObject::tr( "Lambert Azimuthal Equal Area" );
318 if ( projection == QLatin1String( "lagrng" ) )
319 return QObject::tr( "Lagrange" );
320 if ( projection == QLatin1String( "larr" ) )
321 return QObject::tr( "Larrivee" );
322 if ( projection == QLatin1String( "lask" ) )
323 return QObject::tr( "Laskowski" );
324 if ( projection == QLatin1String( "longlat" ) )
325 return QObject::tr( "Long/lat (Geodetic Alias)" );
326 if ( projection == QLatin1String( "latlong" ) )
327 return QObject::tr( "Lat/long (Geodetic Alias)" );
328 if ( projection == QLatin1String( "lcc" ) )
329 return QObject::tr( "Lambert Conformal Conic" );
330 if ( projection == QLatin1String( "lcca" ) )
331 return QObject::tr( "Lambert Conformal Conic Alternative" );
332 if ( projection == QLatin1String( "leac" ) )
333 return QObject::tr( "Lambert Equal Area Conic" );
334 if ( projection == QLatin1String( "lee_os" ) )
335 return QObject::tr( "Lee Oblated Stereographic" );
336 if ( projection == QLatin1String( "loxim" ) )
337 return QObject::tr( "Loximuthal" );
338 if ( projection == QLatin1String( "lsat" ) ) //#spellok
339 return QObject::tr( "Space Oblique for LANDSAT" );
340 if ( projection == QLatin1String( "mbt_s" ) )
341 return QObject::tr( "McBryde-Thomas Flat-Polar Sine (No. 1)" );
342 if ( projection == QLatin1String( "mbt_fps" ) )
343 return QObject::tr( "McBryde-Thomas Flat-Pole Sine (No. 2)" );
344 if ( projection == QLatin1String( "mbtfpp" ) )
345 return QObject::tr( "McBride-Thomas Flat-Polar Parabolic" );
346 if ( projection == QLatin1String( "mbtfpq" ) )
347 return QObject::tr( "McBryde-Thomas Flat-Polar Quartic" );
348 if ( projection == QLatin1String( "mbtfps" ) )
349 return QObject::tr( "McBryde-Thomas Flat-Polar Sinusoidal" );
350 if ( projection == QLatin1String( "merc" ) )
351 return QObject::tr( "Mercator" );
352 if ( projection == QLatin1String( "mil_os" ) )
353 return QObject::tr( "Miller Oblated Stereographic" );
354 if ( projection == QLatin1String( "mill" ) )
355 return QObject::tr( "Miller Cylindrical" );
356 if ( projection == QLatin1String( "mod_krovak" ) )
357 return QObject::tr( "Modified Krovak" );
358 if ( projection == QLatin1String( "moll" ) )
359 return QObject::tr( "Mollweide" );
360 if ( projection == QLatin1String( "murd1" ) )
361 return QObject::tr( "Murdoch I" );
362 if ( projection == QLatin1String( "murd2" ) )
363 return QObject::tr( "Murdoch II" );
364 if ( projection == QLatin1String( "murd3" ) )
365 return QObject::tr( "Murdoch III" );
366 if ( projection == QLatin1String( "natearth" ) )
367 return QObject::tr( "Natural Earth" );
368 if ( projection == QLatin1String( "natearth2" ) )
369 return QObject::tr( "Natural Earth II" );
370 if ( projection == QLatin1String( "nell" ) )
371 return QObject::tr( "Nell" );
372 if ( projection == QLatin1String( "nell_h" ) )
373 return QObject::tr( "Nell-Hammer" );
374 if ( projection == QLatin1String( "nicol" ) )
375 return QObject::tr( "Nicolosi Globular" );
376 if ( projection == QLatin1String( "nsper" ) )
377 return QObject::tr( "Near-sided Perspective" );
378 if ( projection == QLatin1String( "nzmg" ) )
379 return QObject::tr( "New Zealand Map Grid" );
380 if ( projection == QLatin1String( "ob_tran" ) )
381 return QObject::tr( "General Oblique Transformation" );
382 if ( projection == QLatin1String( "ocea" ) )
383 return QObject::tr( "Oblique Cylindrical Equal Area" );
384 if ( projection == QLatin1String( "oea" ) )
385 return QObject::tr( "Oblated Equal Area" );
386 if ( projection == QLatin1String( "omerc" ) )
387 return QObject::tr( "Oblique Mercator" );
388 if ( projection == QLatin1String( "ortel" ) )
389 return QObject::tr( "Ortelius Oval" );
390 if ( projection == QLatin1String( "ortho" ) )
391 return QObject::tr( "Orthographic" );
392 if ( projection == QLatin1String( "patterson" ) )
393 return QObject::tr( "Patterson" );
394 if ( projection == QLatin1String( "pconic" ) )
395 return QObject::tr( "Perspective Conic" );
396 if ( projection == QLatin1String( "peirce_q" ) )
397 return QObject::tr( "Peirce Quincuncial" );
398 if ( projection == QLatin1String( "poly" ) )
399 return QObject::tr( "Polyconic (American)" );
400 if ( projection == QLatin1String( "putp1" ) )
401 return QObject::tr( "Putnins P1" );
402 if ( projection == QLatin1String( "putp2" ) )
403 return QObject::tr( "Putnins P2" );
404 if ( projection == QLatin1String( "putp3" ) )
405 return QObject::tr( "Putnins P3" );
406 if ( projection == QLatin1String( "putp3p" ) )
407 return QObject::tr( "Putnins P3'" );
408 if ( projection == QLatin1String( "putp4p" ) )
409 return QObject::tr( "Putnins P4'" );
410 if ( projection == QLatin1String( "putp5" ) )
411 return QObject::tr( "Putnins P5" );
412 if ( projection == QLatin1String( "putp5p" ) )
413 return QObject::tr( "Putnins P5'" );
414 if ( projection == QLatin1String( "putp6" ) )
415 return QObject::tr( "Putnins P6" );
416 if ( projection == QLatin1String( "putp6p" ) )
417 return QObject::tr( "Putnins P6'" );
418 if ( projection == QLatin1String( "qua_aut" ) )
419 return QObject::tr( "Quartic Authalic" );
420 if ( projection == QLatin1String( "robin" ) )
421 return QObject::tr( "Robinson" );
422 if ( projection == QLatin1String( "rouss" ) )
423 return QObject::tr( "Roussilhe Stereographic" );
424 if ( projection == QLatin1String( "rpoly" ) )
425 return QObject::tr( "Rectangular Polyconic" );
426 if ( projection == QLatin1String( "sinu" ) )
427 return QObject::tr( "Sinusoidal (Sanson-Flamsteed)" );
428 if ( projection == QLatin1String( "somerc" ) )
429 return QObject::tr( "Swiss Oblique Mercator" );
430 if ( projection == QLatin1String( "stere" ) )
431 return QObject::tr( "Stereographic" );
432 if ( projection == QLatin1String( "sterea" ) )
433 return QObject::tr( "Oblique Stereographic Alternative" );
434 if ( projection == QLatin1String( "tcc" ) )
435 return QObject::tr( "Transverse Central Cylindrical" );
436 if ( projection == QLatin1String( "tcea" ) )
437 return QObject::tr( "Transverse Cylindrical Equal Area" );
438 if ( projection == QLatin1String( "times" ) )
439 return QObject::tr( "Times" );
440 if ( projection == QLatin1String( "tissot" ) )
441 return QObject::tr( "Tissot" );
442 if ( projection == QLatin1String( "tmerc" ) )
443 return QObject::tr( "Transverse Mercator" );
444 if ( projection == QLatin1String( "tpeqd" ) )
445 return QObject::tr( "Two Point Equidistant" );
446 if ( projection == QLatin1String( "tpers" ) )
447 return QObject::tr( "Tilted Perspective" );
448 if ( projection == QLatin1String( "ups" ) )
449 return QObject::tr( "Universal Polar Stereographic" );
450 if ( projection == QLatin1String( "urm5" ) )
451 return QObject::tr( "Urmaev V" );
452 if ( projection == QLatin1String( "urmfps" ) )
453 return QObject::tr( "Urmaev Flat-Polar Sinusoidal" );
454 if ( projection == QLatin1String( "utm" ) )
455 return QObject::tr( "Universal Transverse Mercator (UTM)" );
456 if ( projection == QLatin1String( "vandg" ) )
457 return QObject::tr( "van der Grinten (I)" );
458 if ( projection == QLatin1String( "vandg2" ) )
459 return QObject::tr( "van der Grinten II" );
460 if ( projection == QLatin1String( "vandg3" ) )
461 return QObject::tr( "van der Grinten III" );
462 if ( projection == QLatin1String( "vandg4" ) )
463 return QObject::tr( "van der Grinten IV" );
464 if ( projection == QLatin1String( "vitk1" ) )
465 return QObject::tr( "Vitkovsky I" );
466 if ( projection == QLatin1String( "wag1" ) )
467 return QObject::tr( "Wagner I (Kavraisky VI)" );
468 if ( projection == QLatin1String( "wag2" ) )
469 return QObject::tr( "Wagner II" );
470 if ( projection == QLatin1String( "wag3" ) )
471 return QObject::tr( "Wagner III" );
472 if ( projection == QLatin1String( "wag4" ) )
473 return QObject::tr( "Wagner IV" );
474 if ( projection == QLatin1String( "wag5" ) )
475 return QObject::tr( "Wagner V" );
476 if ( projection == QLatin1String( "wag6" ) )
477 return QObject::tr( "Wagner VI" );
478 if ( projection == QLatin1String( "wag7" ) )
479 return QObject::tr( "Wagner VII" );
480 if ( projection == QLatin1String( "weren" ) )
481 return QObject::tr( "Werenskiold I" );
482 if ( projection == QLatin1String( "wink1" ) )
483 return QObject::tr( "Winkel I" );
484 if ( projection == QLatin1String( "wink2" ) )
485 return QObject::tr( "Winkel II" );
486 if ( projection == QLatin1String( "wintri" ) )
487 return QObject::tr( "Winkel Tripel" );
488 if ( projection == QLatin1String( "gstmerc" ) )
489 return QObject::tr( "Gauss-Schreiber" );
490 return QString();
491}
CrsType
Coordinate reference system types.
Definition qgis.h:2222
@ Vertical
Vertical CRS.
@ Temporal
Temporal CRS.
@ Compound
Compound (horizontal + vertical) CRS.
@ Projected
Projected CRS.
@ Other
Other type.
@ Bound
Bound CRS.
@ DerivedProjected
Derived projected CRS.
@ Unknown
Unknown type.
@ Engineering
Engineering CRS.
@ Geographic3d
3D geopraphic CRS
@ Geodetic
Geodetic CRS.
@ Geographic2d
2D geographic CRS
@ Geocentric
Geocentric CRS.
CoordinateOrder
Order of coordinates.
Definition qgis.h:2297
@ XY
Easting/Northing (or Longitude/Latitude for geographic CRS)
@ YX
Northing/Easting (or Latitude/Longitude for geographic CRS)
CrsAxisDirection
Coordinate reference system axis directions.
Definition qgis.h:2247
@ ColumnPositive
Column positive.
@ SouthSouthEast
South South East.
@ NorthWest
North West.
@ ColumnNegative
Column negative.
@ RowPositive
Row positive.
@ DisplayDown
Display down.
@ GeocentricZ
Geocentric (Z)
@ DisplayRight
Display right.
@ WestSouthWest
West South West.
@ RowNegative
Row negative.
@ NorthNorthEast
North North East.
@ EastNorthEast
East North East.
@ Unspecified
Unspecified.
@ NorthEast
North East.
@ NorthNorthWest
North North West.
@ GeocentricY
Geocentric (Y)
@ SouthEast
South East.
@ CounterClockwise
Counter clockwise.
@ SouthSouthWest
South South West.
@ DisplayLeft
Display left.
@ WestNorthWest
West North West.
@ EastSouthEast
East South East.
@ SouthWest
South West.
@ DisplayUp
Display up.
@ GeocentricX
Geocentric (X)
static QString crsTypeToString(Qgis::CrsType type)
Returns a translated string representing a CRS type.
static QString translateProjection(const QString &projection)
Returns a translated string for a projection method.
static Qgis::CoordinateOrder defaultCoordinateOrderForCrs(const QgsCoordinateReferenceSystem &crs)
Returns the default coordinate order to use for the specified crs.
static QString axisDirectionToAbbreviatedString(Qgis::CrsAxisDirection axis)
Returns a translated abbreviation representing an axis direction.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QgsCoordinateReferenceSystem horizontalCrs() const
Returns the horizontal CRS associated with this CRS object.
QList< Qgis::CrsAxisDirection > axisOrdering() const
Returns an ordered list of the axis directions reflecting the native axis order for the CRS.
const QgsCoordinateReferenceSystem & crs