<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6618.4">
<TITLE>svn commit: r1036 - Add missing ReadNext() check</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">r1036 | waltweltonlair | 2007-01-08 17:40:08 +0100 (Mon, 08 Jan 2007) | 10 lines</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">Add missing ReadNext() check</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">The buffer web code was calling ReadNext on an MgSpatialContextReader without</FONT>
<BR><FONT SIZE=2 FACE="Arial">checking the return value. It then immediately called GetCoordinateSystemWkt</FONT>
<BR><FONT SIZE=2 FACE="Arial">on the reader. This generates an MgIndexOutOfRangeException if there are no</FONT>
<BR><FONT SIZE=2 FACE="Arial">spatial contexts. Updated the code to only call GetCoordinateSystemWkt if</FONT>
<BR><FONT SIZE=2 FACE="Arial">ReadNext returns true.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">The fix was made for all three web tier flavors: ASPX, PHP, JSP.</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">===================================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">--- mapviewerjava/buffer.jsp (revision 1035)</FONT>
<BR><FONT SIZE=2 FACE="Arial">+++ mapviewerjava/buffer.jsp (revision 1036)</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -221,17 +221,10 @@</FONT>
<BR><FONT SIZE=2 FACE="Arial"> MgResourceIdentifier featSourceId = new MgResourceIdentifier(selLayer.GetFeatureSourceId());</FONT>
<BR><FONT SIZE=2 FACE="Arial"> MgSpatialContextReader ctxs = featureSrvc.GetSpatialContexts(featSourceId, true);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> String srsDefDs = "";</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if(ctxs != null)</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- ctxs.ReadNext();</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if(ctxs != null && ctxs.ReadNext())</FONT>
<BR><FONT SIZE=2 FACE="Arial"> srsDefDs = ctxs.GetCoordinateSystemWkt();</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if(srsDefDs == null || srsDefDs.length() == 0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- excludedLayers++;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- continue;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- else</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if(srsDefDs == null || srsDefDs.length() == 0)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> excludedLayers++;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> continue;</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -505,16 +498,16 @@</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> String GetMapSrs(MgMap map)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- try</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ try</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> String srs = map.GetMapSRS();</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if(!srs.equals(""))</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if(!srs.equals(""))</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return srs;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> }</FONT>
<BR><FONT SIZE=2 FACE="Arial"> catch(MgException e)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> }</FONT>
<BR><FONT SIZE=2 FACE="Arial">-</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial"> //No SRS, set to ArbitrayXY meters</FONT>
<BR><FONT SIZE=2 FACE="Arial"> //</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">===================================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">--- mapviewernet/buffer.aspx (revision 1035)</FONT>
<BR><FONT SIZE=2 FACE="Arial">+++ mapviewernet/buffer.aspx (revision 1036)</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -202,17 +202,10 @@</FONT>
<BR><FONT SIZE=2 FACE="Arial"> MgResourceIdentifier featSourceId = new MgResourceIdentifier(selLayer.GetFeatureSourceId());</FONT>
<BR><FONT SIZE=2 FACE="Arial"> MgSpatialContextReader ctxs = featureSrvc.GetSpatialContexts(featSourceId, true);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> String srsDefDs = "";</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if (ctxs != null)</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- ctxs.ReadNext();</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if (ctxs != null && ctxs.ReadNext())</FONT>
<BR><FONT SIZE=2 FACE="Arial"> srsDefDs = ctxs.GetCoordinateSystemWkt();</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if (srsDefDs == null || srsDefDs.Length == 0)</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- excludedLayers++;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- continue;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- else</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if (srsDefDs == null || srsDefDs.Length == 0)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> excludedLayers++;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> continue;</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial">===================================================================</FONT>
<BR><FONT SIZE=2 FACE="Arial">--- mapviewerphp/buffer.php (revision 1035)</FONT>
<BR><FONT SIZE=2 FACE="Arial">+++ mapviewerphp/buffer.php (revision 1036)</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -191,17 +191,10 @@</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $featSourceId = new MgResourceIdentifier($selLayer->GetFeatureSourceId());</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $ctxs = $featureSrvc->GetSpatialContexts($featSourceId, true);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $srsDefDs = "";</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if($ctxs != null)</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- $ctxs->ReadNext();</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if($ctxs != null && $ctxs->ReadNext())</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $srsDefDs = $ctxs->GetCoordinateSystemWkt();</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if($srsDefDs == "")</FONT>
<BR><FONT SIZE=2 FACE="Arial">- {</FONT>
<BR><FONT SIZE=2 FACE="Arial">- $excludedLayers ++;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- continue;</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- }</FONT>
<BR><FONT SIZE=2 FACE="Arial">- else</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if($srsDefDs == "")</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $excludedLayers ++;</FONT>
<BR><FONT SIZE=2 FACE="Arial"> continue;</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -213,7 +206,7 @@</FONT>
</P>
<P><FONT SIZE=2 FACE="Arial"> if($arbitraryDsSrs)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $dsSrsUnits = $srsDs->GetUnits();</FONT>
<BR><FONT SIZE=2 FACE="Arial">-</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial"> // exclude layer if:</FONT>
<BR><FONT SIZE=2 FACE="Arial"> // the map is non-arbitrary and the layer is arbitrary or vice-versa</FONT>
<BR><FONT SIZE=2 FACE="Arial"> // or</FONT>
<BR><FONT SIZE=2 FACE="Arial">@@ -474,9 +467,9 @@</FONT>
<BR><FONT SIZE=2 FACE="Arial"> function GetMapSrs($map)</FONT>
<BR><FONT SIZE=2 FACE="Arial"> {</FONT>
<BR><FONT SIZE=2 FACE="Arial"> $srs = $map->GetMapSRS();</FONT>
<BR><FONT SIZE=2 FACE="Arial">- if($srs != "")</FONT>
<BR><FONT SIZE=2 FACE="Arial">+ if($srs != "")</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return $srs;</FONT>
<BR><FONT SIZE=2 FACE="Arial">-</FONT>
<BR><FONT SIZE=2 FACE="Arial">+</FONT>
<BR><FONT SIZE=2 FACE="Arial"> //No SRS, set to ArbitrayXY meters</FONT>
<BR><FONT SIZE=2 FACE="Arial"> //</FONT>
<BR><FONT SIZE=2 FACE="Arial"> return "LOCALCS[\"*XY-MT*\",LOCAL_DATUM[\"*X-Y*\",10000],UNIT[\"Meter\", 1],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]";</FONT>
</P>
<BR>
<P><FONT SIZE=1 FACE="Courier New"> W E @__ __o</FONT>
<BR><FONT SIZE=1 FACE="Courier New"> A T R @___ _ \<,_</FONT>
<BR><FONT SIZE=1 FACE="Courier New"> L @_ (*)/ (*)</FONT>
</P>
</BODY>
</HTML>