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

Tamas Szekeres szekerest at gmail.com
Wed Aug 5 17:11:21 EDT 2009


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/b2dbebd2/attachment.html


More information about the mapserver-users mailing list