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

Murty Maganti MMaganti at oriongis.com
Wed Aug 5 17:39:50 EDT 2009


Hi Tamas,

 

Thanks for your response. I don't have the latest. But, as a workaround,
I have done the same fix in my code i.e. backup the connection type and
change the connection type to MS_INLINE just before calling
whichShapes(). After the change, it is retrieving the attribute values.
Appreciate your help.

 

Thanks

Murty

 

From: Tamas Szekeres [mailto:szekerest at gmail.com] 
Sent: Wednesday, August 05, 2009 5:11 PM
To: Murty Maganti
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] layer.whichShapes() in C# mapscript

 

I suspect you've run into the following issue here:
http://trac.osgeo.org/mapserver/ticket/2689

which have already been fixed in:
http://trac.osgeo.org/mapserver/changeset/9060
http://trac.osgeo.org/mapserver/changeset/9064

Make sure your version is newer than the changesets above.

By using this fix you won't need to call layer.open right after
whichShapes in order to retrieve all the items.

Best regards,

Tamas




2009/8/5 Murty Maganti <MMaganti at oriongis.com>

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


_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

 

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


More information about the mapserver-users mailing list