[mapserver-users] layer.whichShapes() in C# mapscript

Murty Maganti MMaganti at oriongis.com
Wed Aug 5 12:30:47 EDT 2009


Hi

 

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

 

                    layerObj layer = m_map.getLayerByName("Roads");

                    if (layer != null)

                    {

                    layer.template = "abcd";

 

                        if (layer.open() ==
(int)MS_RETURN_VALUE.MS_SUCCESS)

                        {

                            if (layer.whichShapes(m_map.extent) ==
(int)MS_RETURN_VALUE.MS_SUCCESS)

                            {

                                layer.open(); //Required for shape
files. Otherwise, shapeObj.values.length will be zero.

 

                                shapeObj shape = null;

 

                                while ((shape = layer.nextShape()) !=
null)

                                {

                                    if (shape.values != null &&
shape.values.Length > 0)

                                    {

                                        string value = shape.values[0];

                                    }

                                }

 

                            }

                        }

 

                        layer.close();

                    }

 

Please let me know if some thing wrong with code above. Appreciate any
help.

 

Thanks

Murty

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20090805/8da557a8/attachment.html


More information about the mapserver-users mailing list