@@ -986,6 +986,69 @@ int msProjectRect(projectionObj *in, projectionObj *out, rectObj *rect)
986
986
#endif
987
987
}
988
988
989
+ #ifdef USE_PROJ
990
+ static int msProjectSortString (const void * firstelt , const void * secondelt )
991
+ {
992
+ char * firststr = * (char * * )firstelt ;
993
+ char * secondstr = * (char * * )secondelt ;
994
+ return strcmp (firststr , secondstr );
995
+ }
996
+
997
+ /************************************************************************/
998
+ /* msGetProjectNormalized() */
999
+ /************************************************************************/
1000
+
1001
+ static projectionObj * msGetProjectNormalized ( const projectionObj * p )
1002
+ {
1003
+ int i ;
1004
+ char * pszNewProj4Def ;
1005
+ projectionObj * pnew ;
1006
+
1007
+ pnew = (projectionObj * )msSmallMalloc (sizeof (projectionObj ));
1008
+ msInitProjection (pnew );
1009
+ msCopyProjection (pnew , (projectionObj * )p );
1010
+
1011
+ if (p -> proj == NULL )
1012
+ return pnew ;
1013
+
1014
+ /* Normalize definition so that msProjectDiffers() works better */
1015
+ pszNewProj4Def = pj_get_def ( p -> proj , 0 );
1016
+ msFreeCharArray (pnew -> args , pnew -> numargs );
1017
+ pnew -> args = msStringSplit (pszNewProj4Def ,'+' , & pnew -> numargs );
1018
+ for (i = 0 ; i < pnew -> numargs ; i ++ )
1019
+ {
1020
+ /* Remove trailing space */
1021
+ if ( strlen (pnew -> args [i ]) > 0 && pnew -> args [i ][strlen (pnew -> args [i ])- 1 ] == ' ' )
1022
+ pnew -> args [i ][strlen (pnew -> args [i ])- 1 ] = '\0' ;
1023
+ /* Remove spurious no_defs or init= */
1024
+ if ( strcmp (pnew -> args [i ], "no_defs" ) == 0 ||
1025
+ strncmp (pnew -> args [i ], "init=" , 5 ) == 0 )
1026
+ {
1027
+ if ( i < pnew -> numargs - 1 )
1028
+ {
1029
+ msFree (pnew -> args [i ]);
1030
+ memmove (pnew -> args + i , pnew -> args + i + 1 ,
1031
+ sizeof (char * ) * (pnew -> numargs - 1 - i ));
1032
+ }
1033
+ pnew -> numargs -- ;
1034
+ i -- ;
1035
+ continue ;
1036
+ }
1037
+ }
1038
+ /* Sort the strings so they can be compared */
1039
+ qsort (pnew -> args , pnew -> numargs , sizeof (char * ), msProjectSortString );
1040
+ /*{
1041
+ fprintf(stderr, "'%s' =\n", pszNewProj4Def);
1042
+ for(i = 0; i < p->numargs; i++)
1043
+ fprintf(stderr, "'%s' ", p->args[i]);
1044
+ fprintf(stderr, "\n");
1045
+ }*/
1046
+ pj_dalloc (pszNewProj4Def );
1047
+
1048
+ return pnew ;
1049
+ }
1050
+ #endif /* USE_PROJ */
1051
+
989
1052
/************************************************************************/
990
1053
/* msProjectionsDiffer() */
991
1054
/************************************************************************/
@@ -1001,7 +1064,7 @@ int msProjectRect(projectionObj *in, projectionObj *out, rectObj *rect)
1001
1064
** has no arguments, since reprojection won't work anyways.
1002
1065
*/
1003
1066
1004
- int msProjectionsDiffer ( projectionObj * proj1 , projectionObj * proj2 )
1067
+ static int msProjectionsDifferInternal ( projectionObj * proj1 , projectionObj * proj2 )
1005
1068
1006
1069
{
1007
1070
int i ;
@@ -1025,6 +1088,31 @@ int msProjectionsDiffer( projectionObj *proj1, projectionObj *proj2 )
1025
1088
return MS_FALSE ;
1026
1089
}
1027
1090
1091
+ int msProjectionsDiffer ( projectionObj * proj1 , projectionObj * proj2 )
1092
+ {
1093
+ #ifdef USE_PROJ
1094
+ int ret ;
1095
+
1096
+ ret = msProjectionsDifferInternal (proj1 , proj2 );
1097
+ if ( ret )
1098
+ {
1099
+ projectionObj * p1normalized ;
1100
+ projectionObj * p2normalized ;
1101
+
1102
+ p1normalized = msGetProjectNormalized ( proj1 );
1103
+ p2normalized = msGetProjectNormalized ( proj2 );
1104
+ ret = msProjectionsDifferInternal (p1normalized , p2normalized );
1105
+ msFreeProjection (p1normalized );
1106
+ msFree (p1normalized );
1107
+ msFreeProjection (p2normalized );
1108
+ msFree (p2normalized );
1109
+ }
1110
+ return ret ;
1111
+ #else
1112
+ return msProjectionsDifferInternal (proj1 , proj2 );
1113
+ #endif
1114
+ }
1115
+
1028
1116
/************************************************************************/
1029
1117
/* msTestNeedWrap() */
1030
1118
/************************************************************************/
0 commit comments