[Mapguide_dev] svn commit: r1037 - Add missing ReadNext() check

Walt Welton-Lair walt.welton-lair at autodesk.com
Mon Jan 8 19:29:57 EST 2007


r1037 | waltweltonlair | 2007-01-09 02:21:43 +0100 (Tue, 09 Jan 2007) |
12 lines

This is for the 1.1.x branch...

Add missing ReadNext() check

The buffer web code was calling ReadNext on an MgSpatialContextReader
without
checking the return value.  It then immediately called
GetCoordinateSystemWkt
on the reader.  This generates an MgIndexOutOfRangeException if there
are no
spatial contexts.  Updated the code to only call GetCoordinateSystemWkt
if
ReadNext returns true.

The fix was made for all three web tier flavors: ASPX, PHP, JSP.

===================================================================
--- mapviewerjava/buffer.jsp    (revision 1036)
+++ mapviewerjava/buffer.jsp    (revision 1037)
@@ -221,17 +221,10 @@
             MgResourceIdentifier featSourceId = new
MgResourceIdentifier(selLayer.GetFeatureSourceId());
             MgSpatialContextReader ctxs =
featureSrvc.GetSpatialContexts(featSourceId, true);
             String srsDefDs = "";
-            if(ctxs != null)
-            {
-                ctxs.ReadNext();
+            if(ctxs != null && ctxs.ReadNext())
                 srsDefDs = ctxs.GetCoordinateSystemWkt();
-                if(srsDefDs == null || srsDefDs.length() == 0)
-                {
-                    excludedLayers++;
-                    continue;
-                }
-            }
-            else
+
+            if(srsDefDs == null || srsDefDs.length() == 0)
             {
                 excludedLayers++;
                 continue;
@@ -505,16 +498,16 @@

 String GetMapSrs(MgMap map)
 {
-    try
+    try
     {
         String srs = map.GetMapSRS();
-        if(!srs.equals(""))
+        if(!srs.equals(""))
             return srs;
     }
     catch(MgException e)
     {
     }
-
+
     //No SRS, set to ArbitrayXY meters
     //
     return
"LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\",
1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";

===================================================================
--- mapviewernet/buffer.aspx    (revision 1036)
+++ mapviewernet/buffer.aspx    (revision 1037)
@@ -202,17 +202,10 @@
             MgResourceIdentifier featSourceId = new
MgResourceIdentifier(selLayer.GetFeatureSourceId());
             MgSpatialContextReader ctxs =
featureSrvc.GetSpatialContexts(featSourceId, true);
             String srsDefDs = "";
-            if (ctxs != null)
-            {
-                ctxs.ReadNext();
+            if (ctxs != null && ctxs.ReadNext())
                 srsDefDs = ctxs.GetCoordinateSystemWkt();
-                if (srsDefDs == null || srsDefDs.Length == 0)
-                {
-                    excludedLayers++;
-                    continue;
-                }
-            }
-            else
+
+            if (srsDefDs == null || srsDefDs.Length == 0)
             {
                 excludedLayers++;
                 continue;

===================================================================
--- mapviewerphp/buffer.php     (revision 1036)
+++ mapviewerphp/buffer.php     (revision 1037)
@@ -191,17 +191,10 @@
             $featSourceId = new
MgResourceIdentifier($selLayer->GetFeatureSourceId());
             $ctxs = $featureSrvc->GetSpatialContexts($featSourceId,
true);
             $srsDefDs = "";
-            if($ctxs != null)
-            {
-                $ctxs->ReadNext();
+            if($ctxs != null && $ctxs->ReadNext())
                 $srsDefDs = $ctxs->GetCoordinateSystemWkt();
-                if($srsDefDs == "")
-                {
-                    $excludedLayers ++;
-                    continue;
-                }
-            }
-            else
+
+            if($srsDefDs == "")
             {
                 $excludedLayers ++;
                 continue;
@@ -213,7 +206,7 @@

             if($arbitraryDsSrs)
                 $dsSrsUnits = $srsDs->GetUnits();
-
+
             // exclude layer if:
             //  the map is non-arbitrary and the layer is arbitrary or
vice-versa
             //     or
@@ -474,9 +467,9 @@
 function GetMapSrs($map)
 {
     $srs = $map->GetMapSRS();
-    if($srs != "")
+    if($srs != "")
         return $srs;
-
+
     //No SRS, set to ArbitrayXY meters
     //
     return
"LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\",
1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";


 W       E         @__   __o
   A   T   R   @___    _ \<,_
     L           @_   (*)/ (*)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-internals/attachments/20070108/9fb8f578/attachment.html


More information about the Mapguide-internals mailing list