[mapguide-users] RE: Come get your Key IDs

Andy Morsell amorsell at spatialgis.com
Thu Jun 29 13:33:46 EDT 2006


Kori,
I don't think you have to know the column order.  In my case I am getting to
it directly by field name.  I am creating the filter, query options and
feature reader the same way, though.  Also, my MgPropertyType is hardcoded
here.  Your way of determining it from the field is better.
 
Here is part of the C# code for it:
 
//loop through the featureReader, get the ID field, and add it to an array

ArrayList objDBID = new ArrayList(0);
while (featureReader.ReadNext())
   {        
        objDBID.Add(featureReader.GetString("ID")); //TO DO: un-hard code
this.  Pick up the field name to be queried from a request parameter
instead.
   }
 
My biggest problem with these solutions is that the non-programmer types are
not going to be able to easily do this.  We really need a way to easily pass
ANY field in a given layer from a selection set client-side.
 
 
Andy 

  _____  

From: Kori Maleski [mailto:km at pat.ca] 
Sent: Thursday, June 29, 2006 10:15 AM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] RE: Come get your Key IDs


Andrew,

The Selection Set contains the featureIDs for your datasource.
You can get YOUR key IDs from the Selection set by querying the feature,
then reading your preferred key Column (property).

You have to know your key columns position in order to do this - hence my
variable - l_iKeyColumnOrdinal.
i.e. - if my key IDs are in column 4 then  l_iKeyColumnOrdinal = 4
I utilize a lookup table that manages my key columns.  Not sure if this is
the best way but it works.

This returns MY key IDs in a column delimited string.

 

'query the features

Dim l_oQuery As New MgFeatureQueryOptions()
l_oQuery.SetFilter(l_sFilter) 'derived from selection set

 

Dim l_ofeatureSource As MgResourceIdentifier = New
MgResourceIdentifier(l_oSelLayer.GetFeatureSourceId())
Dim l_ofeatures As MgFeatureReader =
l_oFeatureSrvc.SelectFeatures(l_ofeatureSource, l_sFeatureClassName,
l_oQuery)

 

If l_ofeatures.ReadNext() Then
Dim l_sProperty As String = l_ofeatures.GetPropertyName(l_iKeyColumnOrdinal)

Do

Dim pi As Integer
'For pi = 0 To l_ofeatures.GetPropertyCount() - 1

Dim l_iPropType As Integer = l_ofeatures.GetPropertyType(l_sProperty)
Dim l_sPropertyValue As String = ""

Select Case l_iPropType
Case MgPropertyType.Boolean
l_sPropertyValue = l_ofeatures.GetBoolean(l_sProperty).ToString()
Case MgPropertyType.Single
l_sPropertyValue = l_ofeatures.GetSingle(l_sProperty).ToString()
Case MgPropertyType.Double
l_sPropertyValue = l_ofeatures.GetDouble(l_sProperty).ToString()
Case MgPropertyType.Int16
l_sPropertyValue = l_ofeatures.GetInt16(l_sProperty).ToString()
Case MgPropertyType.Int32
l_sPropertyValue = l_ofeatures.GetInt32(l_sProperty).ToString()
Case MgPropertyType.Int64
l_sPropertyValue = l_ofeatures.GetInt64(l_sProperty).ToString()
Case MgPropertyType.String
l_sPropertyValue = l_ofeatures.GetString(l_sProperty)
End Select

If l_sSelectedLayerIDs = "" Then
l_sSelectedLayerIDs = l_sPropertyValue
Else
l_sSelectedLayerIDs = l_sSelectedLayerIDs + "," + l_sPropertyValue
End If

'Next pi

Loop While l_ofeatures.ReadNext()

 
 
 
 
Obviously you have to do this server side...
 
 
Cheers,
 
Kori Maleski  BSc. 
Senior Technical Consultant
 
Pacific Alliance Technologies
Suite 400 - 534 17 Ave. SW Calgary, AB CANADA T2S 0B1
TEL 403.770.1917 FAX 877.691.9149 TOL 877.691.9171  <http://www.pat.ca/>
www.pat.ca

  _____  

From: Andrew DeMerchant [mailto:andrew.demerchant at gemtec.ca]
Sent: Thu 29/06/2006 10:32 AM
To: users at mapguide.osgeo.org
Subject: Re: [mapguide-users] Andy - Question about your tooltips...


 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20060629/46bee822/attachment.html


More information about the Mapguide-users mailing list