supermap filter fieldsparameter 中的fields可以查询聚集函数么

二维(74)
iClient(54)
作者:Lily
& & & &查询是使用SuperMap iClient for JavaScript经常用到的一个功能,当然在使用过程中我们必须设置查询过滤参数,尤其是必设属性-过滤条件(attributeFilter),一般来说就相当于 SQL 语句中的 WHERE 子句,其格式为:WHERE &条件表达式&, attributeFilter 就是其中的“条件表达式”。 该字段的用法为 attributeFilter = “过滤条件”,其中过滤条件是需要我们自己构建的。需要注意的是,由于文件型数据源中的属性信息是以 Access 格式存储的,用SQL或 Oracle 数据库中查询语句进行查询可能会查询不成功,下面以World文件型数据源发布的地图服务和数据服务为例详细介绍一下文件型数据源过滤条件的构建方式。
二、不同类型查询过滤条件构建
1、数值的查询
& & & &对数值的查询过滤条件中可以使用“字段名=( 或&&, &, &, &=, &=, Between…and等等)字段值 ”。
例如:查询World 数据集中SMID字段值为247的记录
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter: "SMID = 247"
可以在浏览器中查看返回结果:
2、日期型字段的查询
& & & &对于日期型字段的查询是我们需要特别注意的,尤其是对于文件型的数据源,经常会有人不知道对于文件型数据源的日期该如何查询,一般对文件型数据源查日期时,查询过滤条件是这样构建的:“字段名=to_date(YYYY-MM-DD HH:MM:SS) ”。(此处要特别注意)
例如: 查询的是 World 数据集中 T_date 字段为 0:00:00的记录
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"T_Date = to_date(
可以看到查询结果:
查询某个时间段的构建方式:“字段名 Between to_date(YYYY-MM-DD HH:MM:SS) and to_date(YYYY-MM-DD HH:MM:SS)” ”
例如:查询的是 World 数据集中2010年全年的记录
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"T_Date Between to_date( 0:0:0) and to_date( 0:0:0)"
查询结果:
3、模糊查询
模糊查询使用 “like”,而且不同类型的数据源使用的匹配符不尽相同。
1)部分匹配,文件型数据源中的通配符为%,并且要使用单引号
例如:查询 World 数据集中 CAPITAL 字段中以“布”开头的那些国家。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"CAPITAL like '布%'"
查询结果有7个“布”字开头的国家:
2)完全匹配
查询过滤条件:“字段名&
like ‘字段值’”(注意字段值必须用单引号)
例如:查询的是 World 数据集中 CAPITAL 字段值为“北京”的国家。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"CAPITAL like '北京'"
查询结果:
3)单字匹配,使用“_”
例如:查询的是 World 数据集中 CAPITAL 字段值为“达”后面仅加一个字符的国家。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"CAPITAL like '达_'"
查询结果:
4、比较运算符过滤条件中的应用
比较运算符,如&, &, &=, &=, && 等等。
例如:查询的是 World 数据集中 Country 字段值的首字母在 F 到 Z 之间的那些国家
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"Country &= '芬兰'"
5、查询特定值
使用 in,确定表达式的值是否等于指定列表内若干值中的任意一个值。
例如:查询的是 World 数据集中 CAPITAL 字段值为“北京”,“万象”的一个或几个国家。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"CAPITAL in ('北京','伦敦')"
查询结果:
注意:对于字符型字段的查询需要将查询值使用单引号(”)或者双引号(”“)括起来,而数值型字段的查询不需要。
6、查询某个字段值是否为空
使用 is NULL 是查询字段值为空,is not NULL是不为空
例如:查询的是 World 数据集中 CAPITAL 字段值不为空的那些国家
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:" CAPITAL is not
查询结果不为空的有20个国家:
7、布尔型字段查询
布尔型字段属性值为 True 或者 False,查询时用1表示True,0表示False。
例如:查询的是 City_R 数据集中沿海的城市。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:" City_R.Coastal = 1"
8、构造组合语句
使用 and,将两个或者多个查询语句组合起来。
例如:查询的是国土面积大于500万平方公里并且1994年人口小于1亿的国家。
getFeatureParam = new SuperMap.REST.FilterParameter({
name: "World@world",
fields:["SMID","CAPITAL","SMAREA","T_DATE"],
attributeFilter:"SmArea & 0 AND World.POP_1994 & "
查询得到满足条件的3个结果:
& & & &以上就是在查询过程中可能用到的过滤条件的构建方式,注意本文主要是针对文件型数据源的,至于数据库型数据源的查询条件其实就和在数据库中的查询条件一样,我这里就不再赘述了。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:301151次
积分:6163
积分:6163
排名:第4129名
原创:301篇
评论:76条
(2)(6)(17)(6)(55)(38)(39)(4)(1)(11)(8)(7)(4)(32)(7)(4)(5)(6)(5)(6)(2)(13)(9)(5)(3)(10)1252人阅读
supermap(7)
原创文章,转载请注明出处!
空间查询关联属性表,并查询空间表和关联表字段示例代码如下:
& & &* 关联测试成功代码
& & var joinItem=new SuperMap.REST.JoinItem({
foreignTableName: &V_ENABLEVIEW_LAND&,
joinFilter: &BBS_PARCEL.CADASTRALNO = V_ENABLEVIEW_LAND.CADASTRALNO &,
joinType: &INNERJOIN&
& & var queryParam, queryByGeometryParameters, queryS
& & queryParam = new SuperMap.REST.FilterParameter({
joinItems:[joinItem],
name: &BBS_PARCEL@grid_sysdb&,
& & & & &BBS_PARCEL.CADASTRALNO as CADASTRALNO&,
& & & & &BBS_PARCEL.LANDUSER as LANDUSER&,
& & & & &BBS_PARCEL.PARCELADDRESS as PARCELADDRESS&,
& & & & &BBS_PARCEL.RIGHTSTYPE_CN as RIGHTSTYPE_CN&,
& & & & &BBS_PARCEL.LANDPURPOSE_CN as LANDPURPOSE_CN&,
& & & & &BBS_PARCEL.PLOTRATIO as PLOTRATIO&,
& & & & &BBS_PARCEL.POSTADDRESS as POSTADDRESS&,
& & & & &BBS_PARCEL.BOOKAREA as BOOKAREA&,
& & & & &BBS_PARCEL.REALAREA as REALAREA&,
& & & & &V_ENABLEVIEW_LAND.FJBM as FJBM&],
displayFilters:[&V_ENABLEVIEW_LAND.FJBM='&+_disCode +&' or V_ENABLEVIEW_LAND.FJBM is null &]
queryByGeometryParameters = new SuperMap.REST.QueryByGeometryParameters({
& & & & queryParams: [queryParam],
& & & & geometry: feature.geometry,
& & & & spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:68257次
积分:1089
积分:1089
排名:千里之外
原创:38篇
转载:19篇
评论:11条
(3)(1)(2)(1)(2)(1)(3)(6)(1)(4)(1)(1)(1)(2)(1)(1)(3)(1)(3)(2)(2)(3)(1)(1)(1)(2)(2)(1)(1)(1)(3)SummaryThis class represents a OGC filter.This class represents a universal filter.Removes all the added references.Evaluates this filter in a specific context. It is recommended to use the instance or subclass to overlay this method.Clones this filter.{String} You can reference &SuperMap.Format.CQL& into your project, which is to return a character string denoted by CQl. Otherwise, &[Object object]& will be returned.
Constructor
SuperMap.FilterThis class represents a universal filter.options{Object} An optional object with properties to set on the instance object.{}
destroydestroy: function()Removes all the added references.
evaluateevaluate: function(context)Evaluates this filter in a specific context. It is recommended to use the instance or subclass to overlay this method.context{Object} Context to use in evaluating the filter.
If a vector feature is provided, the feature.attributes will be used as context.{Boolean} The filter applies.
cloneclone: function()Clones this filter.{} Clones a new filter.
toStringtoString: function(){String} You can reference &SuperMap.Format.CQL& into your project, which is to return a character string denoted by CQl. Otherwise, &[Object object]& will be returned.
SuperMapJavaScript Mapping LibraryFilter
destroy: function()Removes all the added references.evaluate: function(context)Evaluates this filter in a specific context. It is recommended to use the instance or subclass to overlay this method.clone: function()Clones this filter.toString: function(){String} You can reference SuperMap.Format.CQL into your project, which is to return a character string denoted by CQl. Otherwise, &[Object object]& will be returned.This class represents a universal filter.2075人阅读
二维(74)
技术开发(133)
iClient(54)
作者:sniper
&&&&前一段时间有很多朋友问我,怎么用SuperMap iClient for JavaScript实现类似百度地图或高德地图那样拖动一个按钮选择半径,从而查询附近的地理要素。因此,我们今天就来聊一聊怎么实现鼠标拖动进行距离查询。先来看一看是什么效果:
&&&&本文使用的数据为iserver自带的范例数据长春市区图;查询的圆点是地图的中心点,在使用中需要根据实际情况相应改变;查询的目标是中心点周围的学校;
实现拖动查询的代码,主要由以下三部分组成。
&&&&1、距离查询。
&&&&2、拖动按钮选择半径。
&&&&3、在地图移动的时候按钮位置随地图移动。
1、距离查询
&&&&首先使地图缩放至当前查询距离的范围。然后根据半径queryDis进行距离查询,查询出中心点周围的学校。具体请参考iserver范例程序中的距离查询,在这里不再赘述。
function queryByDistanceStart(){
dis = 500;
queryByDistance(dis);
setDrag();
function queryByDistance(queryDis) {
var polygon = SuperMap.Geometry.Polygon.createRegularPolygon(centerPoint,queryDis,50,270);
map.zoomToExtent(polygon.getBounds());
markerLayer.clearMarkers();
var queryByDistanceParams = new SuperMap.REST.QueryByDistanceParameters({
queryParams: new Array(new SuperMap.REST.FilterParameter({name: "School@Changchun"})),
returnContent: true,
distance: queryDis,
geometry: new SuperMap.Geometry.Point(X, Y)
var queryByDistanceService = new SuperMap.REST.QueryByDistanceService(url);
queryByDistanceService.events.on({
"processCompleted": processCompleted,
"processFailed": processFailed
queryByDistanceService.processAsync(queryByDistanceParams);
function processCompleted(queryEventArgs) {
var i, j, result = queryEventArgs.
for(i = 0;i & result.recordsets. i++) {
for(j = 0; j & result.recordsets[i].features. j++) {
var point = result.recordsets[i].features[j].geometry,
size = new SuperMap.Size(44, 33),
offset = new SuperMap.Pixel(-(size.w/2), -size.h),
icon = new SuperMap.Icon("img/marker.png", size, offset);
markerLayer.addMarker(new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon));
function processFailed(e){
alert(e.error.errorMsg);
&&&&以上为距离查询的部分,主要是根据传入的半径值,查询出距离中心点的距离小于该半径的学校,并以marker的形式添加到地图上。
2、拖动按钮选择半径
&&&&我们在做这一部分的功能时,首先要考虑到拖动按钮的类型以及它的位置。本文使用的拖动按钮实际上是一个div,放在map的div之中,具体如下:
id = "map"&
id="dragButton" style="display:"&
type="image" id="TDimg" calss="TD" src="img/TD.png"&
type="text" id="distance" style="font-family: '黑体'; font-weight:"
&&&&接下来就到了本文的重点,实现拖动按钮控制半径的功能。
function setDrag(){
vectorLayer.removeAllFeatures();
var polygon = SuperMap.Geometry.Polygon.createRegularPolygon(centerPoint,dis,50,270);
vectorLayer.addFeatures(new SuperMap.Feature.Vector(polygon,circleStyle));
var dragButtonLonlat=new SuperMap.LonLat(X+dis,Y);
var pixe=map.getPixelFromLonLat(dragButtonLonlat);
$("#dragButton").css({top:(pixe.y-8)+"px",left:(pixe.x-13)+"px"});
$("#distance").val(dis +"米");
$("#dragButton").show();
$('#dragButton').mousedown(
function (event){
var centerPixelX = event.pageX - map.getPixelFromLonLat(new SuperMap.LonLat(X,Y)).x;
var centerPixelY = map.getPixelFromLonLat(new SuperMap.LonLat(X,Y)).y;
$('#map').mousemove(
function (event){
event.preventDefault();
event.stopPropagation();
var eventPixel = new SuperMap.Pixel(event.pageX,centerPixelY);
dis = map.getLonLatFromPixel(eventPixel).lon-X;
var obj = $('#dragButton');
if(event.pageX&map.getPixelFromLonLat(new SuperMap.LonLat(X,Y)).x){
obj.css({'left':event.pageX-13, 'top':centerPixelY-8});
$("#distance").val(dis.toFixed(0)+"米");
var polygon = SuperMap.Geometry.Polygon.createRegularPolygon(centerPoint,dis,50,270);
vectorLayer.removeAllFeatures();
vectorLayer.addFeatures(new SuperMap.Feature.Vector(polygon,circleStyle));
).mouseup(
function (event){
$('#map').unbind("mousemove");
queryByDistance(dis);
$('#map').unbind("mouseup");
&&&&鼠标在拖动按钮的过程主要分三个阶段:鼠标按下;鼠标移动;鼠标抬起。
&&&&因此根据这三个过程,鼠标按下时触发接下来的方法。鼠标移动时,根据鼠标当前的屏幕坐标,调整拖动按钮的位置,并把屏幕坐标转换成地理坐标然后实时在地图上绘圆,同时在文本框中实时显示当前的半径。鼠标抬起时把当前半径传入距离查询方法进行距离查询并解除之前的事件绑定。
&&&&要注意的是,浏览器在鼠标拖动控件的时候有一个默认的提示,鼠标旁边会出现一个禁止的符号。这会影响我们的功能实现,所以要取消浏览器的默认拖动事件。
3、在地图移动的时候使按钮随地图移动
&&&&到上一步结束,大家可以发现我们其实已经可以实现鼠标拖动选择半径并进行距离查询了。但是我们的拖动按钮position设置的是absolute,它在屏幕上的位置是绝对的,他不会随着用户拖动地图而改变位置,所以我们就要对地图做一个监控,当地图移动时拖动按钮跟着移动。具体方法如下:
&&&&首先对地图的移动事件添加监控。
map.events.on({"move":move})
&&&&然后在地图移动的时候调整按钮的位置。
function move(){
if($('#dragButton').is(":visible")){
var pixcel = map.getPixelFromLonLat(new SuperMap.LonLat(X+dis,Y));
$('#dragButton').css({'left':pixcel.x-13,'top':pixcel.y-8});
&&&&到目前为止,我们的功能已经全部实现了。如有需要改进的地方,欢迎大家多多批评指正。
&&&&完整代码如下。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:301153次
积分:6163
积分:6163
排名:第4129名
原创:301篇
评论:76条
(2)(6)(17)(6)(55)(38)(39)(4)(1)(11)(8)(7)(4)(32)(7)(4)(5)(6)(5)(6)(2)(13)(9)(5)(3)(10)}

我要回帖

更多关于 filterparameter 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信