[mapguide-commits] r1199 - trunk/MgDev/Common/CoordinateSystem

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Mon Mar 12 13:04:01 EDT 2007


Author: traianstanev
Date: 2007-03-12 13:04:01 -0400 (Mon, 12 Mar 2007)
New Revision: 1199

Modified:
   trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp
Log:
Rewrote XYExtentToLL. It is around 10 times faster than before when transforming UTM based extents. The problem was that this routine was calling PROJ once per each interpolated point along the extent. Due to a mutex in PROJ, this is the worst way to call it. I changed the code to call PROJ once with all 400 interpolated points and also simplified the line interpolation logic so that it doesn't do multiplications.

Modified: trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp
===================================================================
--- trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp	2007-03-12 16:16:51 UTC (rev 1198)
+++ trunk/MgDev/Common/CoordinateSystem/CoordSysTransform.cpp	2007-03-12 17:04:01 UTC (rev 1199)
@@ -669,72 +669,68 @@
     double xMin = HUGE_VAL;
     double yMin = HUGE_VAL;
 
-    int i;
-    double lat, lon;
+    //temporary arrays for transformation
+    double tess_x[400];
+    double tess_y[400];
 
-    // compute the max and min longitude along the top and bottom borders
+    //temporary counters
+    double* dstx = tess_x;
+    double* dsty = tess_y;
 
+    //top and bottom edges
+
     double xInc = (ptNWX - ptSEX) / 100.0;
-    double tempX;
-    double tempY = ptNWY;
+    double xInterp = ptSEX;   
 
-    for (i = 0; i <= 100; i++)
+    for (int i = 0; i < 100; i++)
     {
-        tempX = ptSEX + i * xInc;
-
-        XYToLL(transform, tempX, tempY, lon, lat);
-
-        xMax = max(lon, xMax);
-        xMin = min(lon, xMin);
-        yMax = max(lat, yMax);
-        yMin = min(lat, yMin);
+        xInterp += xInc;
+        *dstx++ = xInterp;
+        *dsty++ = ptNWY;
     }
 
-    xInc = (ptNWX - ptSEX) / 100.0;
-    tempY = ptSEY;
+    xInterp = ptSEX;
 
-    for (i = 0; i <= 100; i++)
+    for (int i = 0; i < 100; i++)
     {
-        tempX = ptSEX + i * xInc;
-
-        XYToLL(transform, tempX, tempY, lon, lat);
-
-        xMax = max(lon, xMax);
-        xMin = min(lon, xMin);
-        yMax = max(lat, yMax);
-        yMin = min(lat, yMin);
+        xInterp += xInc;
+        *dstx++ = xInterp;
+        *dsty++ = ptSEY;
     }
 
-    // compute the max and min longitude along the left and right borders
+    // left and right borders
 
     double yInc = (ptNWY - ptSEY) / 100.0;
-    tempX = ptNWX;
+    double yInterp = ptSEY;
 
-    for (i = 0; i <= 100; i++)
+    for (int i = 0; i < 100; i++)
     {
-        tempY = ptSEY + i * yInc;
-
-        XYToLL(transform, tempX, tempY, lon, lat);
-
-        xMax = max(lon, xMax);
-        xMin = min(lon, xMin);
-        yMax = max(lat, yMax);
-        yMin = min(lat, yMin);
+        yInterp += yInc;
+        *dstx++ = ptNWX;
+        *dsty++ = yInterp;
     }
 
-    yInc = (ptNWY - ptSEY) / 100.0;
-    tempX = ptSEX;
+    yInterp = ptSEY;
 
-    for (i = 0; i <= 100; i++)
+    for (int i = 0; i < 100; i++)
     {
-        tempY = ptSEY + i * yInc;
+        yInterp += yInc;
+        *dstx++ = ptSEX;
+        *dsty++ = yInterp;
+    }
 
-        XYToLL(transform, tempX, tempY, lon, lat);
+    transform->Transform(400, tess_x, tess_y);
 
-        xMax = max(lon, xMax);
-        xMin = min(lon, xMin);
-        yMax = max(lat, yMax);
-        yMin = min(lat, yMin);
+    dstx = tess_x;
+    dsty = tess_y;
+    for (int i=0; i<400; i++)
+    {
+        xMax = max(*dstx, xMax);
+        xMin = min(*dstx, xMin);
+        yMax = max(*dsty, yMax);
+        yMin = min(*dsty, yMin);
+        dstx++;
+        dsty++;
     }
 
     if(dimension == CCoordinateSystemDimension::XYZ)



More information about the mapguide-commits mailing list