[mapserver-commits] r7264 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Jan 16 00:10:02 EST 2008


Author: warmerdam
Date: 2008-01-16 00:10:02 -0500 (Wed, 16 Jan 2008)
New Revision: 7264

Modified:
   trunk/mapserver/mapfile.c
   trunk/mapserver/mapowscommon.c
   trunk/mapserver/mapproject.c
   trunk/mapserver/mapproject.h
Log:
added axis normalization support (for WCS 1.1, etc)

Modified: trunk/mapserver/mapfile.c
===================================================================
--- trunk/mapserver/mapfile.c	2008-01-15 23:27:01 UTC (rev 7263)
+++ trunk/mapserver/mapfile.c	2008-01-16 05:10:02 UTC (rev 7264)
@@ -1086,7 +1086,7 @@
       /* translate into PROJ.4 format. */
       sprintf( init_string, "init=epsg:%s", value+5 );
 
-      p->args = (char**)malloc(sizeof(char*));
+      p->args = (char**)malloc(sizeof(char*) * 2);
       p->args[0] = strdup(init_string);
       p->numargs = 1;
   }
@@ -1104,9 +1104,15 @@
       /* translate into PROJ.4 format. */
       sprintf( init_string, "init=epsg:%s", code );
 
-      p->args = (char**)malloc(sizeof(char*));
+      p->args = (char**)malloc(sizeof(char*) * 2);
       p->args[0] = strdup(init_string);
       p->numargs = 1;
+
+      if( atoi(code) >= 4000 && atoi(code) < 5000 )
+      {
+          p->args[1] = strdup("+epsgaxis=ne");
+          p->numargs = 2;
+      }
   }
   /*
    * Handle old style comma delimited.  eg. "proj=utm,zone=11,ellps=WGS84".

Modified: trunk/mapserver/mapowscommon.c
===================================================================
--- trunk/mapserver/mapowscommon.c	2008-01-15 23:27:01 UTC (rev 7263)
+++ trunk/mapserver/mapowscommon.c	2008-01-16 05:10:02 UTC (rev 7264)
@@ -467,6 +467,9 @@
  *
  * returns an object of BoundingBox as per subclause 10.2.1
  *
+ * If necessary (ie. an EPSG URN GCS such as 4326) the tuple axes will be
+ * reoriented to match the EPSG coordinate system expectations.
+ *
  * @param psNsOws OWS namespace object
  * @param crs the CRS / EPSG code
  * @param dimensions number of dimensions of the coordinates
@@ -483,6 +486,19 @@
   char UpperCorner[100];
   char dim_string[100];
 
+  /* Do we need to reorient tuple axes? */
+  {
+      projectionObj proj;
+
+      msInitProjection( &proj );
+      if( msLoadProjectionString( &proj, (char *) crs ) == 0 )
+      {
+          msAxisNormalizePoints( &proj, 1, &minx, &miny );
+          msAxisNormalizePoints( &proj, 1, &maxx, &maxy );
+      }
+      msFreeProjection( &proj );
+  }
+
   xmlNodePtr psRootNode = NULL;
 
   if (_validateNamespace(psNsOws) == MS_FAILURE)

Modified: trunk/mapserver/mapproject.c
===================================================================
--- trunk/mapserver/mapproject.c	2008-01-15 23:27:01 UTC (rev 7263)
+++ trunk/mapserver/mapproject.c	2008-01-16 05:10:02 UTC (rev 7264)
@@ -950,3 +950,64 @@
     return pszProjString;
 }
 
+/************************************************************************/
+/*                       msAxisNormalizePoints()                        */
+/*                                                                      */
+/*      Convert the passed points to "easting, northing" axis           */
+/*      orientation if they are not already.                            */
+/************************************************************************/
+
+void msAxisNormalizePoints( projectionObj *proj, int count, 
+                            double *x, double *y )
+
+{
+    int i;
+    const char *axis = NULL;
+
+    for( i = 0; i < proj->numargs; i++ )
+    {
+        if( strstr(proj->args[i],"epsgaxis=") != NULL )
+        {
+            axis = strstr(proj->args[i],"=") + 1;
+            break;
+        }
+    }
+
+    if( axis == NULL )
+        return;
+
+    if( strcasecmp(axis,"en") == 0 )
+        return;
+
+    if( strcasecmp(axis,"ne") != 0 )
+    {
+        msDebug( "msAxisNormalizePoints(): odd +epsgaxis= value: '%s'.",
+                 axis );
+        return;
+    }
+
+    /* Switch axes */
+    for( i = 0; i < count; i++ )
+    {
+        double tmp;
+
+        tmp = x[i];
+        x[i] = y[i];
+        y[i] = tmp;
+    }
+}
+
+/************************************************************************/
+/*                      msAxisDenormalizePoints()                       */
+/*                                                                      */
+/*      Convert points from easting,northing orientation to the         */
+/*      preferred epsg orientation of this projectionObj.               */
+/************************************************************************/
+
+void msAxisDenormalizePoints( projectionObj *proj, int count, 
+                              double *x, double *y )
+
+{
+    /* For how this is essentially identical to normalizing */
+    msAxisNormalizePoints( proj, count, x, y );
+}

Modified: trunk/mapserver/mapproject.h
===================================================================
--- trunk/mapserver/mapproject.h	2008-01-15 23:27:01 UTC (rev 7263)
+++ trunk/mapserver/mapproject.h	2008-01-16 05:10:02 UTC (rev 7264)
@@ -74,6 +74,10 @@
 MS_DLL_EXPORT int msProcessProjection(projectionObj *p);
 MS_DLL_EXPORT int msLoadProjectionString(projectionObj *p, char *value);
 MS_DLL_EXPORT char *msGetProjectionString(projectionObj *proj);
+MS_DLL_EXPORT void msAxisNormalizePoints( projectionObj *proj, int count,
+                                          double *x, double *y );
+MS_DLL_EXPORT void msAxisDenormalizePoints( projectionObj *proj, int count,
+                                            double *x, double *y );
 
 MS_DLL_EXPORT void msSetPROJ_LIB( const char * );
 



More information about the mapserver-commits mailing list