I suspect you&#39;ve run into the following issue here:<br><a href="http://trac.osgeo.org/mapserver/ticket/2689">http://trac.osgeo.org/mapserver/ticket/2689</a><br><br>which have already been fixed in:<br><a href="http://trac.osgeo.org/mapserver/changeset/9060">http://trac.osgeo.org/mapserver/changeset/9060</a><br>
<a href="http://trac.osgeo.org/mapserver/changeset/9064">http://trac.osgeo.org/mapserver/changeset/9064</a><br><br>Make sure your version is newer than the changesets above.<br><br>By using this fix you won&#39;t need to call layer.open right after whichShapes in order to retrieve all the items.<br>
<br>Best regards,<br><br>Tamas<br><br><br><br><div class="gmail_quote">2009/8/5 Murty Maganti <span dir="ltr">&lt;<a href="mailto:MMaganti@oriongis.com">MMaganti@oriongis.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">









<div link="blue" vlink="purple" lang="EN-US">

<div>

<p>Hi</p>

<p> </p>

<p>I am having difficulty performing
layerObj.whichShapes()  and looping through results. For some datasets
like shape files, it requires layerObj.open() call after invoking whichSpaes().
Otherwise, shapeObj.values.length is 0. For ArcSDE, it throws an error on layer.nextShape()
if layer.open() is called after invoking whichShapes(). How to write a single piece
of code that works with all datasets without checking for layer data source type?
Here is the simple test code I am using</p>

<p> </p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
<span style="color: rgb(43, 145, 175);">layerObj</span> layer = m_map.getLayerByName(“Roads”);</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
<span style="color: blue;">if</span> (layer != <span style="color: blue;">null</span>)</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
{</span></p>

<p style="text-indent: 0.5in;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
layer.template = <span style="color: rgb(163, 21, 21);">&quot;abcd&quot;</span>;</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                       
<span style="color: blue;">if</span> (layer.open() == (<span style="color: blue;">int</span>)<span style="color: rgb(43, 145, 175);">MS_RETURN_VALUE</span>.MS_SUCCESS)</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                       
{</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                           
<span style="color: blue;">if</span> (layer.whichShapes(m_map.extent) == (<span style="color: blue;">int</span>)<span style="color: rgb(43, 145, 175);">MS_RETURN_VALUE</span>.MS_SUCCESS)</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                           
{</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                               
layer.open(); //Required for shape files. Otherwise, shapeObj.values.length
will be zero.<span style="color: green;"></span></span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                               
<span style="color: rgb(43, 145, 175);">shapeObj</span> shape = <span style="color: blue;">null</span>;</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                               
<span style="color: blue;">while</span> ((shape = layer.nextShape()) != <span style="color: blue;">null</span>)</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                               
{</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                                   
<span style="color: blue;">if</span> (shape.values != <span style="color: blue;">null</span>
&amp;&amp; shape.values.Length &gt; 0)</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                       
            {</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                                       
<span style="color: blue;">string</span> value = shape.values[0];</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                                   
}</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                               
}</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                           
}</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                        }</span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;"> </span></p>

<p style=""><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                       
layer.close();</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">                   
}</span></p>

<p> </p>

<p>Please let me know if some thing wrong with code above.
Appreciate any help.</p>

<p> </p>

<p>Thanks</p>

<p>Murty</p>

</div>

</div>


<br>_______________________________________________<br>
mapserver-users mailing list<br>
<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/mapserver-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
<br></blockquote></div><br>