QGIS API Documentation 3.99.0-Master (a8882ad4560)
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 ***************************************************************************/
18
20
22{
23 // crs may be a compound crs, so get just the horizontal component first
24 const QgsCoordinateReferenceSystem horizontalCrs = crs.horizontalCrs();
25 if ( !horizontalCrs.isValid() )
27
28 const QList< Qgis::CrsAxisDirection > axisList = horizontalCrs.axisOrdering();
29 if ( axisList.size() < 2 )
31
32 for ( Qgis::CrsAxisDirection axis : axisList )
33 {
34 // we're trying to map all the different possible values to just XY or YX, so excuse the coarseness!
35 switch ( axis )
36 {
47
62
81 break;
82 }
83 }
84
86}
87
89{
90 switch ( axis )
91 {
93 return QObject::tr( "N", "axis" );
95 return QObject::tr( "NNE", "axis" );
97 return QObject::tr( "SSE", "axis" );
99 return QObject::tr( "S", "axis" );
101 return QObject::tr( "SSW", "axis" );
103 return QObject::tr( "NNW", "axis" );
105 return QObject::tr( "Y", "axis" );
107 return QObject::tr( "Up", "axis" );
109 return QObject::tr( "Down", "axis" );
111 return QObject::tr( "NE", "axis" );
113 return QObject::tr( "ENE", "axis" );
115 return QObject::tr( "E", "axis" );
117 return QObject::tr( "ESE", "axis" );
119 return QObject::tr( "SE", "axis" );
121 return QObject::tr( "SW", "axis" );
123 return QObject::tr( "WSW", "axis" );
125 return QObject::tr( "W", "axis" );
127 return QObject::tr( "WNW", "axis" );
129 return QObject::tr( "NW", "axis" );
131 return QObject::tr( "X", "axis" );
133 return QObject::tr( "Disp. R", "axis" );
135 return QObject::tr( "Disp. L", "axis" );
137 return QObject::tr( "Z", "axis" );
139 return QObject::tr( "U", "axis" );
141 return QObject::tr( "D", "axis" );
143 return QObject::tr( "F", "axis" );
145 return QObject::tr( "A", "axis" );
147 return QObject::tr( "P", "axis" );
149 return QObject::tr( "STBD", "axis" );
151 return QObject::tr( "CW", "axis" );
153 return QObject::tr( "CCW", "axis" );
155 return QObject::tr( "C+", "axis" );
157 return QObject::tr( "C-", "axis" );
159 return QObject::tr( "R+", "axis" );
161 return QObject::tr( "R-", "axis" );
163 return QObject::tr( "F", "axis" );
165 return QObject::tr( "P", "axis" );
167 return QObject::tr( "T", "axis" );
169 return QObject::tr( "AF", "axis" );
171 break;
172 }
173
174 return QString();
175}
176
178{
179 switch ( type )
180 {
182 return QObject::tr( "Unknown" );
184 return QObject::tr( "Other" );
186 return QObject::tr( "Geodetic" );
188 return QObject::tr( "Geocentric" );
190 return QObject::tr( "Geographic (2D)" );
192 return QObject::tr( "Geographic (3D)" );
194 return QObject::tr( "Vertical" );
196 return QObject::tr( "Projected" );
198 return QObject::tr( "Compound" );
200 return QObject::tr( "Temporal" );
202 return QObject::tr( "Engineering" );
204 return QObject::tr( "Bound" );
206 return QObject::tr( "Derived projected" );
207 }
208 return QString();
209}
210
212{
213 if ( projection == "adams_ws2"_L1 )
214 return QObject::tr( "Adams World in a Square II" );
215 if ( projection == "aea"_L1 )
216 return QObject::tr( "Albers Equal Area" );
217 if ( projection == "aeqd"_L1 )
218 return QObject::tr( "Azimuthal Equidistant" );
219 if ( projection == "airy"_L1 )
220 return QObject::tr( "Airy" );
221 if ( projection == "aitoff"_L1 )
222 return QObject::tr( "Aitoff" );
223 if ( projection == "alsk"_L1 )
224 return QObject::tr( "Modified Stererographics of Alaska" );
225 if ( projection == "apian"_L1 )
226 return QObject::tr( "Apian Globular I" );
227 if ( projection == "august"_L1 )
228 return QObject::tr( "August Epicycloidal" );
229 if ( projection == "bacon"_L1 )
230 return QObject::tr( "Bacon Globular" );
231 if ( projection == "bipc"_L1 )
232 return QObject::tr( "Bipolar Conic of Western Hemisphere" );
233 if ( projection == "boggs"_L1 )
234 return QObject::tr( "Boggs Eumorphic" );
235 if ( projection == "bonne"_L1 )
236 return QObject::tr( "Bonne (Werner lat_1=90)" );
237 if ( projection == "cass"_L1 )
238 return QObject::tr( "Cassini" );
239 if ( projection == "cc"_L1 )
240 return QObject::tr( "Central Cylindrical" );
241 if ( projection == "cea"_L1 )
242 return QObject::tr( "Equal Area Cylindrical" );
243 if ( projection == "chamb"_L1 )
244 return QObject::tr( "Chamberlin Trimetric" );
245 if ( projection == "col_urban"_L1 )
246 return QObject::tr( "Colombia Urban" );
247 if ( projection == "collg"_L1 )
248 return QObject::tr( "Collignon" );
249 if ( projection == "comill"_L1 )
250 return QObject::tr( "Compact Miller" );
251 if ( projection == "crast"_L1 )
252 return QObject::tr( "Craster Parabolic (Putnins P4)" );
253 if ( projection == "denoy"_L1 )
254 return QObject::tr( "Denoyer Semi-Elliptical" );
255 if ( projection == "eck1"_L1 )
256 return QObject::tr( "Eckert I" );
257 if ( projection == "eck2"_L1 )
258 return QObject::tr( "Eckert II" );
259 if ( projection == "eck3"_L1 )
260 return QObject::tr( "Eckert III" );
261 if ( projection == "eck4"_L1 )
262 return QObject::tr( "Eckert IV" );
263 if ( projection == "eck5"_L1 )
264 return QObject::tr( "Eckert V" );
265 if ( projection == "eck6"_L1 )
266 return QObject::tr( "Eckert VI" );
267 if ( projection == "eqc"_L1 )
268 return QObject::tr( "Equidistant Cylindrical (Plate Carrée)" );
269 if ( projection == "eqdc"_L1 )
270 return QObject::tr( "Equidistant Conic" );
271 if ( projection == "eqearth"_L1 )
272 return QObject::tr( "Equal Earth" );
273 if ( projection == "euler"_L1 )
274 return QObject::tr( "Euler" );
275 if ( projection == "fahey"_L1 )
276 return QObject::tr( "Fahey" );
277 if ( projection == "fouc"_L1 )
278 return QObject::tr( "Foucaut" );
279 if ( projection == "fouc_s"_L1 )
280 return QObject::tr( "Foucaut Sinusoidal" );
281 if ( projection == "gall"_L1 )
282 return QObject::tr( "Gall (Gall Stereographic)" );
283 if ( projection == "geocent"_L1 )
284 return QObject::tr( "Geocentric" );
285 if ( projection == "geos"_L1 )
286 return QObject::tr( "Geostationary Satellite View" );
287 if ( projection == "gins8"_L1 )
288 return QObject::tr( "Ginsburg VIII (TsNIIGAiK)" );
289 if ( projection == "gn_sinu"_L1 )
290 return QObject::tr( "General Sinusoidal Series" );
291 if ( projection == "gnom"_L1 )
292 return QObject::tr( "Gnomonic" );
293 if ( projection == "goode"_L1 )
294 return QObject::tr( "Goode Homolosine" );
295 if ( projection == "gs48"_L1 )
296 return QObject::tr( "Modified Stererographics of 48 U.S." );
297 if ( projection == "gs50"_L1 )
298 return QObject::tr( "Modified Stererographics of 50 U.S." );
299 if ( projection == "hammer"_L1 )
300 return QObject::tr( "Hammer & Eckert-Greifendorff" );
301 if ( projection == "hatano"_L1 )
302 return QObject::tr( "Hatano Asymmetrical Equal Area" );
303 if ( projection == "igh"_L1 )
304 return QObject::tr( "Interrupted Goode Homolosine" );
305 if ( projection == "igh_o"_L1 )
306 return QObject::tr( "Interrupted Goode Homolosine (Oceanic View)" );
307 if ( projection == "imw_p"_L1 )
308 return QObject::tr( "International Map of the World Polyconic" );
309 if ( projection == "kav5"_L1 )
310 return QObject::tr( "Kavraisky V" );
311 if ( projection == "kav7"_L1 )
312 return QObject::tr( "Kavraisky VII" );
313 if ( projection == "krovak"_L1 )
314 return QObject::tr( "Krovak" );
315 if ( projection == "labrd"_L1 )
316 return QObject::tr( "Laborde" );
317 if ( projection == "laea"_L1 )
318 return QObject::tr( "Lambert Azimuthal Equal Area" );
319 if ( projection == "lagrng"_L1 )
320 return QObject::tr( "Lagrange" );
321 if ( projection == "larr"_L1 )
322 return QObject::tr( "Larrivee" );
323 if ( projection == "lask"_L1 )
324 return QObject::tr( "Laskowski" );
325 if ( projection == "longlat"_L1 )
326 return QObject::tr( "Long/lat (Geodetic Alias)" );
327 if ( projection == "latlong"_L1 )
328 return QObject::tr( "Lat/long (Geodetic Alias)" );
329 if ( projection == "lcc"_L1 )
330 return QObject::tr( "Lambert Conformal Conic" );
331 if ( projection == "lcca"_L1 )
332 return QObject::tr( "Lambert Conformal Conic Alternative" );
333 if ( projection == "leac"_L1 )
334 return QObject::tr( "Lambert Equal Area Conic" );
335 if ( projection == "lee_os"_L1 )
336 return QObject::tr( "Lee Oblated Stereographic" );
337 if ( projection == "loxim"_L1 )
338 return QObject::tr( "Loximuthal" );
339 if ( projection == "lsat"_L1 ) //#spellok
340 return QObject::tr( "Space Oblique for LANDSAT" );
341 if ( projection == "mbt_s"_L1 )
342 return QObject::tr( "McBryde-Thomas Flat-Polar Sine (No. 1)" );
343 if ( projection == "mbt_fps"_L1 )
344 return QObject::tr( "McBryde-Thomas Flat-Pole Sine (No. 2)" );
345 if ( projection == "mbtfpp"_L1 )
346 return QObject::tr( "McBride-Thomas Flat-Polar Parabolic" );
347 if ( projection == "mbtfpq"_L1 )
348 return QObject::tr( "McBryde-Thomas Flat-Polar Quartic" );
349 if ( projection == "mbtfps"_L1 )
350 return QObject::tr( "McBryde-Thomas Flat-Polar Sinusoidal" );
351 if ( projection == "merc"_L1 )
352 return QObject::tr( "Mercator" );
353 if ( projection == "mil_os"_L1 )
354 return QObject::tr( "Miller Oblated Stereographic" );
355 if ( projection == "mill"_L1 )
356 return QObject::tr( "Miller Cylindrical" );
357 if ( projection == "mod_krovak"_L1 )
358 return QObject::tr( "Modified Krovak" );
359 if ( projection == "moll"_L1 )
360 return QObject::tr( "Mollweide" );
361 if ( projection == "murd1"_L1 )
362 return QObject::tr( "Murdoch I" );
363 if ( projection == "murd2"_L1 )
364 return QObject::tr( "Murdoch II" );
365 if ( projection == "murd3"_L1 )
366 return QObject::tr( "Murdoch III" );
367 if ( projection == "natearth"_L1 )
368 return QObject::tr( "Natural Earth" );
369 if ( projection == "natearth2"_L1 )
370 return QObject::tr( "Natural Earth II" );
371 if ( projection == "nell"_L1 )
372 return QObject::tr( "Nell" );
373 if ( projection == "nell_h"_L1 )
374 return QObject::tr( "Nell-Hammer" );
375 if ( projection == "nicol"_L1 )
376 return QObject::tr( "Nicolosi Globular" );
377 if ( projection == "nsper"_L1 )
378 return QObject::tr( "Near-sided Perspective" );
379 if ( projection == "nzmg"_L1 )
380 return QObject::tr( "New Zealand Map Grid" );
381 if ( projection == "ob_tran"_L1 )
382 return QObject::tr( "General Oblique Transformation" );
383 if ( projection == "ocea"_L1 )
384 return QObject::tr( "Oblique Cylindrical Equal Area" );
385 if ( projection == "oea"_L1 )
386 return QObject::tr( "Oblated Equal Area" );
387 if ( projection == "omerc"_L1 )
388 return QObject::tr( "Oblique Mercator" );
389 if ( projection == "ortel"_L1 )
390 return QObject::tr( "Ortelius Oval" );
391 if ( projection == "ortho"_L1 )
392 return QObject::tr( "Orthographic" );
393 if ( projection == "patterson"_L1 )
394 return QObject::tr( "Patterson" );
395 if ( projection == "pconic"_L1 )
396 return QObject::tr( "Perspective Conic" );
397 if ( projection == "peirce_q"_L1 )
398 return QObject::tr( "Peirce Quincuncial" );
399 if ( projection == "poly"_L1 )
400 return QObject::tr( "Polyconic (American)" );
401 if ( projection == "putp1"_L1 )
402 return QObject::tr( "Putnins P1" );
403 if ( projection == "putp2"_L1 )
404 return QObject::tr( "Putnins P2" );
405 if ( projection == "putp3"_L1 )
406 return QObject::tr( "Putnins P3" );
407 if ( projection == "putp3p"_L1 )
408 return QObject::tr( "Putnins P3'" );
409 if ( projection == "putp4p"_L1 )
410 return QObject::tr( "Putnins P4'" );
411 if ( projection == "putp5"_L1 )
412 return QObject::tr( "Putnins P5" );
413 if ( projection == "putp5p"_L1 )
414 return QObject::tr( "Putnins P5'" );
415 if ( projection == "putp6"_L1 )
416 return QObject::tr( "Putnins P6" );
417 if ( projection == "putp6p"_L1 )
418 return QObject::tr( "Putnins P6'" );
419 if ( projection == "qua_aut"_L1 )
420 return QObject::tr( "Quartic Authalic" );
421 if ( projection == "robin"_L1 )
422 return QObject::tr( "Robinson" );
423 if ( projection == "rouss"_L1 )
424 return QObject::tr( "Roussilhe Stereographic" );
425 if ( projection == "rpoly"_L1 )
426 return QObject::tr( "Rectangular Polyconic" );
427 if ( projection == "sinu"_L1 )
428 return QObject::tr( "Sinusoidal (Sanson-Flamsteed)" );
429 if ( projection == "spilhaus"_L1 )
430 return QObject::tr( "Spilhaus" );
431 if ( projection == "somerc"_L1 )
432 return QObject::tr( "Swiss Oblique Mercator" );
433 if ( projection == "stere"_L1 )
434 return QObject::tr( "Stereographic" );
435 if ( projection == "sterea"_L1 )
436 return QObject::tr( "Oblique Stereographic Alternative" );
437 if ( projection == "tcc"_L1 )
438 return QObject::tr( "Transverse Central Cylindrical" );
439 if ( projection == "tcea"_L1 )
440 return QObject::tr( "Transverse Cylindrical Equal Area" );
441 if ( projection == "times"_L1 )
442 return QObject::tr( "Times" );
443 if ( projection == "tissot"_L1 )
444 return QObject::tr( "Tissot" );
445 if ( projection == "tmerc"_L1 )
446 return QObject::tr( "Transverse Mercator" );
447 if ( projection == "tpeqd"_L1 )
448 return QObject::tr( "Two Point Equidistant" );
449 if ( projection == "tpers"_L1 )
450 return QObject::tr( "Tilted Perspective" );
451 if ( projection == "ups"_L1 )
452 return QObject::tr( "Universal Polar Stereographic" );
453 if ( projection == "urm5"_L1 )
454 return QObject::tr( "Urmaev V" );
455 if ( projection == "urmfps"_L1 )
456 return QObject::tr( "Urmaev Flat-Polar Sinusoidal" );
457 if ( projection == "utm"_L1 )
458 return QObject::tr( "Universal Transverse Mercator (UTM)" );
459 if ( projection == "vandg"_L1 )
460 return QObject::tr( "van der Grinten (I)" );
461 if ( projection == "vandg2"_L1 )
462 return QObject::tr( "van der Grinten II" );
463 if ( projection == "vandg3"_L1 )
464 return QObject::tr( "van der Grinten III" );
465 if ( projection == "vandg4"_L1 )
466 return QObject::tr( "van der Grinten IV" );
467 if ( projection == "vitk1"_L1 )
468 return QObject::tr( "Vitkovsky I" );
469 if ( projection == "wag1"_L1 )
470 return QObject::tr( "Wagner I (Kavraisky VI)" );
471 if ( projection == "wag2"_L1 )
472 return QObject::tr( "Wagner II" );
473 if ( projection == "wag3"_L1 )
474 return QObject::tr( "Wagner III" );
475 if ( projection == "wag4"_L1 )
476 return QObject::tr( "Wagner IV" );
477 if ( projection == "wag5"_L1 )
478 return QObject::tr( "Wagner V" );
479 if ( projection == "wag6"_L1 )
480 return QObject::tr( "Wagner VI" );
481 if ( projection == "wag7"_L1 )
482 return QObject::tr( "Wagner VII" );
483 if ( projection == "weren"_L1 )
484 return QObject::tr( "Werenskiold I" );
485 if ( projection == "wink1"_L1 )
486 return QObject::tr( "Winkel I" );
487 if ( projection == "wink2"_L1 )
488 return QObject::tr( "Winkel II" );
489 if ( projection == "wintri"_L1 )
490 return QObject::tr( "Winkel Tripel" );
491 if ( projection == "gstmerc"_L1 )
492 return QObject::tr( "Gauss-Schreiber" );
493 return QString();
494}
CrsType
Coordinate reference system types.
Definition qgis.h:2373
@ Vertical
Vertical CRS.
Definition qgis.h:2379
@ Temporal
Temporal CRS.
Definition qgis.h:2382
@ Compound
Compound (horizontal + vertical) CRS.
Definition qgis.h:2381
@ Projected
Projected CRS.
Definition qgis.h:2380
@ Other
Other type.
Definition qgis.h:2385
@ Bound
Bound CRS.
Definition qgis.h:2384
@ DerivedProjected
Derived projected CRS.
Definition qgis.h:2386
@ Unknown
Unknown type.
Definition qgis.h:2374
@ Engineering
Engineering CRS.
Definition qgis.h:2383
@ Geographic3d
3D geopraphic CRS
Definition qgis.h:2378
@ Geodetic
Geodetic CRS.
Definition qgis.h:2375
@ Geographic2d
2D geographic CRS
Definition qgis.h:2377
@ Geocentric
Geocentric CRS.
Definition qgis.h:2376
CoordinateOrder
Order of coordinates.
Definition qgis.h:2448
@ XY
Easting/Northing (or Longitude/Latitude for geographic CRS).
Definition qgis.h:2450
@ YX
Northing/Easting (or Latitude/Longitude for geographic CRS).
Definition qgis.h:2451
CrsAxisDirection
Coordinate reference system axis directions.
Definition qgis.h:2398
@ Starboard
Starboard.
Definition qgis.h:2423
@ ColumnPositive
Column positive.
Definition qgis.h:2426
@ SouthSouthEast
South South East.
Definition qgis.h:2406
@ NorthWest
North West.
Definition qgis.h:2413
@ ColumnNegative
Column negative.
Definition qgis.h:2427
@ RowPositive
Row positive.
Definition qgis.h:2428
@ DisplayDown
Display down.
Definition qgis.h:2433
@ GeocentricZ
Geocentric (Z).
Definition qgis.h:2417
@ DisplayRight
Display right.
Definition qgis.h:2430
@ WestSouthWest
West South West.
Definition qgis.h:2410
@ RowNegative
Row negative.
Definition qgis.h:2429
@ AwayFrom
Away from.
Definition qgis.h:2437
@ NorthNorthEast
North North East.
Definition qgis.h:2400
@ Forward
Forward.
Definition qgis.h:2420
@ EastNorthEast
East North East.
Definition qgis.h:2402
@ Unspecified
Unspecified.
Definition qgis.h:2438
@ NorthEast
North East.
Definition qgis.h:2401
@ NorthNorthWest
North North West.
Definition qgis.h:2414
@ GeocentricY
Geocentric (Y).
Definition qgis.h:2416
@ Towards
Towards.
Definition qgis.h:2436
@ SouthEast
South East.
Definition qgis.h:2405
@ CounterClockwise
Counter clockwise.
Definition qgis.h:2425
@ SouthSouthWest
South South West.
Definition qgis.h:2408
@ DisplayLeft
Display left.
Definition qgis.h:2431
@ WestNorthWest
West North West.
Definition qgis.h:2412
@ EastSouthEast
East South East.
Definition qgis.h:2404
@ Clockwise
Clockwise.
Definition qgis.h:2424
@ SouthWest
South West.
Definition qgis.h:2409
@ DisplayUp
Display up.
Definition qgis.h:2432
@ GeocentricX
Geocentric (X).
Definition qgis.h:2415
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.
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.