Using OutStatistics with Dynamic Layer

4346
2
01-06-2015 02:08 AM
LaurentSIBILLE
New Contributor

Hello,

we're trying to get statistics on dynamic layer, but it seems not work.

We always get an empty result while executing the following querytask.

Is there any other way to get statistics on dynamic layer ?

Dim queryTask = New QueryTask(New Uri(String.Concat(Me.CarteView.MapServicePatrimoine.ServiceUri, "/dynamicLayer/99")))

Dim query = New Query("1=1") With {

                .GroupByFieldsForStatistics = myUniqueValueRenderer.Fields,

                .OutStatistics = myUniqueValueRenderer.Fields.

                                    Select(Function(field) New OutStatistic(

                                                                field,

                                                                String.Format("{0}_{1}", StatisticType.Count.GetNom, field),

                                                                StatisticType.Count

                                                            )

                                    ).

                                    ToArray,

                .Source = rendererTaskParameters.Source

            }

Dim queryResult = Await queryTask.ExecuteAsync(query)

Thanks for your answer,

Best Regards.

0 Kudos
2 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

In your code example what type is "rendererTaskParameters"?

You should not need to specify the DynamicLayer endpoint in the URL - instead it should be specified via the Source property on the Query class - most likely using the QueryTableDataSource class as the datasource property of a new LayerDataSource instance?

Hopefully this sample should demonstrate the right approach: Code Example - QueryTableDataSource

Cheers

Mike

0 Kudos
LaurentSIBILLE
New Contributor

Hi,

Thanks for your answer.

The QueryTask's constructor needs an URI, so which URI should we specify ?

The DynamicLayer we use is created with a QueryTableDataSource as desmonstrate in the sample.

The "rendererTaskParameters" is a GenerateRendererParameters and the source passed to the QueryTask is a LayerDataSource using the QueryTableDataSource.

Dim queryTableSource = New QueryTableDataSource() With {...}

Dim layerSource = LayerDataSource() With {.DataSource = queryTableSource}

Dim rendererTask = New GenerateRendererTask(Me.CarteView.MapServicePatrimoine.ServiceUri)

Dim rendererTaskParameter = New GenerateRendererParameters() With {

                                            .ClassificationDefinition = classificationDefinition,

                                            .Source = layerSource

                                        }

Dim rendererTaskResult = Await rendererTask.GenerateRendererAsync(rendererTaskParameter)

Cheers,

Laurent

0 Kudos