问题
尝试使用该outStatistics
参数查询托管要素图层时,我收到失败的响应,而同一要素图层上的空间查询会返回要素。
该应用程序正在尝试使用来自加利福尼亚的井数据查询要素图层。在 CodePen 中,当搜索地址或使用 Slider 小部件修改缓冲区半径时会进行两个查询:
- 首先是需要多个字段进行查询的 outStatistics 查询
- 基于缓冲区几何的空间查询。
应用程序的 CodePen:
https ://codepen.io/dmarkbreiter/pen/abWXRZx
故障排除
我的第一个猜测是我没有正确地形成我的统计定义。但是,它们看起来格式正确。下面是统计查询及其相关统计定义对象的代码:
// Define Statistic Definitions
const countActive = {
onStatisticField: "WellStatus = 'Active'",
outStatisticFieldName: "active",
statisticType: "count"
};
const countNew = {
onStatisticField: "WellStatus = 'New'",
outStatisticFieldName: "new",
statisticType: "count"
};
const countPlugged = {
onStatisticField: "WellStatus = 'Plugged'",
outStatisticFieldName: "plugged",
statisticType: "count"
};
const countIdle = {
onStatisticField: "WellStatus = 'Idle'",
outStatisticFieldName: "idle",
statisticType: "count"
};
const countAll = {
onStatisticField: "WellStatus",
outStatisticFieldName: "all",
statisticType: "count"
};
// Create query object and define outStatistics
let statsQuery = oilWellsLayer.createQuery();
statsQuery.outStatistics = [countIdle,
countPlugged,
countAll,
countActive,
countNew];
// Query feature layer
oilWellsLayer.queryFeatures(statsQuery).then(response=>{
console.log(response)
}).catch(e=>{
console.log(e);
})
如您所见,除了对象之外,这些统计定义在属性countAll
中使用 SQL 语句。outStatisticField
它们似乎都是有效的 SQL 语句。
我的下一个想法是,可能由我不属于的机构拥有的要素图层不允许查询统计数据。但是,要素服务似乎已Supports Statistics
设置为true
。也许我误解了这意味着什么,但我想这将允许 outStatistics。
问题
为什么我可以在这个要素图层上成功执行空间查询,但不能返回 outStatistics?
这是编码问题还是身份验证问题?