[mapguide-users] Set Filter Options

padmini godavarthi godavarthi.padmini at gmail.com
Thu Feb 5 09:25:51 EST 2009


Hi,
Thanks for ur help.
its working fine.
Now my problem is that i want to create layer(in my application property
layer(sample) thematic colour to the parcels based on setfilter option

Here is my code
-----------------------------------------------------------------------------------

    Dim aggregateOptions1 As MgFeatureAggregateOptions = New
MgFeatureAggregateOptions()

        aggregateOptions1.AddFeatureProperty("PARCEL_ID")
        aggregateOptions1.SelectDistinct(True)
        aggregateOptions1.SetFilter("PARCEL_ID IN ('785_1000','670_286')")
              
Dim increment1 As Double = IIf((5 > 1), 1.0 / (5 - 1), 1.0)

        Dim dataReader1 As MgDataReader =
featureService.SelectAggregate(resId, layer.GetFeatureClassName(),
aggregateOptions1)


        While dataReader1.ReadNext()

            value = GetFeaturePropertyValue(dataReader1, "PARCEL_ID")

            filterText = """ + "PARCEL_ID" + "" = "

            filterText = filterText + value

            areaRuleXML = String.Format(areaRuleTemplate, "PARCEL_ID" + ":"
+ value, filterText, InterpolateColor(portion, "000000", "000000", 0),
InterpolateColor(portion, "000000", "000000", 0))
            areaDoc = New XmlDocument()
            areaDoc.LoadXml(areaRuleXML)
                      areaNode = doc.ImportNode(areaDoc.DocumentElement,
True)
            areaTypeStyle.AppendChild(areaNode)

            portion = portion + increment1
        End While

        dataReader1.Close()
        Dim xmlString As String = doc.DocumentElement.OuterXml
        Dim uniqueName As String = MakeUniqueLayerName(map, "Property
Layer", "sample")
        Dim legendLabel As String = layer.GetLegendLabel()
        If "sample".Length > 0 Then
            legendLabel = legendLabel + " (" + "sample" + ")"
            Dim layerResId As MgResourceIdentifier = New
MgResourceIdentifier("Session:" + sessionId + "//" + uniqueName +
".LayerDefinition")
            resourceService.SetResource(layerResId, New
MgByteReader(xmlString, "text/xml"), Nothing)

            Dim newLayer As MgLayer = New MgLayer(layerResId,
resourceService)
            newLayer.SetName(uniqueName)
            newLayer.SetLegendLabel(legendLabel)
            newLayer.SetDisplayInLegend(layer.GetDisplayInLegend())
            newLayer.SetVisible(True)
            newLayer.SetSelectable(layer.GetSelectable())
            layers.Insert(layers.IndexOf(layer), newLayer)

            map.Save(resourceService)

            'Return uniqueName

        End If
----------------------------------------------------------------

   Private Function InterpolateColor(ByVal portion As Double, ByVal
startColor As String, ByVal endColor As String, ByVal percentTransparent As
Integer) As String

        Dim alpha As Integer = CType((255 * (100.0 - percentTransparent) /
100.0), Integer)
        Dim result As String = ""
        If (startColor.Equals(endColor)) Then

            result = String.Format("{0:X2}{1}", alpha, startColor)

        Else

            Dim red As Integer = CalculateRGB(portion,
startColor.Substring(0, 2), endColor.Substring(0, 2))
            Dim green As Integer = CalculateRGB(portion,
startColor.Substring(2, 2), endColor.Substring(2, 2))
            Dim blue As Integer = CalculateRGB(portion,
startColor.Substring(4, 2), endColor.Substring(4, 2))
            result = String.Format("{0:X2}{1:X2}{2:X2}{3:X2}", alpha, red,
green, blue)
        End If

        Return result
    End Function
-------------------------------------------------------------------------------------------
1)But its not creating the layer 

can u tell me the solution


Regards,
Padmini




Kenneth Skovhede, GEOGRAF A/S wrote:
> 
> It works fine for me if I do:
> filter.SetFilter("ID IN (1,2,3)");
> or
> filter.SetFilter("Name LIKE 'test');
> 
> Regards, Kenneth Skovhede, GEOGRAF A/S
> 
> 
> 
> padmini godavarthi skrev:
>>
>> Hi,
>> Iam using Mapguide opensource 2.0 (with .net 2.0 + IIS 5.1)
>>
>>
>>
>> iam using  MgFeatureQueryOptions and filtering my layer using setfilter 
>>
>>
>> Is there any facility to use "in","like" operators in setfilter option?
>>
>> can u plz tell me the syntax so it will be helpful to me.
>>
>>
>> Thanks and Regards,
>> Padmini.
>>
>>
>>   
> _______________________________________________
> 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/Set-Filter-Options-tp2274545p2275089.html
Sent from the MapGuide Users mailing list archive at Nabble.com.



More information about the mapguide-users mailing list