@@ -161,11 +161,61 @@ static PJ* createNormalizedPJ(projectionObj *in, projectionObj *out, int* pbFree
161
161
fprintf (stderr , "cache miss!\n" );
162
162
#endif
163
163
164
- pj_raw = proj_create_crs_to_crs (in -> proj_ctx -> proj_ctx , in_str , out_str , NULL );
165
- if ( !pj_raw )
166
- return NULL ;
167
- pj_normalized = proj_normalize_for_visualization (in -> proj_ctx -> proj_ctx , pj_raw );
168
- proj_destroy (pj_raw );
164
+ #if PROJ_VERSION_MAJOR == 6 && PROJ_VERSION_MINOR < 2
165
+ if ( strstr (in_str , "+proj=" ) && strstr (in_str , "+over" ) &&
166
+ strstr (out_str , "+proj=" ) && strstr (out_str , "+over" ) &&
167
+ strlen (in_str ) < 400 && strlen (out_str ) < 400 )
168
+ {
169
+ // Fixed per PROJ commit
170
+ // https://github.com/OSGeo/PROJ/commit/78302efb70eb4b49610cda6a60bf9ce39b82264f
171
+ // and
172
+ // https://github.com/OSGeo/PROJ/commit/ae70b26b9cbae85a38d5b26533ba06da0ea13940
173
+ // Fix for wcs_get_capabilities_tileindexmixedsrs_26711.xml and wcs_20_getcov_bands_name_new_reproject.dat
174
+ char szPipeline [1024 ];
175
+ strcpy (szPipeline , "+proj=pipeline" );
176
+ if ( msProjIsGeographicCRS (in ) )
177
+ {
178
+ strcat (szPipeline , " +step +proj=unitconvert +xy_in=deg +xy_out=rad" );
179
+ }
180
+ strcat (szPipeline , " +step +inv " );
181
+ strcat (szPipeline , in_str );
182
+ strcat (szPipeline , " +step " );
183
+ strcat (szPipeline , out_str );
184
+ if ( msProjIsGeographicCRS (out ) )
185
+ {
186
+ strcat (szPipeline , " +step +proj=unitconvert +xy_in=rad +xy_out=deg" );
187
+ }
188
+ /* We do not want datum=NAD83 to imply a transformation with towgs84=0,0,0 */
189
+ {
190
+ char * ptr = szPipeline ;
191
+ while (1 )
192
+ {
193
+ ptr = strstr (ptr , " +datum=NAD83" );
194
+ if ( !ptr )
195
+ break ;
196
+ memcpy (ptr , " +ellps=GRS80" , 13 );
197
+ }
198
+ }
199
+
200
+ /* Remove +nadgrids=@null as it doesn't work if going outside of [-180,180] */
201
+ /* Fixed per https://github.com/OSGeo/PROJ/commit/10a30bb539be1afb25952b19af8bbe72e1b13b56 */
202
+ {
203
+ char * ptr = strstr (szPipeline , " +nadgrids=@null" );
204
+ if ( ptr )
205
+ memcpy (ptr , " " , 16 );
206
+ }
207
+
208
+ pj_normalized = proj_create (in -> proj_ctx -> proj_ctx , szPipeline );
209
+ }
210
+ else
211
+ #endif
212
+ {
213
+ pj_raw = proj_create_crs_to_crs (in -> proj_ctx -> proj_ctx , in_str , out_str , NULL );
214
+ if ( !pj_raw )
215
+ return NULL ;
216
+ pj_normalized = proj_normalize_for_visualization (in -> proj_ctx -> proj_ctx , pj_raw );
217
+ proj_destroy (pj_raw );
218
+ }
169
219
if ( !pj_normalized )
170
220
return NULL ;
171
221
0 commit comments