AnsweredAssumed Answered

Renderer On Date Ranges

Question asked by 240robs on Apr 17, 2013
Latest reply on Apr 23, 2013 by 240robs
Hi Everyone,
So lets say I want to symbolize one field that has date and time and break it down by Current_TimeStamp  for > 90 days, 60 - 90 days etc. Then I would like to render each selection with a specific color, red, yellow, green. I  can select for data range and set the symbols for each range but only the first draws the color. I pull the feature class from SDE and reference the FC three times for each selection, renderer and Geofeaturelayer. The renderer through a loop selects each date and symbolizes each record for each date range (YUK). I figured if I could set individual renderer's for selection I would be OK. Should I continue down this path? Should I try and export the selection to LYR file and import back into ArcMap for symbolization? A bit of confusion here. Heres my code VS 2010 ArcMAP V 10.

            Dim featureInspectLayer As IFeatureLayer = New FeatureLayerClass
            featureInspectLayer.FeatureClass = featureInspectClass
            featureInspectLayer.Name = "Inspections_>_90_Days"
            featureInspectLayer.Visible = True

            ' If activeView Is Nothing OrElse featureInspectLayer Is Nothing OrElse whereClause Is Nothing Then
            'End If
            Dim featureInspectSelection As IFeatureSelection = TryCast(featureInspectLayer, IFeatureSelection) ' Dynamic Cast
            ' Set up the query
            Dim feature As ESRI.ArcGIS.Geodatabase.IFeature
            Dim queryFilter As IQueryFilter = New QueryFilterClass '
            Dim Day90Filter As String = "WHERE [InspectionDate] in (SELECT max([InspectionDate]) FROM VECTOR.SDE.PolyInspection GROUP BY [SourceSiteID]) AND InspectionDate <= Current_TimeStamp - 90"

            queryFilter.WhereClause = Day90Filter
            Dim featSelection As IFeatureSelection = featureInspectLayer
            featSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)

            Dim selectionSet As ISelectionSet = featSelection.SelectionSet
            Dim featCursor As IFeatureCursor = Nothing
            selectionSet.Search(Nothing, True, featCursor)

            Dim NineDay As IRgbColor
            NineDay = New RgbColor
            NineDay.Red = 255
            NineDay.Green = 0
            NineDay.Blue = 0

            Dim symd As New SimpleFillSymbol
            symd.Style = esriSimpleFillStyle.esriSFSSolid
            symd.Outline.Width = 6

            Dim uvRenderer As IUniqueValueRenderer = New UniqueValueRenderer
            uvRenderer.FieldCount = 1
            uvRenderer.Field(0) = "InspectionDate"
            uvRenderer.DefaultSymbol = symd
            uvRenderer.UseDefaultSymbol = True

            Dim sym As ISimpleFillSymbol = Nothing
            feature = featCursor.NextFeature
            Do Until feature Is Nothing
                sym = New SimpleFillSymbol
                sym.Style = esriSimpleFillStyle.esriSFSSolid
                sym.Outline.Width = 6
                sym.Outline.Color = NineDay
                sym.Color = NineDay
                uvRenderer.AddValue(feature.Value(feature.Fields.FindField("InspectionDate")), "", sym)
                feature = featCursor.NextFeature()

            ' adds Inspection Feature layer
            activeView.Extent = activeView.FullExtent
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, Nothing, Nothing)

            Dim geofeatureInspectLayer As IGeoFeatureLayer = featureInspectLayer
            geofeatureInspectLayer.Renderer = uvRenderer

Thanks Folks