[mapguide-commits] r5456 - in trunk/MgDev: Common/MapGuideCommon/Controller Common/MapGuideCommon/Resources Server/src/Services/Rendering

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Thu Dec 9 16:17:27 EST 2010


Author: brucedechant
Date: 2010-12-09 13:17:27 -0800 (Thu, 09 Dec 2010)
New Revision: 5456

Modified:
   trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
   trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
   trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
Log:
Fix for trac ticket 660 - Use more meaningful exception than "The value cannot be less than or equal to zero."
http://trac.osgeo.org/mapguide/ticket/660

Submitted on behalf of Jackie Ng

Notes:
- Added more meaningful error messages.
- Small cleanup of code and messages.


Modified: trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2010-12-09 20:51:18 UTC (rev 5455)
+++ trunk/MgDev/Common/MapGuideCommon/Controller/Controller.cpp	2010-12-09 21:17:27 UTC (rev 5456)
@@ -143,7 +143,7 @@
             arguments.Add(sScale);
 
             throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
-                __LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgMapViewScaleCannotBeLessThanOrEqualToZero", NULL);
         }
 
         map->SetViewScale(scale);
@@ -178,7 +178,7 @@
             arguments.Add(sDpi);
 
             throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
-                __LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgMapDisplayDpiCannotBeLessThanOrEqualToZero", NULL);
         }
 
         map->SetDisplayDpi(dpi);
@@ -210,7 +210,7 @@
             arguments.Add(sWidth);
 
             throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
-                __LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
         }
 
         map->SetDisplayWidth(width);
@@ -242,7 +242,7 @@
             arguments.Add(sHeight);
 
             throw new MgInvalidArgumentException(L"MgController.ApplyMapViewCommands",
-                __LINE__, __WFILE__, &arguments, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
+                __LINE__, __WFILE__, &arguments, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
         }
 
         map->SetDisplayHeight(height);

Modified: trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2010-12-09 20:51:18 UTC (rev 5455)
+++ trunk/MgDev/Common/MapGuideCommon/Resources/mapguide_en.res	2010-12-09 21:17:27 UTC (rev 5456)
@@ -286,7 +286,12 @@
 MgInvalidYear                                         = The year is invalid because it must be between 1 and 9999.
 MgMachineIpMustBeLocalHost                            = The machine IP address must be a local host.
 MgMapCacheCleared                                     = The Tile Service map cache has been cleared.  Please increase TiledMapCacheSize in serverconfig.ini.
+MgMapDisplayDpiCannotBeLessThanOrEqualToZero          = The map DPI cannot be less than or equal to zero.
+MgMapDisplayWidthCannotBeLessThanOrEqualToZero        = The map display width cannot be less than or equal to zero.
+MgMapDisplayHeightCannotBeLessThanOrEqualToZero       = The map display height cannot be less than or equal to zero.
 MgMapLayerGroupNameNotFound                           = The map layer group name was not found.
+MgMapMetersPerUnitCannotBeLessThanOrEqualToZero       = The map meters per unit value cannot be less than or equal to zero.
+MgMapViewScaleCannotBeLessThanOrEqualToZero           = The map view scale cannot be less than or equal to zero.
 MgMissingClassDef                                     = No class definition specified.
 MgMissingSchema                                       = No schema specified.
 MgMissingSrs                                          = No coordinate system specified.

Modified: trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2010-12-09 20:51:18 UTC (rev 5455)
+++ trunk/MgDev/Server/src/Services/Rendering/ServerRenderingService.cpp	2010-12-09 21:17:27 UTC (rev 5456)
@@ -322,9 +322,22 @@
     int dpi              = map->GetDisplayDpi();
     double scale         = map->GetViewScale();
     double metersPerUnit = map->GetMetersPerUnit();
-    if (width <= 0 || height <= 0 || dpi <= 0 || scale <= 0.0 || metersPerUnit <= 0.0)
-        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
 
