首页 文章

如何在geoserver视图中将值作为参数传递给sql查询

提问于
浏览
0

我试图在geoserver中编写sql视图并传递lat long作为参数以获得结果 . 查询在Postgres中运行正常 . 现在我在geoserver中编写查询 .

工作查询是:

select gid ,
  objectid ,
  locality,
  location,
  longitude,
  latitude ,x ,y,geom 
from tablename 
ORDER BY ST_SetSRID(ST_Point('75', '15'), 4326) <-> geom  
LIMIT 10

我试图将其作为参数传递

select gid ,
  objectid ,
  abl_record ,
  district_n ,
  locality_n,
  location_i,
  longitude,
  latitude ,
  x ,
  y,geom  
  from tablename 
  where x=%x% 
    and y=%y% 
  ORDER BY ST_SetSRID(ST_Point(x, y), 4326) <-> geom  
  LIMIT 10

1 回答

  • 1

    它对我来说很好 . 我们必须创建视图查询

    select * 
    from tablename 
    ORDER BY ST_SetSRID(ST_Point(%longitude% , %latitude%), 4326) <-> geom 
    LIMIT 10
    

相关问题