gpt4 book ai didi

javascript - Google Fusion Table 的复杂 SQL 查询出现问题。我可以在查询中使用外部值吗?

转载 作者:行者123 更新时间:2023-11-30 14:37:58 25 4
gpt4 key购买 nike

这个项目的基本轮廓是它是伦敦区之间旅程时间的视觉表示。

到目前为止,我已经设置了一个可以很好地响应基本查询的 google 融合表。但现在我正在尝试根据往返所选多边形的行程时间来更改融合表多边形的颜色。

function fillcolour(match) {
var limit = 0;
var filter = [];

for (x in match) {
if (limit < 5) {
var duration = match[x];
if (dataraw[1]) {
//-------75 and 65 are stand in values at the moment. They will later be filled by variables.
filter.push("(" + generateWhere(x, duration, 75, 65) + ")");
}
limit++;
}
}
where = filter.join(' OR ');

PolygonLayer.setOptions({
query: {
select: 'shape',
from: mapTable
},
styles: [{
polygonOptions: {
fillColor: "#000FFF",
fillOpacity: .8
}
},
{
where: where,
polygonOptions: {
fillColor: "#FFF000"
}
}],
})
};

function generateWhere(Keys, duration, high, low) {
var whereClause = [];
whereClause.push("name");
whereClause.push(" = '");
whereClause.push(Keys);
whereClause.push("' AND ");
whereClause.push(duration);
whereClause.push(" >= ");
whereClause.push(low);
whereClause.push(" AND ");
whereClause.push(duration);
whereClause.push(" < ");
whereClause.push(high);
return whereClause.join('');
}

我知道可能有一种更简单的方法来处理多边形选项,但目前我的 SQL 查询并没有按照我希望的方式运行。

这是被输入 where 语句的查询:

(name = 'Abbey Wood' AND 80 >= 65 AND 80 < 75) OR (name = 'Acton' AND 74 >= 65 AND 74 < 75) OR (name = 'Anerley' AND 46 >= 65 AND 46 < 75)

有人知道为什么这行不通吗?

最佳答案

(name = 'Abbey Wood' AND 80 >= 65 AND 80 < 75) OR (name = 'Acton' AND 74 >= 65 AND 74 < 75) OR (name = 'Anerley' AND 46 >= 65 AND 46 < 75)

查询有两个问题

1) Fusion Table Queries :

"You must use quotes around any column names in the select or where fields that contain spaces, reserved words, or that do not begin with a letter".

2) Row and Query SQL Reference :

"OR is not supported."

因此您需要添加引号并将 OR 子查询拆分为单独的查询

styles: [{
polygonOptions: {
fillColor: "#000FFF",
fillOpacity: .8
}
},
{
where: "name = 'Abbey Wood' AND '80' >= 65 AND '80' < 75",
polygonOptions: {
fillColor: "#FFF000"
}
},
{
where: "name = 'Acton' AND '74' >= 65 AND '74' < 75",
polygonOptions: {
fillColor: "#FFF000"
}
},
{
where: "name = 'Anerley' AND '46' >= 65 AND '46' < 75",
polygonOptions: {
fillColor: "#FFF000"
}
}]

关于javascript - Google Fusion Table 的复杂 SQL 查询出现问题。我可以在查询中使用外部值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50124363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com