+    if (width <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
+
+    if (height <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
+
+    if (dpi <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgMapDisplayDpiCannotBeLessThanOrEqualToZero", NULL);
+
+    if (scale <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgMapViewScaleCannotBeLessThanOrEqualToZero", NULL);
+
+    if (metersPerUnit <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgMapMetersPerUnitCannotBeLessThanOrEqualToZero", NULL);
+
     // sanity check - number of image pixels cannot exceed MAX_PIXELS
     if (width * height > MAX_PIXELS)
         throw new MgOutOfRangeException(L"MgServerRenderingService.RenderDynamicOverlay", __LINE__, __WFILE__, NULL, L"MgInvalidImageSizeTooBig", NULL);
@@ -463,9 +476,19 @@
     // validate map view parameters
     int dpi              = map->GetDisplayDpi();
     double metersPerUnit = map->GetMetersPerUnit();
-    if (width <= 0 || height <= 0 || dpi <= 0 || metersPerUnit <= 0.0)
-        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
 
+    if (width <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
+
+    if (height <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
+
+    if (dpi <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayDpiCannotBeLessThanOrEqualToZero", NULL);
+
+    if (metersPerUnit <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapMetersPerUnitCannotBeLessThanOrEqualToZero", NULL);
+
     // compute a view center and scale from the given extents
     // and pass on to the RenderMap that uses center and scale
 
@@ -595,9 +618,22 @@
     // validate map view parameters
     int dpi              = map->GetDisplayDpi();
     double metersPerUnit = map->GetMetersPerUnit();
-    if (scale <= 0.0 || width <= 0 || height <= 0 || dpi <= 0 || metersPerUnit <= 0.0)
-        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
 
+    if (width <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
+
+    if (height <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
+
+    if (dpi <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapDisplayDpiCannotBeLessThanOrEqualToZero", NULL);
+
+    if (scale <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapViewScaleCannotBeLessThanOrEqualToZero", NULL);
+
+    if (metersPerUnit <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgMapMetersPerUnitCannotBeLessThanOrEqualToZero", NULL);
+
     // sanity check - number of image pixels cannot exceed MAX_PIXELS
     if (width * height > MAX_PIXELS)
         throw new MgOutOfRangeException(L"MgServerRenderingService.RenderMap", __LINE__, __WFILE__, NULL, L"MgInvalidImageSizeTooBig", NULL);
@@ -1217,9 +1253,12 @@
         throw new MgNullArgumentException(L"MgServerRenderingService.RenderMapLegend", __LINE__, __WFILE__, NULL, L"", NULL);
 
     // validate map view parameters
-    if (width <= 0 || height <= 0)
-        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMapLegend", __LINE__, __WFILE__, NULL, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
+    if (width <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMapLegend", __LINE__, __WFILE__, NULL, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
 
+    if (height <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderMapLegend", __LINE__, __WFILE__, NULL, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
+
     // sanity check - number of image pixels cannot exceed MAX_PIXELS
     if (width * height > MAX_PIXELS)
         throw new MgOutOfRangeException(L"MgServerRenderingService.RenderMapLegend", __LINE__, __WFILE__, NULL, L"MgInvalidImageSizeTooBig", NULL);
@@ -1337,9 +1376,22 @@
     int dpi              = map->GetDisplayDpi();
     double scale         = map->GetViewScale();
     double metersPerUnit = map->GetMetersPerUnit();
-    if (width <= 0 || height <= 0 || dpi <= 0 || scale <= 0.0 || metersPerUnit <= 0.0)
-        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgValueCannotBeLessThanOrEqualToZero", NULL);
 
+    if (width <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgMapDisplayWidthCannotBeLessThanOrEqualToZero", NULL);
+
+    if (height <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgMapDisplayHeightCannotBeLessThanOrEqualToZero", NULL);
+
+    if (dpi <= 0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgMapDisplayDpiCannotBeLessThanOrEqualToZero", NULL);
+
+    if (scale <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgMapViewScaleCannotBeLessThanOrEqualToZero", NULL);
+
+    if (metersPerUnit <= 0.0)
+        throw new MgInvalidArgumentException(L"MgServerRenderingService.RenderForSelection", __LINE__, __WFILE__, NULL, L"MgMapMetersPerUnitCannotBeLessThanOrEqualToZero", NULL);
+
     // compute map extent that corresponds to pixel extent
     Ptr<MgPoint> pt          = map->GetViewCenter();
     Ptr<MgCoordinate> center = pt->GetCoordinate();



More information about the mapguide-commits mailing list