Ganos支持属性查询、id查询、时空范围查询等,数据查询的方式为:
URL | /index/:alias/:index/features |
方法 | GET |
URL参数 | 必要:alias=[alphanumeric] ds名称index=[alphanumeric] index 名称可选:q=[alphanumeric] JSON 表示的查询条件 |
成功信息 | Code: 200 Content: GeoJSON 格式的要素集合 |
失败信息Code: 400 - 需要的参数未指定Content: empty |
curl\‘localhost:8080/geoserver/geomesa/geojson/index/:alias/:index/features’ \ —get —data-urlencode ‘q=JSON格式查询条件’
HBase Ganos支持的属性查询谓词:
$lt | 小于 |
$lte | 小于等于 |
$gt | 大于 |
$gte | 大于等于 |
以下分别介绍几种常用的查询方式:
(1) 属性查询 HBase Ganos 属性查询通过谓词运算:
示例 1: 查询 id=0 的要素
curl \‘localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features’ \—get —data-urlencode‘q={ “properties.id”:”0” }’
示例 2: 查询 name=n1 的要素
curl \‘localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features’ \—get —data-urlencode‘q={“properties.name”:”n1”}’
示例 3: 查询 age<30 的所有要素
curl \‘localhost:8080/geoserver/geomesa/geojson/index/my_ds/test/features’ \—get —data-urlencode‘q={“properties.age”:{“$lt”:30}}’
(2)空间查询
示例 1: 通过外包框 BBOX 查询:
q={ “geometry” : { “$bbox” : [-180, -90, 180, 90] }}
示例 2: 空间相交(intersection)查询:
q={ “geometry” : { “$intersects” : { “$geometry” : { “type” : “Point”, “coordinates” : [30, 10] } } }}
示例 3: 空间包含(within)查询:
q={ “geometry” : { “$within” : { “$geometry” : { “type” : “Polygon”, “coordinates”: [ [ [0,0], [3,6], [6,1], [0,0] ] ] }} }}
示例 4: 空间包含(contains)查询:
q={ “geometry” : { “$contains” : { “$geometry” : { “type” : “Point”, “coordinates” : [30, 10] } } }}
(3)时间查询
示例 1:使用$during 谓词指定时间区间
curl \‘localhost:8080/geoserver/geomesa/geojson/index/myds/test/features’ \—get —data-urlencode‘q={“dtg”:{“$during”:”2018-01-02T08:00:00Z/2018-03-02T10:00:00Z”}}’
示例 2: 使用 $lt(), $gt $lte 和 $gte
curl \ ‘localhost:8080/geoserver/geomesa/geojson/index/myds/test/features’ \—get —data-urlencode‘q={“dtg”:{“$lt” : “2013-01-02 00:00:00”}}’
(4)组合查询
AND: 创建查询条件: a=5 AND b=6,
{ “a” : 5, “b” : 6 }
OR: 创建查询条件: a=5 OR a=6,
{ “$or” : [ { “a” : 5 }, { “b” : 6 } ] }
示例 1: 时空查询配合属性查询:
curl /‘http://localhost:8080/geoserver/geomesa/geojson/index/tdrive_ds/tdrive_index/featu res’—get —data-urlencode‘q={ “geometry”:{“$bbox”:[116.3383,39.8291,116.3384,39.8292]}, “properties.taxi_num”:”1131”, “properties.dtg”:{“$gt” : “2008-02-08T08:00:00.000+0000”}, “properties.dtg”:{“$lt” : “2008-02-08T12:21:16.000+0000”}}’
</article>
</main>