39 static
bool sDisableCache = false;
44 static const QMap< QString, QString > sProj6EllipsoidAcronymMap
46 {
"clrk80",
"clrk80ign" },
47 {
"Adrastea2000",
"ESRI:107909"},
48 {
"Amalthea2000",
"ESRI:107910"},
49 {
"Ananke2000",
"ESRI:107911"},
50 {
"Ariel2000",
"ESRI:107945"},
51 {
"Atlas2000",
"ESRI:107926"},
52 {
"Belinda2000",
"ESRI:107946"},
53 {
"Bianca2000",
"ESRI:107947"},
54 {
"Callisto2000",
"ESRI:107912"},
55 {
"Calypso2000",
"ESRI:107927"},
56 {
"Carme2000",
"ESRI:107913"},
57 {
"Charon2000",
"ESRI:107970"},
58 {
"Cordelia2000",
"ESRI:107948"},
59 {
"Cressida2000",
"ESRI:107949"},
60 {
"Deimos2000",
"ESRI:107906"},
61 {
"Desdemona2000",
"ESRI:107950"},
62 {
"Despina2000",
"ESRI:107961"},
63 {
"Dione2000",
"ESRI:107928"},
64 {
"Elara2000",
"ESRI:107914"},
65 {
"Enceladus2000",
"ESRI:107929"},
66 {
"Epimetheus2000",
"ESRI:107930"},
67 {
"Europa2000",
"ESRI:107915"},
68 {
"Galatea2000",
"ESRI:107962"},
69 {
"Ganymede2000",
"ESRI:107916"},
70 {
"Helene2000",
"ESRI:107931"},
71 {
"Himalia2000",
"ESRI:107917"},
72 {
"Hyperion2000",
"ESRI:107932"},
73 {
"Iapetus2000",
"ESRI:107933"},
74 {
"Io2000",
"ESRI:107918"},
75 {
"Janus2000",
"ESRI:107934"},
76 {
"Juliet2000",
"ESRI:107951"},
77 {
"Jupiter2000",
"ESRI:107908"},
78 {
"Larissa2000",
"ESRI:107963"},
79 {
"Leda2000",
"ESRI:107919"},
80 {
"Lysithea2000",
"ESRI:107920"},
81 {
"Mars2000",
"ESRI:107905"},
82 {
"Mercury2000",
"ESRI:107900"},
83 {
"Metis2000",
"ESRI:107921"},
84 {
"Mimas2000",
"ESRI:107935"},
85 {
"Miranda2000",
"ESRI:107952"},
86 {
"Moon2000",
"ESRI:107903"},
87 {
"Naiad2000",
"ESRI:107964"},
88 {
"Neptune2000",
"ESRI:107960"},
89 {
"Nereid2000",
"ESRI:107965"},
90 {
"Oberon2000",
"ESRI:107953"},
91 {
"Ophelia2000",
"ESRI:107954"},
92 {
"Pan2000",
"ESRI:107936"},
93 {
"Pandora2000",
"ESRI:107937"},
94 {
"Pasiphae2000",
"ESRI:107922"},
95 {
"Phobos2000",
"ESRI:107907"},
96 {
"Phoebe2000",
"ESRI:107938"},
97 {
"Pluto2000",
"ESRI:107969"},
98 {
"Portia2000",
"ESRI:107955"},
99 {
"Prometheus2000",
"ESRI:107939"},
100 {
"Proteus2000",
"ESRI:107966"},
101 {
"Puck2000",
"ESRI:107956"},
102 {
"Rhea2000",
"ESRI:107940"},
103 {
"Rosalind2000",
"ESRI:107957"},
104 {
"Saturn2000",
"ESRI:107925"},
105 {
"Sinope2000",
"ESRI:107923"},
106 {
"Telesto2000",
"ESRI:107941"},
107 {
"Tethys2000",
"ESRI:107942"},
108 {
"Thalassa2000",
"ESRI:107967"},
109 {
"Thebe2000",
"ESRI:107924"},
110 {
"Titan2000",
"ESRI:107943"},
111 {
"Titania2000",
"ESRI:107958"},
112 {
"Triton2000",
"ESRI:107968"},
113 {
"Umbriel2000",
"ESRI:107959"},
114 {
"Uranus2000",
"ESRI:107944"},
115 {
"Venus2000",
"ESRI:107902"},
116 {
"IGNF:ELG053",
"EPSG:7030"},
117 {
"IGNF:ELG052",
"EPSG:7043"},
118 {
"IGNF:ELG102",
"EPSG:7043"},
119 {
"WGS66",
"ESRI:107001"},
120 {
"plessis",
"EPSG:7027"},
121 {
"IGNF:ELG017",
"EPSG:7027"},
122 {
"mod_airy",
"EPSG:7002"},
123 {
"IGNF:ELG037",
"EPSG:7019"},
124 {
"IGNF:ELG108",
"EPSG:7036"},
125 {
"cape",
"EPSG:7034"},
126 {
"IGNF:ELG010",
"EPSG:7011"},
127 {
"IGNF:ELG003",
"EPSG:7012"},
128 {
"IGNF:ELG004",
"EPSG:7008"},
129 {
"GSK2011",
"EPSG:1025"},
130 {
"airy",
"EPSG:7001"},
131 {
"aust_SA",
"EPSG:7003"},
132 {
"bessel",
"EPSG:7004"},
133 {
"clrk66",
"EPSG:7008"},
134 {
"clrk80ign",
"EPSG:7011"},
135 {
"evrst30",
"EPSG:7015"},
136 {
"evrstSS",
"EPSG:7016"},
137 {
"evrst48",
"EPSG:7018"},
138 {
"GRS80",
"EPSG:7019"},
139 {
"helmert",
"EPSG:7020"},
140 {
"intl",
"EPSG:7022"},
141 {
"krass",
"EPSG:7024"},
142 {
"NWL9D",
"EPSG:7025"},
143 {
"WGS84",
"EPSG:7030"},
144 {
"GRS67",
"EPSG:7036"},
145 {
"WGS72",
"EPSG:7043"},
146 {
"bess_nam",
"EPSG:7046"},
147 {
"IAU76",
"EPSG:7049"},
148 {
"sphere",
"EPSG:7052"},
149 {
"hough",
"EPSG:7053"},
150 {
"evrst69",
"EPSG:7056"},
151 {
"fschr60",
"ESRI:107002"},
152 {
"fschr68",
"ESRI:107003"},
153 {
"fschr60m",
"ESRI:107004"},
154 {
"walbeck",
"ESRI:107007"},
155 {
"IGNF:ELG001",
"EPSG:7022"},
156 {
"engelis",
"EPSG:7054"},
157 {
"evrst56",
"EPSG:7044"},
158 {
"SEasia",
"ESRI:107004"},
159 {
"SGS85",
"EPSG:7054"},
160 {
"andrae",
"PROJ:ANDRAE"},
161 {
"clrk80",
"EPSG:7034"},
163 {
"delmbr",
"PROJ:DELMBR"},
164 {
"Earth2000",
"PROJ:EARTH2000"},
165 {
"kaula",
"PROJ:KAULA"},
166 {
"lerch",
"PROJ:LERCH"},
167 {
"MERIT",
"PROJ:MERIT"},
168 {
"mprts",
"PROJ:MPRTS"},
169 {
"new_intl",
"PROJ:NEW_INTL"},
170 {
"WGS60",
"PROJ:WGS60"}
173 QString ellipsoid = e;
175 static std::once_flag initialized;
176 std::call_once( initialized, [ = ]
179 ( void )definitions();
182 ellipsoid = sProj6EllipsoidAcronymMap.value( ellipsoid, ellipsoid );
187 if ( !sDisableCache )
189 const QHash< QString, EllipsoidParameters >::const_iterator cacheIt = sEllipsoidCache()->constFind( ellipsoid );
190 if ( cacheIt != sEllipsoidCache()->constEnd() )
205 if ( ellipsoid.startsWith( QLatin1String(
"PARAMETER" ) ) )
207 QStringList paramList = ellipsoid.split(
':' );
208 bool semiMajorOk, semiMinorOk;
209 const double semiMajor = paramList[1].toDouble( & semiMajorOk );
210 const double semiMinor = paramList[2].toDouble( & semiMinorOk );
211 if ( semiMajorOk && semiMinorOk )
220 params.
valid =
false;
224 if ( !sDisableCache )
226 sEllipsoidCache()->insert( ellipsoid, params );
230 params.
valid =
false;
233 if ( !sDisableCache )
235 sEllipsoidCache()->insert( ellipsoid, params );
244 if ( !sDefinitionCache()->isEmpty() )
246 return *sDefinitionCache();
250 QList<QgsEllipsoidUtils::EllipsoidDefinition> defs;
255 if ( PROJ_STRING_LIST authorities = proj_get_authorities_from_database( context ) )
257 PROJ_STRING_LIST authoritiesIt = authorities;
258 while (
char *authority = *authoritiesIt )
260 if ( PROJ_STRING_LIST codes = proj_get_codes_from_database( context, authority, PJ_TYPE_ELLIPSOID, 0 ) )
262 PROJ_STRING_LIST codesIt = codes;
263 while (
char *code = *codesIt )
266 if ( ellipsoid.get() )
269 QString name = QString( proj_get_name( ellipsoid.get() ) );
270 def.
acronym = QStringLiteral(
"%1:%2" ).arg( authority, code );
271 name.replace(
'_',
' ' );
272 def.
description = QStringLiteral(
"%1 (%2:%3)" ).arg( name, authority, code );
274 #if PROJ_VERSION_MAJOR>8 || (PROJ_VERSION_MAJOR==8 && PROJ_VERSION_MINOR>=1)
275 def.
celestialBodyName = proj_get_celestial_body_name( context, ellipsoid.get() );
278 double semiMajor, semiMinor, invFlattening;
279 int semiMinorComputed = 0;
280 if ( proj_ellipsoid_get_parameters( context, ellipsoid.get(), &semiMajor, &semiMinor, &semiMinorComputed, &invFlattening ) )
285 if ( !semiMinorComputed )
298 if ( !sDisableCache )
300 sEllipsoidCache()->insert( def.acronym, def.parameters );
306 proj_string_list_destroy( codes );
311 proj_string_list_destroy( authorities );
316 collator.setCaseSensitivity( Qt::CaseInsensitive );
319 return collator.compare( a.description, b.description ) < 0;
321 if ( !sDisableCache )
323 *sDefinitionCache() = defs;
332 const QList<QgsEllipsoidUtils::EllipsoidDefinition> defs =
definitions();
333 result.reserve( defs.size() );
336 result << def.acronym;
351 if ( !sDisableCache )
354 sDisableCache =
true;
355 sEllipsoidCache()->clear();
356 sDefinitionCache()->clear();