[英]Geoserver WFS layer as Timestamp fields converted to string on OpenLayers Vector layer
I am using a WFS layer in open layers with the following code: 我正在使用以下代码在开放层中使用WFS层:
crashes = new OpenLayers.Layer.Vector(title, {
strategies: [new OpenLayers.Strategy.BBOX({resFactor: 1}), clusterStrategy],
minScale: minimumScale,
visibility:visiblity,
displayInLayerSwitcher:showInLayerSwitcher,
protocol: new OpenLayers.Protocol.WFS({
version: "1.1.0",
srsName: srid,
url: wfsUrl,
featureType: layerName,
geometryName: geomCol,
featurePrefix: prefix,
featureNS : namespace
}),
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": {
fillColor: "red",
strokeColor: "#32a8a9"
}
})
});
from a function where the parameters are passed in. This layer works nicely. 从传递参数的函数中获取。此层很好地工作。
I now want to apply filters to this layer, one of which being using the between comparison on a date field. 我现在想将过滤器应用于此层,其中之一是在日期字段上使用之间的比较。
,new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.BETWEEN,
property: "CRASH_DATE",
lowerBoundary: new Date(2011,0,1);,
upperBoundary: new Date(2014,0,1);
})
It appears as if all the fields are converted to string types so trying to do this camparison results in no data being returned: 似乎所有字段都被转换为字符串类型,因此尝试执行此Camparison不会导致返回任何数据:
I have also tried creating function filter which returns no results: 我也尝试过创建不返回任何结果的函数过滤器:
vehicleCrashLayer.filter = new OpenLayers.Filter.Logical({
type: OpenLayers.Filter.Logical.AND,
filters: [
new OpenLayers.Filter.Spatial({
type: OpenLayers.Filter.Spatial.INTERSECTS,
value: event.feature.geometry,
})
,new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
property: "SEVERITY",
value: "Property Damage Only"
})
,new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
property: "SEVERITY",
value: "Not Known"
})
,new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.NOT_EQUAL_TO,
property: "SEVERITY",
value: "Not Stated"
})
,new OpenLayers.Filter.Function({
name: 'dateBetween',
type: OpenLayers.Filter.Function,
evaluate: function(feature){
console.log(feature.attributes);
var x=0;
return true;
}
})
]
});
Can anyone help with this. 有人能帮忙吗。 Examples are few and far between.
例子很少而且相去甚远。
I haven't tested this, but have you tried timestamp-like value? 我还没有测试过,但是您是否尝试过类似时间戳的值? in Javascript:
new Date().getTime()
This returns the number of miliseconds since the given time. 用Java语言编写:
new Date().getTime()
返回自给定时间以来的毫秒数。 If you could arrange your database to return this value too, you'd be working with an integer. 如果您也可以安排数据库返回该值,则可以使用整数。 And that is pretty easy...
这很容易...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.