[mapguide-users] Tooltip value from object

Matteo matteo.conte1979 at libero.it
Thu Mar 26 13:13:10 EDT 2009


Hi Dave,
 this is my code:

Dim objQueryOptions As MgFeatureQueryOptions = New MgFeatureQueryOptions()
Dim strTooltipExpression as string= ="Concat (  'Nome Sito: '  ,  Concat (  NOME_SITO ,  Concat ( '\nCodice Sito: ' , Concat (  SITENUMBER ,  Concat (  '\nSrambling Code: ' ,  SCRAMBLING_CODE  )   )     )   )   )"
objQueryOptions.AddComputedProperty("thetooltip", strTooltipExpression )

Dim objFeatureReader As MgFeatureReader
objFeatureReader = objFeatureServ.SelectFeatures(New MgResourceIdentifier(objLayer.GetFeatureSourceId), objLayer.GetFeatureClassName, objQueryOptions)
While objFeatureReader.ReadNext()
  Dim strTooltipValue as string=GetValueFromReader(objFeatureReader, objFeatureReader.GetPropertyType("thetooltip"), "thetooltip") ' I get the error on this line of code
End While

GetValueFromReader function is a my function that return the property value. This is the function code:
 Function GetValueFromReader(ByVal objFeatureReader As MgReader, ByVal intpropertyType As Integer, ByVal strpropertyName As String) As String
        Dim isNull As Boolean = objFeatureReader.IsNull(strpropertyName)
        
        If intpropertyType = MgPropertyType.Boolean Then
            If isNull Then
                Return "null"
            Else
                Return objFeatureReader.GetBoolean(strpropertyName).ToString()
            End If
             
        ElseIf intpropertyType = MgPropertyType.Byte Then
            
            If isNull Then
                Return "null"
            Else
                Return objFeatureReader.GetByte(strpropertyName).ToString()
            End If
            
        ElseIf intpropertyType = MgPropertyType.Clob Then
            If isNull Then
                Return "null"
            Else
                Return "notNull"
            End If
            
        ElseIf intpropertyType = MgPropertyType.DateTime Then
            Dim dateTimeStr As String = Nothing
            If isNull Then
                Return "null"
            Else
                Dim aDateTime As MgDateTime = objFeatureReader.GetDateTime(strpropertyName)
                dateTimeStr = aDateTime.Month.ToString() + "."c + aDateTime.Day.ToString() + "."c + aDateTime.Year.ToString() + ":"c + aDateTime.Hour.ToString() + ":"c + aDateTime.Minute.ToString() + ":"c + aDateTime.Second.ToString()
                Return dateTimeStr
            End If
           
        ElseIf intpropertyType = MgPropertyType.Double Then
            If isNull Then
                Return "0"
            Else
                Return objFeatureReader.GetDouble(strpropertyName).ToString()
            End If

        ElseIf intpropertyType = MgPropertyType.Feature Then
            If isNull Then
                Return "null"
            Else
                Return "notNull"
            End If
        ElseIf intpropertyType = MgPropertyType.Int16 Then
            If isNull Then
                Return "0"
            Else
                Return objFeatureReader.GetInt16(strpropertyName).ToString()
            End If
            
        ElseIf intpropertyType = MgPropertyType.Int32 Then
            If isNull Then
                Return "0"
            Else
                Return objFeatureReader.GetInt32(strpropertyName).ToString()
            End If
          
        ElseIf intpropertyType = MgPropertyType.Int64 Then
            If isNull Then
                Return "0"
            Else
                Return objFeatureReader.GetInt64(strpropertyName).ToString()
            End If
         
        ElseIf intpropertyType = MgPropertyType.Raster Then
            If isNull Then
                Return "null"
            Else
                Return "notNull"
            End If
          
        ElseIf intpropertyType = MgPropertyType.Single Then
            If isNull Then
                Return "null"
            Else
                Return objFeatureReader.GetSingle(strpropertyName).ToString()
            End If

        ElseIf intpropertyType = MgPropertyType.String Then
            If isNull Then
                Return "null"
            Else
                Return objFeatureReader.GetString(strpropertyName)
            End If
            
        Else
            Return ""
        End If
    End Function

Regards,
Matteo


Can you show a larger block of code? It seems like something else is wrong after you add the computed property to the QueryFeatureOptions object.

Dave

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Matteo
Sent: Thursday, March 26, 2009 6:19 AM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] Tooltip value from object


Hi Dave,
  the Response.Write("Computed Property index: " + result.ToString()); expression return to me "1". So I think that 1 property is add but when I try to get the property values MG give me this error "OSGeo.MapGuide.MgObjectNotFoundException: The specified object was not found".

I call my property with this name "thetooltip" and the property expression is: Concat (  'Nome Sito: '  ,  Concat (  NOME_SITO ,  Concat ( '\nCodice Sito: ' , Concat (  SITENUMBER ,  Concat (  '\nSrambling Code: ' ,  SCRAMBLING_CODE  )   )     )   )   )

I can't modify the featuresource because is used from another program

Regards,
Matteo


So I'm guessing in your code you have something like:

result=mgFeatQueryOptions.AddComputedProperty(computedPropAlias, computedProp);
So what if you add a debug statement after it to do something like echo the following:

Response.Write("Computed Property index: " + result.ToString());

An alternative to trying to do this in code might be to edit the feature source and add the computed property there. Create your layer using the extended feature class and in your code you can just select this property without having to do the computed property bit, but if there is something wrong with the expression you have maybe that is causing the computed property to actually get added. I wouldn't call it tooltip by the way as that seems too much like a keyword. I would call it theToolTip or something to be safe.

Dave
-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Matteo
Sent: Wednesday, March 25, 2009 10:57 AM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] Tooltip value from object


Hi Dave,
  now I get the tooltip expression from Layer definition and I add a computed property on MgFeatureQueryOptions. I have used "tooltip" alias. However when I try to read the tooltip property mapguide not find it on property collection.
Can you help me?
Regards,
Matteo


Can you parse the layer definition to get the expression and execute a query using the expression as the select statement with the addition of a feature id or key value?

Dave

-----Original Message-----
From: mapguide-users-bounces at lists.osgeo.org [mailto:mapguide-users-bounces at lists.osgeo.org] On Behalf Of Matteo
Sent: Tuesday, March 24, 2009 11:39 AM
To: mapguide-users at lists.osgeo.org
Subject: [mapguide-users] Tooltip value from object


Hi All,
  I need to get the tooltip value from a single object of a layer. In the layer definition the tooltip is an expression. I develop with MG 2.0.2 and ASP.NET
Have any ideas?
Regards,
Matteo
-- 
View this message in context: http://n2.nabble.com/Tooltip-value-from-object-tp2528017p2528017.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

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



-- 
View this message in context: http://n2.nabble.com/Tooltip-value-from-object-tp2528017p2533619.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

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



-- 
View this message in context: http://n2.nabble.com/Tooltip-value-from-object-tp2528017p2538007.html
Sent from the MapGuide Users mailing list archive at Nabble.com.

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



-- 
View this message in context: http://n2.nabble.com/Tooltip-value-from-object-tp2528017p2539760.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list