[mapguide-users] Tooltip value from object
Matteo
matteo.conte1979 at libero.it
Thu Mar 26 17:35:14 EDT 2009
Yes I use ODBC provider to connect at the MSSQL 2005 tables.
Tomorrow morning I test the computed property from Studio and so I can answer at your question.
Regards
Matteo
Are you using the ODBC provider then for the connection since you pointed out the Lat/Lon fields?
It may be a bug with the ODBC provider. I understand your need to code it, however I was wondering if you tested it with Studio also. If that fails too it's likely a general bug.
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 2:50 PM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] Tooltip value from object
Dave, my featuresource is a MSSQL 2005 table with LAT, LON fields
Add a computed property via Studio is not a good solution for my case because I manage 10 projects with a total of 100 featuresource of this type and this function will work for all of those
Thanks a lot
Matteo
What is the data format of the feature source SDF, SHP? It may be a bug.
What if you make a copy of the existing feature source and add the computed property via Studio does that work?
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 1:33 PM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] Tooltip value from object
Hi Dave,
if I change this code
Dim strTooltipValue as string=GetValueFromReader(objFeatureReader, objFeatureReader.GetPropertyType("thetooltip"), "thetooltip")
with this one
Dim strTooltipValue as string=GetValueFromReader(objFeatureReader, objFeatureReader.GetPropertyType("ID"), "ID")
where ID is a property of featuresource I haven't any error so I think that the problem is the computed property.
Matteo
I would do the following to better debug things.
You should check that the objFeatureReader returned from the SelectFeatures call is not null before starting the .ReadNext.
As well note that you don't appear to have set the filter either so you will likely get more than 1 record back from your data.
You might also try the SelectFeatures without adding the computed property, but instead specify an existing known property and include the filter.
This looks like it should work.
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 11:13 AM
To: mapguide-users at lists.osgeo.org
Subject: RE: [mapguide-users] Tooltip value from object
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.
_______________________________________________
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-tp2528017p2540610.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-tp2528017p2541011.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-tp2528017p2541225.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list