[mapguide-users] MgSelection.AddFeatures Bug?

Walt Welton-Lair walt.welton-lair at autodesk.com
Wed Mar 14 08:16:06 EDT 2007


By calling ReadNext on the feature reader you've read all the available
features out of the reader...  Just call AddFeatures with your reader
without doing your check.  If the reader contains no features then
nothing will be added to the selection.
 
Walt

  _____  

From: mapguide-users-bounces at lists.osgeo.org
[mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Buscher,
Shane
Sent: Tuesday, March 13, 2007 10:22 PM
To: Mapguide_users at lists.osgeo.org
Subject: [mapguide-users] MgSelection.AddFeatures Bug?



I'm simply trying to highlight selected features based on an attribute
query. When I obtain a feature reader I check to make sure that there
are items in it, then I execute the MgSelection.AddFeatures method.
Nothing gets selected in the long run after I call the
SetSelectionXML('xml') viewer api function and refresh the map.  I took
a look at the xml being passed and noticed there are no records in it.
Is there something I'm doing wrong here?  There are definitely records
in the feature reader that aren't making it into the xml.  Or maybe
there's a bug in the MgSelection.AddFeatures() method?  Any help would
be greatly appreciated.

Regards,

Shane

Dim layer As MgLayer = _map.GetLayers.GetItem(0)

Dim className As String = layer.GetFeatureClassName

Dim resourceId As New MgResourceIdentifier(layer.GetFeatureSourceId)

Dim queryString As String

Dim queryOption As New MgFeatureQueryOptions()

queryOption.SetFilter(queryString)

Dim featureReader As MgFeatureReader

featureReader = _featureService.SelectFeatures(resourceId, className,
queryOption)

Dim i As Integer = 0

While featureReader.ReadNext

   i = i + 1

End While

If i > 0 Then

   Dim selection As New MgSelection(_map)

   selection.AddFeatures(layer, featureReader, 0)

   Dim xml As String = selection.ToXml()

End If

<?xml version="1.0" encoding="UTF-8"?>

<FeatureSet xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance>
xsi:noNamespaceSchemaLocation="FeatureSet-1.0.0.xsd"></FeatureSet>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070314/9dc9aa48/attachment.html


More information about the mapguide-users mailing list