[fdo-commits] r111 - branches/3.2.x/Providers/WMS/Src/Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Wed Jan 24 16:23:03 EST 2007


Author: romicadascalescu
Date: 2007-01-24 16:23:03 -0500 (Wed, 24 Jan 2007)
New Revision: 111

Modified:
   branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.cpp
   branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.h
Log:
Fixed WMS: Default width and height are not accepted

Modified: branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.cpp
===================================================================
--- branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.cpp	2007-01-18 15:47:12 UTC (rev 110)
+++ branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.cpp	2007-01-24 21:23:03 UTC (rev 111)
@@ -28,7 +28,12 @@
 #include <WMS/Override/FdoWmsOvPhysicalSchemaMapping.h>
 
 #include <malloc.h>
+#include <math.h>
 
+#define MAXPOWER2RESOLUTION 4096
+#define DEFAULTRESOLUTIONX 1000
+#define DEFAULTRESOLUTIONY 1000
+
 FdoWmsSelectCommand::FdoWmsSelectCommand (FdoWmsConnection* connection) :
     FdoWmsFeatureCommand<FdoISelect> (connection),
     mType (FdoLockType_None),
@@ -745,12 +750,11 @@
 
 	if (!bClip && !bResample)
 	{
-		// Get the default HEIGHT value and calculate the WIDTH value.
-		height = _getDefaultImageHeight ();		
-		width = (FdoSize)((bbox->GetMaxX() - bbox->GetMinX()) / (bbox->GetMaxY() - bbox->GetMinY()) * height);
-        if (width > 2048) {
+        height = DEFAULTRESOLUTIONX;
+        width = DEFAULTRESOLUTIONY;
+        AdjustResolutionWithExtent(width, height, bbox->GetMinX(), bbox->GetMinY(), bbox->GetMaxX(), bbox->GetMaxY());
+        if (width > 2048)
             width = 2048;
-        }
 	}
 }
 
@@ -816,3 +820,25 @@
     return L"";
 }
 
+void FdoWmsSelectCommand::AdjustResolutionWithExtent(FdoSize& resolutionX, FdoSize& resolutionY, double dMinX, double dMinY, double dMaxX, double dMaxY)
+{
+    double deltaExtentsX = fabs(dMaxX - dMinX);
+    double deltaExtentsY = fabs(dMaxY - dMinY);
+ 
+    // Adjust resolution to the next power of 2
+    FdoSize maxresolution = max(resolutionX,resolutionY);
+    FdoSize power2resolution;
+    for (power2resolution=1; power2resolution<MAXPOWER2RESOLUTION && power2resolution<maxresolution; power2resolution<<=1)
+        ;
+        
+    if (deltaExtentsX > deltaExtentsY)
+    {
+        resolutionX = power2resolution;
+        resolutionY = static_cast<int>(resolutionX * deltaExtentsY / deltaExtentsX);
+    }
+    else
+    {
+        resolutionY = power2resolution;
+        resolutionX = static_cast<int>(resolutionY * deltaExtentsX / deltaExtentsY);
+    }
+}

Modified: branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.h
===================================================================
--- branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.h	2007-01-18 15:47:12 UTC (rev 110)
+++ branches/3.2.x/Providers/WMS/Src/Provider/FdoWmsSelectCommand.h	2007-01-24 21:23:03 UTC (rev 111)
@@ -134,6 +134,9 @@
     // This method is used to get the original name of the layer.
     FdoString* _getOriginalLayerName (FdoString* mangledLayerName);
 
+    // Adjust the resolution of the grid layer according the extent.
+    void AdjustResolutionWithExtent(FdoSize& resolutionX, FdoSize& resolutionY, double dMinX, double dMinY, double dMaxX, double dMaxY);
+
 	// Lock support
     FdoLockType mType;
     FdoLockStrategy mStrategy;



More information about the fdo-commits mailing list