Select to view content in your preferred language

query features within a polygon with statistics definition

2413
10
08-17-2016 07:53 AM
clementinechasles
New Contributor

Hello everybody,

I'm trying to make a queryFeatures on a feature layer with StatisticDefinition : I would like to calculate statistics on the field "TOTAL" of my feature layer res, with the features which are within my polygon.

Here's my code below : for the moment, I just append a console.log with the result, but the query doesn't work. The array of features stays empty and I don't have any error message. So I guess my query is poorly constructed but I don't see where.

Could you help me please ?

function (polygon, res) {
                                            
                                            var queryParams = new Query();
                                            queryParams.spatialRelationship = Query.SPATIAL_REL_WITHIN;
                                            queryParams.geometry = polygon.geometry ;
                                            queryParams.outFields = ["*"]; 


                                            var countSD = new StatisticDefinition();
                                            var sumSD = new StatisticDefinition();
                                            var avgSD = new StatisticDefinition();
                                            queryParams.outStatistics = [countSD, sumSD, avgSD];
                                            
                                            var sqlExpression = "TOTAL";
                                            
                                            countSD.statisticType = "count";
                                            countSD.onStatisticField = sqlExpression;
                                            countSD.outStatisticFieldName = "CountResDial";
                                            
                                            sumSD.statisticType = "sum";
                                            sumSD.onStatisticField = sqlExpression;
                                            sumSD.outStatisticFieldName = "SumResDial";
                                            
                                            avgSD.statisticType = "avg";
                                            avgSD.onStatisticField = sqlExpression;
                                            avgSD.outStatisticFieldName = "AvgResDial";
                                            
                                            
                                            res.queryFeatures(queryParams,
                                                                function (results){
                                                                    console.log(">>>>>>>>>>>>>> r\351sultats de la query : ");
                                                                    console.log(results);
                                                                },
                                                                function (err){
                                                                    console.log("Impossible r\351cup\351rer le nombre de dialys\351s dans les                                                                     tranches isochrones : ", err);
                                                                }
                                            );
                                        }

0 Kudos
10 Replies
KristianEkenes
Esri Regular Contributor

If this still doesn't work, could you post a link to a sample app reproducing the issue?

0 Kudos